Merge branch 'develop'
This commit is contained in:
commit
7ddc2b6a89
16
.travis.yml
16
.travis.yml
@ -1,16 +0,0 @@
|
|||||||
language: cpp
|
|
||||||
compiler:
|
|
||||||
- gcc
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- sudo apt-add-repository -y ppa:czchen/travis-ci
|
|
||||||
- sudo add-apt-repository -y ppa:ubuntu-sdk-team/ppa
|
|
||||||
- sudo add-apt-repository -y ppa:canonical-qt5-edgers/qt5-proper
|
|
||||||
- sudo apt-get update -yqq
|
|
||||||
- sudo apt-get install -yqq cmake
|
|
||||||
- sudo apt-get install -yqq ubuntu-sdk
|
|
||||||
|
|
||||||
script: "cmake . && make -j4"
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
irc: "irc.esper.net#MultiMC"
|
|
130
CMakeLists.txt
130
CMakeLists.txt
@ -178,49 +178,53 @@ logger/QsLog.h
|
|||||||
logger/QsLogDest.cpp
|
logger/QsLogDest.cpp
|
||||||
logger/QsLogDest.h
|
logger/QsLogDest.h
|
||||||
|
|
||||||
# GUI
|
# GUI - windows
|
||||||
gui/mainwindow.h
|
gui/MainWindow.h
|
||||||
gui/mainwindow.cpp
|
gui/MainWindow.cpp
|
||||||
gui/settingsdialog.h
|
gui/ConsoleWindow.h
|
||||||
gui/settingsdialog.cpp
|
gui/ConsoleWindow.cpp
|
||||||
gui/CopyInstanceDialog.h
|
|
||||||
gui/CopyInstanceDialog.cpp
|
# GUI - dialogs
|
||||||
gui/newinstancedialog.h
|
gui/dialogs/SettingsDialog.h
|
||||||
gui/newinstancedialog.cpp
|
gui/dialogs/SettingsDialog.cpp
|
||||||
gui/logindialog.h
|
gui/dialogs/CopyInstanceDialog.h
|
||||||
gui/logindialog.cpp
|
gui/dialogs/CopyInstanceDialog.cpp
|
||||||
gui/ProgressDialog.h
|
gui/dialogs/dialogs/
|
||||||
gui/ProgressDialog.cpp
|
gui/dialogs/NewInstanceDialog.cpp
|
||||||
gui/aboutdialog.h
|
gui/dialogs/LoginDialog.h
|
||||||
gui/aboutdialog.cpp
|
gui/dialogs/LoginDialog.cpp
|
||||||
gui/consolewindow.h
|
gui/dialogs/ProgressDialog.h
|
||||||
gui/consolewindow.cpp
|
gui/dialogs/ProgressDialog.cpp
|
||||||
gui/instancedelegate.h
|
gui/dialogs/AboutDialog.h
|
||||||
gui/instancedelegate.cpp
|
gui/dialogs/AboutDialog.cpp
|
||||||
gui/versionselectdialog.h
|
gui/dialogs/VersionSelectDialog.h
|
||||||
gui/versionselectdialog.cpp
|
gui/dialogs/VersionSelectDialog.cpp
|
||||||
gui/lwjglselectdialog.h
|
gui/dialogs/LwjglSelectDialog.h
|
||||||
gui/lwjglselectdialog.cpp
|
gui/dialogs/LwjglSelectDialog.cpp
|
||||||
gui/instancesettings.h
|
gui/dialogs/InstanceSettings.h
|
||||||
gui/instancesettings.cpp
|
gui/dialogs/InstanceSettings.cpp
|
||||||
gui/IconPickerDialog.h
|
gui/dialogs/IconPickerDialog.h
|
||||||
gui/IconPickerDialog.cpp
|
gui/dialogs/IconPickerDialog.cpp
|
||||||
gui/LegacyModEditDialog.h
|
gui/dialogs/LegacyModEditDialog.h
|
||||||
gui/LegacyModEditDialog.cpp
|
gui/dialogs/LegacyModEditDialog.cpp
|
||||||
gui/OneSixModEditDialog.h
|
gui/dialogs/OneSixModEditDialog.h
|
||||||
gui/OneSixModEditDialog.cpp
|
gui/dialogs/OneSixModEditDialog.cpp
|
||||||
gui/ModEditDialogCommon.h
|
gui/dialogs/ModEditDialogCommon.h
|
||||||
gui/ModEditDialogCommon.cpp
|
gui/dialogs/ModEditDialogCommon.cpp
|
||||||
gui/ModListView.h
|
gui/dialogs/EditNotesDialog.h
|
||||||
gui/ModListView.cpp
|
gui/dialogs/EditNotesDialog.cpp
|
||||||
gui/LabeledToolButton.h
|
gui/dialogs/CustomMessageBox.h
|
||||||
gui/LabeledToolButton.cpp
|
gui/dialogs/CustomMessageBox.cpp
|
||||||
gui/EditNotesDialog.h
|
|
||||||
gui/EditNotesDialog.cpp
|
# GUI - widgets
|
||||||
gui/MCModInfoFrame.h
|
gui/widgets/InstanceDelegate.h
|
||||||
gui/MCModInfoFrame.cpp
|
gui/widgets/InstanceDelegate.cpp
|
||||||
gui/CustomMessageBox.h
|
gui/widgets/ModListView.h
|
||||||
gui/CustomMessageBox.cpp
|
gui/widgets/ModListView.cpp
|
||||||
|
gui/widgets/LabeledToolButton.h
|
||||||
|
gui/widgets/LabeledToolButton.cpp
|
||||||
|
gui/widgets/MCModInfoFrame.h
|
||||||
|
gui/widgets/MCModInfoFrame.cpp
|
||||||
|
|
||||||
# Base classes and infrastructure
|
# Base classes and infrastructure
|
||||||
logic/BaseVersion.h
|
logic/BaseVersion.h
|
||||||
@ -332,24 +336,28 @@ logic/NagUtils.cpp
|
|||||||
|
|
||||||
######## UIs ########
|
######## UIs ########
|
||||||
SET(MULTIMC_UIS
|
SET(MULTIMC_UIS
|
||||||
gui/mainwindow.ui
|
|
||||||
gui/settingsdialog.ui
|
|
||||||
gui/CopyInstanceDialog.ui
|
|
||||||
gui/newinstancedialog.ui
|
|
||||||
gui/logindialog.ui
|
|
||||||
gui/aboutdialog.ui
|
|
||||||
gui/consolewindow.ui
|
|
||||||
gui/versionselectdialog.ui
|
|
||||||
gui/lwjglselectdialog.ui
|
|
||||||
gui/instancesettings.ui
|
|
||||||
|
|
||||||
gui/ProgressDialog.ui
|
# Windows
|
||||||
gui/IconPickerDialog.ui
|
gui/MainWindow.ui
|
||||||
gui/LegacyModEditDialog.ui
|
gui/ConsoleWindow.ui
|
||||||
gui/OneSixModEditDialog.ui
|
|
||||||
gui/EditNotesDialog.ui
|
|
||||||
|
|
||||||
gui/MCModInfoFrame.ui
|
# Dialogs
|
||||||
|
gui/dialogs/SettingsDialog.ui
|
||||||
|
gui/dialogs/CopyInstanceDialog.ui
|
||||||
|
gui/dialogs/NewInstanceDialog.ui
|
||||||
|
gui/dialogs/LoginDialog.ui
|
||||||
|
gui/dialogs/AboutDialog.ui
|
||||||
|
gui/dialogs/VersionSelectDialog.ui
|
||||||
|
gui/dialogs/LwjglSelectDialog.ui
|
||||||
|
gui/dialogs/InstanceSettings.ui
|
||||||
|
gui/dialogs/ProgressDialog.ui
|
||||||
|
gui/dialogs/IconPickerDialog.ui
|
||||||
|
gui/dialogs/LegacyModEditDialog.ui
|
||||||
|
gui/dialogs/OneSixModEditDialog.ui
|
||||||
|
gui/dialogs/EditNotesDialog.ui
|
||||||
|
|
||||||
|
# Widgets/other
|
||||||
|
gui/widgets/MCModInfoFrame.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
set (FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${MULTIMC_SOURCES} ${MULTIMC_UIS})
|
set (FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${MULTIMC_SOURCES} ${MULTIMC_UIS})
|
||||||
@ -364,9 +372,9 @@ ENDIF()
|
|||||||
IF(UNIX AND NOT APPLE)
|
IF(UNIX AND NOT APPLE)
|
||||||
SET(MultiMC_QT_ADDITIONAL_MODULES ${MultiMC_QT_ADDITIONAL_MODULES} X11Extras)
|
SET(MultiMC_QT_ADDITIONAL_MODULES ${MultiMC_QT_ADDITIONAL_MODULES} X11Extras)
|
||||||
SET(MultiMC_LINK_ADDITIONAL_LIBS ${MultiMC_LINK_ADDITIONAL_LIBS} xcb)
|
SET(MultiMC_LINK_ADDITIONAL_LIBS ${MultiMC_LINK_ADDITIONAL_LIBS} xcb)
|
||||||
LIST(APPEND MULTIMC_SOURCES gui/platform_x11.cpp)
|
LIST(APPEND MULTIMC_SOURCES gui/Platform_X11.cpp)
|
||||||
ELSE()
|
ELSE()
|
||||||
LIST(APPEND MULTIMC_SOURCES gui/platform_other.cpp)
|
LIST(APPEND MULTIMC_SOURCES gui/Platform_Other.cpp)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "gui/mainwindow.h"
|
#include "gui/MainWindow.h"
|
||||||
#include "gui/versionselectdialog.h"
|
#include "gui/dialogs/VersionSelectDialog.h"
|
||||||
#include "logic/lists/InstanceList.h"
|
#include "logic/lists/InstanceList.h"
|
||||||
#include "logic/lists/IconList.h"
|
#include "logic/lists/IconList.h"
|
||||||
#include "logic/lists/LwjglVersionList.h"
|
#include "logic/lists/LwjglVersionList.h"
|
||||||
@ -24,7 +24,7 @@
|
|||||||
#include "cmdutils.h"
|
#include "cmdutils.h"
|
||||||
#include <inisettingsobject.h>
|
#include <inisettingsobject.h>
|
||||||
#include <setting.h>
|
#include <setting.h>
|
||||||
#include <logger/QsLog.h>
|
#include "logger/QsLog.h"
|
||||||
#include <logger/QsLogDest.h>
|
#include <logger/QsLogDest.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -20,4 +20,3 @@
|
|||||||
#else
|
#else
|
||||||
#define CLASSPARSER_EXPORT Q_DECL_IMPORT
|
#define CLASSPARSER_EXPORT Q_DECL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -13,7 +13,8 @@ namespace java
|
|||||||
{
|
{
|
||||||
std::pair<uint16_t, element_value *> &val = name_val_pairs[i];
|
std::pair<uint16_t, element_value *> &val = name_val_pairs[i];
|
||||||
auto name_idx = val.first;
|
auto name_idx = val.first;
|
||||||
ss << pool[name_idx].str_data << "(" << name_idx << ")" << " = " << val.second->toString() << std::endl;
|
ss << pool[name_idx].str_data << "(" << name_idx << ")"
|
||||||
|
<< " = " << val.second->toString() << std::endl;
|
||||||
}
|
}
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
@ -39,7 +40,8 @@ namespace java
|
|||||||
return ann;
|
return ann;
|
||||||
}
|
}
|
||||||
|
|
||||||
element_value* element_value::readElementValue ( util::membuffer& input, java::constant_pool& pool )
|
element_value *element_value::readElementValue(util::membuffer &input,
|
||||||
|
java::constant_pool &pool)
|
||||||
{
|
{
|
||||||
element_value_type type = INVALID;
|
element_value_type type = INVALID;
|
||||||
input.read(type);
|
input.read(type);
|
||||||
|
@ -15,7 +15,8 @@ namespace java
|
|||||||
ARRAY = '[', // one array dimension
|
ARRAY = '[', // one array dimension
|
||||||
PRIMITIVE_INT = 'I', // integer
|
PRIMITIVE_INT = 'I', // integer
|
||||||
PRIMITIVE_BYTE = 'B', // signed byte
|
PRIMITIVE_BYTE = 'B', // signed byte
|
||||||
PRIMITIVE_CHAR = 'C', // Unicode character code point in the Basic Multilingual Plane, encoded with UTF-16
|
PRIMITIVE_CHAR = 'C', // Unicode character code point in the Basic Multilingual Plane,
|
||||||
|
// encoded with UTF-16
|
||||||
PRIMITIVE_DOUBLE = 'D', // double-precision floating-point value
|
PRIMITIVE_DOUBLE = 'D', // double-precision floating-point value
|
||||||
PRIMITIVE_FLOAT = 'F', // single-precision floating-point value
|
PRIMITIVE_FLOAT = 'F', // single-precision floating-point value
|
||||||
PRIMITIVE_LONG = 'J', // long integer
|
PRIMITIVE_LONG = 'J', // long integer
|
||||||
@ -23,7 +24,8 @@ namespace java
|
|||||||
PRIMITIVE_BOOLEAN = 'Z' // true or false
|
PRIMITIVE_BOOLEAN = 'Z' // true or false
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* The element_value structure is a discriminated union representing the value of an element-value pair.
|
* The element_value structure is a discriminated union representing the value of an
|
||||||
|
*element-value pair.
|
||||||
* It is used to represent element values in all attributes that describe annotations
|
* It is used to represent element values in all attributes that describe annotations
|
||||||
* - RuntimeVisibleAnnotations
|
* - RuntimeVisibleAnnotations
|
||||||
* - RuntimeInvisibleAnnotations
|
* - RuntimeInvisibleAnnotations
|
||||||
@ -52,13 +54,15 @@ namespace java
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each value of the annotations table represents a single runtime-visible annotation on a program element.
|
* Each value of the annotations table represents a single runtime-visible annotation on a
|
||||||
|
* program element.
|
||||||
* The annotation structure has the following format:
|
* The annotation structure has the following format:
|
||||||
*/
|
*/
|
||||||
class annotation
|
class annotation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::vector<std::pair<uint16_t, element_value *>> value_list;
|
typedef std::vector<std::pair<uint16_t, element_value *>> value_list;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* The value of the type_index item must be a valid index into the constant_pool table.
|
* The value of the type_index item must be a valid index into the constant_pool table.
|
||||||
@ -70,9 +74,12 @@ namespace java
|
|||||||
/**
|
/**
|
||||||
* map between element_name_index and value.
|
* map between element_name_index and value.
|
||||||
*
|
*
|
||||||
* The value of the element_name_index item must be a valid index into the constant_pool table.
|
* The value of the element_name_index item must be a valid index into the constant_pool
|
||||||
* The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure representing
|
*table.
|
||||||
* a valid field descriptor (§4.3.2) that denotes the name of the annotation type element represented
|
* The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure
|
||||||
|
*representing
|
||||||
|
* a valid field descriptor (§4.3.2) that denotes the name of the annotation type element
|
||||||
|
*represented
|
||||||
* by this element_value_pairs entry.
|
* by this element_value_pairs entry.
|
||||||
*/
|
*/
|
||||||
value_list name_val_pairs;
|
value_list name_val_pairs;
|
||||||
@ -80,8 +87,10 @@ namespace java
|
|||||||
* Reference to the parent constant pool
|
* Reference to the parent constant pool
|
||||||
*/
|
*/
|
||||||
constant_pool &pool;
|
constant_pool &pool;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
annotation(uint16_t type_index, constant_pool& pool):type_index(type_index), pool(pool) {};
|
annotation(uint16_t type_index, constant_pool &pool)
|
||||||
|
: type_index(type_index), pool(pool) {};
|
||||||
~annotation()
|
~annotation()
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < name_val_pairs.size(); i++)
|
for (unsigned i = 0; i < name_val_pairs.size(); i++)
|
||||||
@ -92,7 +101,8 @@ namespace java
|
|||||||
void add_pair(uint16_t key, element_value *value)
|
void add_pair(uint16_t key, element_value *value)
|
||||||
{
|
{
|
||||||
name_val_pairs.push_back(std::make_pair(key, value));
|
name_val_pairs.push_back(std::make_pair(key, value));
|
||||||
};
|
}
|
||||||
|
;
|
||||||
value_list::const_iterator begin()
|
value_list::const_iterator begin()
|
||||||
{
|
{
|
||||||
return name_val_pairs.cbegin();
|
return name_val_pairs.cbegin();
|
||||||
@ -106,17 +116,16 @@ namespace java
|
|||||||
};
|
};
|
||||||
typedef std::vector<annotation *> annotation_table;
|
typedef std::vector<annotation *> annotation_table;
|
||||||
|
|
||||||
|
|
||||||
/// type for simple value annotation elements
|
/// type for simple value annotation elements
|
||||||
class element_value_simple : public element_value
|
class element_value_simple : public element_value
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/// index of the constant in the constant pool
|
/// index of the constant in the constant pool
|
||||||
uint16_t index;
|
uint16_t index;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
element_value_simple(element_value_type type, uint16_t index , constant_pool& pool):
|
element_value_simple(element_value_type type, uint16_t index, constant_pool &pool)
|
||||||
element_value(type, pool), index(index)
|
: element_value(type, pool), index(index) {
|
||||||
{
|
|
||||||
// TODO: verify consistency
|
// TODO: verify consistency
|
||||||
};
|
};
|
||||||
uint16_t getIndex()
|
uint16_t getIndex()
|
||||||
@ -126,7 +135,8 @@ namespace java
|
|||||||
virtual std::string toString()
|
virtual std::string toString()
|
||||||
{
|
{
|
||||||
return pool[index].toString();
|
return pool[index].toString();
|
||||||
};
|
}
|
||||||
|
;
|
||||||
};
|
};
|
||||||
/// The enum_const_value item is used if the tag item is 'e'.
|
/// The enum_const_value item is used if the tag item is 'e'.
|
||||||
class element_value_enum : public element_value
|
class element_value_enum : public element_value
|
||||||
@ -135,19 +145,25 @@ namespace java
|
|||||||
/**
|
/**
|
||||||
* The value of the type_name_index item must be a valid index into the constant_pool table.
|
* The value of the type_name_index item must be a valid index into the constant_pool table.
|
||||||
* The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure
|
* The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure
|
||||||
* representing a valid field descriptor (§4.3.2) that denotes the internal form of the binary
|
* representing a valid field descriptor (§4.3.2) that denotes the internal form of the
|
||||||
* name (§4.2.1) of the type of the enum constant represented by this element_value structure.
|
* binary
|
||||||
|
* name (§4.2.1) of the type of the enum constant represented by this element_value
|
||||||
|
* structure.
|
||||||
*/
|
*/
|
||||||
uint16_t typeIndex;
|
uint16_t typeIndex;
|
||||||
/**
|
/**
|
||||||
* The value of the const_name_index item must be a valid index into the constant_pool table.
|
* The value of the const_name_index item must be a valid index into the constant_pool
|
||||||
|
* table.
|
||||||
* The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure
|
* The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure
|
||||||
* representing the simple name of the enum constant represented by this element_value structure.
|
* representing the simple name of the enum constant represented by this element_value
|
||||||
|
* structure.
|
||||||
*/
|
*/
|
||||||
uint16_t valueIndex;
|
uint16_t valueIndex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
element_value_enum(element_value_type type, uint16_t typeIndex, uint16_t valueIndex, constant_pool& pool):
|
element_value_enum(element_value_type type, uint16_t typeIndex, uint16_t valueIndex,
|
||||||
element_value(type, pool), typeIndex(typeIndex), valueIndex(valueIndex)
|
constant_pool &pool)
|
||||||
|
: element_value(type, pool), typeIndex(typeIndex), valueIndex(valueIndex)
|
||||||
{
|
{
|
||||||
// TODO: verify consistency
|
// TODO: verify consistency
|
||||||
}
|
}
|
||||||
@ -162,7 +178,8 @@ namespace java
|
|||||||
virtual std::string toString()
|
virtual std::string toString()
|
||||||
{
|
{
|
||||||
return "enum value";
|
return "enum value";
|
||||||
};
|
}
|
||||||
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
class element_value_class : public element_value
|
class element_value_class : public element_value
|
||||||
@ -179,9 +196,10 @@ namespace java
|
|||||||
* Or in plain english, you can store type information in annotations. Yay.
|
* Or in plain english, you can store type information in annotations. Yay.
|
||||||
*/
|
*/
|
||||||
uint16_t classIndex;
|
uint16_t classIndex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
element_value_class(element_value_type type, uint16_t classIndex, constant_pool& pool):
|
element_value_class(element_value_type type, uint16_t classIndex, constant_pool &pool)
|
||||||
element_value(type, pool), classIndex(classIndex)
|
: element_value(type, pool), classIndex(classIndex)
|
||||||
{
|
{
|
||||||
// TODO: verify consistency
|
// TODO: verify consistency
|
||||||
}
|
}
|
||||||
@ -192,7 +210,8 @@ namespace java
|
|||||||
virtual std::string toString()
|
virtual std::string toString()
|
||||||
{
|
{
|
||||||
return "class";
|
return "class";
|
||||||
};
|
}
|
||||||
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// nested annotations... yay
|
/// nested annotations... yay
|
||||||
@ -200,10 +219,11 @@ namespace java
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
annotation *nestedAnnotation;
|
annotation *nestedAnnotation;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
element_value_annotation(element_value_type type, annotation * nestedAnnotation, constant_pool& pool):
|
element_value_annotation(element_value_type type, annotation *nestedAnnotation,
|
||||||
element_value(type, pool), nestedAnnotation(nestedAnnotation)
|
constant_pool &pool)
|
||||||
{};
|
: element_value(type, pool), nestedAnnotation(nestedAnnotation) {};
|
||||||
~element_value_annotation()
|
~element_value_annotation()
|
||||||
{
|
{
|
||||||
if (nestedAnnotation)
|
if (nestedAnnotation)
|
||||||
@ -215,7 +235,8 @@ namespace java
|
|||||||
virtual std::string toString()
|
virtual std::string toString()
|
||||||
{
|
{
|
||||||
return "nested annotation";
|
return "nested annotation";
|
||||||
};
|
}
|
||||||
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// and arrays!
|
/// and arrays!
|
||||||
@ -223,19 +244,22 @@ namespace java
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::vector<element_value *> elem_vec;
|
typedef std::vector<element_value *> elem_vec;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
elem_vec values;
|
elem_vec values;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
element_value_array ( element_value_type type, std::vector <element_value *>& values, constant_pool& pool ):
|
element_value_array(element_value_type type, std::vector<element_value *> &values,
|
||||||
element_value(type, pool), values(values)
|
constant_pool &pool)
|
||||||
{};
|
: element_value(type, pool), values(values) {};
|
||||||
~element_value_array()
|
~element_value_array()
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < values.size(); i++)
|
for (unsigned i = 0; i < values.size(); i++)
|
||||||
{
|
{
|
||||||
delete values[i];
|
delete values[i];
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
;
|
||||||
elem_vec::const_iterator begin()
|
elem_vec::const_iterator begin()
|
||||||
{
|
{
|
||||||
return values.cbegin();
|
return values.cbegin();
|
||||||
@ -247,6 +271,7 @@ namespace java
|
|||||||
virtual std::string toString()
|
virtual std::string toString()
|
||||||
{
|
{
|
||||||
return "array";
|
return "array";
|
||||||
};
|
}
|
||||||
|
;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -37,7 +37,8 @@ namespace java
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
// read fields (and attributes from inside fields) (and possible inner classes. yay for recursion!)
|
// read fields (and attributes from inside fields) (and possible inner classes. yay for
|
||||||
|
// recursion!)
|
||||||
// for now though, we will ignore all attributes
|
// for now though, we will ignore all attributes
|
||||||
/*
|
/*
|
||||||
* field_info
|
* field_info
|
||||||
@ -131,11 +132,13 @@ namespace java
|
|||||||
num_annotations--;
|
num_annotations--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else skip(attr_length);
|
else
|
||||||
|
skip(attr_length);
|
||||||
class_attr_count--;
|
class_attr_count--;
|
||||||
}
|
}
|
||||||
valid = true;
|
valid = true;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
bool valid;
|
bool valid;
|
||||||
bool is_synthetic;
|
bool is_synthetic;
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
|
@ -112,7 +112,8 @@ namespace java
|
|||||||
ss << "Class: " << ref_type.class_idx;
|
ss << "Class: " << ref_type.class_idx;
|
||||||
break;
|
break;
|
||||||
case j_nameandtype:
|
case j_nameandtype:
|
||||||
ss << "NameAndType: " << name_and_type.name_index << " " << name_and_type.descriptor_index;
|
ss << "NameAndType: " << name_and_type.name_index << " "
|
||||||
|
<< name_and_type.descriptor_index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ss.str();
|
return ss.str();
|
||||||
@ -148,7 +149,8 @@ namespace java
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper class that represents the custom container used in Java class file for storage of constants
|
* A helper class that represents the custom container used in Java class file for storage of
|
||||||
|
* constants
|
||||||
*/
|
*/
|
||||||
class constant_pool
|
class constant_pool
|
||||||
{
|
{
|
||||||
@ -156,7 +158,9 @@ namespace java
|
|||||||
/**
|
/**
|
||||||
* Create a pool of constants
|
* Create a pool of constants
|
||||||
*/
|
*/
|
||||||
constant_pool(){}
|
constant_pool()
|
||||||
|
{
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Load a java constant pool
|
* Load a java constant pool
|
||||||
*/
|
*/
|
||||||
@ -172,7 +176,8 @@ namespace java
|
|||||||
const constant &cnst = constant(buf);
|
const constant &cnst = constant(buf);
|
||||||
constants.push_back(cnst);
|
constants.push_back(cnst);
|
||||||
last_constant = &constants[constants.size() - 1];
|
last_constant = &constants[constants.size() - 1];
|
||||||
if(last_constant->type == constant::j_double || last_constant->type == constant::j_long)
|
if (last_constant->type == constant::j_double ||
|
||||||
|
last_constant->type == constant::j_long)
|
||||||
{
|
{
|
||||||
// push in a fake constant to preserve indexing
|
// push in a fake constant to preserve indexing
|
||||||
constants.push_back(constant(0));
|
constants.push_back(constant(0));
|
||||||
@ -197,15 +202,18 @@ namespace java
|
|||||||
throw new classfile_exception();
|
throw new classfile_exception();
|
||||||
}
|
}
|
||||||
return constants[constant_index - 1];
|
return constants[constant_index - 1];
|
||||||
};
|
}
|
||||||
|
;
|
||||||
container_type::const_iterator begin() const
|
container_type::const_iterator begin() const
|
||||||
{
|
{
|
||||||
return constants.begin();
|
return constants.begin();
|
||||||
};
|
}
|
||||||
|
;
|
||||||
container_type::const_iterator end() const
|
container_type::const_iterator end() const
|
||||||
{
|
{
|
||||||
return constants.end();
|
return constants.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
container_type constants;
|
container_type constants;
|
||||||
};
|
};
|
||||||
|
@ -2,5 +2,7 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
namespace java
|
namespace java
|
||||||
{
|
{
|
||||||
class classfile_exception : public std::exception {};
|
class classfile_exception : public std::exception
|
||||||
|
{
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -10,53 +10,67 @@ namespace util
|
|||||||
inline uint64_t bigswap(uint64_t x)
|
inline uint64_t bigswap(uint64_t x)
|
||||||
{
|
{
|
||||||
return x;
|
return x;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
inline uint32_t bigswap(uint32_t x)
|
inline uint32_t bigswap(uint32_t x)
|
||||||
{
|
{
|
||||||
return x;
|
return x;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
inline uint16_t bigswap(uint16_t x)
|
inline uint16_t bigswap(uint16_t x)
|
||||||
{
|
{
|
||||||
return x;
|
return x;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
inline int64_t bigswap(int64_t x)
|
inline int64_t bigswap(int64_t x)
|
||||||
{
|
{
|
||||||
return x;
|
return x;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
inline int32_t bigswap(int32_t x)
|
inline int32_t bigswap(int32_t x)
|
||||||
{
|
{
|
||||||
return x;
|
return x;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
inline int16_t bigswap(int16_t x)
|
inline int16_t bigswap(int16_t x)
|
||||||
{
|
{
|
||||||
return x;
|
return x;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
#else
|
#else
|
||||||
inline uint64_t bigswap(uint64_t x)
|
inline uint64_t bigswap(uint64_t x)
|
||||||
{
|
{
|
||||||
return (x>>56) | ((x<<40) & 0x00FF000000000000) | ((x<<24) & 0x0000FF0000000000) | ((x<<8) & 0x000000FF00000000) |
|
return (x >> 56) | ((x << 40) & 0x00FF000000000000) | ((x << 24) & 0x0000FF0000000000) |
|
||||||
((x>>8) & 0x00000000FF000000) | ((x>>24) & 0x0000000000FF0000) | ((x>>40) & 0x000000000000FF00) | (x<<56);
|
((x << 8) & 0x000000FF00000000) | ((x >> 8) & 0x00000000FF000000) |
|
||||||
};
|
((x >> 24) & 0x0000000000FF0000) | ((x >> 40) & 0x000000000000FF00) | (x << 56);
|
||||||
|
}
|
||||||
|
;
|
||||||
inline uint32_t bigswap(uint32_t x)
|
inline uint32_t bigswap(uint32_t x)
|
||||||
{
|
{
|
||||||
return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
|
return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
|
||||||
};
|
}
|
||||||
|
;
|
||||||
inline uint16_t bigswap(uint16_t x)
|
inline uint16_t bigswap(uint16_t x)
|
||||||
{
|
{
|
||||||
return (x >> 8) | (x << 8);
|
return (x >> 8) | (x << 8);
|
||||||
};
|
}
|
||||||
|
;
|
||||||
inline int64_t bigswap(int64_t x)
|
inline int64_t bigswap(int64_t x)
|
||||||
{
|
{
|
||||||
return (x>>56) | ((x<<40) & 0x00FF000000000000) | ((x<<24) & 0x0000FF0000000000) | ((x<<8) & 0x000000FF00000000) |
|
return (x >> 56) | ((x << 40) & 0x00FF000000000000) | ((x << 24) & 0x0000FF0000000000) |
|
||||||
((x>>8) & 0x00000000FF000000) | ((x>>24) & 0x0000000000FF0000) | ((x>>40) & 0x000000000000FF00) | (x<<56);
|
((x << 8) & 0x000000FF00000000) | ((x >> 8) & 0x00000000FF000000) |
|
||||||
};
|
((x >> 24) & 0x0000000000FF0000) | ((x >> 40) & 0x000000000000FF00) | (x << 56);
|
||||||
|
}
|
||||||
|
;
|
||||||
inline int32_t bigswap(int32_t x)
|
inline int32_t bigswap(int32_t x)
|
||||||
{
|
{
|
||||||
return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
|
return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
|
||||||
};
|
}
|
||||||
|
;
|
||||||
inline int16_t bigswap(int16_t x)
|
inline int16_t bigswap(int16_t x)
|
||||||
{
|
{
|
||||||
return (x >> 8) | (x << 8);
|
return (x >> 8) | (x << 8);
|
||||||
};
|
}
|
||||||
|
;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,8 @@ QString GetMinecraftJarVersion(QString jarName)
|
|||||||
Minecraft.read(classfile, size);
|
Minecraft.read(classfile, size);
|
||||||
|
|
||||||
// parse Minecraft.class
|
// parse Minecraft.class
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
char *temp = classfile;
|
char *temp = classfile;
|
||||||
java::classfile MinecraftClass(temp, size);
|
java::classfile MinecraftClass(temp, size);
|
||||||
java::constant_pool constants = MinecraftClass.constants;
|
java::constant_pool constants = MinecraftClass.constants;
|
||||||
@ -66,7 +67,10 @@ QString GetMinecraftJarVersion(QString jarName)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(java::classfile_exception &) {}
|
}
|
||||||
|
catch (java::classfile_exception &)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
delete[] classfile;
|
delete[] classfile;
|
||||||
@ -76,5 +80,4 @@ QString GetMinecraftJarVersion(QString jarName)
|
|||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,7 @@ namespace util
|
|||||||
/**
|
/**
|
||||||
* Read some value. That's all ;)
|
* Read some value. That's all ;)
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T> void read(T &val)
|
||||||
void read(T& val)
|
|
||||||
{
|
{
|
||||||
val = *(T *)current;
|
val = *(T *)current;
|
||||||
current += sizeof(T);
|
current += sizeof(T);
|
||||||
@ -33,8 +32,7 @@ namespace util
|
|||||||
* Read a big-endian number
|
* Read a big-endian number
|
||||||
* valid for 2-byte, 4-byte and 8-byte variables
|
* valid for 2-byte, 4-byte and 8-byte variables
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T> void read_be(T &val)
|
||||||
void read_be(T& val)
|
|
||||||
{
|
{
|
||||||
val = util::bigswap(*(T *)current);
|
val = util::bigswap(*(T *)current);
|
||||||
current += sizeof(T);
|
current += sizeof(T);
|
||||||
@ -58,6 +56,7 @@ namespace util
|
|||||||
{
|
{
|
||||||
current += N;
|
current += N;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *start, *end, *current;
|
char *start, *end, *current;
|
||||||
};
|
};
|
||||||
|
@ -35,13 +35,10 @@ public class MCFrame extends Frame implements WindowListener
|
|||||||
{
|
{
|
||||||
super ( title );
|
super ( title );
|
||||||
BufferedImage image = null;
|
BufferedImage image = null;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
image = ImageIO.read ( new File ( "icon.png" ) );
|
image = ImageIO.read ( new File ( "icon.png" ) );
|
||||||
setIconImage ( image );
|
setIconImage ( image );
|
||||||
}
|
} catch ( IOException e ) {
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
this.addWindowListener ( this );
|
this.addWindowListener ( this );
|
||||||
@ -49,11 +46,9 @@ public class MCFrame extends Frame implements WindowListener
|
|||||||
|
|
||||||
public void start ( Applet mcApplet, String user, String session, Dimension winSize, boolean maximize )
|
public void start ( Applet mcApplet, String user, String session, Dimension winSize, boolean maximize )
|
||||||
{
|
{
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
appletWrap = new Launcher ( mcApplet, new URL ( "http://www.minecraft.net/game" ) );
|
appletWrap = new Launcher ( mcApplet, new URL ( "http://www.minecraft.net/game" ) );
|
||||||
}
|
} catch ( MalformedURLException ignored ) {}
|
||||||
catch (MalformedURLException ignored){}
|
|
||||||
|
|
||||||
appletWrap.setParameter ( "username", user );
|
appletWrap.setParameter ( "username", user );
|
||||||
appletWrap.setParameter ( "sessionid", session );
|
appletWrap.setParameter ( "sessionid", session );
|
||||||
@ -65,8 +60,9 @@ public class MCFrame extends Frame implements WindowListener
|
|||||||
this.pack();
|
this.pack();
|
||||||
this.setLocationRelativeTo ( null );
|
this.setLocationRelativeTo ( null );
|
||||||
this.setResizable ( true );
|
this.setResizable ( true );
|
||||||
if (maximize)
|
if ( maximize ) {
|
||||||
this.setExtendedState ( MAXIMIZED_BOTH );
|
this.setExtendedState ( MAXIMIZED_BOTH );
|
||||||
|
}
|
||||||
|
|
||||||
validate();
|
validate();
|
||||||
appletWrap.init();
|
appletWrap.init();
|
||||||
@ -83,15 +79,11 @@ public class MCFrame extends Frame implements WindowListener
|
|||||||
@Override
|
@Override
|
||||||
public void windowClosing ( WindowEvent e )
|
public void windowClosing ( WindowEvent e )
|
||||||
{
|
{
|
||||||
new Thread()
|
new Thread() {
|
||||||
{
|
public void run() {
|
||||||
public void run()
|
try {
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.sleep ( 30000L );
|
Thread.sleep ( 30000L );
|
||||||
} catch (InterruptedException localInterruptedException)
|
} catch ( InterruptedException localInterruptedException ) {
|
||||||
{
|
|
||||||
localInterruptedException.printStackTrace();
|
localInterruptedException.printStackTrace();
|
||||||
}
|
}
|
||||||
System.out.println ( "FORCING EXIT!" );
|
System.out.println ( "FORCING EXIT!" );
|
||||||
@ -100,8 +92,7 @@ public class MCFrame extends Frame implements WindowListener
|
|||||||
}
|
}
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
if (appletWrap != null)
|
if ( appletWrap != null ) {
|
||||||
{
|
|
||||||
appletWrap.stop();
|
appletWrap.stop();
|
||||||
appletWrap.destroy();
|
appletWrap.destroy();
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BASICSETTINGSOBJECT_H
|
#pragma once
|
||||||
#define BASICSETTINGSOBJECT_H
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@ -32,7 +31,8 @@ class LIBSETTINGS_EXPORT BasicSettingsObject : public SettingsObject
|
|||||||
public:
|
public:
|
||||||
explicit BasicSettingsObject(QObject *parent = 0);
|
explicit BasicSettingsObject(QObject *parent = 0);
|
||||||
|
|
||||||
protected slots:
|
protected
|
||||||
|
slots:
|
||||||
virtual void changeSetting(const Setting &setting, QVariant value);
|
virtual void changeSetting(const Setting &setting, QVariant value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -40,5 +40,3 @@ protected:
|
|||||||
|
|
||||||
QSettings config;
|
QSettings config;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BASICSETTINGSOBJECT_H
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef INISETTINGSOBJECT_H
|
#pragma once
|
||||||
#define INISETTINGSOBJECT_H
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
@ -22,7 +21,7 @@
|
|||||||
|
|
||||||
#include "settingsobject.h"
|
#include "settingsobject.h"
|
||||||
|
|
||||||
#include "libutil_config.h"
|
#include "libsettings_config.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief A settings object that stores its settings in an INIFile.
|
* \brief A settings object that stores its settings in an INIFile.
|
||||||
@ -37,7 +36,10 @@ public:
|
|||||||
* \brief Gets the path to the INI file.
|
* \brief Gets the path to the INI file.
|
||||||
* \return The path to the INI file.
|
* \return The path to the INI file.
|
||||||
*/
|
*/
|
||||||
virtual QString filePath() const { return m_filePath; }
|
virtual QString filePath() const
|
||||||
|
{
|
||||||
|
return m_filePath;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Sets the path to the INI file and reloads it.
|
* \brief Sets the path to the INI file and reloads it.
|
||||||
@ -45,7 +47,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void setFilePath(const QString &filePath);
|
virtual void setFilePath(const QString &filePath);
|
||||||
|
|
||||||
protected slots:
|
protected
|
||||||
|
slots:
|
||||||
virtual void changeSetting(const Setting &setting, QVariant value);
|
virtual void changeSetting(const Setting &setting, QVariant value);
|
||||||
virtual void resetSetting(const Setting &setting);
|
virtual void resetSetting(const Setting &setting);
|
||||||
|
|
||||||
@ -56,5 +59,3 @@ protected:
|
|||||||
|
|
||||||
QString m_filePath;
|
QString m_filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INISETTINGSOBJECT_H
|
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef KEYRING_H
|
#pragma once
|
||||||
#define KEYRING_H
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@ -82,11 +81,12 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// fall back to StubKeyring if false
|
/// fall back to StubKeyring if false
|
||||||
virtual bool isValid() { return false; }
|
virtual bool isValid()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Keyring *m_instance;
|
static Keyring *m_instance;
|
||||||
static void destroy();
|
static void destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEYRING_H
|
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OVERRIDESETTING_H
|
#pragma once
|
||||||
#define OVERRIDESETTING_H
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
@ -39,5 +38,3 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
Setting *m_other;
|
Setting *m_other;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OVERRIDESETTING_H
|
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SETTING_H
|
#pragma once
|
||||||
#define SETTING_H
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@ -39,10 +38,14 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* \brief Gets this setting's ID.
|
* \brief Gets this setting's ID.
|
||||||
* This is used to refer to the setting within the application.
|
* This is used to refer to the setting within the application.
|
||||||
* \warning Changing the ID while the setting is registered with a SettingsObject results in undefined behavior.
|
* \warning Changing the ID while the setting is registered with a SettingsObject results in
|
||||||
|
* undefined behavior.
|
||||||
* \return The ID of the setting.
|
* \return The ID of the setting.
|
||||||
*/
|
*/
|
||||||
virtual QString id() const { return m_id; }
|
virtual QString id() const
|
||||||
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets this setting's config file key.
|
* \brief Gets this setting's config file key.
|
||||||
@ -50,7 +53,10 @@ public:
|
|||||||
* the same as the setting's ID, but it can be different.
|
* the same as the setting's ID, but it can be different.
|
||||||
* \return The setting's config file key.
|
* \return The setting's config file key.
|
||||||
*/
|
*/
|
||||||
virtual QString configKey() const { return id(); }
|
virtual QString configKey() const
|
||||||
|
{
|
||||||
|
return id();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets this setting's value as a QVariant.
|
* \brief Gets this setting's value as a QVariant.
|
||||||
@ -66,9 +72,10 @@ public:
|
|||||||
* This function is just shorthand for get().value<T>()
|
* This function is just shorthand for get().value<T>()
|
||||||
* \return The setting's actual value.
|
* \return The setting's actual value.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template <typename T> inline T value() const
|
||||||
inline T value() const { return get().value<T>(); }
|
{
|
||||||
|
return get().value<T>();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets this setting's default value.
|
* \brief Gets this setting's default value.
|
||||||
@ -90,7 +97,8 @@ signals:
|
|||||||
*/
|
*/
|
||||||
void settingReset(const Setting &setting);
|
void settingReset(const Setting &setting);
|
||||||
|
|
||||||
public slots:
|
public
|
||||||
|
slots:
|
||||||
/*!
|
/*!
|
||||||
* \brief Changes the setting's value.
|
* \brief Changes the setting's value.
|
||||||
* This is done by emitting the settingChanged() signal which will then be
|
* This is done by emitting the settingChanged() signal which will then be
|
||||||
@ -106,9 +114,8 @@ public slots:
|
|||||||
* \param value The new value.
|
* \param value The new value.
|
||||||
*/
|
*/
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QVariant m_defVal;
|
QVariant m_defVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTING_H
|
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
class Setting;
|
class Setting;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief The SettingsObject handles communicating settings between the application and a settings file.
|
* \brief The SettingsObject handles communicating settings between the application and a
|
||||||
|
*settings file.
|
||||||
* The class keeps a list of Setting objects. Each Setting object represents one
|
* The class keeps a list of Setting objects. Each Setting object represents one
|
||||||
* of the application's settings. These Setting objects are registered with
|
* of the application's settings. These Setting objects are registered with
|
||||||
* a SettingsObject and can be managed similarly to the way a list works.
|
* a SettingsObject and can be managed similarly to the way a list works.
|
||||||
@ -40,7 +41,8 @@ public:
|
|||||||
explicit SettingsObject(QObject *parent = 0);
|
explicit SettingsObject(QObject *parent = 0);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Registers the given setting with this SettingsObject and connects the necessary signals.
|
* \brief Registers the given setting with this SettingsObject and connects the necessary
|
||||||
|
* signals.
|
||||||
* This will fail if there is already a setting with the same ID as
|
* This will fail if there is already a setting with the same ID as
|
||||||
* the one that is being registered.
|
* the one that is being registered.
|
||||||
* \note Registering a setting object causes the SettingsObject to take ownership
|
* \note Registering a setting object causes the SettingsObject to take ownership
|
||||||
@ -54,7 +56,8 @@ public:
|
|||||||
virtual bool registerSetting(Setting *setting);
|
virtual bool registerSetting(Setting *setting);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Unregisters the given setting from this SettingsObject and disconnects its signals.
|
* \brief Unregisters the given setting from this SettingsObject and disconnects its
|
||||||
|
* signals.
|
||||||
* \note This does not delete the setting. Furthermore, when the setting is
|
* \note This does not delete the setting. Furthermore, when the setting is
|
||||||
* unregistered, the SettingsObject drops ownership of the setting. This means
|
* unregistered, the SettingsObject drops ownership of the setting. This means
|
||||||
* that if you unregister a setting, its parent is set to null and you become
|
* that if you unregister a setting, its parent is set to null and you become
|
||||||
@ -63,7 +66,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void unregisterSetting(Setting *setting);
|
virtual void unregisterSetting(Setting *setting);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the setting with the given ID.
|
* \brief Gets the setting with the given ID.
|
||||||
* \param id The ID of the setting to get.
|
* \param id The ID of the setting to get.
|
||||||
@ -79,8 +81,10 @@ public:
|
|||||||
* \return A pointer to the setting with the given ID.
|
* \return A pointer to the setting with the given ID.
|
||||||
* \sa getSetting()
|
* \sa getSetting()
|
||||||
*/
|
*/
|
||||||
inline Setting *operator [](const QString &id) { return getSetting(id); }
|
inline Setting *operator[](const QString &id)
|
||||||
|
{
|
||||||
|
return getSetting(id);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the value of the setting with the given ID.
|
* \brief Gets the value of the setting with the given ID.
|
||||||
@ -137,7 +141,8 @@ signals:
|
|||||||
*/
|
*/
|
||||||
void settingReset(const Setting &setting);
|
void settingReset(const Setting &setting);
|
||||||
|
|
||||||
protected slots:
|
protected
|
||||||
|
slots:
|
||||||
/*!
|
/*!
|
||||||
* \brief Changes a setting.
|
* \brief Changes a setting.
|
||||||
* This slot is usually connected to each Setting object's
|
* This slot is usually connected to each Setting object's
|
||||||
|
@ -16,10 +16,8 @@
|
|||||||
#include "include/basicsettingsobject.h"
|
#include "include/basicsettingsobject.h"
|
||||||
#include "include/setting.h"
|
#include "include/setting.h"
|
||||||
|
|
||||||
BasicSettingsObject::BasicSettingsObject(QObject *parent) :
|
BasicSettingsObject::BasicSettingsObject(QObject *parent) : SettingsObject(parent)
|
||||||
SettingsObject(parent)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicSettingsObject::changeSetting(const Setting &setting, QVariant value)
|
void BasicSettingsObject::changeSetting(const Setting &setting, QVariant value)
|
||||||
|
@ -19,10 +19,8 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
INIFile::INIFile()
|
INIFile::INIFile()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString INIFile::unescape(QString orig)
|
QString INIFile::unescape(QString orig)
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
#include "include/inisettingsobject.h"
|
#include "include/inisettingsobject.h"
|
||||||
#include "include/setting.h"
|
#include "include/setting.h"
|
||||||
|
|
||||||
INISettingsObject::INISettingsObject(const QString &path, QObject *parent) :
|
INISettingsObject::INISettingsObject(const QString &path, QObject *parent)
|
||||||
SettingsObject(parent)
|
: SettingsObject(parent)
|
||||||
{
|
{
|
||||||
m_filePath = path;
|
m_filePath = path;
|
||||||
m_ini.loadFile(path);
|
m_ini.loadFile(path);
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
#include "include/overridesetting.h"
|
#include "include/overridesetting.h"
|
||||||
|
|
||||||
OverrideSetting::OverrideSetting(const QString &name, Setting *other, QObject *parent) :
|
OverrideSetting::OverrideSetting(const QString &name, Setting *other, QObject *parent)
|
||||||
Setting(name, QVariant(), parent)
|
: Setting(name, QVariant(), parent)
|
||||||
{
|
{
|
||||||
m_other = other;
|
m_other = other;
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,9 @@
|
|||||||
#include "include/setting.h"
|
#include "include/setting.h"
|
||||||
#include "include/settingsobject.h"
|
#include "include/settingsobject.h"
|
||||||
|
|
||||||
Setting::Setting(QString id, QVariant defVal, QObject *parent) :
|
Setting::Setting(QString id, QVariant defVal, QObject *parent)
|
||||||
QObject(parent), m_id(id), m_defVal(defVal)
|
: QObject(parent), m_id(id), m_defVal(defVal)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant Setting::get() const
|
QVariant Setting::get() const
|
||||||
|
@ -18,10 +18,8 @@
|
|||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
SettingsObject::SettingsObject(QObject *parent) :
|
SettingsObject::SettingsObject(QObject *parent) : QObject(parent)
|
||||||
QObject(parent)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingsObject::registerSetting(Setting *setting)
|
bool SettingsObject::registerSetting(Setting *setting)
|
||||||
@ -29,15 +27,17 @@ bool SettingsObject::registerSetting(Setting *setting)
|
|||||||
// Check if setting is null or we already have a setting with the same ID.
|
// Check if setting is null or we already have a setting with the same ID.
|
||||||
if (!setting)
|
if (!setting)
|
||||||
{
|
{
|
||||||
qDebug(QString("Failed to register setting. Setting is null.").
|
qDebug(QString("Failed to register setting. Setting is null.")
|
||||||
arg(setting->id()).toUtf8());
|
.arg(setting->id())
|
||||||
|
.toUtf8());
|
||||||
return false; // Fail
|
return false; // Fail
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contains(setting->id()))
|
if (contains(setting->id()))
|
||||||
{
|
{
|
||||||
qDebug(QString("Failed to register setting %1. ID already exists.").
|
qDebug(QString("Failed to register setting %1. ID already exists.")
|
||||||
arg(setting->id()).toUtf8());
|
.arg(setting->id())
|
||||||
|
.toUtf8());
|
||||||
return false; // Fail
|
return false; // Fail
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,6 @@ void SettingsObject::unregisterSetting(Setting *setting)
|
|||||||
setting->setParent(NULL); // Drop ownership.
|
setting->setParent(NULL); // Drop ownership.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Setting *SettingsObject::getSetting(const QString &id) const
|
Setting *SettingsObject::getSetting(const QString &id) const
|
||||||
{
|
{
|
||||||
// Make sure there is a setting with the given ID.
|
// Make sure there is a setting with the given ID.
|
||||||
@ -85,8 +84,7 @@ bool SettingsObject::set(const QString &id, QVariant value)
|
|||||||
Setting *setting = getSetting(id);
|
Setting *setting = getSetting(id);
|
||||||
if (!setting)
|
if (!setting)
|
||||||
{
|
{
|
||||||
qDebug(QString("Error changing setting %1. Setting doesn't exist.").
|
qDebug(QString("Error changing setting %1. Setting doesn't exist.").arg(id).toUtf8());
|
||||||
arg(id).toUtf8());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -103,7 +101,6 @@ void SettingsObject::reset(const QString &id) const
|
|||||||
setting->reset();
|
setting->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<Setting *> SettingsObject::getSettings()
|
QList<Setting *> SettingsObject::getSettings()
|
||||||
{
|
{
|
||||||
return m_settings.values();
|
return m_settings.values();
|
||||||
@ -114,7 +111,6 @@ bool SettingsObject::contains(const QString &id)
|
|||||||
return m_settings.contains(id);
|
return m_settings.contains(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SettingsObject::connectSignals(const Setting &setting)
|
void SettingsObject::connectSignals(const Setting &setting)
|
||||||
{
|
{
|
||||||
connect(&setting, SIGNAL(settingChanged(const Setting &, QVariant)),
|
connect(&setting, SIGNAL(settingChanged(const Setting &, QVariant)),
|
||||||
@ -122,21 +118,19 @@ void SettingsObject::connectSignals(const Setting &setting)
|
|||||||
connect(&setting, SIGNAL(settingChanged(const Setting &, QVariant)),
|
connect(&setting, SIGNAL(settingChanged(const Setting &, QVariant)),
|
||||||
SIGNAL(settingChanged(const Setting &, QVariant)));
|
SIGNAL(settingChanged(const Setting &, QVariant)));
|
||||||
|
|
||||||
connect(&setting, SIGNAL(settingReset(Setting)),
|
connect(&setting, SIGNAL(settingReset(Setting)), SLOT(resetSetting(const Setting &)));
|
||||||
SLOT(resetSetting(const Setting &)));
|
connect(&setting, SIGNAL(settingReset(Setting)), SIGNAL(settingReset(const Setting &)));
|
||||||
connect(&setting, SIGNAL(settingReset(Setting)),
|
|
||||||
SIGNAL(settingReset(const Setting &)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsObject::disconnectSignals(const Setting &setting)
|
void SettingsObject::disconnectSignals(const Setting &setting)
|
||||||
{
|
{
|
||||||
setting.disconnect(SIGNAL(settingChanged(const Setting &, QVariant)),
|
setting.disconnect(SIGNAL(settingChanged(const Setting &, QVariant)), this,
|
||||||
this, SLOT(changeSetting(const Setting &, QVariant)));
|
SLOT(changeSetting(const Setting &, QVariant)));
|
||||||
setting.disconnect(SIGNAL(settingChanged(const Setting &, QVariant)),
|
setting.disconnect(SIGNAL(settingChanged(const Setting &, QVariant)), this,
|
||||||
this, SIGNAL(settingChanged(const Setting &, QVariant)));
|
SIGNAL(settingChanged(const Setting &, QVariant)));
|
||||||
|
|
||||||
setting.disconnect(SIGNAL(settingReset(const Setting &, QVariant)),
|
setting.disconnect(SIGNAL(settingReset(const Setting &, QVariant)), this,
|
||||||
this, SLOT(resetSetting(const Setting &, QVariant)));
|
SLOT(resetSetting(const Setting &, QVariant)));
|
||||||
setting.disconnect(SIGNAL(settingReset(const Setting &, QVariant)),
|
setting.disconnect(SIGNAL(settingReset(const Setting &, QVariant)), this,
|
||||||
this, SIGNAL(settingReset(const Setting &, QVariant)));
|
SIGNAL(settingReset(const Setting &, QVariant)));
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,8 @@ void StubKeyring::removeStoredAccount ( QString service, QString username )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: this needs tweaking/changes for user account level storage
|
// FIXME: this needs tweaking/changes for user account level storage
|
||||||
StubKeyring::StubKeyring() :
|
StubKeyring::StubKeyring()
|
||||||
|
:
|
||||||
// m_settings(QSettings::UserScope, "Orochimarufan", "Keyring")
|
// m_settings(QSettings::UserScope, "Orochimarufan", "Keyring")
|
||||||
m_settings("keyring.cfg", QSettings::IniFormat)
|
m_settings("keyring.cfg", QSettings::IniFormat)
|
||||||
{
|
{
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef STUBKEYRING_H
|
#pragma once
|
||||||
#define STUBKEYRING_H
|
|
||||||
|
|
||||||
#include "include/keyring.h"
|
#include "include/keyring.h"
|
||||||
|
|
||||||
@ -30,12 +29,14 @@ public:
|
|||||||
virtual bool hasPassword(QString service, QString username);
|
virtual bool hasPassword(QString service, QString username);
|
||||||
virtual QStringList getStoredAccounts(QString service);
|
virtual QStringList getStoredAccounts(QString service);
|
||||||
virtual void removeStoredAccount(QString service, QString username);
|
virtual void removeStoredAccount(QString service, QString username);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Keyring;
|
friend class Keyring;
|
||||||
explicit StubKeyring();
|
explicit StubKeyring();
|
||||||
virtual bool isValid() { return true; }
|
virtual bool isValid()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QSettings m_settings;
|
QSettings m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STUBKEYRING_H
|
|
||||||
|
@ -22,21 +22,18 @@ find_package(Qt5Core REQUIRED)
|
|||||||
include_directories(${Qt5Base_INCLUDE_DIRS})
|
include_directories(${Qt5Base_INCLUDE_DIRS})
|
||||||
# include_directories(${Qt5Network_INCLUDE_DIRS})
|
# include_directories(${Qt5Network_INCLUDE_DIRS})
|
||||||
|
|
||||||
SET(LIBUTIL_HEADERS
|
SET(LIBUTIL_SOURCES
|
||||||
include/libutil_config.h
|
include/libutil_config.h
|
||||||
|
|
||||||
include/apputils.h
|
|
||||||
|
|
||||||
include/pathutils.h
|
include/pathutils.h
|
||||||
include/osutils.h
|
|
||||||
include/userutils.h
|
|
||||||
include/cmdutils.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(LIBUTIL_SOURCES
|
|
||||||
src/pathutils.cpp
|
src/pathutils.cpp
|
||||||
src/osutils.cpp
|
|
||||||
|
include/osutils.h
|
||||||
|
|
||||||
|
include/userutils.h
|
||||||
src/userutils.cpp
|
src/userutils.cpp
|
||||||
|
|
||||||
|
include/cmdutils.h
|
||||||
src/cmdutils.cpp
|
src/cmdutils.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -50,7 +47,7 @@ add_definitions(-DLIBUTIL_LIBRARY)
|
|||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
add_library(libUtil STATIC ${LIBUTIL_SOURCES} ${LIBUTIL_HEADERS})
|
add_library(libUtil STATIC ${LIBUTIL_SOURCES})
|
||||||
# qt5_use_modules(libUtil Core Network)
|
# qt5_use_modules(libUtil Core Network)
|
||||||
qt5_use_modules(libUtil Core)
|
qt5_use_modules(libUtil Core)
|
||||||
target_link_libraries(libUtil)
|
target_link_libraries(libUtil)
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CMDUTILS_H
|
#pragma once
|
||||||
#define CMDUTILS_H
|
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -33,8 +32,10 @@
|
|||||||
* @brief commandline parsing and processing utilities
|
* @brief commandline parsing and processing utilities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Util {
|
namespace Util
|
||||||
namespace Commandline {
|
{
|
||||||
|
namespace Commandline
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief split a string into argv items like a shell would do
|
* @brief split a string into argv items like a shell would do
|
||||||
@ -211,14 +212,16 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Important: the common part MUST BE COMMON ON ALL THREE structs
|
// Important: the common part MUST BE COMMON ON ALL THREE structs
|
||||||
struct CommonDef {
|
struct CommonDef
|
||||||
|
{
|
||||||
QString name;
|
QString name;
|
||||||
QString doc;
|
QString doc;
|
||||||
QString metavar;
|
QString metavar;
|
||||||
QVariant def;
|
QVariant def;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OptionDef {
|
struct OptionDef
|
||||||
|
{
|
||||||
// common
|
// common
|
||||||
QString name;
|
QString name;
|
||||||
QString doc;
|
QString doc;
|
||||||
@ -229,7 +232,8 @@ private:
|
|||||||
QChar flag;
|
QChar flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PositionalDef {
|
struct PositionalDef
|
||||||
|
{
|
||||||
// common
|
// common
|
||||||
QString name;
|
QString name;
|
||||||
QString doc;
|
QString doc;
|
||||||
@ -247,8 +251,5 @@ private:
|
|||||||
|
|
||||||
void getPrefix(QString &opt, QString &flag);
|
void getPrefix(QString &opt, QString &flag);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CMDUTILS_H
|
|
||||||
|
@ -26,4 +26,3 @@
|
|||||||
#define LIBUTIL_EXPORT Q_DECL_IMPORT
|
#define LIBUTIL_EXPORT Q_DECL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OSUTILS_H
|
#pragma once
|
||||||
#define OSUTILS_H
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@ -25,5 +24,3 @@
|
|||||||
#elif __linux__
|
#elif __linux__
|
||||||
#define LINUX 1
|
#define LINUX 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // OSUTILS_H
|
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PATHUTILS_H
|
#pragma once
|
||||||
#define PATHUTILS_H
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@ -58,5 +57,3 @@ LIBUTIL_EXPORT void openFileInDefaultProgram ( QString filename );
|
|||||||
|
|
||||||
/// Opens the given directory in the default application.
|
/// Opens the given directory in the default application.
|
||||||
LIBUTIL_EXPORT void openDirInDefaultProgram(QString dirpath, bool ensureExists = false);
|
LIBUTIL_EXPORT void openDirInDefaultProgram(QString dirpath, bool ensureExists = false);
|
||||||
|
|
||||||
#endif // PATHUTILS_H
|
|
||||||
|
@ -1,129 +0,0 @@
|
|||||||
/* Copyright 2013 MultiMC Contributors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SIGLIST_H
|
|
||||||
#define SIGLIST_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QList>
|
|
||||||
|
|
||||||
// A QList that allows emitting signals when the list changes.
|
|
||||||
// Since QObject doesn't support templates, to use this class with a
|
|
||||||
// certain type, you should create a class deriving from SigList<T> and then
|
|
||||||
// call the DEFINE_SIGLIST_SIGNALS(T) and SETUP_SIGLIST_SIGNALS(T) macros.
|
|
||||||
template <typename T>
|
|
||||||
class SigList : public QList<T>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit SigList() : QList<T>() {}
|
|
||||||
|
|
||||||
virtual void append(const T &value);
|
|
||||||
virtual void append(const QList<T> &other);
|
|
||||||
|
|
||||||
virtual void clear();
|
|
||||||
|
|
||||||
virtual void erase(typename QList<T>::iterator pos);
|
|
||||||
virtual void erase(typename QList<T>::iterator first, typename QList<T>::iterator last);
|
|
||||||
|
|
||||||
virtual void insert(int i, const T &t);
|
|
||||||
virtual void insert(typename QList<T>::iterator before, const T &t);
|
|
||||||
|
|
||||||
virtual void move(int from, int to);
|
|
||||||
|
|
||||||
virtual void pop_back() { takeLast(); }
|
|
||||||
virtual void pop_front() { takeFirst(); }
|
|
||||||
|
|
||||||
virtual void push_back(const T &t) { append(t); }
|
|
||||||
virtual void push_front(const T &t) { prepend(t); }
|
|
||||||
|
|
||||||
virtual void prepend(const T &t);
|
|
||||||
|
|
||||||
virtual int removeAll(const T &t);
|
|
||||||
virtual bool removeOne(const T &t);
|
|
||||||
|
|
||||||
virtual void removeAt(int i) { takeAt(i); }
|
|
||||||
virtual void removeFirst() { takeFirst(); }
|
|
||||||
virtual void removeLast() { takeLast(); }
|
|
||||||
|
|
||||||
virtual void swap(QList<T> &other);
|
|
||||||
virtual void swap(int i, int j);
|
|
||||||
|
|
||||||
virtual T takeAt(int i);
|
|
||||||
virtual T takeFirst();
|
|
||||||
virtual T takeLast();
|
|
||||||
|
|
||||||
virtual QList<T> &operator +=(const QList<T> &other) { append(other); return *this; }
|
|
||||||
virtual QList<T> &operator +=(const T &value) { append(value); return *this; }
|
|
||||||
virtual QList<T> &operator <<(const QList<T> &other) { append(other); return *this; }
|
|
||||||
virtual QList<T> &operator <<(const T &value) { append(value); return *this; }
|
|
||||||
|
|
||||||
virtual QList<T> &operator =(const QList<T> &other);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Signal emitted after an item is added to the list.
|
|
||||||
// Contains a reference to item and the item's new index.
|
|
||||||
virtual void onItemAdded(const T &item, int index) = 0;
|
|
||||||
|
|
||||||
// Signal emitted after multiple items are added to the list at once.
|
|
||||||
// The items parameter is a const reference to a QList of the items that
|
|
||||||
// were added.
|
|
||||||
// The firstIndex parameter is the new index of the first item added.
|
|
||||||
virtual void onItemsAdded(const QList<T> &items, int firstIndex) = 0;
|
|
||||||
|
|
||||||
// Signal emitted after an item is removed to the list.
|
|
||||||
// Contains a reference to the item and the item's old index.
|
|
||||||
virtual void onItemRemoved(const T &item, int index) = 0;
|
|
||||||
|
|
||||||
// Signal emitted after multiple items are removed from the list at once.
|
|
||||||
// The items parameter is a const reference to a QList of the items that
|
|
||||||
// were added.
|
|
||||||
// The firstIndex parameter is the new index of the first item added.
|
|
||||||
virtual void onItemsRemoved(const QList<T> &items, int firstIndex) = 0;
|
|
||||||
|
|
||||||
// Signal emitted after an item is moved to another index.
|
|
||||||
// Contains the item, the old index, and the new index.
|
|
||||||
virtual void onItemMoved(const T &item, int oldIndex, int newIndex) = 0;
|
|
||||||
|
|
||||||
// Signal emitted after an operation that changes the whole list occurs.
|
|
||||||
// This signal should be treated as if all data in the entire list was cleared
|
|
||||||
// and new data added in its place.
|
|
||||||
virtual void onInvalidated() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Defines the signals for a SigList
|
|
||||||
#define DEFINE_SIGLIST_SIGNALS(TYPE) \
|
|
||||||
Q_SIGNAL void itemAdded(TYPE const &item, int index);\
|
|
||||||
Q_SIGNAL void itemsAdded(const QList<TYPE> &items, int firstIndex);\
|
|
||||||
Q_SIGNAL void itemRemoved(TYPE const &item, int index);\
|
|
||||||
Q_SIGNAL void itemsRemoved(const QList<TYPE> &items, int firstIndex);\
|
|
||||||
Q_SIGNAL void itemMoved(TYPE const &item, int oldIndex, int newIndex);\
|
|
||||||
Q_SIGNAL void invalidated();
|
|
||||||
|
|
||||||
// Overrides the onItem* functions and causes them to emit their corresponding
|
|
||||||
// signals.
|
|
||||||
#define SETUP_SIGLIST_SIGNALS(TYPE) \
|
|
||||||
virtual void onItemAdded(TYPE const &item, int index)\
|
|
||||||
{ emit itemAdded(item, index); }\
|
|
||||||
virtual void onItemsAdded(const QList<TYPE> &items, int firstIndex)\
|
|
||||||
{ emit itemsAdded(items, firstIndex); }\
|
|
||||||
virtual void onItemRemoved(TYPE const &item, int index)\
|
|
||||||
{ emit itemRemoved(item, index); }\
|
|
||||||
virtual void onItemsRemoved(const QList<TYPE> &items, int firstIndex)\
|
|
||||||
{ emit itemsRemoved(items, firstIndex); }\
|
|
||||||
virtual void onItemMoved(TYPE const &item, int oldIndex, int newIndex)\
|
|
||||||
{ emit itemMoved(item, oldIndex, newIndex); }\
|
|
||||||
virtual void onInvalidated() { emit invalidated(); }
|
|
||||||
|
|
||||||
#endif // SIGLIST_H
|
|
@ -1,156 +0,0 @@
|
|||||||
/* Copyright 2013 MultiMC Contributors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "siglist.h"
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::append(const T &value)
|
|
||||||
{
|
|
||||||
QList<T>::append(value);
|
|
||||||
onItemAdded(value, QList<T>::length() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::prepend(const T &value)
|
|
||||||
{
|
|
||||||
QList<T>::prepend(value);
|
|
||||||
onItemAdded(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::append(const QList<T> &other)
|
|
||||||
{
|
|
||||||
int index = QList<T>::length();
|
|
||||||
QList<T>::append(other);
|
|
||||||
onItemsAdded(other, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::clear()
|
|
||||||
{
|
|
||||||
QList<T>::clear();
|
|
||||||
onInvalidated();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::erase(typename QList<T>::iterator pos)
|
|
||||||
{
|
|
||||||
T value = *pos;
|
|
||||||
int index = QList<T>::indexOf(*pos);
|
|
||||||
QList<T>::erase(pos);
|
|
||||||
onItemRemoved(value, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::erase(typename QList<T>::iterator first, typename QList<T>::iterator last)
|
|
||||||
{
|
|
||||||
QList<T> removedValues;
|
|
||||||
int firstIndex = QList<T>::indexOf(*first);
|
|
||||||
|
|
||||||
for (auto iter = first; iter < last; iter++)
|
|
||||||
{
|
|
||||||
removedValues << *iter;
|
|
||||||
QList<T>::erase(iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
onItemsRemoved(removedValues, firstIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::insert(int i, const T &t)
|
|
||||||
{
|
|
||||||
QList<T>::insert(i, t);
|
|
||||||
onItemAdded(t, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::insert(typename QList<T>::iterator before, const T &t)
|
|
||||||
{
|
|
||||||
QList<T>::insert(before, t);
|
|
||||||
onItemAdded(t, QList<T>::indexOf(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::move(int from, int to)
|
|
||||||
{
|
|
||||||
const T &item = QList<T>::at(from);
|
|
||||||
QList<T>::move(from, to);
|
|
||||||
onItemMoved(item, from, to);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
int SigList<T>::removeAll(const T &t)
|
|
||||||
{
|
|
||||||
int retVal = QList<T>::removeAll(t);
|
|
||||||
onInvalidated();
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool SigList<T>::removeOne(const T &t)
|
|
||||||
{
|
|
||||||
int index = QList<T>::indexOf(t);
|
|
||||||
if (QList<T>::removeOne(t))
|
|
||||||
{
|
|
||||||
onItemRemoved(t, index);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::swap(QList<T> &other)
|
|
||||||
{
|
|
||||||
QList<T>::swap(other);
|
|
||||||
onInvalidated();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SigList<T>::swap(int i, int j)
|
|
||||||
{
|
|
||||||
const T &item1 = QList<T>::at(i);
|
|
||||||
const T &item2 = QList<T>::at(j);
|
|
||||||
QList<T>::swap(i, j);
|
|
||||||
onItemMoved(item1, i, j);
|
|
||||||
onItemMoved(item2, j, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T SigList<T>::takeAt(int i)
|
|
||||||
{
|
|
||||||
T val = QList<T>::takeAt(i);
|
|
||||||
onItemRemoved(val, i);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T SigList<T>::takeFirst()
|
|
||||||
{
|
|
||||||
return takeAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T SigList<T>::takeLast()
|
|
||||||
{
|
|
||||||
return takeAt(QList<T>::length() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
QList<T> &SigList<T>::operator =(const QList<T> &other)
|
|
||||||
{
|
|
||||||
QList<T>::operator =(other);
|
|
||||||
onInvalidated();
|
|
||||||
return *this;
|
|
||||||
}
|
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef USERUTILS_H
|
#pragma once
|
||||||
#define USERUTILS_H
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@ -13,7 +12,6 @@ LIBUTIL_EXPORT QString getDesktopDir();
|
|||||||
// Create a shortcut at *location*, pointing to *dest* called with the arguments *args*
|
// Create a shortcut at *location*, pointing to *dest* called with the arguments *args*
|
||||||
// call it *name* and assign it the icon *icon*
|
// call it *name* and assign it the icon *icon*
|
||||||
// return true if operation succeeded
|
// return true if operation succeeded
|
||||||
LIBUTIL_EXPORT bool createShortCut(QString location, QString dest, QStringList args, QString name, QString iconLocation);
|
LIBUTIL_EXPORT bool createShortCut(QString location, QString dest, QStringList args,
|
||||||
|
QString name, QString iconLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USERUTILS_H
|
|
||||||
|
@ -21,8 +21,10 @@
|
|||||||
* @file libutil/src/cmdutils.cpp
|
* @file libutil/src/cmdutils.cpp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Util {
|
namespace Util
|
||||||
namespace Commandline {
|
{
|
||||||
|
namespace Commandline
|
||||||
|
{
|
||||||
|
|
||||||
// commandline splitter
|
// commandline splitter
|
||||||
QStringList splitArgs(QString args)
|
QStringList splitArgs(QString args)
|
||||||
@ -73,7 +75,6 @@ QStringList splitArgs(QString args)
|
|||||||
return argv;
|
return argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Parser::Parser(FlagStyle::Enum flagStyle, ArgumentStyle::Enum argStyle)
|
Parser::Parser(FlagStyle::Enum flagStyle, ArgumentStyle::Enum argStyle)
|
||||||
{
|
{
|
||||||
m_flagStyle = flagStyle;
|
m_flagStyle = flagStyle;
|
||||||
@ -213,7 +214,8 @@ QString Parser::compileHelp(QString progName, int helpIndent, bool useFlags)
|
|||||||
help << optPrefix << option->name;
|
help << optPrefix << option->name;
|
||||||
if (option->type == otOption)
|
if (option->type == otOption)
|
||||||
{
|
{
|
||||||
QString arg = QString("%1%2").arg(((m_argStyle == ArgumentStyle::Equals) ? "=" : " "), option->metavar);
|
QString arg = QString("%1%2").arg(
|
||||||
|
((m_argStyle == ArgumentStyle::Equals) ? "=" : " "), option->metavar);
|
||||||
nameLength += arg.length();
|
nameLength += arg.length();
|
||||||
help << arg;
|
help << arg;
|
||||||
}
|
}
|
||||||
@ -286,7 +288,8 @@ QHash<QString, QVariant> Parser::parse(QStringList argv)
|
|||||||
QString name = expecting.first();
|
QString name = expecting.first();
|
||||||
|
|
||||||
if (map.contains(name))
|
if (map.contains(name))
|
||||||
throw ParsingError(QString("Option %2%1 was given multiple times").arg(name, optionPrefix));
|
throw ParsingError(
|
||||||
|
QString("Option %2%1 was given multiple times").arg(name, optionPrefix));
|
||||||
|
|
||||||
map[name] = QVariant(arg);
|
map[name] = QVariant(arg);
|
||||||
|
|
||||||
@ -302,7 +305,9 @@ QHash<QString, QVariant> Parser::parse(QStringList argv)
|
|||||||
QString name = arg.mid(optionPrefix.length());
|
QString name = arg.mid(optionPrefix.length());
|
||||||
QString equals;
|
QString equals;
|
||||||
|
|
||||||
if ((m_argStyle == ArgumentStyle::Equals || m_argStyle == ArgumentStyle::SpaceAndEquals) && name.contains("="))
|
if ((m_argStyle == ArgumentStyle::Equals ||
|
||||||
|
m_argStyle == ArgumentStyle::SpaceAndEquals) &&
|
||||||
|
name.contains("="))
|
||||||
{
|
{
|
||||||
int i = name.indexOf("=");
|
int i = name.indexOf("=");
|
||||||
equals = name.mid(i + 1);
|
equals = name.mid(i + 1);
|
||||||
@ -312,7 +317,8 @@ QHash<QString, QVariant> Parser::parse(QStringList argv)
|
|||||||
if (m_options.contains(name))
|
if (m_options.contains(name))
|
||||||
{
|
{
|
||||||
if (map.contains(name))
|
if (map.contains(name))
|
||||||
throw ParsingError(QString("Option %2%1 was given multiple times").arg(name, optionPrefix));
|
throw ParsingError(QString("Option %2%1 was given multiple times")
|
||||||
|
.arg(name, optionPrefix));
|
||||||
|
|
||||||
OptionDef *option = m_options[name];
|
OptionDef *option = m_options[name];
|
||||||
if (option->type == otSwitch)
|
if (option->type == otSwitch)
|
||||||
@ -326,7 +332,8 @@ QHash<QString, QVariant> Parser::parse(QStringList argv)
|
|||||||
else if (m_argStyle == ArgumentStyle::SpaceAndEquals)
|
else if (m_argStyle == ArgumentStyle::SpaceAndEquals)
|
||||||
expecting.append(name);
|
expecting.append(name);
|
||||||
else
|
else
|
||||||
throw ParsingError(QString("Option %2%1 reqires an argument.").arg(name, optionPrefix));
|
throw ParsingError(QString("Option %2%1 reqires an argument.")
|
||||||
|
.arg(name, optionPrefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -343,7 +350,9 @@ QHash<QString, QVariant> Parser::parse(QStringList argv)
|
|||||||
QString flags = arg.mid(flagPrefix.length());
|
QString flags = arg.mid(flagPrefix.length());
|
||||||
QString equals;
|
QString equals;
|
||||||
|
|
||||||
if ((m_argStyle == ArgumentStyle::Equals || m_argStyle == ArgumentStyle::SpaceAndEquals) && flags.contains("="))
|
if ((m_argStyle == ArgumentStyle::Equals ||
|
||||||
|
m_argStyle == ArgumentStyle::SpaceAndEquals) &&
|
||||||
|
flags.contains("="))
|
||||||
{
|
{
|
||||||
int i = flags.indexOf("=");
|
int i = flags.indexOf("=");
|
||||||
equals = flags.mid(i + 1);
|
equals = flags.mid(i + 1);
|
||||||
@ -360,7 +369,8 @@ QHash<QString, QVariant> Parser::parse(QStringList argv)
|
|||||||
OptionDef *option = m_flags[flag];
|
OptionDef *option = m_flags[flag];
|
||||||
|
|
||||||
if (map.contains(option->name))
|
if (map.contains(option->name))
|
||||||
throw ParsingError(QString("Option %2%1 was given multiple times").arg(option->name, optionPrefix));
|
throw ParsingError(QString("Option %2%1 was given multiple times")
|
||||||
|
.arg(option->name, optionPrefix));
|
||||||
|
|
||||||
if (option->type == otSwitch)
|
if (option->type == otSwitch)
|
||||||
map[option->name] = true;
|
map[option->name] = true;
|
||||||
@ -372,11 +382,14 @@ QHash<QString, QVariant> Parser::parse(QStringList argv)
|
|||||||
if (i == flags.length() - 1)
|
if (i == flags.length() - 1)
|
||||||
map[option->name] = equals;
|
map[option->name] = equals;
|
||||||
else
|
else
|
||||||
throw ParsingError(QString("Flag %4%2 of Argument-requiring Option %1 not last flag in %4%3").arg(option->name, flag, flags, flagPrefix));
|
throw ParsingError(QString("Flag %4%2 of Argument-requiring Option "
|
||||||
|
"%1 not last flag in %4%3")
|
||||||
|
.arg(option->name, flag, flags, flagPrefix));
|
||||||
else if (m_argStyle == ArgumentStyle::SpaceAndEquals)
|
else if (m_argStyle == ArgumentStyle::SpaceAndEquals)
|
||||||
expecting.append(option->name);
|
expecting.append(option->name);
|
||||||
else
|
else
|
||||||
throw ParsingError(QString("Option %1 reqires an argument. (flag %3%2)").arg(option->name, flag, flagPrefix));
|
throw ParsingError(QString("Option %1 reqires an argument. (flag %3%2)")
|
||||||
|
.arg(option->name, flag, flagPrefix));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,13 +407,15 @@ QHash<QString, QVariant> Parser::parse(QStringList argv)
|
|||||||
|
|
||||||
// check if we're missing something
|
// check if we're missing something
|
||||||
if (!expecting.isEmpty())
|
if (!expecting.isEmpty())
|
||||||
throw ParsingError(QString("Was still expecting arguments for %2%1").arg(expecting.join(QString(", ")+optionPrefix), optionPrefix));
|
throw ParsingError(QString("Was still expecting arguments for %2%1").arg(
|
||||||
|
expecting.join(QString(", ") + optionPrefix), optionPrefix));
|
||||||
|
|
||||||
while (positionals.hasNext())
|
while (positionals.hasNext())
|
||||||
{
|
{
|
||||||
PositionalDef *param = positionals.next();
|
PositionalDef *param = positionals.next();
|
||||||
if (param->required)
|
if (param->required)
|
||||||
throw ParsingError(QString("Missing required positional argument '%1'").arg(param->name));
|
throw ParsingError(
|
||||||
|
QString("Missing required positional argument '%1'").arg(param->name));
|
||||||
else
|
else
|
||||||
map[param->name] = param->def;
|
map[param->name] = param->def;
|
||||||
}
|
}
|
||||||
@ -455,17 +470,16 @@ void Parser::getPrefix(QString &opt, QString &flag)
|
|||||||
else if (m_flagStyle == FlagStyle::Unix)
|
else if (m_flagStyle == FlagStyle::Unix)
|
||||||
opt = flag = "-";
|
opt = flag = "-";
|
||||||
// else if (m_flagStyle == FlagStyle::GNU)
|
// else if (m_flagStyle == FlagStyle::GNU)
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
opt = "--";
|
opt = "--";
|
||||||
flag = "-";
|
flag = "-";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParsingError
|
// ParsingError
|
||||||
ParsingError::ParsingError(const QString &what)
|
ParsingError::ParsingError(const QString &what) : std::runtime_error(what.toStdString())
|
||||||
:std::runtime_error(what.toStdString())
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,6 @@ bool ensureFolderPathExists(QString foldernamepath)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool copyPath(QString src, QString dst)
|
bool copyPath(QString src, QString dst)
|
||||||
{
|
{
|
||||||
QDir dir(src);
|
QDir dir(src);
|
||||||
@ -149,5 +148,3 @@ void openFileInDefaultProgram ( QString filename )
|
|||||||
{
|
{
|
||||||
QDesktopServices::openUrl("file:///" + QFileInfo(filename).absolutePath());
|
QDesktopServices::openUrl("file:///" + QFileInfo(filename).absolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ HRESULT CreateLink(LPCSTR linkPath, LPCSTR targetPath, LPCSTR args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IShellLink *link;
|
IShellLink *link;
|
||||||
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&link);
|
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
|
||||||
|
(LPVOID *)&link);
|
||||||
|
|
||||||
if (SUCCEEDED(hres))
|
if (SUCCEEDED(hres))
|
||||||
{
|
{
|
||||||
@ -70,7 +70,8 @@ QString Util::getDesktopDir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cross-platform Shortcut creation
|
// Cross-platform Shortcut creation
|
||||||
bool Util::createShortCut(QString location, QString dest, QStringList args, QString name, QString icon)
|
bool Util::createShortCut(QString location, QString dest, QStringList args, QString name,
|
||||||
|
QString icon)
|
||||||
{
|
{
|
||||||
#if LINUX
|
#if LINUX
|
||||||
location = PathCombine(location, name + ".desktop");
|
location = PathCombine(location, name + ".desktop");
|
||||||
@ -84,8 +85,10 @@ bool Util::createShortCut(QString location, QString dest, QStringList args, QStr
|
|||||||
if (!args.empty())
|
if (!args.empty())
|
||||||
argstring = " '" + args.join("' '") + "'";
|
argstring = " '" + args.join("' '") + "'";
|
||||||
|
|
||||||
stream << "[Desktop Entry]" << "\n";
|
stream << "[Desktop Entry]"
|
||||||
stream << "Type=Application" << "\n";
|
<< "\n";
|
||||||
|
stream << "Type=Application"
|
||||||
|
<< "\n";
|
||||||
stream << "TryExec=" << dest.toLocal8Bit() << "\n";
|
stream << "TryExec=" << dest.toLocal8Bit() << "\n";
|
||||||
stream << "Exec=" << dest.toLocal8Bit() << argstring.toLocal8Bit() << "\n";
|
stream << "Exec=" << dest.toLocal8Bit() << argstring.toLocal8Bit() << "\n";
|
||||||
stream << "Name=" << name.toLocal8Bit() << "\n";
|
stream << "Name=" << name.toLocal8Bit() << "\n";
|
||||||
@ -94,7 +97,8 @@ bool Util::createShortCut(QString location, QString dest, QStringList args, QStr
|
|||||||
stream.flush();
|
stream.flush();
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup | QFileDevice::ExeOther);
|
f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup |
|
||||||
|
QFileDevice::ExeOther);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#elif WINDOWS
|
#elif WINDOWS
|
||||||
|
@ -37,7 +37,6 @@ extern "C" {
|
|||||||
#define XZ_DEC_SPARC
|
#define XZ_DEC_SPARC
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* In Linux, this is used to make extern functions static when needed. */
|
/* In Linux, this is used to make extern functions static when needed. */
|
||||||
#ifndef XZ_EXTERN
|
#ifndef XZ_EXTERN
|
||||||
#define XZ_EXTERN extern
|
#define XZ_EXTERN extern
|
||||||
@ -68,7 +67,8 @@ extern "C" {
|
|||||||
* with support for all operation modes, but the preboot code may
|
* with support for all operation modes, but the preboot code may
|
||||||
* be built with fewer features to minimize code size.
|
* be built with fewer features to minimize code size.
|
||||||
*/
|
*/
|
||||||
enum xz_mode {
|
enum xz_mode
|
||||||
|
{
|
||||||
XZ_SINGLE,
|
XZ_SINGLE,
|
||||||
XZ_PREALLOC,
|
XZ_PREALLOC,
|
||||||
XZ_DYNALLOC
|
XZ_DYNALLOC
|
||||||
@ -124,7 +124,8 @@ enum xz_mode {
|
|||||||
* (relatively) clear that the compressed input is truncated, XZ_DATA_ERROR
|
* (relatively) clear that the compressed input is truncated, XZ_DATA_ERROR
|
||||||
* is used instead of XZ_BUF_ERROR.
|
* is used instead of XZ_BUF_ERROR.
|
||||||
*/
|
*/
|
||||||
enum xz_ret {
|
enum xz_ret
|
||||||
|
{
|
||||||
XZ_OK,
|
XZ_OK,
|
||||||
XZ_STREAM_END,
|
XZ_STREAM_END,
|
||||||
XZ_UNSUPPORTED_CHECK,
|
XZ_UNSUPPORTED_CHECK,
|
||||||
@ -152,7 +153,8 @@ enum xz_ret {
|
|||||||
* Only the contents of the output buffer from out[out_pos] onward, and
|
* Only the contents of the output buffer from out[out_pos] onward, and
|
||||||
* the variables in_pos and out_pos are modified by the XZ code.
|
* the variables in_pos and out_pos are modified by the XZ code.
|
||||||
*/
|
*/
|
||||||
struct xz_buf {
|
struct xz_buf
|
||||||
|
{
|
||||||
const uint8_t *in;
|
const uint8_t *in;
|
||||||
size_t in_pos;
|
size_t in_pos;
|
||||||
size_t in_size;
|
size_t in_size;
|
||||||
|
@ -64,8 +64,7 @@ typedef unsigned char bool;
|
|||||||
*/
|
*/
|
||||||
#ifndef __always_inline
|
#ifndef __always_inline
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# define __always_inline \
|
#define __always_inline inline __attribute__((__always_inline__))
|
||||||
inline __attribute__((__always_inline__))
|
|
||||||
#else
|
#else
|
||||||
#define __always_inline inline
|
#define __always_inline inline
|
||||||
#endif
|
#endif
|
||||||
@ -75,20 +74,16 @@ typedef unsigned char bool;
|
|||||||
#ifndef get_unaligned_le32
|
#ifndef get_unaligned_le32
|
||||||
static inline uint32_t get_unaligned_le32(const uint8_t *buf)
|
static inline uint32_t get_unaligned_le32(const uint8_t *buf)
|
||||||
{
|
{
|
||||||
return (uint32_t)buf[0]
|
return (uint32_t)buf[0] | ((uint32_t)buf[1] << 8) | ((uint32_t)buf[2] << 16) |
|
||||||
| ((uint32_t)buf[1] << 8)
|
((uint32_t)buf[3] << 24);
|
||||||
| ((uint32_t)buf[2] << 16)
|
|
||||||
| ((uint32_t)buf[3] << 24);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef get_unaligned_be32
|
#ifndef get_unaligned_be32
|
||||||
static inline uint32_t get_unaligned_be32(const uint8_t *buf)
|
static inline uint32_t get_unaligned_be32(const uint8_t *buf)
|
||||||
{
|
{
|
||||||
return (uint32_t)(buf[0] << 24)
|
return (uint32_t)(buf[0] << 24) | ((uint32_t)buf[1] << 16) | ((uint32_t)buf[2] << 8) |
|
||||||
| ((uint32_t)buf[1] << 16)
|
(uint32_t)buf[3];
|
||||||
| ((uint32_t)buf[2] << 8)
|
|
||||||
| (uint32_t)buf[3];
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@ XZ_EXTERN void xz_crc32_init(void)
|
|||||||
uint32_t j;
|
uint32_t j;
|
||||||
uint32_t r;
|
uint32_t r;
|
||||||
|
|
||||||
for (i = 0; i < 256; ++i) {
|
for (i = 0; i < 256; ++i)
|
||||||
|
{
|
||||||
r = i;
|
r = i;
|
||||||
for (j = 0; j < 8; ++j)
|
for (j = 0; j < 8; ++j)
|
||||||
r = (r >> 1) ^ (poly & ~((r & 1) - 1));
|
r = (r >> 1) ^ (poly & ~((r & 1) - 1));
|
||||||
@ -50,7 +51,8 @@ XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc)
|
|||||||
{
|
{
|
||||||
crc = ~crc;
|
crc = ~crc;
|
||||||
|
|
||||||
while (size != 0) {
|
while (size != 0)
|
||||||
|
{
|
||||||
crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
|
crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
|
||||||
--size;
|
--size;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@ XZ_EXTERN void xz_crc64_init(void)
|
|||||||
uint32_t j;
|
uint32_t j;
|
||||||
uint64_t r;
|
uint64_t r;
|
||||||
|
|
||||||
for (i = 0; i < 256; ++i) {
|
for (i = 0; i < 256; ++i)
|
||||||
|
{
|
||||||
r = i;
|
r = i;
|
||||||
for (j = 0; j < 8; ++j)
|
for (j = 0; j < 8; ++j)
|
||||||
r = (r >> 1) ^ (poly & ~((r & 1) - 1));
|
r = (r >> 1) ^ (poly & ~((r & 1) - 1));
|
||||||
@ -41,7 +42,8 @@ XZ_EXTERN uint64_t xz_crc64(const uint8_t *buf, size_t size, uint64_t crc)
|
|||||||
{
|
{
|
||||||
crc = ~crc;
|
crc = ~crc;
|
||||||
|
|
||||||
while (size != 0) {
|
while (size != 0)
|
||||||
|
{
|
||||||
crc = xz_crc64_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
|
crc = xz_crc64_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
|
||||||
--size;
|
--size;
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
#ifdef XZ_DEC_BCJ
|
#ifdef XZ_DEC_BCJ
|
||||||
|
|
||||||
struct xz_dec_bcj {
|
struct xz_dec_bcj
|
||||||
|
{
|
||||||
/* Type of the BCJ filter being used */
|
/* Type of the BCJ filter being used */
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
BCJ_X86 = 4, /* x86 or x86-64 */
|
BCJ_X86 = 4, /* x86 or x86-64 */
|
||||||
BCJ_POWERPC = 5, /* Big endian only */
|
BCJ_POWERPC = 5, /* Big endian only */
|
||||||
BCJ_IA64 = 6, /* Big or little endian */
|
BCJ_IA64 = 6, /* Big or little endian */
|
||||||
@ -52,7 +54,8 @@ struct xz_dec_bcj {
|
|||||||
size_t out_pos;
|
size_t out_pos;
|
||||||
size_t out_size;
|
size_t out_size;
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
/* Amount of already filtered data in the beginning of buf */
|
/* Amount of already filtered data in the beginning of buf */
|
||||||
size_t filtered;
|
size_t filtered;
|
||||||
|
|
||||||
@ -87,8 +90,8 @@ static inline int bcj_x86_test_msbyte(uint8_t b)
|
|||||||
|
|
||||||
static size_t bcj_x86(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
static size_t bcj_x86(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
||||||
{
|
{
|
||||||
static const bool mask_to_allowed_status[8]
|
static const bool mask_to_allowed_status[8] = {true, true, true, false,
|
||||||
= { true, true, true, false, true, false, false, false };
|
true, false, false, false};
|
||||||
|
|
||||||
static const uint8_t mask_to_bit_num[8] = {0, 1, 2, 2, 3, 3, 3, 3};
|
static const uint8_t mask_to_bit_num[8] = {0, 1, 2, 2, 3, 3, 3, 3};
|
||||||
|
|
||||||
@ -104,19 +107,24 @@ static size_t bcj_x86(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size -= 4;
|
size -= 4;
|
||||||
for (i = 0; i < size; ++i) {
|
for (i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
if ((buf[i] & 0xFE) != 0xE8)
|
if ((buf[i] & 0xFE) != 0xE8)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
prev_pos = i - prev_pos;
|
prev_pos = i - prev_pos;
|
||||||
if (prev_pos > 3) {
|
if (prev_pos > 3)
|
||||||
|
{
|
||||||
prev_mask = 0;
|
prev_mask = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
prev_mask = (prev_mask << (prev_pos - 1)) & 7;
|
prev_mask = (prev_mask << (prev_pos - 1)) & 7;
|
||||||
if (prev_mask != 0) {
|
if (prev_mask != 0)
|
||||||
|
{
|
||||||
b = buf[i + 4 - mask_to_bit_num[prev_mask]];
|
b = buf[i + 4 - mask_to_bit_num[prev_mask]];
|
||||||
if (!mask_to_allowed_status[prev_mask]
|
if (!mask_to_allowed_status[prev_mask] || bcj_x86_test_msbyte(b))
|
||||||
|| bcj_x86_test_msbyte(b)) {
|
{
|
||||||
prev_pos = i;
|
prev_pos = i;
|
||||||
prev_mask = (prev_mask << 1) | 1;
|
prev_mask = (prev_mask << 1) | 1;
|
||||||
continue;
|
continue;
|
||||||
@ -126,9 +134,11 @@ static size_t bcj_x86(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
|
|
||||||
prev_pos = i;
|
prev_pos = i;
|
||||||
|
|
||||||
if (bcj_x86_test_msbyte(buf[i + 4])) {
|
if (bcj_x86_test_msbyte(buf[i + 4]))
|
||||||
|
{
|
||||||
src = get_unaligned_le32(buf + i + 1);
|
src = get_unaligned_le32(buf + i + 1);
|
||||||
while (true) {
|
while (true)
|
||||||
|
{
|
||||||
dest = src - (s->pos + (uint32_t)i + 5);
|
dest = src - (s->pos + (uint32_t)i + 5);
|
||||||
if (prev_mask == 0)
|
if (prev_mask == 0)
|
||||||
break;
|
break;
|
||||||
@ -145,7 +155,9 @@ static size_t bcj_x86(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
dest |= (uint32_t)0 - (dest & 0x01000000);
|
dest |= (uint32_t)0 - (dest & 0x01000000);
|
||||||
put_unaligned_le32(dest, buf + i + 1);
|
put_unaligned_le32(dest, buf + i + 1);
|
||||||
i += 4;
|
i += 4;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
prev_mask = (prev_mask << 1) | 1;
|
prev_mask = (prev_mask << 1) | 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,9 +174,11 @@ static size_t bcj_powerpc(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
size_t i;
|
size_t i;
|
||||||
uint32_t instr;
|
uint32_t instr;
|
||||||
|
|
||||||
for (i = 0; i + 4 <= size; i += 4) {
|
for (i = 0; i + 4 <= size; i += 4)
|
||||||
|
{
|
||||||
instr = get_unaligned_be32(buf + i);
|
instr = get_unaligned_be32(buf + i);
|
||||||
if ((instr & 0xFC000003) == 0x48000001) {
|
if ((instr & 0xFC000003) == 0x48000001)
|
||||||
|
{
|
||||||
instr &= 0x03FFFFFC;
|
instr &= 0x03FFFFFC;
|
||||||
instr -= s->pos + (uint32_t)i;
|
instr -= s->pos + (uint32_t)i;
|
||||||
instr &= 0x03FFFFFC;
|
instr &= 0x03FFFFFC;
|
||||||
@ -180,12 +194,8 @@ static size_t bcj_powerpc(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
#ifdef XZ_DEC_IA64
|
#ifdef XZ_DEC_IA64
|
||||||
static size_t bcj_ia64(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
static size_t bcj_ia64(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
||||||
{
|
{
|
||||||
static const uint8_t branch_table[32] = {
|
static const uint8_t branch_table[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
4, 4, 6, 6, 0, 0, 7, 7, 4, 4, 0, 0, 4, 4, 0, 0};
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
4, 4, 6, 6, 0, 0, 7, 7,
|
|
||||||
4, 4, 0, 0, 4, 4, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The local variables take a little bit stack space, but it's less
|
* The local variables take a little bit stack space, but it's less
|
||||||
@ -219,9 +229,11 @@ static size_t bcj_ia64(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
/* Instruction normalized with bit_res for easier manipulation */
|
/* Instruction normalized with bit_res for easier manipulation */
|
||||||
uint64_t norm;
|
uint64_t norm;
|
||||||
|
|
||||||
for (i = 0; i + 16 <= size; i += 16) {
|
for (i = 0; i + 16 <= size; i += 16)
|
||||||
|
{
|
||||||
mask = branch_table[buf[i] & 0x1F];
|
mask = branch_table[buf[i] & 0x1F];
|
||||||
for (slot = 0, bit_pos = 5; slot < 3; ++slot, bit_pos += 41) {
|
for (slot = 0, bit_pos = 5; slot < 3; ++slot, bit_pos += 41)
|
||||||
|
{
|
||||||
if (((mask >> slot) & 1) == 0)
|
if (((mask >> slot) & 1) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -229,13 +241,12 @@ static size_t bcj_ia64(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
bit_res = bit_pos & 7;
|
bit_res = bit_pos & 7;
|
||||||
instr = 0;
|
instr = 0;
|
||||||
for (j = 0; j < 6; ++j)
|
for (j = 0; j < 6; ++j)
|
||||||
instr |= (uint64_t)(buf[i + j + byte_pos])
|
instr |= (uint64_t)(buf[i + j + byte_pos]) << (8 * j);
|
||||||
<< (8 * j);
|
|
||||||
|
|
||||||
norm = instr >> bit_res;
|
norm = instr >> bit_res;
|
||||||
|
|
||||||
if (((norm >> 37) & 0x0F) == 0x05
|
if (((norm >> 37) & 0x0F) == 0x05 && ((norm >> 9) & 0x07) == 0)
|
||||||
&& ((norm >> 9) & 0x07) == 0) {
|
{
|
||||||
addr = (norm >> 13) & 0x0FFFFF;
|
addr = (norm >> 13) & 0x0FFFFF;
|
||||||
addr |= ((uint32_t)(norm >> 36) & 1) << 20;
|
addr |= ((uint32_t)(norm >> 36) & 1) << 20;
|
||||||
addr <<= 4;
|
addr <<= 4;
|
||||||
@ -244,15 +255,13 @@ static size_t bcj_ia64(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
|
|
||||||
norm &= ~((uint64_t)0x8FFFFF << 13);
|
norm &= ~((uint64_t)0x8FFFFF << 13);
|
||||||
norm |= (uint64_t)(addr & 0x0FFFFF) << 13;
|
norm |= (uint64_t)(addr & 0x0FFFFF) << 13;
|
||||||
norm |= (uint64_t)(addr & 0x100000)
|
norm |= (uint64_t)(addr & 0x100000) << (36 - 20);
|
||||||
<< (36 - 20);
|
|
||||||
|
|
||||||
instr &= (1 << bit_res) - 1;
|
instr &= (1 << bit_res) - 1;
|
||||||
instr |= norm << bit_res;
|
instr |= norm << bit_res;
|
||||||
|
|
||||||
for (j = 0; j < 6; j++)
|
for (j = 0; j < 6; j++)
|
||||||
buf[i + j + byte_pos]
|
buf[i + j + byte_pos] = (uint8_t)(instr >> (8 * j));
|
||||||
= (uint8_t)(instr >> (8 * j));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,10 +276,12 @@ static size_t bcj_arm(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
size_t i;
|
size_t i;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
|
|
||||||
for (i = 0; i + 4 <= size; i += 4) {
|
for (i = 0; i + 4 <= size; i += 4)
|
||||||
if (buf[i + 3] == 0xEB) {
|
{
|
||||||
addr = (uint32_t)buf[i] | ((uint32_t)buf[i + 1] << 8)
|
if (buf[i + 3] == 0xEB)
|
||||||
| ((uint32_t)buf[i + 2] << 16);
|
{
|
||||||
|
addr =
|
||||||
|
(uint32_t)buf[i] | ((uint32_t)buf[i + 1] << 8) | ((uint32_t)buf[i + 2] << 16);
|
||||||
addr <<= 2;
|
addr <<= 2;
|
||||||
addr -= s->pos + (uint32_t)i + 8;
|
addr -= s->pos + (uint32_t)i + 8;
|
||||||
addr >>= 2;
|
addr >>= 2;
|
||||||
@ -290,13 +301,12 @@ static size_t bcj_armthumb(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
size_t i;
|
size_t i;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
|
|
||||||
for (i = 0; i + 4 <= size; i += 2) {
|
for (i = 0; i + 4 <= size; i += 2)
|
||||||
if ((buf[i + 1] & 0xF8) == 0xF0
|
{
|
||||||
&& (buf[i + 3] & 0xF8) == 0xF8) {
|
if ((buf[i + 1] & 0xF8) == 0xF0 && (buf[i + 3] & 0xF8) == 0xF8)
|
||||||
addr = (((uint32_t)buf[i + 1] & 0x07) << 19)
|
{
|
||||||
| ((uint32_t)buf[i] << 11)
|
addr = (((uint32_t)buf[i + 1] & 0x07) << 19) | ((uint32_t)buf[i] << 11) |
|
||||||
| (((uint32_t)buf[i + 3] & 0x07) << 8)
|
(((uint32_t)buf[i + 3] & 0x07) << 8) | (uint32_t)buf[i + 2];
|
||||||
| (uint32_t)buf[i + 2];
|
|
||||||
addr <<= 1;
|
addr <<= 1;
|
||||||
addr -= s->pos + (uint32_t)i + 4;
|
addr -= s->pos + (uint32_t)i + 4;
|
||||||
addr >>= 1;
|
addr >>= 1;
|
||||||
@ -318,14 +328,16 @@ static size_t bcj_sparc(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
size_t i;
|
size_t i;
|
||||||
uint32_t instr;
|
uint32_t instr;
|
||||||
|
|
||||||
for (i = 0; i + 4 <= size; i += 4) {
|
for (i = 0; i + 4 <= size; i += 4)
|
||||||
|
{
|
||||||
instr = get_unaligned_be32(buf + i);
|
instr = get_unaligned_be32(buf + i);
|
||||||
if ((instr >> 22) == 0x100 || (instr >> 22) == 0x1FF) {
|
if ((instr >> 22) == 0x100 || (instr >> 22) == 0x1FF)
|
||||||
|
{
|
||||||
instr <<= 2;
|
instr <<= 2;
|
||||||
instr -= s->pos + (uint32_t)i;
|
instr -= s->pos + (uint32_t)i;
|
||||||
instr >>= 2;
|
instr >>= 2;
|
||||||
instr = ((uint32_t)0x40000000 - (instr & 0x400000))
|
instr =
|
||||||
| 0x40000000 | (instr & 0x3FFFFF);
|
((uint32_t)0x40000000 - (instr & 0x400000)) | 0x40000000 | (instr & 0x3FFFFF);
|
||||||
put_unaligned_be32(instr, buf + i);
|
put_unaligned_be32(instr, buf + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -342,15 +354,15 @@ static size_t bcj_sparc(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
|||||||
* pointers, which could be problematic in the kernel boot code, which must
|
* pointers, which could be problematic in the kernel boot code, which must
|
||||||
* avoid pointers to static data (at least on x86).
|
* avoid pointers to static data (at least on x86).
|
||||||
*/
|
*/
|
||||||
static void bcj_apply(struct xz_dec_bcj *s,
|
static void bcj_apply(struct xz_dec_bcj *s, uint8_t *buf, size_t *pos, size_t size)
|
||||||
uint8_t *buf, size_t *pos, size_t size)
|
|
||||||
{
|
{
|
||||||
size_t filtered;
|
size_t filtered;
|
||||||
|
|
||||||
buf += *pos;
|
buf += *pos;
|
||||||
size -= *pos;
|
size -= *pos;
|
||||||
|
|
||||||
switch (s->type) {
|
switch (s->type)
|
||||||
|
{
|
||||||
#ifdef XZ_DEC_X86
|
#ifdef XZ_DEC_X86
|
||||||
case BCJ_X86:
|
case BCJ_X86:
|
||||||
filtered = bcj_x86(s, buf, size);
|
filtered = bcj_x86(s, buf, size);
|
||||||
@ -414,8 +426,7 @@ static void bcj_flush(struct xz_dec_bcj *s, struct xz_buf *b)
|
|||||||
* data in chunks of 1-16 bytes. To hide this issue, this function does
|
* data in chunks of 1-16 bytes. To hide this issue, this function does
|
||||||
* some buffering.
|
* some buffering.
|
||||||
*/
|
*/
|
||||||
XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
|
XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, struct xz_dec_lzma2 *lzma2,
|
||||||
struct xz_dec_lzma2 *lzma2,
|
|
||||||
struct xz_buf *b)
|
struct xz_buf *b)
|
||||||
{
|
{
|
||||||
size_t out_start;
|
size_t out_start;
|
||||||
@ -425,7 +436,8 @@ XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
|
|||||||
* immediatelly if we couldn't flush everything, or if the next
|
* immediatelly if we couldn't flush everything, or if the next
|
||||||
* filter in the chain had already returned XZ_STREAM_END.
|
* filter in the chain had already returned XZ_STREAM_END.
|
||||||
*/
|
*/
|
||||||
if (s->temp.filtered > 0) {
|
if (s->temp.filtered > 0)
|
||||||
|
{
|
||||||
bcj_flush(s, b);
|
bcj_flush(s, b);
|
||||||
if (s->temp.filtered > 0)
|
if (s->temp.filtered > 0)
|
||||||
return XZ_OK;
|
return XZ_OK;
|
||||||
@ -446,14 +458,14 @@ XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
|
|||||||
* case where the output buffer is full and the next filter has no
|
* case where the output buffer is full and the next filter has no
|
||||||
* more output coming but hasn't returned XZ_STREAM_END yet.
|
* more output coming but hasn't returned XZ_STREAM_END yet.
|
||||||
*/
|
*/
|
||||||
if (s->temp.size < b->out_size - b->out_pos || s->temp.size == 0) {
|
if (s->temp.size < b->out_size - b->out_pos || s->temp.size == 0)
|
||||||
|
{
|
||||||
out_start = b->out_pos;
|
out_start = b->out_pos;
|
||||||
memcpy(b->out + b->out_pos, s->temp.buf, s->temp.size);
|
memcpy(b->out + b->out_pos, s->temp.buf, s->temp.size);
|
||||||
b->out_pos += s->temp.size;
|
b->out_pos += s->temp.size;
|
||||||
|
|
||||||
s->ret = xz_dec_lzma2_run(lzma2, b);
|
s->ret = xz_dec_lzma2_run(lzma2, b);
|
||||||
if (s->ret != XZ_STREAM_END
|
if (s->ret != XZ_STREAM_END && (s->ret != XZ_OK || s->single_call))
|
||||||
&& (s->ret != XZ_OK || s->single_call))
|
|
||||||
return s->ret;
|
return s->ret;
|
||||||
|
|
||||||
bcj_apply(s, b->out, &out_start, b->out_pos);
|
bcj_apply(s, b->out, &out_start, b->out_pos);
|
||||||
@ -487,7 +499,8 @@ XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
|
|||||||
* A mix of filtered and unfiltered data may be left in temp; it will
|
* A mix of filtered and unfiltered data may be left in temp; it will
|
||||||
* be taken care on the next call to this function.
|
* be taken care on the next call to this function.
|
||||||
*/
|
*/
|
||||||
if (b->out_pos < b->out_size) {
|
if (b->out_pos < b->out_size)
|
||||||
|
{
|
||||||
/* Make b->out{,_pos,_size} temporarily point to s->temp. */
|
/* Make b->out{,_pos,_size} temporarily point to s->temp. */
|
||||||
s->out = b->out;
|
s->out = b->out;
|
||||||
s->out_pos = b->out_pos;
|
s->out_pos = b->out_pos;
|
||||||
@ -535,7 +548,8 @@ XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call)
|
|||||||
|
|
||||||
XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id)
|
XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id)
|
||||||
{
|
{
|
||||||
switch (id) {
|
switch (id)
|
||||||
|
{
|
||||||
#ifdef XZ_DEC_X86
|
#ifdef XZ_DEC_X86
|
||||||
case BCJ_X86:
|
case BCJ_X86:
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,7 +41,8 @@
|
|||||||
* in which the dictionary variables address the actual output
|
* in which the dictionary variables address the actual output
|
||||||
* buffer directly.
|
* buffer directly.
|
||||||
*/
|
*/
|
||||||
struct dictionary {
|
struct dictionary
|
||||||
|
{
|
||||||
/* Beginning of the history buffer */
|
/* Beginning of the history buffer */
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
@ -92,7 +93,8 @@ struct dictionary {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Range decoder */
|
/* Range decoder */
|
||||||
struct rc_dec {
|
struct rc_dec
|
||||||
|
{
|
||||||
uint32_t range;
|
uint32_t range;
|
||||||
uint32_t code;
|
uint32_t code;
|
||||||
|
|
||||||
@ -112,7 +114,8 @@ struct rc_dec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Probabilities for a length decoder. */
|
/* Probabilities for a length decoder. */
|
||||||
struct lzma_len_dec {
|
struct lzma_len_dec
|
||||||
|
{
|
||||||
/* Probability of match length being at least 10 */
|
/* Probability of match length being at least 10 */
|
||||||
uint16_t choice;
|
uint16_t choice;
|
||||||
|
|
||||||
@ -129,7 +132,8 @@ struct lzma_len_dec {
|
|||||||
uint16_t high[LEN_HIGH_SYMBOLS];
|
uint16_t high[LEN_HIGH_SYMBOLS];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lzma_dec {
|
struct lzma_dec
|
||||||
|
{
|
||||||
/* Distances of latest four matches */
|
/* Distances of latest four matches */
|
||||||
uint32_t rep0;
|
uint32_t rep0;
|
||||||
uint32_t rep1;
|
uint32_t rep1;
|
||||||
@ -211,9 +215,11 @@ struct lzma_dec {
|
|||||||
uint16_t literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE];
|
uint16_t literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lzma2_dec {
|
struct lzma2_dec
|
||||||
|
{
|
||||||
/* Position in xz_dec_lzma2_run(). */
|
/* Position in xz_dec_lzma2_run(). */
|
||||||
enum lzma2_seq {
|
enum lzma2_seq
|
||||||
|
{
|
||||||
SEQ_CONTROL,
|
SEQ_CONTROL,
|
||||||
SEQ_UNCOMPRESSED_1,
|
SEQ_UNCOMPRESSED_1,
|
||||||
SEQ_UNCOMPRESSED_2,
|
SEQ_UNCOMPRESSED_2,
|
||||||
@ -250,7 +256,8 @@ struct lzma2_dec {
|
|||||||
bool need_props;
|
bool need_props;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xz_dec_lzma2 {
|
struct xz_dec_lzma2
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* The order below is important on x86 to reduce code size and
|
* The order below is important on x86 to reduce code size and
|
||||||
* it shouldn't hurt on other platforms. Everything up to and
|
* it shouldn't hurt on other platforms. Everything up to and
|
||||||
@ -269,7 +276,8 @@ struct xz_dec_lzma2 {
|
|||||||
* Temporary buffer which holds small number of input bytes between
|
* Temporary buffer which holds small number of input bytes between
|
||||||
* decoder calls. See lzma2_lzma() for details.
|
* decoder calls. See lzma2_lzma() for details.
|
||||||
*/
|
*/
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint8_t buf[3 * LZMA_IN_REQUIRED];
|
uint8_t buf[3 * LZMA_IN_REQUIRED];
|
||||||
} temp;
|
} temp;
|
||||||
@ -285,7 +293,8 @@ struct xz_dec_lzma2 {
|
|||||||
*/
|
*/
|
||||||
static void dict_reset(struct dictionary *dict, struct xz_buf *b)
|
static void dict_reset(struct dictionary *dict, struct xz_buf *b)
|
||||||
{
|
{
|
||||||
if (DEC_IS_SINGLE(dict->mode)) {
|
if (DEC_IS_SINGLE(dict->mode))
|
||||||
|
{
|
||||||
dict->buf = b->out + b->out_pos;
|
dict->buf = b->out + b->out_pos;
|
||||||
dict->end = b->out_size - b->out_pos;
|
dict->end = b->out_size - b->out_pos;
|
||||||
}
|
}
|
||||||
@ -358,7 +367,8 @@ static bool dict_repeat(struct dictionary *dict, uint32_t *len, uint32_t dist)
|
|||||||
if (dist >= dict->pos)
|
if (dist >= dict->pos)
|
||||||
back += dict->end;
|
back += dict->end;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
dict->buf[dict->pos++] = dict->buf[back++];
|
dict->buf[dict->pos++] = dict->buf[back++];
|
||||||
if (back == dict->end)
|
if (back == dict->end)
|
||||||
back = 0;
|
back = 0;
|
||||||
@ -371,15 +381,13 @@ static bool dict_repeat(struct dictionary *dict, uint32_t *len, uint32_t dist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Copy uncompressed data as is from input to dictionary and output buffers. */
|
/* Copy uncompressed data as is from input to dictionary and output buffers. */
|
||||||
static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
|
static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b, uint32_t *left)
|
||||||
uint32_t *left)
|
|
||||||
{
|
{
|
||||||
size_t copy_size;
|
size_t copy_size;
|
||||||
|
|
||||||
while (*left > 0 && b->in_pos < b->in_size
|
while (*left > 0 && b->in_pos < b->in_size && b->out_pos < b->out_size)
|
||||||
&& b->out_pos < b->out_size) {
|
{
|
||||||
copy_size = min(b->in_size - b->in_pos,
|
copy_size = min(b->in_size - b->in_pos, b->out_size - b->out_pos);
|
||||||
b->out_size - b->out_pos);
|
|
||||||
if (copy_size > dict->end - dict->pos)
|
if (copy_size > dict->end - dict->pos)
|
||||||
copy_size = dict->end - dict->pos;
|
copy_size = dict->end - dict->pos;
|
||||||
if (copy_size > *left)
|
if (copy_size > *left)
|
||||||
@ -393,12 +401,12 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
|
|||||||
if (dict->full < dict->pos)
|
if (dict->full < dict->pos)
|
||||||
dict->full = dict->pos;
|
dict->full = dict->pos;
|
||||||
|
|
||||||
if (DEC_IS_MULTI(dict->mode)) {
|
if (DEC_IS_MULTI(dict->mode))
|
||||||
|
{
|
||||||
if (dict->pos == dict->end)
|
if (dict->pos == dict->end)
|
||||||
dict->pos = 0;
|
dict->pos = 0;
|
||||||
|
|
||||||
memcpy(b->out + b->out_pos, b->in + b->in_pos,
|
memcpy(b->out + b->out_pos, b->in + b->in_pos, copy_size);
|
||||||
copy_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dict->start = dict->pos;
|
dict->start = dict->pos;
|
||||||
@ -417,12 +425,12 @@ static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b)
|
|||||||
{
|
{
|
||||||
size_t copy_size = dict->pos - dict->start;
|
size_t copy_size = dict->pos - dict->start;
|
||||||
|
|
||||||
if (DEC_IS_MULTI(dict->mode)) {
|
if (DEC_IS_MULTI(dict->mode))
|
||||||
|
{
|
||||||
if (dict->pos == dict->end)
|
if (dict->pos == dict->end)
|
||||||
dict->pos = 0;
|
dict->pos = 0;
|
||||||
|
|
||||||
memcpy(b->out + b->out_pos, dict->buf + dict->start,
|
memcpy(b->out + b->out_pos, dict->buf + dict->start, copy_size);
|
||||||
copy_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dict->start = dict->pos;
|
dict->start = dict->pos;
|
||||||
@ -448,7 +456,8 @@ static void rc_reset(struct rc_dec *rc)
|
|||||||
*/
|
*/
|
||||||
static bool rc_read_init(struct rc_dec *rc, struct xz_buf *b)
|
static bool rc_read_init(struct rc_dec *rc, struct xz_buf *b)
|
||||||
{
|
{
|
||||||
while (rc->init_bytes_left > 0) {
|
while (rc->init_bytes_left > 0)
|
||||||
|
{
|
||||||
if (b->in_pos == b->in_size)
|
if (b->in_pos == b->in_size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -477,7 +486,8 @@ static inline bool rc_is_finished(const struct rc_dec *rc)
|
|||||||
/* Read the next input byte if needed. */
|
/* Read the next input byte if needed. */
|
||||||
static __always_inline void rc_normalize(struct rc_dec *rc)
|
static __always_inline void rc_normalize(struct rc_dec *rc)
|
||||||
{
|
{
|
||||||
if (rc->range < RC_TOP_VALUE) {
|
if (rc->range < RC_TOP_VALUE)
|
||||||
|
{
|
||||||
rc->range <<= RC_SHIFT_BITS;
|
rc->range <<= RC_SHIFT_BITS;
|
||||||
rc->code = (rc->code << RC_SHIFT_BITS) + rc->in[rc->in_pos++];
|
rc->code = (rc->code << RC_SHIFT_BITS) + rc->in[rc->in_pos++];
|
||||||
}
|
}
|
||||||
@ -501,11 +511,14 @@ static __always_inline int rc_bit(struct rc_dec *rc, uint16_t *prob)
|
|||||||
|
|
||||||
rc_normalize(rc);
|
rc_normalize(rc);
|
||||||
bound = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) * *prob;
|
bound = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) * *prob;
|
||||||
if (rc->code < bound) {
|
if (rc->code < bound)
|
||||||
|
{
|
||||||
rc->range = bound;
|
rc->range = bound;
|
||||||
*prob += (RC_BIT_MODEL_TOTAL - *prob) >> RC_MOVE_BITS;
|
*prob += (RC_BIT_MODEL_TOTAL - *prob) >> RC_MOVE_BITS;
|
||||||
bit = 0;
|
bit = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
rc->range -= bound;
|
rc->range -= bound;
|
||||||
rc->code -= bound;
|
rc->code -= bound;
|
||||||
*prob -= *prob >> RC_MOVE_BITS;
|
*prob -= *prob >> RC_MOVE_BITS;
|
||||||
@ -516,12 +529,12 @@ static __always_inline int rc_bit(struct rc_dec *rc, uint16_t *prob)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Decode a bittree starting from the most significant bit. */
|
/* Decode a bittree starting from the most significant bit. */
|
||||||
static __always_inline uint32_t rc_bittree(struct rc_dec *rc,
|
static __always_inline uint32_t rc_bittree(struct rc_dec *rc, uint16_t *probs, uint32_t limit)
|
||||||
uint16_t *probs, uint32_t limit)
|
|
||||||
{
|
{
|
||||||
uint32_t symbol = 1;
|
uint32_t symbol = 1;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
if (rc_bit(rc, &probs[symbol]))
|
if (rc_bit(rc, &probs[symbol]))
|
||||||
symbol = (symbol << 1) + 1;
|
symbol = (symbol << 1) + 1;
|
||||||
else
|
else
|
||||||
@ -532,18 +545,21 @@ static __always_inline uint32_t rc_bittree(struct rc_dec *rc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Decode a bittree starting from the least significant bit. */
|
/* Decode a bittree starting from the least significant bit. */
|
||||||
static __always_inline void rc_bittree_reverse(struct rc_dec *rc,
|
static __always_inline void rc_bittree_reverse(struct rc_dec *rc, uint16_t *probs,
|
||||||
uint16_t *probs,
|
|
||||||
uint32_t *dest, uint32_t limit)
|
uint32_t *dest, uint32_t limit)
|
||||||
{
|
{
|
||||||
uint32_t symbol = 1;
|
uint32_t symbol = 1;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
|
||||||
do {
|
do
|
||||||
if (rc_bit(rc, &probs[symbol])) {
|
{
|
||||||
|
if (rc_bit(rc, &probs[symbol]))
|
||||||
|
{
|
||||||
symbol = (symbol << 1) + 1;
|
symbol = (symbol << 1) + 1;
|
||||||
*dest += 1 << i;
|
*dest += 1 << i;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
symbol <<= 1;
|
symbol <<= 1;
|
||||||
}
|
}
|
||||||
} while (++i < limit);
|
} while (++i < limit);
|
||||||
@ -554,7 +570,8 @@ static inline void rc_direct(struct rc_dec *rc, uint32_t *dest, uint32_t limit)
|
|||||||
{
|
{
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
rc_normalize(rc);
|
rc_normalize(rc);
|
||||||
rc->range >>= 1;
|
rc->range >>= 1;
|
||||||
rc->code -= rc->range;
|
rc->code -= rc->range;
|
||||||
@ -589,22 +606,29 @@ static void lzma_literal(struct xz_dec_lzma2 *s)
|
|||||||
|
|
||||||
probs = lzma_literal_probs(s);
|
probs = lzma_literal_probs(s);
|
||||||
|
|
||||||
if (lzma_state_is_literal(s->lzma.state)) {
|
if (lzma_state_is_literal(s->lzma.state))
|
||||||
|
{
|
||||||
symbol = rc_bittree(&s->rc, probs, 0x100);
|
symbol = rc_bittree(&s->rc, probs, 0x100);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
symbol = 1;
|
symbol = 1;
|
||||||
match_byte = dict_get(&s->dict, s->lzma.rep0) << 1;
|
match_byte = dict_get(&s->dict, s->lzma.rep0) << 1;
|
||||||
offset = 0x100;
|
offset = 0x100;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
match_bit = match_byte & offset;
|
match_bit = match_byte & offset;
|
||||||
match_byte <<= 1;
|
match_byte <<= 1;
|
||||||
i = offset + match_bit + symbol;
|
i = offset + match_bit + symbol;
|
||||||
|
|
||||||
if (rc_bit(&s->rc, &probs[i])) {
|
if (rc_bit(&s->rc, &probs[i]))
|
||||||
|
{
|
||||||
symbol = (symbol << 1) + 1;
|
symbol = (symbol << 1) + 1;
|
||||||
offset &= match_bit;
|
offset &= match_bit;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
symbol <<= 1;
|
symbol <<= 1;
|
||||||
offset &= ~match_bit;
|
offset &= ~match_bit;
|
||||||
}
|
}
|
||||||
@ -616,26 +640,30 @@ static void lzma_literal(struct xz_dec_lzma2 *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Decode the length of the match into s->lzma.len. */
|
/* Decode the length of the match into s->lzma.len. */
|
||||||
static void lzma_len(struct xz_dec_lzma2 *s, struct lzma_len_dec *l,
|
static void lzma_len(struct xz_dec_lzma2 *s, struct lzma_len_dec *l, uint32_t pos_state)
|
||||||
uint32_t pos_state)
|
|
||||||
{
|
{
|
||||||
uint16_t *probs;
|
uint16_t *probs;
|
||||||
uint32_t limit;
|
uint32_t limit;
|
||||||
|
|
||||||
if (!rc_bit(&s->rc, &l->choice)) {
|
if (!rc_bit(&s->rc, &l->choice))
|
||||||
|
{
|
||||||
probs = l->low[pos_state];
|
probs = l->low[pos_state];
|
||||||
limit = LEN_LOW_SYMBOLS;
|
limit = LEN_LOW_SYMBOLS;
|
||||||
s->lzma.len = MATCH_LEN_MIN;
|
s->lzma.len = MATCH_LEN_MIN;
|
||||||
} else {
|
}
|
||||||
if (!rc_bit(&s->rc, &l->choice2)) {
|
else
|
||||||
|
{
|
||||||
|
if (!rc_bit(&s->rc, &l->choice2))
|
||||||
|
{
|
||||||
probs = l->mid[pos_state];
|
probs = l->mid[pos_state];
|
||||||
limit = LEN_MID_SYMBOLS;
|
limit = LEN_MID_SYMBOLS;
|
||||||
s->lzma.len = MATCH_LEN_MIN + LEN_LOW_SYMBOLS;
|
s->lzma.len = MATCH_LEN_MIN + LEN_LOW_SYMBOLS;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
probs = l->high;
|
probs = l->high;
|
||||||
limit = LEN_HIGH_SYMBOLS;
|
limit = LEN_HIGH_SYMBOLS;
|
||||||
s->lzma.len = MATCH_LEN_MIN + LEN_LOW_SYMBOLS
|
s->lzma.len = MATCH_LEN_MIN + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS;
|
||||||
+ LEN_MID_SYMBOLS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,23 +688,26 @@ static void lzma_match(struct xz_dec_lzma2 *s, uint32_t pos_state)
|
|||||||
probs = s->lzma.dist_slot[lzma_get_dist_state(s->lzma.len)];
|
probs = s->lzma.dist_slot[lzma_get_dist_state(s->lzma.len)];
|
||||||
dist_slot = rc_bittree(&s->rc, probs, DIST_SLOTS) - DIST_SLOTS;
|
dist_slot = rc_bittree(&s->rc, probs, DIST_SLOTS) - DIST_SLOTS;
|
||||||
|
|
||||||
if (dist_slot < DIST_MODEL_START) {
|
if (dist_slot < DIST_MODEL_START)
|
||||||
|
{
|
||||||
s->lzma.rep0 = dist_slot;
|
s->lzma.rep0 = dist_slot;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
limit = (dist_slot >> 1) - 1;
|
limit = (dist_slot >> 1) - 1;
|
||||||
s->lzma.rep0 = 2 + (dist_slot & 1);
|
s->lzma.rep0 = 2 + (dist_slot & 1);
|
||||||
|
|
||||||
if (dist_slot < DIST_MODEL_END) {
|
if (dist_slot < DIST_MODEL_END)
|
||||||
|
{
|
||||||
s->lzma.rep0 <<= limit;
|
s->lzma.rep0 <<= limit;
|
||||||
probs = s->lzma.dist_special + s->lzma.rep0
|
probs = s->lzma.dist_special + s->lzma.rep0 - dist_slot - 1;
|
||||||
- dist_slot - 1;
|
rc_bittree_reverse(&s->rc, probs, &s->lzma.rep0, limit);
|
||||||
rc_bittree_reverse(&s->rc, probs,
|
}
|
||||||
&s->lzma.rep0, limit);
|
else
|
||||||
} else {
|
{
|
||||||
rc_direct(&s->rc, &s->lzma.rep0, limit - ALIGN_BITS);
|
rc_direct(&s->rc, &s->lzma.rep0, limit - ALIGN_BITS);
|
||||||
s->lzma.rep0 <<= ALIGN_BITS;
|
s->lzma.rep0 <<= ALIGN_BITS;
|
||||||
rc_bittree_reverse(&s->rc, s->lzma.dist_align,
|
rc_bittree_reverse(&s->rc, s->lzma.dist_align, &s->lzma.rep0, ALIGN_BITS);
|
||||||
&s->lzma.rep0, ALIGN_BITS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -689,20 +720,29 @@ static void lzma_rep_match(struct xz_dec_lzma2 *s, uint32_t pos_state)
|
|||||||
{
|
{
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
if (!rc_bit(&s->rc, &s->lzma.is_rep0[s->lzma.state])) {
|
if (!rc_bit(&s->rc, &s->lzma.is_rep0[s->lzma.state]))
|
||||||
if (!rc_bit(&s->rc, &s->lzma.is_rep0_long[
|
{
|
||||||
s->lzma.state][pos_state])) {
|
if (!rc_bit(&s->rc, &s->lzma.is_rep0_long[s->lzma.state][pos_state]))
|
||||||
|
{
|
||||||
lzma_state_short_rep(&s->lzma.state);
|
lzma_state_short_rep(&s->lzma.state);
|
||||||
s->lzma.len = 1;
|
s->lzma.len = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (!rc_bit(&s->rc, &s->lzma.is_rep1[s->lzma.state])) {
|
else
|
||||||
|
{
|
||||||
|
if (!rc_bit(&s->rc, &s->lzma.is_rep1[s->lzma.state]))
|
||||||
|
{
|
||||||
tmp = s->lzma.rep1;
|
tmp = s->lzma.rep1;
|
||||||
} else {
|
}
|
||||||
if (!rc_bit(&s->rc, &s->lzma.is_rep2[s->lzma.state])) {
|
else
|
||||||
|
{
|
||||||
|
if (!rc_bit(&s->rc, &s->lzma.is_rep2[s->lzma.state]))
|
||||||
|
{
|
||||||
tmp = s->lzma.rep2;
|
tmp = s->lzma.rep2;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
tmp = s->lzma.rep3;
|
tmp = s->lzma.rep3;
|
||||||
s->lzma.rep3 = s->lzma.rep2;
|
s->lzma.rep3 = s->lzma.rep2;
|
||||||
}
|
}
|
||||||
@ -734,13 +774,16 @@ static bool lzma_main(struct xz_dec_lzma2 *s)
|
|||||||
* Decode more LZMA symbols. One iteration may consume up to
|
* Decode more LZMA symbols. One iteration may consume up to
|
||||||
* LZMA_IN_REQUIRED - 1 bytes.
|
* LZMA_IN_REQUIRED - 1 bytes.
|
||||||
*/
|
*/
|
||||||
while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) {
|
while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc))
|
||||||
|
{
|
||||||
pos_state = s->dict.pos & s->lzma.pos_mask;
|
pos_state = s->dict.pos & s->lzma.pos_mask;
|
||||||
|
|
||||||
if (!rc_bit(&s->rc, &s->lzma.is_match[
|
if (!rc_bit(&s->rc, &s->lzma.is_match[s->lzma.state][pos_state]))
|
||||||
s->lzma.state][pos_state])) {
|
{
|
||||||
lzma_literal(s);
|
lzma_literal(s);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (rc_bit(&s->rc, &s->lzma.is_rep[s->lzma.state]))
|
if (rc_bit(&s->rc, &s->lzma.is_rep[s->lzma.state]))
|
||||||
lzma_rep_match(s, pos_state);
|
lzma_rep_match(s, pos_state);
|
||||||
else
|
else
|
||||||
@ -802,7 +845,8 @@ static bool lzma_props(struct xz_dec_lzma2 *s, uint8_t props)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
s->lzma.pos_mask = 0;
|
s->lzma.pos_mask = 0;
|
||||||
while (props >= 9 * 5) {
|
while (props >= 9 * 5)
|
||||||
|
{
|
||||||
props -= 9 * 5;
|
props -= 9 * 5;
|
||||||
++s->lzma.pos_mask;
|
++s->lzma.pos_mask;
|
||||||
}
|
}
|
||||||
@ -810,7 +854,8 @@ static bool lzma_props(struct xz_dec_lzma2 *s, uint8_t props)
|
|||||||
s->lzma.pos_mask = (1 << s->lzma.pos_mask) - 1;
|
s->lzma.pos_mask = (1 << s->lzma.pos_mask) - 1;
|
||||||
|
|
||||||
s->lzma.literal_pos_mask = 0;
|
s->lzma.literal_pos_mask = 0;
|
||||||
while (props >= 9) {
|
while (props >= 9)
|
||||||
|
{
|
||||||
props -= 9;
|
props -= 9;
|
||||||
++s->lzma.literal_pos_mask;
|
++s->lzma.literal_pos_mask;
|
||||||
}
|
}
|
||||||
@ -849,7 +894,8 @@ static bool lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b)
|
|||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
in_avail = b->in_size - b->in_pos;
|
in_avail = b->in_size - b->in_pos;
|
||||||
if (s->temp.size > 0 || s->lzma2.compressed == 0) {
|
if (s->temp.size > 0 || s->lzma2.compressed == 0)
|
||||||
|
{
|
||||||
tmp = 2 * LZMA_IN_REQUIRED - s->temp.size;
|
tmp = 2 * LZMA_IN_REQUIRED - s->temp.size;
|
||||||
if (tmp > s->lzma2.compressed - s->temp.size)
|
if (tmp > s->lzma2.compressed - s->temp.size)
|
||||||
tmp = s->lzma2.compressed - s->temp.size;
|
tmp = s->lzma2.compressed - s->temp.size;
|
||||||
@ -858,16 +904,19 @@ static bool lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b)
|
|||||||
|
|
||||||
memcpy(s->temp.buf + s->temp.size, b->in + b->in_pos, tmp);
|
memcpy(s->temp.buf + s->temp.size, b->in + b->in_pos, tmp);
|
||||||
|
|
||||||
if (s->temp.size + tmp == s->lzma2.compressed) {
|
if (s->temp.size + tmp == s->lzma2.compressed)
|
||||||
memzero(s->temp.buf + s->temp.size + tmp,
|
{
|
||||||
sizeof(s->temp.buf)
|
memzero(s->temp.buf + s->temp.size + tmp, sizeof(s->temp.buf) - s->temp.size - tmp);
|
||||||
- s->temp.size - tmp);
|
|
||||||
s->rc.in_limit = s->temp.size + tmp;
|
s->rc.in_limit = s->temp.size + tmp;
|
||||||
} else if (s->temp.size + tmp < LZMA_IN_REQUIRED) {
|
}
|
||||||
|
else if (s->temp.size + tmp < LZMA_IN_REQUIRED)
|
||||||
|
{
|
||||||
s->temp.size += tmp;
|
s->temp.size += tmp;
|
||||||
b->in_pos += tmp;
|
b->in_pos += tmp;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
s->rc.in_limit = s->temp.size + tmp - LZMA_IN_REQUIRED;
|
s->rc.in_limit = s->temp.size + tmp - LZMA_IN_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -879,10 +928,10 @@ static bool lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b)
|
|||||||
|
|
||||||
s->lzma2.compressed -= s->rc.in_pos;
|
s->lzma2.compressed -= s->rc.in_pos;
|
||||||
|
|
||||||
if (s->rc.in_pos < s->temp.size) {
|
if (s->rc.in_pos < s->temp.size)
|
||||||
|
{
|
||||||
s->temp.size -= s->rc.in_pos;
|
s->temp.size -= s->rc.in_pos;
|
||||||
memmove(s->temp.buf, s->temp.buf + s->rc.in_pos,
|
memmove(s->temp.buf, s->temp.buf + s->rc.in_pos, s->temp.size);
|
||||||
s->temp.size);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,7 +940,8 @@ static bool lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
in_avail = b->in_size - b->in_pos;
|
in_avail = b->in_size - b->in_pos;
|
||||||
if (in_avail >= LZMA_IN_REQUIRED) {
|
if (in_avail >= LZMA_IN_REQUIRED)
|
||||||
|
{
|
||||||
s->rc.in = b->in;
|
s->rc.in = b->in;
|
||||||
s->rc.in_pos = b->in_pos;
|
s->rc.in_pos = b->in_pos;
|
||||||
|
|
||||||
@ -912,7 +962,8 @@ static bool lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
in_avail = b->in_size - b->in_pos;
|
in_avail = b->in_size - b->in_pos;
|
||||||
if (in_avail < LZMA_IN_REQUIRED) {
|
if (in_avail < LZMA_IN_REQUIRED)
|
||||||
|
{
|
||||||
if (in_avail > s->lzma2.compressed)
|
if (in_avail > s->lzma2.compressed)
|
||||||
in_avail = s->lzma2.compressed;
|
in_avail = s->lzma2.compressed;
|
||||||
|
|
||||||
@ -928,13 +979,14 @@ static bool lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b)
|
|||||||
* Take care of the LZMA2 control layer, and forward the job of actual LZMA
|
* Take care of the LZMA2 control layer, and forward the job of actual LZMA
|
||||||
* decoding or copying of uncompressed chunks to other functions.
|
* decoding or copying of uncompressed chunks to other functions.
|
||||||
*/
|
*/
|
||||||
XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
|
XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, struct xz_buf *b)
|
||||||
struct xz_buf *b)
|
|
||||||
{
|
{
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
|
|
||||||
while (b->in_pos < b->in_size || s->lzma2.sequence == SEQ_LZMA_RUN) {
|
while (b->in_pos < b->in_size || s->lzma2.sequence == SEQ_LZMA_RUN)
|
||||||
switch (s->lzma2.sequence) {
|
{
|
||||||
|
switch (s->lzma2.sequence)
|
||||||
|
{
|
||||||
case SEQ_CONTROL:
|
case SEQ_CONTROL:
|
||||||
/*
|
/*
|
||||||
* LZMA2 control byte
|
* LZMA2 control byte
|
||||||
@ -972,38 +1024,45 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
|
|||||||
if (tmp == 0x00)
|
if (tmp == 0x00)
|
||||||
return XZ_STREAM_END;
|
return XZ_STREAM_END;
|
||||||
|
|
||||||
if (tmp >= 0xE0 || tmp == 0x01) {
|
if (tmp >= 0xE0 || tmp == 0x01)
|
||||||
|
{
|
||||||
s->lzma2.need_props = true;
|
s->lzma2.need_props = true;
|
||||||
s->lzma2.need_dict_reset = false;
|
s->lzma2.need_dict_reset = false;
|
||||||
dict_reset(&s->dict, b);
|
dict_reset(&s->dict, b);
|
||||||
} else if (s->lzma2.need_dict_reset) {
|
}
|
||||||
|
else if (s->lzma2.need_dict_reset)
|
||||||
|
{
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmp >= 0x80) {
|
if (tmp >= 0x80)
|
||||||
|
{
|
||||||
s->lzma2.uncompressed = (tmp & 0x1F) << 16;
|
s->lzma2.uncompressed = (tmp & 0x1F) << 16;
|
||||||
s->lzma2.sequence = SEQ_UNCOMPRESSED_1;
|
s->lzma2.sequence = SEQ_UNCOMPRESSED_1;
|
||||||
|
|
||||||
if (tmp >= 0xC0) {
|
if (tmp >= 0xC0)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* When there are new properties,
|
* When there are new properties,
|
||||||
* state reset is done at
|
* state reset is done at
|
||||||
* SEQ_PROPERTIES.
|
* SEQ_PROPERTIES.
|
||||||
*/
|
*/
|
||||||
s->lzma2.need_props = false;
|
s->lzma2.need_props = false;
|
||||||
s->lzma2.next_sequence
|
s->lzma2.next_sequence = SEQ_PROPERTIES;
|
||||||
= SEQ_PROPERTIES;
|
}
|
||||||
|
else if (s->lzma2.need_props)
|
||||||
} else if (s->lzma2.need_props) {
|
{
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
s->lzma2.next_sequence
|
{
|
||||||
= SEQ_LZMA_PREPARE;
|
s->lzma2.next_sequence = SEQ_LZMA_PREPARE;
|
||||||
if (tmp >= 0xA0)
|
if (tmp >= 0xA0)
|
||||||
lzma_reset(s);
|
lzma_reset(s);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (tmp > 0x02)
|
if (tmp > 0x02)
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
@ -1014,26 +1073,22 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SEQ_UNCOMPRESSED_1:
|
case SEQ_UNCOMPRESSED_1:
|
||||||
s->lzma2.uncompressed
|
s->lzma2.uncompressed += (uint32_t)b->in[b->in_pos++] << 8;
|
||||||
+= (uint32_t)b->in[b->in_pos++] << 8;
|
|
||||||
s->lzma2.sequence = SEQ_UNCOMPRESSED_2;
|
s->lzma2.sequence = SEQ_UNCOMPRESSED_2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEQ_UNCOMPRESSED_2:
|
case SEQ_UNCOMPRESSED_2:
|
||||||
s->lzma2.uncompressed
|
s->lzma2.uncompressed += (uint32_t)b->in[b->in_pos++] + 1;
|
||||||
+= (uint32_t)b->in[b->in_pos++] + 1;
|
|
||||||
s->lzma2.sequence = SEQ_COMPRESSED_0;
|
s->lzma2.sequence = SEQ_COMPRESSED_0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEQ_COMPRESSED_0:
|
case SEQ_COMPRESSED_0:
|
||||||
s->lzma2.compressed
|
s->lzma2.compressed = (uint32_t)b->in[b->in_pos++] << 8;
|
||||||
= (uint32_t)b->in[b->in_pos++] << 8;
|
|
||||||
s->lzma2.sequence = SEQ_COMPRESSED_1;
|
s->lzma2.sequence = SEQ_COMPRESSED_1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEQ_COMPRESSED_1:
|
case SEQ_COMPRESSED_1:
|
||||||
s->lzma2.compressed
|
s->lzma2.compressed += (uint32_t)b->in[b->in_pos++] + 1;
|
||||||
+= (uint32_t)b->in[b->in_pos++] + 1;
|
|
||||||
s->lzma2.sequence = s->lzma2.next_sequence;
|
s->lzma2.sequence = s->lzma2.next_sequence;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1063,26 +1118,24 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
|
|||||||
* the output buffer yet, we may run this loop
|
* the output buffer yet, we may run this loop
|
||||||
* multiple times without changing s->lzma2.sequence.
|
* multiple times without changing s->lzma2.sequence.
|
||||||
*/
|
*/
|
||||||
dict_limit(&s->dict, min_t(size_t,
|
dict_limit(&s->dict,
|
||||||
b->out_size - b->out_pos,
|
min_t(size_t, b->out_size - b->out_pos, s->lzma2.uncompressed));
|
||||||
s->lzma2.uncompressed));
|
|
||||||
if (!lzma2_lzma(s, b))
|
if (!lzma2_lzma(s, b))
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
s->lzma2.uncompressed -= dict_flush(&s->dict, b);
|
s->lzma2.uncompressed -= dict_flush(&s->dict, b);
|
||||||
|
|
||||||
if (s->lzma2.uncompressed == 0) {
|
if (s->lzma2.uncompressed == 0)
|
||||||
if (s->lzma2.compressed > 0 || s->lzma.len > 0
|
{
|
||||||
|| !rc_is_finished(&s->rc))
|
if (s->lzma2.compressed > 0 || s->lzma.len > 0 || !rc_is_finished(&s->rc))
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
rc_reset(&s->rc);
|
rc_reset(&s->rc);
|
||||||
s->lzma2.sequence = SEQ_CONTROL;
|
s->lzma2.sequence = SEQ_CONTROL;
|
||||||
|
}
|
||||||
} else if (b->out_pos == b->out_size
|
else if (b->out_pos == b->out_size ||
|
||||||
|| (b->in_pos == b->in_size
|
(b->in_pos == b->in_size && s->temp.size < s->lzma2.compressed))
|
||||||
&& s->temp.size
|
{
|
||||||
< s->lzma2.compressed)) {
|
|
||||||
return XZ_OK;
|
return XZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1101,8 +1154,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
|
|||||||
return XZ_OK;
|
return XZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode,
|
XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, uint32_t dict_max)
|
||||||
uint32_t dict_max)
|
|
||||||
{
|
{
|
||||||
struct xz_dec_lzma2 *s = kmalloc(sizeof(*s), GFP_KERNEL);
|
struct xz_dec_lzma2 *s = kmalloc(sizeof(*s), GFP_KERNEL);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
@ -1111,13 +1163,17 @@ XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode,
|
|||||||
s->dict.mode = mode;
|
s->dict.mode = mode;
|
||||||
s->dict.size_max = dict_max;
|
s->dict.size_max = dict_max;
|
||||||
|
|
||||||
if (DEC_IS_PREALLOC(mode)) {
|
if (DEC_IS_PREALLOC(mode))
|
||||||
|
{
|
||||||
s->dict.buf = vmalloc(dict_max);
|
s->dict.buf = vmalloc(dict_max);
|
||||||
if (s->dict.buf == NULL) {
|
if (s->dict.buf == NULL)
|
||||||
|
{
|
||||||
kfree(s);
|
kfree(s);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else if (DEC_IS_DYNALLOC(mode)) {
|
}
|
||||||
|
else if (DEC_IS_DYNALLOC(mode))
|
||||||
|
{
|
||||||
s->dict.buf = NULL;
|
s->dict.buf = NULL;
|
||||||
s->dict.allocated = 0;
|
s->dict.allocated = 0;
|
||||||
}
|
}
|
||||||
@ -1134,17 +1190,21 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props)
|
|||||||
s->dict.size = 2 + (props & 1);
|
s->dict.size = 2 + (props & 1);
|
||||||
s->dict.size <<= (props >> 1) + 11;
|
s->dict.size <<= (props >> 1) + 11;
|
||||||
|
|
||||||
if (DEC_IS_MULTI(s->dict.mode)) {
|
if (DEC_IS_MULTI(s->dict.mode))
|
||||||
|
{
|
||||||
if (s->dict.size > s->dict.size_max)
|
if (s->dict.size > s->dict.size_max)
|
||||||
return XZ_MEMLIMIT_ERROR;
|
return XZ_MEMLIMIT_ERROR;
|
||||||
|
|
||||||
s->dict.end = s->dict.size;
|
s->dict.end = s->dict.size;
|
||||||
|
|
||||||
if (DEC_IS_DYNALLOC(s->dict.mode)) {
|
if (DEC_IS_DYNALLOC(s->dict.mode))
|
||||||
if (s->dict.allocated < s->dict.size) {
|
{
|
||||||
|
if (s->dict.allocated < s->dict.size)
|
||||||
|
{
|
||||||
vfree(s->dict.buf);
|
vfree(s->dict.buf);
|
||||||
s->dict.buf = vmalloc(s->dict.size);
|
s->dict.buf = vmalloc(s->dict.size);
|
||||||
if (s->dict.buf == NULL) {
|
if (s->dict.buf == NULL)
|
||||||
|
{
|
||||||
s->dict.allocated = 0;
|
s->dict.allocated = 0;
|
||||||
return XZ_MEM_ERROR;
|
return XZ_MEM_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,18 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Hash used to validate the Index field */
|
/* Hash used to validate the Index field */
|
||||||
struct xz_dec_hash {
|
struct xz_dec_hash
|
||||||
|
{
|
||||||
vli_type unpadded;
|
vli_type unpadded;
|
||||||
vli_type uncompressed;
|
vli_type uncompressed;
|
||||||
uint32_t crc32;
|
uint32_t crc32;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xz_dec {
|
struct xz_dec
|
||||||
|
{
|
||||||
/* Position in dec_main() */
|
/* Position in dec_main() */
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SEQ_STREAM_HEADER,
|
SEQ_STREAM_HEADER,
|
||||||
SEQ_BLOCK_START,
|
SEQ_BLOCK_START,
|
||||||
SEQ_BLOCK_HEADER,
|
SEQ_BLOCK_HEADER,
|
||||||
@ -69,7 +72,8 @@ struct xz_dec {
|
|||||||
bool allow_buf_error;
|
bool allow_buf_error;
|
||||||
|
|
||||||
/* Information stored in Block Header */
|
/* Information stored in Block Header */
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Value stored in the Compressed Size field, or
|
* Value stored in the Compressed Size field, or
|
||||||
* VLI_UNKNOWN if Compressed Size is not present.
|
* VLI_UNKNOWN if Compressed Size is not present.
|
||||||
@ -87,7 +91,8 @@ struct xz_dec {
|
|||||||
} block_header;
|
} block_header;
|
||||||
|
|
||||||
/* Information collected when decoding Blocks */
|
/* Information collected when decoding Blocks */
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
/* Observed compressed size of the current Block */
|
/* Observed compressed size of the current Block */
|
||||||
vli_type compressed;
|
vli_type compressed;
|
||||||
|
|
||||||
@ -105,9 +110,11 @@ struct xz_dec {
|
|||||||
} block;
|
} block;
|
||||||
|
|
||||||
/* Variables needed when verifying the Index field */
|
/* Variables needed when verifying the Index field */
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
/* Position in dec_index() */
|
/* Position in dec_index() */
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
SEQ_INDEX_COUNT,
|
SEQ_INDEX_COUNT,
|
||||||
SEQ_INDEX_UNPADDED,
|
SEQ_INDEX_UNPADDED,
|
||||||
SEQ_INDEX_UNCOMPRESSED
|
SEQ_INDEX_UNCOMPRESSED
|
||||||
@ -133,7 +140,8 @@ struct xz_dec {
|
|||||||
* to a multiple of four bytes; the size_t variables before it
|
* to a multiple of four bytes; the size_t variables before it
|
||||||
* should guarantee this.
|
* should guarantee this.
|
||||||
*/
|
*/
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
size_t pos;
|
size_t pos;
|
||||||
size_t size;
|
size_t size;
|
||||||
uint8_t buf[1024];
|
uint8_t buf[1024];
|
||||||
@ -149,14 +157,8 @@ struct xz_dec {
|
|||||||
|
|
||||||
#ifdef XZ_DEC_ANY_CHECK
|
#ifdef XZ_DEC_ANY_CHECK
|
||||||
/* Sizes of the Check field with different Check IDs */
|
/* Sizes of the Check field with different Check IDs */
|
||||||
static const uint8_t check_sizes[16] = {
|
static const uint8_t check_sizes[16] = {0, 4, 4, 4, 8, 8, 8, 16,
|
||||||
0,
|
16, 16, 32, 32, 32, 64, 64, 64};
|
||||||
4, 4, 4,
|
|
||||||
8, 8, 8,
|
|
||||||
16, 16, 16,
|
|
||||||
32, 32, 32,
|
|
||||||
64, 64, 64
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -167,14 +169,14 @@ static const uint8_t check_sizes[16] = {
|
|||||||
*/
|
*/
|
||||||
static bool fill_temp(struct xz_dec *s, struct xz_buf *b)
|
static bool fill_temp(struct xz_dec *s, struct xz_buf *b)
|
||||||
{
|
{
|
||||||
size_t copy_size = min_t(size_t,
|
size_t copy_size = min_t(size_t, b->in_size - b->in_pos, s->temp.size - s->temp.pos);
|
||||||
b->in_size - b->in_pos, s->temp.size - s->temp.pos);
|
|
||||||
|
|
||||||
memcpy(s->temp.buf + s->temp.pos, b->in + b->in_pos, copy_size);
|
memcpy(s->temp.buf + s->temp.pos, b->in + b->in_pos, copy_size);
|
||||||
b->in_pos += copy_size;
|
b->in_pos += copy_size;
|
||||||
s->temp.pos += copy_size;
|
s->temp.pos += copy_size;
|
||||||
|
|
||||||
if (s->temp.pos == s->temp.size) {
|
if (s->temp.pos == s->temp.size)
|
||||||
|
{
|
||||||
s->temp.pos = 0;
|
s->temp.pos = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -183,21 +185,22 @@ static bool fill_temp(struct xz_dec *s, struct xz_buf *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Decode a variable-length integer (little-endian base-128 encoding) */
|
/* Decode a variable-length integer (little-endian base-128 encoding) */
|
||||||
static enum xz_ret dec_vli(struct xz_dec *s, const uint8_t *in,
|
static enum xz_ret dec_vli(struct xz_dec *s, const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||||
size_t *in_pos, size_t in_size)
|
|
||||||
{
|
{
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
|
|
||||||
if (s->pos == 0)
|
if (s->pos == 0)
|
||||||
s->vli = 0;
|
s->vli = 0;
|
||||||
|
|
||||||
while (*in_pos < in_size) {
|
while (*in_pos < in_size)
|
||||||
|
{
|
||||||
byte = in[*in_pos];
|
byte = in[*in_pos];
|
||||||
++*in_pos;
|
++*in_pos;
|
||||||
|
|
||||||
s->vli |= (vli_type)(byte & 0x7F) << s->pos;
|
s->vli |= (vli_type)(byte & 0x7F) << s->pos;
|
||||||
|
|
||||||
if ((byte & 0x80) == 0) {
|
if ((byte & 0x80) == 0)
|
||||||
|
{
|
||||||
/* Don't allow non-minimal encodings. */
|
/* Don't allow non-minimal encodings. */
|
||||||
if (byte == 0 && s->pos != 0)
|
if (byte == 0 && s->pos != 0)
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
@ -247,33 +250,28 @@ static enum xz_ret dec_block(struct xz_dec *s, struct xz_buf *b)
|
|||||||
* There is no need to separately check for VLI_UNKNOWN, since
|
* There is no need to separately check for VLI_UNKNOWN, since
|
||||||
* the observed sizes are always smaller than VLI_UNKNOWN.
|
* the observed sizes are always smaller than VLI_UNKNOWN.
|
||||||
*/
|
*/
|
||||||
if (s->block.compressed > s->block_header.compressed
|
if (s->block.compressed > s->block_header.compressed ||
|
||||||
|| s->block.uncompressed
|
s->block.uncompressed > s->block_header.uncompressed)
|
||||||
> s->block_header.uncompressed)
|
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
if (s->check_type == XZ_CHECK_CRC32)
|
if (s->check_type == XZ_CHECK_CRC32)
|
||||||
s->crc = xz_crc32(b->out + s->out_start,
|
s->crc = xz_crc32(b->out + s->out_start, b->out_pos - s->out_start, s->crc);
|
||||||
b->out_pos - s->out_start, s->crc);
|
|
||||||
#ifdef XZ_USE_CRC64
|
#ifdef XZ_USE_CRC64
|
||||||
else if (s->check_type == XZ_CHECK_CRC64)
|
else if (s->check_type == XZ_CHECK_CRC64)
|
||||||
s->crc = xz_crc64(b->out + s->out_start,
|
s->crc = xz_crc64(b->out + s->out_start, b->out_pos - s->out_start, s->crc);
|
||||||
b->out_pos - s->out_start, s->crc);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ret == XZ_STREAM_END) {
|
if (ret == XZ_STREAM_END)
|
||||||
if (s->block_header.compressed != VLI_UNKNOWN
|
{
|
||||||
&& s->block_header.compressed
|
if (s->block_header.compressed != VLI_UNKNOWN &&
|
||||||
!= s->block.compressed)
|
s->block_header.compressed != s->block.compressed)
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
if (s->block_header.uncompressed != VLI_UNKNOWN
|
if (s->block_header.uncompressed != VLI_UNKNOWN &&
|
||||||
&& s->block_header.uncompressed
|
s->block_header.uncompressed != s->block.uncompressed)
|
||||||
!= s->block.uncompressed)
|
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
s->block.hash.unpadded += s->block_header.size
|
s->block.hash.unpadded += s->block_header.size + s->block.compressed;
|
||||||
+ s->block.compressed;
|
|
||||||
|
|
||||||
#ifdef XZ_DEC_ANY_CHECK
|
#ifdef XZ_DEC_ANY_CHECK
|
||||||
s->block.hash.unpadded += check_sizes[s->check_type];
|
s->block.hash.unpadded += check_sizes[s->check_type];
|
||||||
@ -285,9 +283,8 @@ static enum xz_ret dec_block(struct xz_dec *s, struct xz_buf *b)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
s->block.hash.uncompressed += s->block.uncompressed;
|
s->block.hash.uncompressed += s->block.uncompressed;
|
||||||
s->block.hash.crc32 = xz_crc32(
|
s->block.hash.crc32 = xz_crc32((const uint8_t *)&s->block.hash, sizeof(s->block.hash),
|
||||||
(const uint8_t *)&s->block.hash,
|
s->block.hash.crc32);
|
||||||
sizeof(s->block.hash), s->block.hash.crc32);
|
|
||||||
|
|
||||||
++s->block.count;
|
++s->block.count;
|
||||||
}
|
}
|
||||||
@ -315,14 +312,17 @@ static enum xz_ret dec_index(struct xz_dec *s, struct xz_buf *b)
|
|||||||
{
|
{
|
||||||
enum xz_ret ret;
|
enum xz_ret ret;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
ret = dec_vli(s, b->in, &b->in_pos, b->in_size);
|
ret = dec_vli(s, b->in, &b->in_pos, b->in_size);
|
||||||
if (ret != XZ_STREAM_END) {
|
if (ret != XZ_STREAM_END)
|
||||||
|
{
|
||||||
index_update(s, b);
|
index_update(s, b);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (s->index.sequence) {
|
switch (s->index.sequence)
|
||||||
|
{
|
||||||
case SEQ_INDEX_COUNT:
|
case SEQ_INDEX_COUNT:
|
||||||
s->index.count = s->vli;
|
s->index.count = s->vli;
|
||||||
|
|
||||||
@ -344,10 +344,8 @@ static enum xz_ret dec_index(struct xz_dec *s, struct xz_buf *b)
|
|||||||
|
|
||||||
case SEQ_INDEX_UNCOMPRESSED:
|
case SEQ_INDEX_UNCOMPRESSED:
|
||||||
s->index.hash.uncompressed += s->vli;
|
s->index.hash.uncompressed += s->vli;
|
||||||
s->index.hash.crc32 = xz_crc32(
|
s->index.hash.crc32 = xz_crc32((const uint8_t *)&s->index.hash,
|
||||||
(const uint8_t *)&s->index.hash,
|
sizeof(s->index.hash), s->index.hash.crc32);
|
||||||
sizeof(s->index.hash),
|
|
||||||
s->index.hash.crc32);
|
|
||||||
--s->index.count;
|
--s->index.count;
|
||||||
s->index.sequence = SEQ_INDEX_UNPADDED;
|
s->index.sequence = SEQ_INDEX_UNPADDED;
|
||||||
break;
|
break;
|
||||||
@ -362,10 +360,10 @@ static enum xz_ret dec_index(struct xz_dec *s, struct xz_buf *b)
|
|||||||
* of s->crc. s->pos must be zero when starting to validate the first byte.
|
* of s->crc. s->pos must be zero when starting to validate the first byte.
|
||||||
* The "bits" argument allows using the same code for both CRC32 and CRC64.
|
* The "bits" argument allows using the same code for both CRC32 and CRC64.
|
||||||
*/
|
*/
|
||||||
static enum xz_ret crc_validate(struct xz_dec *s, struct xz_buf *b,
|
static enum xz_ret crc_validate(struct xz_dec *s, struct xz_buf *b, uint32_t bits)
|
||||||
uint32_t bits)
|
{
|
||||||
|
do
|
||||||
{
|
{
|
||||||
do {
|
|
||||||
if (b->in_pos == b->in_size)
|
if (b->in_pos == b->in_size)
|
||||||
return XZ_OK;
|
return XZ_OK;
|
||||||
|
|
||||||
@ -389,7 +387,8 @@ static enum xz_ret crc_validate(struct xz_dec *s, struct xz_buf *b,
|
|||||||
*/
|
*/
|
||||||
static bool check_skip(struct xz_dec *s, struct xz_buf *b)
|
static bool check_skip(struct xz_dec *s, struct xz_buf *b)
|
||||||
{
|
{
|
||||||
while (s->pos < check_sizes[s->check_type]) {
|
while (s->pos < check_sizes[s->check_type])
|
||||||
|
{
|
||||||
if (b->in_pos == b->in_size)
|
if (b->in_pos == b->in_size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -409,8 +408,8 @@ static enum xz_ret dec_stream_header(struct xz_dec *s)
|
|||||||
if (!memeq(s->temp.buf, HEADER_MAGIC, HEADER_MAGIC_SIZE))
|
if (!memeq(s->temp.buf, HEADER_MAGIC, HEADER_MAGIC_SIZE))
|
||||||
return XZ_FORMAT_ERROR;
|
return XZ_FORMAT_ERROR;
|
||||||
|
|
||||||
if (xz_crc32(s->temp.buf + HEADER_MAGIC_SIZE, 2, 0)
|
if (xz_crc32(s->temp.buf + HEADER_MAGIC_SIZE, 2, 0) !=
|
||||||
!= get_le32(s->temp.buf + HEADER_MAGIC_SIZE + 2))
|
get_le32(s->temp.buf + HEADER_MAGIC_SIZE + 2))
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
if (s->temp.buf[HEADER_MAGIC_SIZE] != 0)
|
if (s->temp.buf[HEADER_MAGIC_SIZE] != 0)
|
||||||
@ -476,8 +475,7 @@ static enum xz_ret dec_block_header(struct xz_dec *s)
|
|||||||
* eight bytes so this is safe.
|
* eight bytes so this is safe.
|
||||||
*/
|
*/
|
||||||
s->temp.size -= 4;
|
s->temp.size -= 4;
|
||||||
if (xz_crc32(s->temp.buf, s->temp.size, 0)
|
if (xz_crc32(s->temp.buf, s->temp.size, 0) != get_le32(s->temp.buf + s->temp.size))
|
||||||
!= get_le32(s->temp.buf + s->temp.size))
|
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
s->temp.pos = 2;
|
s->temp.pos = 2;
|
||||||
@ -494,31 +492,36 @@ static enum xz_ret dec_block_header(struct xz_dec *s)
|
|||||||
return XZ_OPTIONS_ERROR;
|
return XZ_OPTIONS_ERROR;
|
||||||
|
|
||||||
/* Compressed Size */
|
/* Compressed Size */
|
||||||
if (s->temp.buf[1] & 0x40) {
|
if (s->temp.buf[1] & 0x40)
|
||||||
if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size)
|
{
|
||||||
!= XZ_STREAM_END)
|
if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size) != XZ_STREAM_END)
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
s->block_header.compressed = s->vli;
|
s->block_header.compressed = s->vli;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
s->block_header.compressed = VLI_UNKNOWN;
|
s->block_header.compressed = VLI_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Uncompressed Size */
|
/* Uncompressed Size */
|
||||||
if (s->temp.buf[1] & 0x80) {
|
if (s->temp.buf[1] & 0x80)
|
||||||
if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size)
|
{
|
||||||
!= XZ_STREAM_END)
|
if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size) != XZ_STREAM_END)
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
s->block_header.uncompressed = s->vli;
|
s->block_header.uncompressed = s->vli;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
s->block_header.uncompressed = VLI_UNKNOWN;
|
s->block_header.uncompressed = VLI_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XZ_DEC_BCJ
|
#ifdef XZ_DEC_BCJ
|
||||||
/* If there are two filters, the first one must be a BCJ filter. */
|
/* If there are two filters, the first one must be a BCJ filter. */
|
||||||
s->bcj_active = s->temp.buf[1] & 0x01;
|
s->bcj_active = s->temp.buf[1] & 0x01;
|
||||||
if (s->bcj_active) {
|
if (s->bcj_active)
|
||||||
|
{
|
||||||
if (s->temp.size - s->temp.pos < 2)
|
if (s->temp.size - s->temp.pos < 2)
|
||||||
return XZ_OPTIONS_ERROR;
|
return XZ_OPTIONS_ERROR;
|
||||||
|
|
||||||
@ -577,8 +580,10 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
|
|||||||
*/
|
*/
|
||||||
s->in_start = b->in_pos;
|
s->in_start = b->in_pos;
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
switch (s->sequence) {
|
{
|
||||||
|
switch (s->sequence)
|
||||||
|
{
|
||||||
case SEQ_STREAM_HEADER:
|
case SEQ_STREAM_HEADER:
|
||||||
/*
|
/*
|
||||||
* Stream Header is copied to s->temp, and then
|
* Stream Header is copied to s->temp, and then
|
||||||
@ -610,7 +615,8 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
|
|||||||
return XZ_OK;
|
return XZ_OK;
|
||||||
|
|
||||||
/* See if this is the beginning of the Index field. */
|
/* See if this is the beginning of the Index field. */
|
||||||
if (b->in[b->in_pos] == 0) {
|
if (b->in[b->in_pos] == 0)
|
||||||
|
{
|
||||||
s->in_start = b->in_pos++;
|
s->in_start = b->in_pos++;
|
||||||
s->sequence = SEQ_INDEX;
|
s->sequence = SEQ_INDEX;
|
||||||
break;
|
break;
|
||||||
@ -620,8 +626,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
|
|||||||
* Calculate the size of the Block Header and
|
* Calculate the size of the Block Header and
|
||||||
* prepare to decode it.
|
* prepare to decode it.
|
||||||
*/
|
*/
|
||||||
s->block_header.size
|
s->block_header.size = ((uint32_t)b->in[b->in_pos] + 1) * 4;
|
||||||
= ((uint32_t)b->in[b->in_pos] + 1) * 4;
|
|
||||||
|
|
||||||
s->temp.size = s->block_header.size;
|
s->temp.size = s->block_header.size;
|
||||||
s->temp.pos = 0;
|
s->temp.pos = 0;
|
||||||
@ -652,7 +657,8 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
|
|||||||
* anymore, so we use it here to test the size
|
* anymore, so we use it here to test the size
|
||||||
* of the Block Padding field.
|
* of the Block Padding field.
|
||||||
*/
|
*/
|
||||||
while (s->block.compressed & 3) {
|
while (s->block.compressed & 3)
|
||||||
|
{
|
||||||
if (b->in_pos == b->in_size)
|
if (b->in_pos == b->in_size)
|
||||||
return XZ_OK;
|
return XZ_OK;
|
||||||
|
|
||||||
@ -665,18 +671,21 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
|
|||||||
s->sequence = SEQ_BLOCK_CHECK;
|
s->sequence = SEQ_BLOCK_CHECK;
|
||||||
|
|
||||||
case SEQ_BLOCK_CHECK:
|
case SEQ_BLOCK_CHECK:
|
||||||
if (s->check_type == XZ_CHECK_CRC32) {
|
if (s->check_type == XZ_CHECK_CRC32)
|
||||||
|
{
|
||||||
ret = crc_validate(s, b, 32);
|
ret = crc_validate(s, b, 32);
|
||||||
if (ret != XZ_STREAM_END)
|
if (ret != XZ_STREAM_END)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else if (IS_CRC64(s->check_type)) {
|
else if (IS_CRC64(s->check_type))
|
||||||
|
{
|
||||||
ret = crc_validate(s, b, 64);
|
ret = crc_validate(s, b, 64);
|
||||||
if (ret != XZ_STREAM_END)
|
if (ret != XZ_STREAM_END)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#ifdef XZ_DEC_ANY_CHECK
|
#ifdef XZ_DEC_ANY_CHECK
|
||||||
else if (!check_skip(s, b)) {
|
else if (!check_skip(s, b))
|
||||||
|
{
|
||||||
return XZ_OK;
|
return XZ_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -692,9 +701,10 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
|
|||||||
s->sequence = SEQ_INDEX_PADDING;
|
s->sequence = SEQ_INDEX_PADDING;
|
||||||
|
|
||||||
case SEQ_INDEX_PADDING:
|
case SEQ_INDEX_PADDING:
|
||||||
while ((s->index.size + (b->in_pos - s->in_start))
|
while ((s->index.size + (b->in_pos - s->in_start)) & 3)
|
||||||
& 3) {
|
{
|
||||||
if (b->in_pos == b->in_size) {
|
if (b->in_pos == b->in_size)
|
||||||
|
{
|
||||||
index_update(s, b);
|
index_update(s, b);
|
||||||
return XZ_OK;
|
return XZ_OK;
|
||||||
}
|
}
|
||||||
@ -707,8 +717,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
|
|||||||
index_update(s, b);
|
index_update(s, b);
|
||||||
|
|
||||||
/* Compare the hashes to validate the Index field. */
|
/* Compare the hashes to validate the Index field. */
|
||||||
if (!memeq(&s->block.hash, &s->index.hash,
|
if (!memeq(&s->block.hash, &s->index.hash, sizeof(s->block.hash)))
|
||||||
sizeof(s->block.hash)))
|
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
s->sequence = SEQ_INDEX_CRC32;
|
s->sequence = SEQ_INDEX_CRC32;
|
||||||
@ -770,23 +779,26 @@ XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b)
|
|||||||
out_start = b->out_pos;
|
out_start = b->out_pos;
|
||||||
ret = dec_main(s, b);
|
ret = dec_main(s, b);
|
||||||
|
|
||||||
if (DEC_IS_SINGLE(s->mode)) {
|
if (DEC_IS_SINGLE(s->mode))
|
||||||
|
{
|
||||||
if (ret == XZ_OK)
|
if (ret == XZ_OK)
|
||||||
ret = b->in_pos == b->in_size
|
ret = b->in_pos == b->in_size ? XZ_DATA_ERROR : XZ_BUF_ERROR;
|
||||||
? XZ_DATA_ERROR : XZ_BUF_ERROR;
|
|
||||||
|
|
||||||
if (ret != XZ_STREAM_END) {
|
if (ret != XZ_STREAM_END)
|
||||||
|
{
|
||||||
b->in_pos = in_start;
|
b->in_pos = in_start;
|
||||||
b->out_pos = out_start;
|
b->out_pos = out_start;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (ret == XZ_OK && in_start == b->in_pos
|
else if (ret == XZ_OK && in_start == b->in_pos && out_start == b->out_pos)
|
||||||
&& out_start == b->out_pos) {
|
{
|
||||||
if (s->allow_buf_error)
|
if (s->allow_buf_error)
|
||||||
ret = XZ_BUF_ERROR;
|
ret = XZ_BUF_ERROR;
|
||||||
|
|
||||||
s->allow_buf_error = true;
|
s->allow_buf_error = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
s->allow_buf_error = false;
|
s->allow_buf_error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,7 +849,8 @@ XZ_EXTERN void xz_dec_reset(struct xz_dec *s)
|
|||||||
|
|
||||||
XZ_EXTERN void xz_dec_end(struct xz_dec *s)
|
XZ_EXTERN void xz_dec_end(struct xz_dec *s)
|
||||||
{
|
{
|
||||||
if (s != NULL) {
|
if (s != NULL)
|
||||||
|
{
|
||||||
xz_dec_lzma2_end(s->lzma2);
|
xz_dec_lzma2_end(s->lzma2);
|
||||||
#ifdef XZ_DEC_BCJ
|
#ifdef XZ_DEC_BCJ
|
||||||
xz_dec_bcj_end(s->bcj);
|
xz_dec_bcj_end(s->bcj);
|
||||||
|
@ -39,7 +39,8 @@
|
|||||||
* The symbol names are in from STATE_oldest_older_previous. REP means
|
* The symbol names are in from STATE_oldest_older_previous. REP means
|
||||||
* either short or long repeated match, and NONLIT means any non-literal.
|
* either short or long repeated match, and NONLIT means any non-literal.
|
||||||
*/
|
*/
|
||||||
enum lzma_state {
|
enum lzma_state
|
||||||
|
{
|
||||||
STATE_LIT_LIT,
|
STATE_LIT_LIT,
|
||||||
STATE_MATCH_LIT_LIT,
|
STATE_MATCH_LIT_LIT,
|
||||||
STATE_REP_LIT_LIT,
|
STATE_REP_LIT_LIT,
|
||||||
@ -146,8 +147,7 @@ static inline bool lzma_state_is_literal(enum lzma_state state)
|
|||||||
*/
|
*/
|
||||||
static inline uint32_t lzma_get_dist_state(uint32_t len)
|
static inline uint32_t lzma_get_dist_state(uint32_t len)
|
||||||
{
|
{
|
||||||
return len < DIST_STATES + MATCH_LEN_MIN
|
return len < DIST_STATES + MATCH_LEN_MIN ? len - MATCH_LEN_MIN : DIST_STATES - 1;
|
||||||
? len - MATCH_LEN_MIN : DIST_STATES - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -51,8 +51,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If no specific decoding mode is requested, enable support for all modes. */
|
/* If no specific decoding mode is requested, enable support for all modes. */
|
||||||
#if !defined(XZ_DEC_SINGLE) && !defined(XZ_DEC_PREALLOC) \
|
#if !defined(XZ_DEC_SINGLE) && !defined(XZ_DEC_PREALLOC) && !defined(XZ_DEC_DYNALLOC)
|
||||||
&& !defined(XZ_DEC_DYNALLOC)
|
|
||||||
#define XZ_DEC_SINGLE
|
#define XZ_DEC_SINGLE
|
||||||
#define XZ_DEC_PREALLOC
|
#define XZ_DEC_PREALLOC
|
||||||
#define XZ_DEC_DYNALLOC
|
#define XZ_DEC_DYNALLOC
|
||||||
@ -94,10 +93,9 @@
|
|||||||
* XZ_DEC_BCJ is used to enable generic support for BCJ decoders.
|
* XZ_DEC_BCJ is used to enable generic support for BCJ decoders.
|
||||||
*/
|
*/
|
||||||
#ifndef XZ_DEC_BCJ
|
#ifndef XZ_DEC_BCJ
|
||||||
# if defined(XZ_DEC_X86) || defined(XZ_DEC_POWERPC) \
|
#if defined(XZ_DEC_X86) || defined(XZ_DEC_POWERPC) || defined(XZ_DEC_IA64) || \
|
||||||
|| defined(XZ_DEC_IA64) || defined(XZ_DEC_ARM) \
|
defined(XZ_DEC_ARM) || defined(XZ_DEC_ARM) || defined(XZ_DEC_ARMTHUMB) || \
|
||||||
|| defined(XZ_DEC_ARM) || defined(XZ_DEC_ARMTHUMB) \
|
defined(XZ_DEC_SPARC)
|
||||||
|| defined(XZ_DEC_SPARC)
|
|
||||||
#define XZ_DEC_BCJ
|
#define XZ_DEC_BCJ
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -106,8 +104,7 @@
|
|||||||
* Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used
|
* Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used
|
||||||
* before calling xz_dec_lzma2_run().
|
* before calling xz_dec_lzma2_run().
|
||||||
*/
|
*/
|
||||||
XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode,
|
XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, uint32_t dict_max);
|
||||||
uint32_t dict_max);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Decode the LZMA2 properties (one byte) and reset the decoder. Return
|
* Decode the LZMA2 properties (one byte) and reset the decoder. Return
|
||||||
@ -115,12 +112,10 @@ XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode,
|
|||||||
* big enough, and XZ_OPTIONS_ERROR if props indicates something that this
|
* big enough, and XZ_OPTIONS_ERROR if props indicates something that this
|
||||||
* decoder doesn't support.
|
* decoder doesn't support.
|
||||||
*/
|
*/
|
||||||
XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s,
|
XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props);
|
||||||
uint8_t props);
|
|
||||||
|
|
||||||
/* Decode raw LZMA2 stream from b->in to b->out. */
|
/* Decode raw LZMA2 stream from b->in to b->out. */
|
||||||
XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
|
XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, struct xz_buf *b);
|
||||||
struct xz_buf *b);
|
|
||||||
|
|
||||||
/* Free the memory allocated for the LZMA2 decoder. */
|
/* Free the memory allocated for the LZMA2 decoder. */
|
||||||
XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s);
|
XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s);
|
||||||
@ -145,8 +140,7 @@ XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id);
|
|||||||
* a BCJ filter in the chain. If the chain has only LZMA2, xz_dec_lzma2_run()
|
* a BCJ filter in the chain. If the chain has only LZMA2, xz_dec_lzma2_run()
|
||||||
* must be called directly.
|
* must be called directly.
|
||||||
*/
|
*/
|
||||||
XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
|
XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, struct xz_dec_lzma2 *lzma2,
|
||||||
struct xz_dec_lzma2 *lzma2,
|
|
||||||
struct xz_buf *b);
|
struct xz_buf *b);
|
||||||
|
|
||||||
/* Free the memory allocated for the BCJ filters. */
|
/* Free the memory allocated for the BCJ filters. */
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
#if defined(__KERNEL__) && !XZ_INTERNAL_CRC32
|
#if defined(__KERNEL__) && !XZ_INTERNAL_CRC32
|
||||||
#include <linux/crc32.h>
|
#include <linux/crc32.h>
|
||||||
#undef crc32
|
#undef crc32
|
||||||
# define xz_crc32(buf, size, crc) \
|
#define xz_crc32(buf, size, crc) (~crc32_le(~(uint32_t)(crc), buf, size))
|
||||||
(~crc32_le(~(uint32_t)(crc), buf, size))
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -49,7 +48,8 @@ typedef uint64_t vli_type;
|
|||||||
#define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7)
|
#define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7)
|
||||||
|
|
||||||
/* Integrity Check types */
|
/* Integrity Check types */
|
||||||
enum xz_check {
|
enum xz_check
|
||||||
|
{
|
||||||
XZ_CHECK_NONE = 0,
|
XZ_CHECK_NONE = 0,
|
||||||
XZ_CHECK_CRC32 = 1,
|
XZ_CHECK_CRC32 = 1,
|
||||||
XZ_CHECK_CRC64 = 4,
|
XZ_CHECK_CRC64 = 4,
|
||||||
|
@ -29,7 +29,8 @@ int main(int argc, char **argv)
|
|||||||
enum xz_ret ret;
|
enum xz_ret ret;
|
||||||
const char *msg;
|
const char *msg;
|
||||||
|
|
||||||
if (argc >= 2 && strcmp(argv[1], "--help") == 0) {
|
if (argc >= 2 && strcmp(argv[1], "--help") == 0)
|
||||||
|
{
|
||||||
fputs("Uncompress a .xz file from stdin to stdout.\n"
|
fputs("Uncompress a .xz file from stdin to stdout.\n"
|
||||||
"Arguments other than `--help' are ignored.\n",
|
"Arguments other than `--help' are ignored.\n",
|
||||||
stdout);
|
stdout);
|
||||||
@ -46,7 +47,8 @@ int main(int argc, char **argv)
|
|||||||
* is allocated once the headers have been parsed.
|
* is allocated once the headers have been parsed.
|
||||||
*/
|
*/
|
||||||
s = xz_dec_init(XZ_DYNALLOC, 1 << 26);
|
s = xz_dec_init(XZ_DYNALLOC, 1 << 26);
|
||||||
if (s == NULL) {
|
if (s == NULL)
|
||||||
|
{
|
||||||
msg = "Memory allocation failed\n";
|
msg = "Memory allocation failed\n";
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -58,16 +60,20 @@ int main(int argc, char **argv)
|
|||||||
b.out_pos = 0;
|
b.out_pos = 0;
|
||||||
b.out_size = BUFSIZ;
|
b.out_size = BUFSIZ;
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
if (b.in_pos == b.in_size) {
|
{
|
||||||
|
if (b.in_pos == b.in_size)
|
||||||
|
{
|
||||||
b.in_size = fread(in, 1, sizeof(in), stdin);
|
b.in_size = fread(in, 1, sizeof(in), stdin);
|
||||||
b.in_pos = 0;
|
b.in_pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = xz_dec_run(s, &b);
|
ret = xz_dec_run(s, &b);
|
||||||
|
|
||||||
if (b.out_pos == sizeof(out)) {
|
if (b.out_pos == sizeof(out))
|
||||||
if (fwrite(out, 1, b.out_pos, stdout) != b.out_pos) {
|
{
|
||||||
|
if (fwrite(out, 1, b.out_pos, stdout) != b.out_pos)
|
||||||
|
{
|
||||||
msg = "Write error\n";
|
msg = "Write error\n";
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -79,22 +85,25 @@ int main(int argc, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
#ifdef XZ_DEC_ANY_CHECK
|
#ifdef XZ_DEC_ANY_CHECK
|
||||||
if (ret == XZ_UNSUPPORTED_CHECK) {
|
if (ret == XZ_UNSUPPORTED_CHECK)
|
||||||
|
{
|
||||||
fputs(argv[0], stderr);
|
fputs(argv[0], stderr);
|
||||||
fputs(": ", stderr);
|
fputs(": ", stderr);
|
||||||
fputs("Unsupported check; not verifying "
|
fputs("Unsupported check; not verifying "
|
||||||
"file integrity\n", stderr);
|
"file integrity\n",
|
||||||
|
stderr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fwrite(out, 1, b.out_pos, stdout) != b.out_pos
|
if (fwrite(out, 1, b.out_pos, stdout) != b.out_pos || fclose(stdout))
|
||||||
|| fclose(stdout)) {
|
{
|
||||||
msg = "Write error\n";
|
msg = "Write error\n";
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ret) {
|
switch (ret)
|
||||||
|
{
|
||||||
case XZ_STREAM_END:
|
case XZ_STREAM_END:
|
||||||
xz_dec_end(s);
|
xz_dec_end(s);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,11 +1,26 @@
|
|||||||
#include "consolewindow.h"
|
/* Copyright 2013 MultiMC Contributors
|
||||||
#include "ui_consolewindow.h"
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ConsoleWindow.h"
|
||||||
|
#include "ui_ConsoleWindow.h"
|
||||||
|
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <gui/platform.h>
|
#include <gui/Platform.h>
|
||||||
#include <gui/CustomMessageBox.h>
|
#include <gui/dialogs/CustomMessageBox.h>
|
||||||
|
|
||||||
ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) :
|
ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
@ -1,10 +1,25 @@
|
|||||||
#ifndef CONSOLEWINDOW_H
|
/* Copyright 2013 MultiMC Contributors
|
||||||
#define CONSOLEWINDOW_H
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "logic/MinecraftProcess.h"
|
#include "logic/MinecraftProcess.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class ConsoleWindow;
|
class ConsoleWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +38,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setMayClose(bool mayclose);
|
void setMayClose(bool mayclose);
|
||||||
|
|
||||||
public slots:
|
public
|
||||||
|
slots:
|
||||||
/**
|
/**
|
||||||
* @brief write a string
|
* @brief write a string
|
||||||
* @param data the string
|
* @param data the string
|
||||||
@ -46,7 +62,8 @@ public slots:
|
|||||||
*/
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private slots:
|
private
|
||||||
|
slots:
|
||||||
void on_closeButton_clicked();
|
void on_closeButton_clicked();
|
||||||
void on_btnKillMinecraft_clicked();
|
void on_btnKillMinecraft_clicked();
|
||||||
void onEnded(BaseInstance *instance);
|
void onEnded(BaseInstance *instance);
|
||||||
@ -60,4 +77,3 @@ private:
|
|||||||
bool m_mayclose;
|
bool m_mayclose;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONSOLEWINDOW_H
|
|
@ -1,19 +0,0 @@
|
|||||||
#include "CustomMessageBox.h"
|
|
||||||
|
|
||||||
namespace CustomMessageBox
|
|
||||||
{
|
|
||||||
QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text,
|
|
||||||
QMessageBox::Icon icon, QMessageBox::StandardButtons buttons,
|
|
||||||
QMessageBox::StandardButton defaultButton)
|
|
||||||
{
|
|
||||||
QMessageBox *messageBox = new QMessageBox(parent);
|
|
||||||
messageBox->setWindowTitle(title);
|
|
||||||
messageBox->setText(text);
|
|
||||||
messageBox->setStandardButtons(buttons);
|
|
||||||
messageBox->setDefaultButton(defaultButton);
|
|
||||||
messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
|
||||||
messageBox->setIcon(icon);
|
|
||||||
|
|
||||||
return messageBox;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
namespace CustomMessageBox
|
|
||||||
{
|
|
||||||
QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text,
|
|
||||||
QMessageBox::Icon icon = QMessageBox::NoIcon,
|
|
||||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
|
||||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
#include "EditNotesDialog.h"
|
|
||||||
#include "ui_EditNotesDialog.h"
|
|
||||||
#include "gui/platform.h"
|
|
||||||
|
|
||||||
#include <QIcon>
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
EditNotesDialog::EditNotesDialog( QString notes, QString name, QWidget* parent ) :
|
|
||||||
m_instance_notes(notes),
|
|
||||||
m_instance_name(name),
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::EditNotesDialog)
|
|
||||||
{
|
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
|
||||||
ui->setupUi(this);
|
|
||||||
ui->noteEditor->setText(notes);
|
|
||||||
setWindowTitle(tr("Edit notes of %1").arg(m_instance_name));
|
|
||||||
//connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
|
||||||
}
|
|
||||||
|
|
||||||
EditNotesDialog::~EditNotesDialog()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString EditNotesDialog::getText()
|
|
||||||
{
|
|
||||||
return ui->noteEditor->toPlainText();
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class EditNotesDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
class EditNotesDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit EditNotesDialog(QString notes, QString name, QWidget *parent = 0);
|
|
||||||
~EditNotesDialog();
|
|
||||||
QString getText();
|
|
||||||
private:
|
|
||||||
Ui::EditNotesDialog *ui;
|
|
||||||
QString m_instance_name;
|
|
||||||
QString m_instance_notes;
|
|
||||||
};
|
|
@ -1,147 +0,0 @@
|
|||||||
#include <MultiMC.h>
|
|
||||||
#include "IconPickerDialog.h"
|
|
||||||
#include "instancedelegate.h"
|
|
||||||
#include "ui_IconPickerDialog.h"
|
|
||||||
#include "logic/lists/IconList.h"
|
|
||||||
#include "gui/platform.h"
|
|
||||||
#include <QKeyEvent>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QFileDialog>
|
|
||||||
|
|
||||||
IconPickerDialog::IconPickerDialog(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::IconPickerDialog)
|
|
||||||
{
|
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowModality(Qt::WindowModal);
|
|
||||||
|
|
||||||
auto contentsWidget = ui->iconView;
|
|
||||||
contentsWidget->setViewMode(QListView::IconMode);
|
|
||||||
contentsWidget->setFlow(QListView::LeftToRight);
|
|
||||||
contentsWidget->setIconSize(QSize(48, 48));
|
|
||||||
contentsWidget->setMovement(QListView::Static);
|
|
||||||
contentsWidget->setResizeMode(QListView::Adjust);
|
|
||||||
contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
||||||
contentsWidget->setSpacing(5);
|
|
||||||
contentsWidget->setWordWrap(false);
|
|
||||||
contentsWidget->setWrapping(true);
|
|
||||||
contentsWidget->setUniformItemSizes(true);
|
|
||||||
contentsWidget->setTextElideMode(Qt::ElideRight);
|
|
||||||
contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
|
||||||
contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
||||||
contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
contentsWidget->setItemDelegate(new ListViewDelegate());
|
|
||||||
|
|
||||||
//contentsWidget->setAcceptDrops(true);
|
|
||||||
contentsWidget->setDropIndicatorShown(true);
|
|
||||||
contentsWidget->viewport()->setAcceptDrops(true);
|
|
||||||
contentsWidget->setDragDropMode(QAbstractItemView::DropOnly);
|
|
||||||
contentsWidget->setDefaultDropAction(Qt::CopyAction);
|
|
||||||
|
|
||||||
contentsWidget->installEventFilter(this);
|
|
||||||
|
|
||||||
contentsWidget->setModel(MMC->icons().get());
|
|
||||||
|
|
||||||
auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"),QDialogButtonBox::ResetRole);
|
|
||||||
auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"),QDialogButtonBox::ResetRole);
|
|
||||||
|
|
||||||
|
|
||||||
connect(buttonAdd,SIGNAL(clicked(bool)),SLOT(addNewIcon()));
|
|
||||||
connect(buttonRemove,SIGNAL(clicked(bool)),SLOT(removeSelectedIcon()));
|
|
||||||
|
|
||||||
connect
|
|
||||||
(
|
|
||||||
contentsWidget,
|
|
||||||
SIGNAL(doubleClicked(QModelIndex)),
|
|
||||||
SLOT(activated(QModelIndex))
|
|
||||||
);
|
|
||||||
|
|
||||||
connect
|
|
||||||
(
|
|
||||||
contentsWidget->selectionModel(),
|
|
||||||
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
|
||||||
SLOT(selectionChanged(QItemSelection,QItemSelection))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
bool IconPickerDialog::eventFilter ( QObject* obj, QEvent* evt)
|
|
||||||
{
|
|
||||||
if(obj != ui->iconView)
|
|
||||||
return QDialog::eventFilter(obj ,evt);
|
|
||||||
if (evt->type() != QEvent::KeyPress)
|
|
||||||
{
|
|
||||||
return QDialog::eventFilter(obj ,evt);
|
|
||||||
}
|
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(evt);
|
|
||||||
switch(keyEvent->key())
|
|
||||||
{
|
|
||||||
case Qt::Key_Delete:
|
|
||||||
removeSelectedIcon();
|
|
||||||
return true;
|
|
||||||
case Qt::Key_Plus:
|
|
||||||
addNewIcon();
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return QDialog::eventFilter(obj ,evt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IconPickerDialog::addNewIcon()
|
|
||||||
{
|
|
||||||
//: The title of the select icons open file dialog
|
|
||||||
QString selectIcons = tr("Select Icons");
|
|
||||||
//: The type of icon files
|
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, selectIcons, QString(), tr("Icons") + "(*.png *.jpg *.jpeg)");
|
|
||||||
MMC->icons()->installIcons(fileNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IconPickerDialog::removeSelectedIcon()
|
|
||||||
{
|
|
||||||
MMC->icons()->deleteIcon(selectedIconKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void IconPickerDialog::activated ( QModelIndex index )
|
|
||||||
{
|
|
||||||
selectedIconKey = index.data(Qt::UserRole).toString();
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void IconPickerDialog::selectionChanged ( QItemSelection selected, QItemSelection deselected )
|
|
||||||
{
|
|
||||||
if(selected.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QString key = selected.first().indexes().first().data(Qt::UserRole).toString();
|
|
||||||
if(!key.isEmpty())
|
|
||||||
selectedIconKey = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
int IconPickerDialog::exec ( QString selection )
|
|
||||||
{
|
|
||||||
auto list = MMC->icons();
|
|
||||||
auto contentsWidget = ui->iconView;
|
|
||||||
selectedIconKey = selection;
|
|
||||||
|
|
||||||
|
|
||||||
int index_nr = list->getIconIndex(selection);
|
|
||||||
auto model_index = list->index(index_nr);
|
|
||||||
contentsWidget->selectionModel()->select(model_index, QItemSelectionModel::Current | QItemSelectionModel::Select);
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(this, "delayed_scroll", Qt::QueuedConnection, Q_ARG(QModelIndex,model_index));
|
|
||||||
return QDialog::exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void IconPickerDialog::delayed_scroll ( QModelIndex model_index )
|
|
||||||
{
|
|
||||||
auto contentsWidget = ui->iconView;
|
|
||||||
contentsWidget->scrollTo(model_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
IconPickerDialog::~IconPickerDialog()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QItemSelection>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class IconPickerDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
class IconPickerDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit IconPickerDialog(QWidget *parent = 0);
|
|
||||||
~IconPickerDialog();
|
|
||||||
int exec(QString selection);
|
|
||||||
QString selectedIconKey;
|
|
||||||
protected:
|
|
||||||
virtual bool eventFilter ( QObject* , QEvent* );
|
|
||||||
private:
|
|
||||||
Ui::IconPickerDialog *ui;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void selectionChanged ( QItemSelection,QItemSelection );
|
|
||||||
void activated ( QModelIndex );
|
|
||||||
void delayed_scroll ( QModelIndex );
|
|
||||||
void addNewIcon();
|
|
||||||
void removeSelectedIcon();
|
|
||||||
};
|
|
@ -1,22 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QToolButton>
|
|
||||||
|
|
||||||
class QLabel;
|
|
||||||
|
|
||||||
class LabeledToolButton : public QToolButton
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
QLabel * m_label;
|
|
||||||
|
|
||||||
public:
|
|
||||||
LabeledToolButton(QWidget * parent = 0);
|
|
||||||
|
|
||||||
QString text() const;
|
|
||||||
void setText(const QString & text);
|
|
||||||
virtual QSize sizeHint() const;
|
|
||||||
protected:
|
|
||||||
void resizeEvent(QResizeEvent * event);
|
|
||||||
};
|
|
@ -16,10 +16,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include <MultiMC.h>
|
#include "MultiMC.h"
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "MainWindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_MainWindow.h"
|
||||||
#include "keyring.h"
|
#include "keyring.h"
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
@ -40,17 +40,25 @@
|
|||||||
#include "categorizedview.h"
|
#include "categorizedview.h"
|
||||||
#include "categorydrawer.h"
|
#include "categorydrawer.h"
|
||||||
|
|
||||||
#include "gui/settingsdialog.h"
|
#include "gui/Platform.h"
|
||||||
#include "gui/newinstancedialog.h"
|
|
||||||
#include "gui/logindialog.h"
|
#include "gui/widgets/InstanceDelegate.h"
|
||||||
#include "gui/ProgressDialog.h"
|
#include "gui/widgets/LabeledToolButton.h"
|
||||||
#include "gui/aboutdialog.h"
|
|
||||||
#include "gui/versionselectdialog.h"
|
#include "gui/dialogs/SettingsDialog.h"
|
||||||
#include "gui/lwjglselectdialog.h"
|
#include "gui/dialogs/NewInstanceDialog.h"
|
||||||
#include "gui/consolewindow.h"
|
#include "gui/dialogs/LoginDialog.h"
|
||||||
#include "gui/instancesettings.h"
|
#include "gui/dialogs/ProgressDialog.h"
|
||||||
#include "gui/platform.h"
|
#include "gui/dialogs/AboutDialog.h"
|
||||||
#include "gui/CustomMessageBox.h"
|
#include "gui/dialogs/VersionSelectDialog.h"
|
||||||
|
#include "gui/dialogs/CustomMessageBox.h"
|
||||||
|
#include "gui/dialogs/LwjglSelectDialog.h"
|
||||||
|
#include "gui/dialogs/InstanceSettings.h"
|
||||||
|
#include "gui/dialogs/IconPickerDialog.h"
|
||||||
|
#include "gui/dialogs/EditNotesDialog.h"
|
||||||
|
#include "gui/dialogs/CopyInstanceDialog.h"
|
||||||
|
|
||||||
|
#include "gui/ConsoleWindow.h"
|
||||||
|
|
||||||
#include "logic/lists/InstanceList.h"
|
#include "logic/lists/InstanceList.h"
|
||||||
#include "logic/lists/MinecraftVersionList.h"
|
#include "logic/lists/MinecraftVersionList.h"
|
||||||
@ -70,12 +78,6 @@
|
|||||||
|
|
||||||
#include "logic/LegacyInstance.h"
|
#include "logic/LegacyInstance.h"
|
||||||
|
|
||||||
#include "instancedelegate.h"
|
|
||||||
#include "IconPickerDialog.h"
|
|
||||||
#include "LabeledToolButton.h"
|
|
||||||
#include "EditNotesDialog.h"
|
|
||||||
#include "CopyInstanceDialog.h"
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
@ -533,9 +535,9 @@ void MainWindow::instanceActivated(QModelIndex index)
|
|||||||
BaseInstance *inst =
|
BaseInstance *inst =
|
||||||
(BaseInstance *)index.data(InstanceList::InstancePointerRole).value<void *>();
|
(BaseInstance *)index.data(InstanceList::InstancePointerRole).value<void *>();
|
||||||
|
|
||||||
NagUtils::checkJVMArgs(MMC->settings()->get("JvmArgs").toString(), this);
|
NagUtils::checkJVMArgs(inst->settings().get("JvmArgs").toString(), this);
|
||||||
|
|
||||||
bool autoLogin = MMC->settings()->get("AutoLogin").toBool();
|
bool autoLogin = inst->settings().get("AutoLogin").toBool();
|
||||||
if (autoLogin)
|
if (autoLogin)
|
||||||
doAutoLogin();
|
doAutoLogin();
|
||||||
else
|
else
|
||||||
@ -546,7 +548,7 @@ void MainWindow::on_actionLaunchInstance_triggered()
|
|||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
NagUtils::checkJVMArgs(MMC->settings()->get("JvmArgs").toString(), this);
|
NagUtils::checkJVMArgs(m_selectedInstance->settings().get("JvmArgs").toString(), this);
|
||||||
doLogin();
|
doLogin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -824,7 +826,7 @@ void MainWindow::on_actionInstanceSettings_triggered()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
InstanceSettings settings(&m_selectedInstance->settings(), this);
|
InstanceSettings settings(&m_selectedInstance->settings(), this);
|
||||||
settings.setWindowTitle(QString("Instance settings"));
|
settings.setWindowTitle(tr("Instance settings"));
|
||||||
settings.exec();
|
settings.exec();
|
||||||
}
|
}
|
||||||
|
|
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
#pragma once
|
||||||
#define MAINWINDOW_H
|
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
@ -166,5 +165,3 @@ private:
|
|||||||
QLabel *m_statusLeft;
|
QLabel *m_statusLeft;
|
||||||
QLabel *m_statusRight;
|
QLabel *m_statusRight;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
|
@ -1,41 +0,0 @@
|
|||||||
#include "ModEditDialogCommon.h"
|
|
||||||
#include "CustomMessageBox.h"
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QString>
|
|
||||||
#include <QUrl>
|
|
||||||
bool lastfirst(QModelIndexList &list, int &first, int &last)
|
|
||||||
{
|
|
||||||
if (!list.size())
|
|
||||||
return false;
|
|
||||||
first = last = list[0].row();
|
|
||||||
for (auto item : list)
|
|
||||||
{
|
|
||||||
int row = item.row();
|
|
||||||
if (row < first)
|
|
||||||
first = row;
|
|
||||||
if (row > last)
|
|
||||||
last = row;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void showWebsiteForMod(QWidget *parentDlg, Mod &m)
|
|
||||||
{
|
|
||||||
QString url = m.homeurl();
|
|
||||||
if (url.size())
|
|
||||||
{
|
|
||||||
// catch the cases where the protocol is missing
|
|
||||||
if(!url.startsWith("http"))
|
|
||||||
{
|
|
||||||
url = "http://" + url;
|
|
||||||
}
|
|
||||||
QDesktopServices::openUrl(url);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CustomMessageBox::selectable(parentDlg, parentDlg->tr("How sad!"),
|
|
||||||
parentDlg->tr("The mod author didn't provide a website link for this mod."),
|
|
||||||
QMessageBox::Warning);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <QAbstractItemModel>
|
|
||||||
#include <logic/Mod.h>
|
|
||||||
|
|
||||||
bool lastfirst (QModelIndexList & list, int & first, int & last);
|
|
||||||
|
|
||||||
void showWebsiteForMod(QWidget * parentDlg, Mod& m);
|
|
@ -1,13 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <QTreeView>
|
|
||||||
|
|
||||||
class Mod;
|
|
||||||
|
|
||||||
class ModListView: public QTreeView
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit ModListView ( QWidget* parent = 0 );
|
|
||||||
virtual void setModel ( QAbstractItemModel* model );
|
|
||||||
|
|
||||||
};
|
|
@ -15,11 +15,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PLATFORM_H
|
#pragma once
|
||||||
#define PLATFORM_H
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file platform.h
|
* @file Platform.h
|
||||||
* This file contains platform-specific functions, tweaks and fixes.
|
* This file contains platform-specific functions, tweaks and fixes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -31,5 +30,3 @@ public:
|
|||||||
// X11 WM_CLASS
|
// X11 WM_CLASS
|
||||||
static void fixWM_CLASS(QWidget *widget);
|
static void fixWM_CLASS(QWidget *widget);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLATFORM_H
|
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gui/platform.h>
|
#include <gui/Platform.h>
|
||||||
/**
|
/**
|
||||||
* Stub for non-X11 platforms
|
* Stub for non-X11 platforms
|
||||||
* @brief MultiMCPlatform::fixWM_CLASS
|
* @brief MultiMCPlatform::fixWM_CLASS
|
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gui/platform.h>
|
#include <gui/Platform.h>
|
||||||
#include <QtX11Extras/QX11Info>
|
#include <QtX11Extras/QX11Info>
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
|
@ -1,24 +0,0 @@
|
|||||||
#include "aboutdialog.h"
|
|
||||||
#include "ui_aboutdialog.h"
|
|
||||||
#include <QIcon>
|
|
||||||
#include <MultiMC.h>
|
|
||||||
#include "gui/platform.h"
|
|
||||||
|
|
||||||
AboutDialog::AboutDialog(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::AboutDialog)
|
|
||||||
{
|
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
ui->icon->setPixmap(QIcon(":/icons/multimc/scalable/apps/multimc.svg").pixmap(64));
|
|
||||||
ui->title->setText("MultiMC " + MMC->version().toString());
|
|
||||||
connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
|
||||||
|
|
||||||
MMC->connect(ui->aboutQt, SIGNAL(clicked()), SLOT(aboutQt()));
|
|
||||||
}
|
|
||||||
|
|
||||||
AboutDialog::~AboutDialog()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
#ifndef ABOUTDIALOG_H
|
|
||||||
#define ABOUTDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class AboutDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
class AboutDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit AboutDialog(QWidget *parent = 0);
|
|
||||||
~AboutDialog();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::AboutDialog *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ABOUTDIALOG_H
|
|
37
gui/dialogs/AboutDialog.cpp
Normal file
37
gui/dialogs/AboutDialog.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/* Copyright 2013 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "AboutDialog.h"
|
||||||
|
#include "ui_AboutDialog.h"
|
||||||
|
#include <QIcon>
|
||||||
|
#include "MultiMC.h"
|
||||||
|
#include "gui/Platform.h"
|
||||||
|
|
||||||
|
AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog)
|
||||||
|
{
|
||||||
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->icon->setPixmap(QIcon(":/icons/multimc/scalable/apps/multimc.svg").pixmap(64));
|
||||||
|
ui->title->setText("MultiMC " + MMC->version().toString());
|
||||||
|
connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||||
|
|
||||||
|
MMC->connect(ui->aboutQt, SIGNAL(clicked()), SLOT(aboutQt()));
|
||||||
|
}
|
||||||
|
|
||||||
|
AboutDialog::~AboutDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
35
gui/dialogs/AboutDialog.h
Normal file
35
gui/dialogs/AboutDialog.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* Copyright 2013 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class AboutDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AboutDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AboutDialog(QWidget *parent = 0);
|
||||||
|
~AboutDialog();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AboutDialog *ui;
|
||||||
|
};
|
@ -59,7 +59,7 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="pixmap">
|
<property name="pixmap">
|
||||||
<pixmap resource="../multimc.qrc">:/icons/multimc/scalable/apps/multimc.svg</pixmap>
|
<pixmap resource="../../multimc.qrc">:/icons/multimc/scalable/apps/multimc.svg</pixmap>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -101,7 +101,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>432</width>
|
<width>432</width>
|
||||||
<height>197</height>
|
<height>179</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -159,8 +159,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>432</width>
|
<width>98</width>
|
||||||
<height>197</height>
|
<height>120</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -176,13 +176,13 @@
|
|||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Andrew Okin &lt;</span><a href="mailto:forkk@forkk.net"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">forkk@forkk.net</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Andrew Okin &lt;</span><a href="mailto:forkk@forkk.net"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">forkk@forkk.net</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Petr Mrázek &lt;</span><a href="mailto:peterix@gmail.com"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">peterix@gmail.com</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Petr Mrázek &lt;</span><a href="mailto:peterix@gmail.com"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">peterix@gmail.com</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Orochimarufan &lt;</span><a href="mailto:orochimarufan.x3@gmail.com"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">orochimarufan.x3@gmail.com</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Orochimarufan &lt;</span><a href="mailto:orochimarufan.x3@gmail.com"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">orochimarufan.x3@gmail.com</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">TakSuyu &lt;</span><a href="mailto:taksuyu@gmail.com"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">taksuyu@gmail.com</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">TakSuyu &lt;</span><a href="mailto:taksuyu@gmail.com"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">taksuyu@gmail.com</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Sky (Drayshak) &lt;</span><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">multimc@bunnies.cc</span><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Sky (Drayshak) &lt;</span><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">multimc@bunnies.cc</span><span style=" font-family:'Ubuntu';">&gt;</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Kilobyte &lt;</span><a href="mailto:stiepen22@gmx.de"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">stiepen22@gmx.de</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p></body></html></string>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Kilobyte &lt;</span><a href="mailto:stiepen22@gmx.de"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">stiepen22@gmx.de</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -203,8 +203,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>432</width>
|
<width>98</width>
|
||||||
<height>197</height>
|
<height>88</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -226,7 +226,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Copyright 2012 MultiMC Contributors</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Copyright 2012 MultiMC Contributors</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">you may not use this file except in compliance with the License.</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">you may not use this file except in compliance with the License.</span></p>
|
||||||
@ -309,7 +309,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../multimc.qrc"/>
|
<include location="../../multimc.qrc"/>
|
||||||
|
<include location="../../multimc.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
@ -13,24 +13,24 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <MultiMC.h>
|
#include <QLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "MultiMC.h"
|
||||||
#include "CopyInstanceDialog.h"
|
#include "CopyInstanceDialog.h"
|
||||||
#include "ui_CopyInstanceDialog.h"
|
#include "ui_CopyInstanceDialog.h"
|
||||||
|
|
||||||
|
#include "gui/Platform.h"
|
||||||
|
#include "gui/dialogs/VersionSelectDialog.h"
|
||||||
|
#include "gui/dialogs/ProgressDialog.h"
|
||||||
|
#include "gui/dialogs/IconPickerDialog.h"
|
||||||
|
|
||||||
#include "logic/InstanceFactory.h"
|
#include "logic/InstanceFactory.h"
|
||||||
#include "logic/BaseVersion.h"
|
#include "logic/BaseVersion.h"
|
||||||
#include "logic/lists/IconList.h"
|
#include "logic/lists/IconList.h"
|
||||||
#include "logic/lists/MinecraftVersionList.h"
|
#include "logic/lists/MinecraftVersionList.h"
|
||||||
#include "logic/tasks/Task.h"
|
#include "logic/tasks/Task.h"
|
||||||
#include <logic/BaseInstance.h>
|
#include "logic/BaseInstance.h"
|
||||||
|
|
||||||
#include "gui/platform.h"
|
|
||||||
#include "versionselectdialog.h"
|
|
||||||
#include "ProgressDialog.h"
|
|
||||||
#include "IconPickerDialog.h"
|
|
||||||
|
|
||||||
#include <QLayout>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
CopyInstanceDialog::CopyInstanceDialog(BaseInstance *original, QWidget *parent)
|
CopyInstanceDialog::CopyInstanceDialog(BaseInstance *original, QWidget *parent)
|
||||||
: m_original(original), QDialog(parent), ui(new Ui::CopyInstanceDialog)
|
: m_original(original), QDialog(parent), ui(new Ui::CopyInstanceDialog)
|
@ -17,7 +17,7 @@
|
|||||||
<string>Copy Instance</string>
|
<string>Copy Instance</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset resource="../multimc.qrc">
|
<iconset resource="../../multimc.qrc">
|
||||||
<normaloff>:/icons/toolbar/copy</normaloff>:/icons/toolbar/copy</iconset>
|
<normaloff>:/icons/toolbar/copy</normaloff>:/icons/toolbar/copy</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="modal">
|
<property name="modal">
|
||||||
@ -42,7 +42,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="iconButton">
|
<widget class="QToolButton" name="iconButton">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../multimc.qrc">
|
<iconset resource="../../multimc.qrc">
|
||||||
<normaloff>:/icons/instances/infinity</normaloff>:/icons/instances/infinity</iconset>
|
<normaloff>:/icons/instances/infinity</normaloff>:/icons/instances/infinity</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
@ -95,7 +95,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../multimc.qrc"/>
|
<include location="../../multimc.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
34
gui/dialogs/CustomMessageBox.cpp
Normal file
34
gui/dialogs/CustomMessageBox.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* Copyright 2013 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CustomMessageBox.h"
|
||||||
|
|
||||||
|
namespace CustomMessageBox
|
||||||
|
{
|
||||||
|
QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text,
|
||||||
|
QMessageBox::Icon icon, QMessageBox::StandardButtons buttons,
|
||||||
|
QMessageBox::StandardButton defaultButton)
|
||||||
|
{
|
||||||
|
QMessageBox *messageBox = new QMessageBox(parent);
|
||||||
|
messageBox->setWindowTitle(title);
|
||||||
|
messageBox->setText(text);
|
||||||
|
messageBox->setStandardButtons(buttons);
|
||||||
|
messageBox->setDefaultButton(defaultButton);
|
||||||
|
messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
|
messageBox->setIcon(icon);
|
||||||
|
|
||||||
|
return messageBox;
|
||||||
|
}
|
||||||
|
}
|
26
gui/dialogs/CustomMessageBox.h
Normal file
26
gui/dialogs/CustomMessageBox.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* Copyright 2013 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
namespace CustomMessageBox
|
||||||
|
{
|
||||||
|
QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text,
|
||||||
|
QMessageBox::Icon icon = QMessageBox::NoIcon,
|
||||||
|
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||||
|
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||||
|
}
|
42
gui/dialogs/EditNotesDialog.cpp
Normal file
42
gui/dialogs/EditNotesDialog.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* Copyright 2013 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "EditNotesDialog.h"
|
||||||
|
#include "ui_EditNotesDialog.h"
|
||||||
|
#include "gui/Platform.h"
|
||||||
|
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
EditNotesDialog::EditNotesDialog(QString notes, QString name, QWidget *parent)
|
||||||
|
: m_instance_notes(notes), m_instance_name(name), QDialog(parent),
|
||||||
|
ui(new Ui::EditNotesDialog)
|
||||||
|
{
|
||||||
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->noteEditor->setText(notes);
|
||||||
|
setWindowTitle(tr("Edit notes of %1").arg(m_instance_name));
|
||||||
|
// connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||||
|
}
|
||||||
|
|
||||||
|
EditNotesDialog::~EditNotesDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString EditNotesDialog::getText()
|
||||||
|
{
|
||||||
|
return ui->noteEditor->toPlainText();
|
||||||
|
}
|
38
gui/dialogs/EditNotesDialog.h
Normal file
38
gui/dialogs/EditNotesDialog.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* Copyright 2013 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class EditNotesDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class EditNotesDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit EditNotesDialog(QString notes, QString name, QWidget *parent = 0);
|
||||||
|
~EditNotesDialog();
|
||||||
|
QString getText();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::EditNotesDialog *ui;
|
||||||
|
QString m_instance_name;
|
||||||
|
QString m_instance_notes;
|
||||||
|
};
|
156
gui/dialogs/IconPickerDialog.cpp
Normal file
156
gui/dialogs/IconPickerDialog.cpp
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/* Copyright 2013 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
#include "MultiMC.h"
|
||||||
|
|
||||||
|
#include "IconPickerDialog.h"
|
||||||
|
#include "ui_IconPickerDialog.h"
|
||||||
|
|
||||||
|
#include "gui/Platform.h"
|
||||||
|
#include "gui/widgets/InstanceDelegate.h"
|
||||||
|
|
||||||
|
#include "logic/lists/IconList.h"
|
||||||
|
|
||||||
|
IconPickerDialog::IconPickerDialog(QWidget *parent)
|
||||||
|
: QDialog(parent), ui(new Ui::IconPickerDialog)
|
||||||
|
{
|
||||||
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
|
ui->setupUi(this);
|
||||||
|
setWindowModality(Qt::WindowModal);
|
||||||
|
|
||||||
|
auto contentsWidget = ui->iconView;
|
||||||
|
contentsWidget->setViewMode(QListView::IconMode);
|
||||||
|
contentsWidget->setFlow(QListView::LeftToRight);
|
||||||
|
contentsWidget->setIconSize(QSize(48, 48));
|
||||||
|
contentsWidget->setMovement(QListView::Static);
|
||||||
|
contentsWidget->setResizeMode(QListView::Adjust);
|
||||||
|
contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
contentsWidget->setSpacing(5);
|
||||||
|
contentsWidget->setWordWrap(false);
|
||||||
|
contentsWidget->setWrapping(true);
|
||||||
|
contentsWidget->setUniformItemSizes(true);
|
||||||
|
contentsWidget->setTextElideMode(Qt::ElideRight);
|
||||||
|
contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
|
contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
|
contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
contentsWidget->setItemDelegate(new ListViewDelegate());
|
||||||
|
|
||||||
|
// contentsWidget->setAcceptDrops(true);
|
||||||
|
contentsWidget->setDropIndicatorShown(true);
|
||||||
|
contentsWidget->viewport()->setAcceptDrops(true);
|
||||||
|
contentsWidget->setDragDropMode(QAbstractItemView::DropOnly);
|
||||||
|
contentsWidget->setDefaultDropAction(Qt::CopyAction);
|
||||||
|
|
||||||
|
contentsWidget->installEventFilter(this);
|
||||||
|
|
||||||
|
contentsWidget->setModel(MMC->icons().get());
|
||||||
|
|
||||||
|
auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"), QDialogButtonBox::ResetRole);
|
||||||
|
auto buttonRemove =
|
||||||
|
ui->buttonBox->addButton(tr("Remove Icon"), QDialogButtonBox::ResetRole);
|
||||||
|
|
||||||
|
connect(buttonAdd, SIGNAL(clicked(bool)), SLOT(addNewIcon()));
|
||||||
|
connect(buttonRemove, SIGNAL(clicked(bool)), SLOT(removeSelectedIcon()));
|
||||||
|
|
||||||
|
connect(contentsWidget, SIGNAL(doubleClicked(QModelIndex)), SLOT(activated(QModelIndex)));
|
||||||
|
|
||||||
|
connect(contentsWidget->selectionModel(),
|
||||||
|
SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
|
||||||
|
SLOT(selectionChanged(QItemSelection, QItemSelection)));
|
||||||
|
}
|
||||||
|
bool IconPickerDialog::eventFilter(QObject *obj, QEvent *evt)
|
||||||
|
{
|
||||||
|
if (obj != ui->iconView)
|
||||||
|
return QDialog::eventFilter(obj, evt);
|
||||||
|
if (evt->type() != QEvent::KeyPress)
|
||||||
|
{
|
||||||
|
return QDialog::eventFilter(obj, evt);
|
||||||
|
}
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(evt);
|
||||||
|
switch (keyEvent->key())
|
||||||
|
{
|
||||||
|
case Qt::Key_Delete:
|
||||||
|
removeSelectedIcon();
|
||||||
|
return true;
|
||||||
|
case Qt::Key_Plus:
|
||||||
|
addNewIcon();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QDialog::eventFilter(obj, evt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IconPickerDialog::addNewIcon()
|
||||||
|
{
|
||||||
|
//: The title of the select icons open file dialog
|
||||||
|
QString selectIcons = tr("Select Icons");
|
||||||
|
//: The type of icon files
|
||||||
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, selectIcons, QString(),
|
||||||
|
tr("Icons") + "(*.png *.jpg *.jpeg)");
|
||||||
|
MMC->icons()->installIcons(fileNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IconPickerDialog::removeSelectedIcon()
|
||||||
|
{
|
||||||
|
MMC->icons()->deleteIcon(selectedIconKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IconPickerDialog::activated(QModelIndex index)
|
||||||
|
{
|
||||||
|
selectedIconKey = index.data(Qt::UserRole).toString();
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IconPickerDialog::selectionChanged(QItemSelection selected, QItemSelection deselected)
|
||||||
|
{
|
||||||
|
if (selected.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString key = selected.first().indexes().first().data(Qt::UserRole).toString();
|
||||||
|
if (!key.isEmpty())
|
||||||
|
selectedIconKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
int IconPickerDialog::exec(QString selection)
|
||||||
|
{
|
||||||
|
auto list = MMC->icons();
|
||||||
|
auto contentsWidget = ui->iconView;
|
||||||
|
selectedIconKey = selection;
|
||||||
|
|
||||||
|
int index_nr = list->getIconIndex(selection);
|
||||||
|
auto model_index = list->index(index_nr);
|
||||||
|
contentsWidget->selectionModel()->select(
|
||||||
|
model_index, QItemSelectionModel::Current | QItemSelectionModel::Select);
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(this, "delayed_scroll", Qt::QueuedConnection,
|
||||||
|
Q_ARG(QModelIndex, model_index));
|
||||||
|
return QDialog::exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IconPickerDialog::delayed_scroll(QModelIndex model_index)
|
||||||
|
{
|
||||||
|
auto contentsWidget = ui->iconView;
|
||||||
|
contentsWidget->scrollTo(model_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
IconPickerDialog::~IconPickerDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
48
gui/dialogs/IconPickerDialog.h
Normal file
48
gui/dialogs/IconPickerDialog.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* Copyright 2013 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QItemSelection>
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class IconPickerDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class IconPickerDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit IconPickerDialog(QWidget *parent = 0);
|
||||||
|
~IconPickerDialog();
|
||||||
|
int exec(QString selection);
|
||||||
|
QString selectedIconKey;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool eventFilter(QObject *, QEvent *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::IconPickerDialog *ui;
|
||||||
|
|
||||||
|
private
|
||||||
|
slots:
|
||||||
|
void selectionChanged(QItemSelection, QItemSelection);
|
||||||
|
void activated(QModelIndex);
|
||||||
|
void delayed_scroll(QModelIndex);
|
||||||
|
void addNewIcon();
|
||||||
|
void removeSelectedIcon();
|
||||||
|
};
|
@ -17,14 +17,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "instancesettings.h"
|
#include "InstanceSettings.h"
|
||||||
#include "ui_instancesettings.h"
|
#include "ui_InstanceSettings.h"
|
||||||
#include "gui/platform.h"
|
#include "gui/Platform.h"
|
||||||
|
#include "logic/NagUtils.h"
|
||||||
|
|
||||||
InstanceSettings::InstanceSettings( SettingsObject * obj, QWidget *parent) :
|
InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent)
|
||||||
m_obj(obj),
|
: m_obj(obj), QDialog(parent), ui(new Ui::InstanceSettings)
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::InstanceSettings)
|
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -58,7 +57,6 @@ void InstanceSettings::on_buttonBox_rejected()
|
|||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InstanceSettings::applySettings()
|
void InstanceSettings::applySettings()
|
||||||
{
|
{
|
||||||
// Console
|
// Console
|
||||||
@ -91,20 +89,18 @@ void InstanceSettings::applySettings()
|
|||||||
m_obj->reset("MinecraftWinHeight");
|
m_obj->reset("MinecraftWinHeight");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Auto Login
|
// Auto Login
|
||||||
bool login = ui->accountSettingsGroupBox->isChecked();
|
bool login = ui->accountSettingsBox->isChecked();
|
||||||
m_obj->set("OverrideLogin", login);
|
m_obj->set("OverrideLogin", login);
|
||||||
if (login)
|
if (login)
|
||||||
{
|
{
|
||||||
m_obj->set("AutoLogin", ui->autoLoginChecBox->isChecked());
|
m_obj->set("AutoLogin", ui->autoLoginCheckBox->isChecked());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_obj->reset("AutoLogin");
|
m_obj->reset("AutoLogin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Memory
|
// Memory
|
||||||
bool memory = ui->memoryGroupBox->isChecked();
|
bool memory = ui->memoryGroupBox->isChecked();
|
||||||
m_obj->set("OverrideMemory", memory);
|
m_obj->set("OverrideMemory", memory);
|
||||||
@ -121,7 +117,6 @@ void InstanceSettings::applySettings()
|
|||||||
m_obj->reset("PermGen");
|
m_obj->reset("PermGen");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Java Settings
|
// Java Settings
|
||||||
bool java = ui->javaSettingsGroupBox->isChecked();
|
bool java = ui->javaSettingsGroupBox->isChecked();
|
||||||
m_obj->set("OverrideJava", java);
|
m_obj->set("OverrideJava", java);
|
||||||
@ -129,6 +124,8 @@ void InstanceSettings::applySettings()
|
|||||||
{
|
{
|
||||||
m_obj->set("JavaPath", ui->javaPathTextBox->text());
|
m_obj->set("JavaPath", ui->javaPathTextBox->text());
|
||||||
m_obj->set("JvmArgs", ui->jvmArgsTextBox->text());
|
m_obj->set("JvmArgs", ui->jvmArgsTextBox->text());
|
||||||
|
|
||||||
|
NagUtils::checkJVMArgs(m_obj->get("JvmArgs").toString(), this->parentWidget());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -136,7 +133,6 @@ void InstanceSettings::applySettings()
|
|||||||
m_obj->reset("JvmArgs");
|
m_obj->reset("JvmArgs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Custom Commands
|
// Custom Commands
|
||||||
bool custcmd = ui->customCommandsGroupBox->isChecked();
|
bool custcmd = ui->customCommandsGroupBox->isChecked();
|
||||||
m_obj->set("OverrideCommands", custcmd);
|
m_obj->set("OverrideCommands", custcmd);
|
||||||
@ -150,7 +146,6 @@ void InstanceSettings::applySettings()
|
|||||||
m_obj->reset("PreLaunchCommand");
|
m_obj->reset("PreLaunchCommand");
|
||||||
m_obj->reset("PostExitCommand");
|
m_obj->reset("PostExitCommand");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceSettings::loadSettings()
|
void InstanceSettings::loadSettings()
|
||||||
@ -166,10 +161,9 @@ void InstanceSettings::loadSettings()
|
|||||||
ui->windowWidthSpinBox->setValue(m_obj->get("MinecraftWinWidth").toInt());
|
ui->windowWidthSpinBox->setValue(m_obj->get("MinecraftWinWidth").toInt());
|
||||||
ui->windowHeightSpinBox->setValue(m_obj->get("MinecraftWinHeight").toInt());
|
ui->windowHeightSpinBox->setValue(m_obj->get("MinecraftWinHeight").toInt());
|
||||||
|
|
||||||
|
|
||||||
// Auto Login
|
// Auto Login
|
||||||
ui->accountSettingsGroupBox->setChecked(m_obj->get("OverrideLogin").toBool());
|
ui->accountSettingsBox->setChecked(m_obj->get("OverrideLogin").toBool());
|
||||||
ui->autoLoginChecBox->setChecked(m_obj->get("AutoLogin").toBool());
|
ui->autoLoginCheckBox->setChecked(m_obj->get("AutoLogin").toBool());
|
||||||
|
|
||||||
// Memory
|
// Memory
|
||||||
ui->memoryGroupBox->setChecked(m_obj->get("OverrideMemory").toBool());
|
ui->memoryGroupBox->setChecked(m_obj->get("OverrideMemory").toBool());
|
50
gui/dialogs/InstanceSettings.h
Normal file
50
gui/dialogs/InstanceSettings.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/* Copyright 2013 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include "settingsobject.h"
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class InstanceSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
class InstanceSettings : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit InstanceSettings(SettingsObject *s, QWidget *parent = 0);
|
||||||
|
~InstanceSettings();
|
||||||
|
|
||||||
|
void updateCheckboxStuff();
|
||||||
|
|
||||||
|
void applySettings();
|
||||||
|
void loadSettings();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void showEvent(QShowEvent *);
|
||||||
|
private
|
||||||
|
slots:
|
||||||
|
void on_customCommandsGroupBox_toggled(bool arg1);
|
||||||
|
void on_buttonBox_accepted();
|
||||||
|
void on_buttonBox_rejected();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::InstanceSettings *ui;
|
||||||
|
SettingsObject *m_obj;
|
||||||
|
};
|
@ -132,7 +132,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="accountSettingsGroupBox">
|
<widget class="QGroupBox" name="accountSettingsBox">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -147,16 +147,10 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="autoLoginChecBox">
|
<widget class="QCheckBox" name="autoLoginCheckBox">
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Login automatically when an instance icon is double clicked?</string>
|
<string>Login automatically when an instance icon is double clicked?</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -403,8 +397,7 @@
|
|||||||
<tabstop>consoleSettingsBox</tabstop>
|
<tabstop>consoleSettingsBox</tabstop>
|
||||||
<tabstop>showConsoleCheck</tabstop>
|
<tabstop>showConsoleCheck</tabstop>
|
||||||
<tabstop>autoCloseConsoleCheck</tabstop>
|
<tabstop>autoCloseConsoleCheck</tabstop>
|
||||||
<tabstop>accountSettingsGroupBox</tabstop>
|
<tabstop>accountSettingsBox</tabstop>
|
||||||
<tabstop>autoLoginChecBox</tabstop>
|
|
||||||
<tabstop>memoryGroupBox</tabstop>
|
<tabstop>memoryGroupBox</tabstop>
|
||||||
<tabstop>minMemSpinBox</tabstop>
|
<tabstop>minMemSpinBox</tabstop>
|
||||||
<tabstop>maxMemSpinBox</tabstop>
|
<tabstop>maxMemSpinBox</tabstop>
|
@ -16,12 +16,12 @@
|
|||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
#include "LegacyModEditDialog.h"
|
#include "LegacyModEditDialog.h"
|
||||||
#include "ModEditDialogCommon.h"
|
#include "ModEditDialogCommon.h"
|
||||||
#include "versionselectdialog.h"
|
#include "VersionSelectDialog.h"
|
||||||
#include "ProgressDialog.h"
|
#include "ProgressDialog.h"
|
||||||
#include "ui_LegacyModEditDialog.h"
|
#include "ui_LegacyModEditDialog.h"
|
||||||
#include "logic/ModList.h"
|
#include "logic/ModList.h"
|
||||||
#include "logic/lists/ForgeVersionList.h"
|
#include "logic/lists/ForgeVersionList.h"
|
||||||
#include "gui/platform.h"
|
#include "gui/Platform.h"
|
||||||
|
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
@ -307,12 +307,12 @@
|
|||||||
<customwidget>
|
<customwidget>
|
||||||
<class>ModListView</class>
|
<class>ModListView</class>
|
||||||
<extends>QTreeView</extends>
|
<extends>QTreeView</extends>
|
||||||
<header>gui/ModListView.h</header>
|
<header>gui/widgets/ModListView.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>MCModInfoFrame</class>
|
<class>MCModInfoFrame</class>
|
||||||
<extends>QFrame</extends>
|
<extends>QFrame</extends>
|
||||||
<header>gui/MCModInfoFrame.h</header>
|
<header>gui/widgets/MCModInfoFrame.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
@ -13,10 +13,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "logindialog.h"
|
#include "LoginDialog.h"
|
||||||
#include "ui_logindialog.h"
|
#include "ui_LoginDialog.h"
|
||||||
#include "keyring.h"
|
#include "keyring.h"
|
||||||
#include "gui/platform.h"
|
#include "gui/Platform.h"
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -24,11 +24,10 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
#include "logic/net/HttpMetaCache.h"
|
#include "logic/net/HttpMetaCache.h"
|
||||||
#include <logger/QsLog.h>
|
#include "logger/QsLog.h"
|
||||||
|
|
||||||
LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) :
|
LoginDialog::LoginDialog(QWidget *parent, const QString &loginErrMsg)
|
||||||
QDialog(parent),
|
: QDialog(parent), ui(new Ui::LoginDialog)
|
||||||
ui(new Ui::LoginDialog)
|
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -45,7 +44,8 @@ LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) :
|
|||||||
//: The username during login (placeholder)
|
//: The username during login (placeholder)
|
||||||
ui->usernameTextBox->lineEdit()->setPlaceholderText(tr("Name"));
|
ui->usernameTextBox->lineEdit()->setPlaceholderText(tr("Name"));
|
||||||
|
|
||||||
connect(ui->usernameTextBox, SIGNAL(currentTextChanged(QString)), this, SLOT(userTextChanged(QString)));
|
connect(ui->usernameTextBox, SIGNAL(currentTextChanged(QString)), this,
|
||||||
|
SLOT(userTextChanged(QString)));
|
||||||
connect(ui->forgetButton, SIGNAL(clicked(bool)), this, SLOT(forgetCurrentUser()));
|
connect(ui->forgetButton, SIGNAL(clicked(bool)), this, SLOT(forgetCurrentUser()));
|
||||||
connect(offlineButton, SIGNAL(clicked(bool)), this, SLOT(launchOffline()));
|
connect(offlineButton, SIGNAL(clicked(bool)), this, SLOT(launchOffline()));
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) :
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->loginErrorLabel->setVisible(true);
|
ui->loginErrorLabel->setVisible(true);
|
||||||
ui->loginErrorLabel->setText(QString("<span style=\" color:#ff0000;\">%1</span>").
|
ui->loginErrorLabel->setText(
|
||||||
arg(loginErrMsg));
|
QString("<span style=\" color:#ff0000;\">%1</span>").arg(loginErrMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->lblFace->setVisible(false);
|
ui->lblFace->setVisible(false);
|
||||||
@ -154,7 +154,6 @@ void LoginDialog::usernameToggled ( bool state )
|
|||||||
blockToggles = false;
|
blockToggles = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LoginDialog::userTextChanged(const QString &user)
|
void LoginDialog::userTextChanged(const QString &user)
|
||||||
{
|
{
|
||||||
blockToggles = true;
|
blockToggles = true;
|
||||||
@ -171,7 +170,8 @@ void LoginDialog::userTextChanged ( const QString& user )
|
|||||||
|
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
{
|
{
|
||||||
auto filename = MMC->metacache()->resolveEntry("skins", "skins.json")->getFullPath();
|
auto filename =
|
||||||
|
MMC->metacache()->resolveEntry("skins", "skins.json")->getFullPath();
|
||||||
QFile listFile(filename);
|
QFile listFile(filename);
|
||||||
if (!listFile.open(QIODevice::ReadOnly))
|
if (!listFile.open(QIODevice::ReadOnly))
|
||||||
return;
|
return;
|
||||||
@ -192,11 +192,16 @@ void LoginDialog::userTextChanged ( const QString& user )
|
|||||||
|
|
||||||
if (!mapped_username.isEmpty())
|
if (!mapped_username.isEmpty())
|
||||||
{
|
{
|
||||||
QFile fskin(MMC->metacache()->resolveEntry("skins", mapped_username + ".png")->getFullPath());
|
QFile fskin(MMC->metacache()
|
||||||
|
->resolveEntry("skins", mapped_username + ".png")
|
||||||
|
->getFullPath());
|
||||||
if (fskin.exists())
|
if (fskin.exists())
|
||||||
{
|
{
|
||||||
QPixmap skin(MMC->metacache()->resolveEntry("skins", mapped_username + ".png")->getFullPath());
|
QPixmap skin(MMC->metacache()
|
||||||
QPixmap face = skin.copy(8, 8, 8, 8).scaled(48, 48, Qt::KeepAspectRatio);
|
->resolveEntry("skins", mapped_username + ".png")
|
||||||
|
->getFullPath());
|
||||||
|
QPixmap face =
|
||||||
|
skin.copy(8, 8, 8, 8).scaled(48, 48, Qt::KeepAspectRatio);
|
||||||
|
|
||||||
ui->lblFace->setPixmap(face);
|
ui->lblFace->setPixmap(face);
|
||||||
gotFace = true;
|
gotFace = true;
|
||||||
@ -210,7 +215,6 @@ void LoginDialog::userTextChanged ( const QString& user )
|
|||||||
blockToggles = false;
|
blockToggles = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LoginDialog::accept()
|
void LoginDialog::accept()
|
||||||
{
|
{
|
||||||
bool saveName = ui->rememberUsernameCheckbox->isChecked();
|
bool saveName = ui->rememberUsernameCheckbox->isChecked();
|
@ -13,13 +13,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LOGINDIALOG_H
|
#pragma once
|
||||||
#define LOGINDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class LoginDialog;
|
class LoginDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,18 +34,24 @@ public:
|
|||||||
QString getUsername() const;
|
QString getUsername() const;
|
||||||
QString getPassword() const;
|
QString getPassword() const;
|
||||||
|
|
||||||
inline bool isOnline() { return isOnline_; }
|
inline bool isOnline()
|
||||||
|
{
|
||||||
|
return isOnline_;
|
||||||
|
}
|
||||||
|
|
||||||
void forceOnline();
|
void forceOnline();
|
||||||
|
|
||||||
public slots:
|
public
|
||||||
|
slots:
|
||||||
virtual void accept();
|
virtual void accept();
|
||||||
virtual void userTextChanged(const QString &user);
|
virtual void userTextChanged(const QString &user);
|
||||||
virtual void forgetCurrentUser();
|
virtual void forgetCurrentUser();
|
||||||
private slots:
|
private
|
||||||
|
slots:
|
||||||
void usernameToggled(bool);
|
void usernameToggled(bool);
|
||||||
void passwordToggled(bool);
|
void passwordToggled(bool);
|
||||||
void launchOffline();
|
void launchOffline();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::LoginDialog *ui;
|
Ui::LoginDialog *ui;
|
||||||
bool blockToggles;
|
bool blockToggles;
|
||||||
@ -53,5 +59,3 @@ private:
|
|||||||
bool isOnline_;
|
bool isOnline_;
|
||||||
bool onlineForced;
|
bool onlineForced;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LOGINDIALOG_H
|
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>476</width>
|
<width>496</width>
|
||||||
<height>168</height>
|
<height>168</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -50,7 +50,7 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="pixmap">
|
<property name="pixmap">
|
||||||
<pixmap resource="../multimc.qrc">:/icons/instances/steve</pixmap>
|
<pixmap resource="../../multimc.qrc">:/icons/instances/steve</pixmap>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
<property name="scaledContents">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -146,6 +146,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
|
<include location="../../multimc.qrc"/>
|
||||||
<include location="../multimc.qrc"/>
|
<include location="../multimc.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
@ -14,15 +14,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
#include "lwjglselectdialog.h"
|
#include "LwjglSelectDialog.h"
|
||||||
#include "ui_lwjglselectdialog.h"
|
#include "ui_LwjglSelectDialog.h"
|
||||||
#include "gui/platform.h"
|
#include "gui/Platform.h"
|
||||||
|
|
||||||
#include "logic/lists/LwjglVersionList.h"
|
#include "logic/lists/LwjglVersionList.h"
|
||||||
|
|
||||||
LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) :
|
LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent)
|
||||||
QDialog(parent),
|
: QDialog(parent), ui(new Ui::LWJGLSelectDialog)
|
||||||
ui(new Ui::LWJGLSelectDialog)
|
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -30,7 +29,8 @@ LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) :
|
|||||||
auto lwjgllist = MMC->lwjgllist();
|
auto lwjgllist = MMC->lwjgllist();
|
||||||
ui->lwjglListView->setModel(lwjgllist.get());
|
ui->lwjglListView->setModel(lwjgllist.get());
|
||||||
|
|
||||||
connect(lwjgllist.get(), SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool)));
|
connect(lwjgllist.get(), SIGNAL(loadingStateUpdated(bool)),
|
||||||
|
SLOT(loadingStateUpdated(bool)));
|
||||||
connect(lwjgllist.get(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
connect(lwjgllist.get(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
||||||
loadingStateUpdated(lwjgllist->isLoading());
|
loadingStateUpdated(lwjgllist->isLoading());
|
||||||
}
|
}
|
||||||
@ -42,9 +42,9 @@ LWJGLSelectDialog::~LWJGLSelectDialog()
|
|||||||
|
|
||||||
QString LWJGLSelectDialog::selectedVersion() const
|
QString LWJGLSelectDialog::selectedVersion() const
|
||||||
{
|
{
|
||||||
return MMC->lwjgllist()->data(
|
return MMC->lwjgllist()
|
||||||
ui->lwjglListView->selectionModel()->currentIndex(),
|
->data(ui->lwjglListView->selectionModel()->currentIndex(), Qt::DisplayRole)
|
||||||
Qt::DisplayRole).toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LWJGLSelectDialog::on_refreshButton_clicked()
|
void LWJGLSelectDialog::on_refreshButton_clicked()
|
@ -13,8 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LWJGLSELECTDIALOG_H
|
#pragma once
|
||||||
#define LWJGLSELECTDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
@ -33,7 +32,8 @@ public:
|
|||||||
|
|
||||||
QString selectedVersion() const;
|
QString selectedVersion() const;
|
||||||
|
|
||||||
private slots:
|
private
|
||||||
|
slots:
|
||||||
void on_refreshButton_clicked();
|
void on_refreshButton_clicked();
|
||||||
|
|
||||||
void loadingStateUpdated(bool loading);
|
void loadingStateUpdated(bool loading);
|
||||||
@ -42,5 +42,3 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
Ui::LWJGLSelectDialog *ui;
|
Ui::LWJGLSelectDialog *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LWJGLSELECTDIALOG_H
|
|
57
gui/dialogs/ModEditDialogCommon.cpp
Normal file
57
gui/dialogs/ModEditDialogCommon.cpp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* Copyright 2013 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ModEditDialogCommon.h"
|
||||||
|
#include "CustomMessageBox.h"
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
bool lastfirst(QModelIndexList &list, int &first, int &last)
|
||||||
|
{
|
||||||
|
if (!list.size())
|
||||||
|
return false;
|
||||||
|
first = last = list[0].row();
|
||||||
|
for (auto item : list)
|
||||||
|
{
|
||||||
|
int row = item.row();
|
||||||
|
if (row < first)
|
||||||
|
first = row;
|
||||||
|
if (row > last)
|
||||||
|
last = row;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void showWebsiteForMod(QWidget *parentDlg, Mod &m)
|
||||||
|
{
|
||||||
|
QString url = m.homeurl();
|
||||||
|
if (url.size())
|
||||||
|
{
|
||||||
|
// catch the cases where the protocol is missing
|
||||||
|
if (!url.startsWith("http"))
|
||||||
|
{
|
||||||
|
url = "http://" + url;
|
||||||
|
}
|
||||||
|
QDesktopServices::openUrl(url);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CustomMessageBox::selectable(
|
||||||
|
parentDlg, parentDlg->tr("How sad!"),
|
||||||
|
parentDlg->tr("The mod author didn't provide a website link for this mod."),
|
||||||
|
QMessageBox::Warning);
|
||||||
|
}
|
||||||
|
}
|
@ -13,9 +13,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef APPUTILS_H
|
#pragma once
|
||||||
#define APPUTILS_H
|
#include <QAbstractItemModel>
|
||||||
|
#include <logic/Mod.h>
|
||||||
|
|
||||||
#define STR_VAL(val) # val
|
bool lastfirst(QModelIndexList &list, int &first, int &last);
|
||||||
|
|
||||||
#endif // APPUTILS_H
|
void showWebsiteForMod(QWidget *parentDlg, Mod &m);
|
@ -13,9 +13,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <MultiMC.h>
|
#include "MultiMC.h"
|
||||||
#include "newinstancedialog.h"
|
#include "NewInstanceDialog.h"
|
||||||
#include "ui_newinstancedialog.h"
|
#include "ui_NewInstanceDialog.h"
|
||||||
|
|
||||||
#include "logic/InstanceFactory.h"
|
#include "logic/InstanceFactory.h"
|
||||||
#include "logic/BaseVersion.h"
|
#include "logic/BaseVersion.h"
|
||||||
@ -23,8 +23,8 @@
|
|||||||
#include "logic/lists/MinecraftVersionList.h"
|
#include "logic/lists/MinecraftVersionList.h"
|
||||||
#include "logic/tasks/Task.h"
|
#include "logic/tasks/Task.h"
|
||||||
|
|
||||||
#include "gui/platform.h"
|
#include "gui/Platform.h"
|
||||||
#include "versionselectdialog.h"
|
#include "VersionSelectDialog.h"
|
||||||
#include "ProgressDialog.h"
|
#include "ProgressDialog.h"
|
||||||
#include "IconPickerDialog.h"
|
#include "IconPickerDialog.h"
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user