Merge branch 'develop' of github.com:MultiMC/MultiMC5 into develop
This commit is contained in:
commit
613699b362
199
CMakeLists.txt
199
CMakeLists.txt
@ -27,14 +27,14 @@ ENDIF()
|
|||||||
######## Set compiler flags ########
|
######## Set compiler flags ########
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
message(STATUS "Using APPLE CMAKE_CXX_FLAGS")
|
message(STATUS "Using APPLE CMAKE_CXX_FLAGS")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
|
||||||
ELSEIF(UNIX)
|
ELSEIF(UNIX)
|
||||||
# assume GCC, add C++0x/C++11 stuff
|
# assume GCC, add C++0x/C++11 stuff
|
||||||
MESSAGE(STATUS "Using UNIX CMAKE_CXX_FLAGS")
|
MESSAGE(STATUS "Using UNIX CMAKE_CXX_FLAGS")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
|
||||||
ELSEIF(MINGW)
|
ELSEIF(MINGW)
|
||||||
MESSAGE(STATUS "Using MINGW CMAKE_CXX_FLAGS")
|
MESSAGE(STATUS "Using MINGW CMAKE_CXX_FLAGS")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
################################ INCLUDE LIBRARIES ################################
|
################################ INCLUDE LIBRARIES ################################
|
||||||
@ -48,6 +48,23 @@ find_package(Qt5LinguistTools REQUIRED)
|
|||||||
|
|
||||||
include_directories(${Qt5Widgets_INCLUDE_DIRS})
|
include_directories(${Qt5Widgets_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
# The Qt5 cmake files don't provide its install paths, so ask qmake.
|
||||||
|
get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION)
|
||||||
|
function(QUERY_QMAKE VAR RESULT)
|
||||||
|
exec_program(${QMAKE_EXECUTABLE} ARGS "-query ${VAR}" RETURN_VALUE return_code OUTPUT_VARIABLE output )
|
||||||
|
if(NOT return_code)
|
||||||
|
file(TO_CMAKE_PATH "${output}" output)
|
||||||
|
set(${RESULT} ${output} PARENT_SCOPE)
|
||||||
|
endif(NOT return_code)
|
||||||
|
endfunction(QUERY_QMAKE)
|
||||||
|
|
||||||
|
query_qmake(QT_INSTALL_PLUGINS QT_PLUGINS_DIR)
|
||||||
|
query_qmake(QT_INSTALL_IMPORTS QT_IMPORTS_DIR)
|
||||||
|
query_qmake(QT_INSTALL_LIBS QT_LIBS_DIR)
|
||||||
|
query_qmake(QT_HOST_DATA QT_DATA_DIR)
|
||||||
|
set(QT_MKSPECS_DIR ${QT_DATA_DIR}/mkspecs)
|
||||||
|
|
||||||
|
|
||||||
######## Included Libs ########
|
######## Included Libs ########
|
||||||
|
|
||||||
# Add quazip
|
# Add quazip
|
||||||
@ -289,11 +306,14 @@ logic/auth/MojangAccount.h
|
|||||||
logic/auth/MojangAccount.cpp
|
logic/auth/MojangAccount.cpp
|
||||||
logic/auth/YggdrasilTask.h
|
logic/auth/YggdrasilTask.h
|
||||||
logic/auth/YggdrasilTask.cpp
|
logic/auth/YggdrasilTask.cpp
|
||||||
logic/auth/AuthenticateTask.h
|
logic/auth/flows/AuthenticateTask.h
|
||||||
logic/auth/AuthenticateTask.cpp
|
logic/auth/flows/AuthenticateTask.cpp
|
||||||
logic/auth/ValidateTask.h
|
logic/auth/flows/RefreshTask.cpp
|
||||||
logic/auth/ValidateTask.cpp
|
logic/auth/flows/RefreshTask.cpp
|
||||||
|
logic/auth/flows/ValidateTask.h
|
||||||
|
logic/auth/flows/ValidateTask.cpp
|
||||||
|
logic/auth/flows/InvalidateTask.h
|
||||||
|
logic/auth/flows/InvalidateTask.cpp
|
||||||
|
|
||||||
# legacy instances
|
# legacy instances
|
||||||
logic/LegacyInstance.h
|
logic/LegacyInstance.h
|
||||||
@ -439,7 +459,6 @@ CONFIGURE_FILE(generated.qrc.in generated.qrc)
|
|||||||
QT5_ADD_RESOURCES(GENERATED_QRC ${CMAKE_CURRENT_BINARY_DIR}/generated.qrc)
|
QT5_ADD_RESOURCES(GENERATED_QRC ${CMAKE_CURRENT_BINARY_DIR}/generated.qrc)
|
||||||
QT5_ADD_RESOURCES(GRAPHICS_QRC graphics.qrc)
|
QT5_ADD_RESOURCES(GRAPHICS_QRC graphics.qrc)
|
||||||
|
|
||||||
|
|
||||||
# Add executable
|
# Add executable
|
||||||
ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32
|
ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32
|
||||||
${MULTIMC_SOURCES} ${MULTIMC_UI} ${GRAPHICS_QRC} ${GENERATED_QRC} ${MULTIMC_RCS})
|
${MULTIMC_SOURCES} ${MULTIMC_UI} ${GRAPHICS_QRC} ${GENERATED_QRC} ${MULTIMC_RCS})
|
||||||
@ -449,110 +468,122 @@ TARGET_LINK_LIBRARIES(MultiMC xz-embedded unpack200 quazip libUtil libSettings l
|
|||||||
QT5_USE_MODULES(MultiMC Core Widgets Network Xml ${MultiMC_QT_ADDITIONAL_MODULES})
|
QT5_USE_MODULES(MultiMC Core Widgets Network Xml ${MultiMC_QT_ADDITIONAL_MODULES})
|
||||||
ADD_DEPENDENCIES(MultiMC MultiMCLauncher JavaCheck)
|
ADD_DEPENDENCIES(MultiMC MultiMCLauncher JavaCheck)
|
||||||
|
|
||||||
option(BUILD_KEYRING_TEST "Build the simple keyring test binary" OFF)
|
|
||||||
IF(BUILD_KEYRING_TEST)
|
|
||||||
# test.cpp
|
|
||||||
ADD_EXECUTABLE(Test test.cpp)
|
|
||||||
QT5_USE_MODULES(Test Core)
|
|
||||||
TARGET_LINK_LIBRARIES(Test libUtil libSettings)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
################################ INSTALLATION AND PACKAGING ################################
|
################################ INSTALLATION AND PACKAGING ################################
|
||||||
# use QtCreator's QTDIR var
|
|
||||||
IF(DEFINED ENV{QTDIR})
|
|
||||||
SET(Qt5_DIR $ENV{QTDIR})
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
######## Plugin and library folders ########
|
######## Packaging/install paths setup ########
|
||||||
|
|
||||||
|
IF(UNIX AND APPLE)
|
||||||
|
SET(PLUGIN_DEST_DIR MultiMC.app/Contents/MacOS)
|
||||||
|
SET(QTCONF_DEST_DIR MultiMC.app/Contents/Resources)
|
||||||
|
SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.app")
|
||||||
|
|
||||||
|
SET(MACOSX_BUNDLE_BUNDLE_NAME "MultiMC")
|
||||||
|
SET(MACOSX_BUNDLE_INFO_STRING "MultiMC Minecraft launcher and management utility.")
|
||||||
|
SET(MACOSX_BUNDLE_BUNDLE_VERSION "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_REV}.${MultiMC_VERSION_BUILD}")
|
||||||
|
#SET(MACOSX_BUNDLE_GUI_IDENTIFIER "")
|
||||||
|
SET(MACOSX_BUNDLE_ICON_FILE MultiMC.icns)
|
||||||
|
ELSEIF(UNIX)
|
||||||
SET(PLUGIN_DEST_DIR plugins)
|
SET(PLUGIN_DEST_DIR plugins)
|
||||||
SET(QTCONF_DEST_DIR .)
|
SET(QTCONF_DEST_DIR .)
|
||||||
SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC")
|
SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC")
|
||||||
|
ELSEIF(WIN32)
|
||||||
IF(WIN32)
|
|
||||||
SET(PLUGIN_DEST_DIR .)
|
SET(PLUGIN_DEST_DIR .)
|
||||||
SET(QTCONF_DEST_DIR .)
|
SET(QTCONF_DEST_DIR .)
|
||||||
SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe")
|
SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.exe")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(UNIX)
|
# directories to look for dependencies
|
||||||
IF(APPLE)
|
SET(DIRS "${QT_LIBS_DIR}")
|
||||||
SET(PLUGIN_DEST_DIR MultiMC.app/Contents/MacOS)
|
|
||||||
SET(QTCONF_DEST_DIR MultiMC.app/Contents/Resources)
|
|
||||||
SET(APPS "\${CMAKE_INSTALL_PREFIX}/MultiMC.app")
|
|
||||||
ELSE()
|
|
||||||
SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/MultiMC")
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(QT_PLUGINS_DIR ${Qt5_DIR}/plugins)
|
|
||||||
SET(QT_LIBRARY_DIRS ${Qt5_DIR}/lib)
|
|
||||||
|
|
||||||
|
|
||||||
######## OS X Bundle Info ########
|
|
||||||
|
|
||||||
IF(APPLE)
|
|
||||||
SET(MACOSX_BUNDLE_BUNDLE_NAME "MultiMC")
|
|
||||||
SET(MACOSX_BUNDLE_INFO_STRING "MultiMC Minecraft launcher and management utility.")
|
|
||||||
SET(MACOSX_BUNDLE_BUNDLE_VERSION
|
|
||||||
"${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}.${MultiMC_VERSION_REV}.${MultiMC_VERSION_BUILD}")
|
|
||||||
#SET(MACOSX_BUNDLE_GUI_IDENTIFIER "")
|
|
||||||
SET(MACOSX_BUNDLE_ICON_FILE MultiMC.icns)
|
|
||||||
ENDIF(APPLE)
|
|
||||||
|
|
||||||
######## Install ########
|
######## Install ########
|
||||||
|
|
||||||
#### Executable ####
|
#### Executable ####
|
||||||
IF(WIN32)
|
IF(APPLE AND UNIX) ## OSX
|
||||||
|
INSTALL(TARGETS MultiMC
|
||||||
|
BUNDLE DESTINATION . COMPONENT Runtime
|
||||||
|
RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime
|
||||||
|
)
|
||||||
|
|
||||||
|
ELSEIF(UNIX) ## LINUX and similar
|
||||||
|
INSTALL(TARGETS MultiMC
|
||||||
|
BUNDLE DESTINATION . COMPONENT Runtime
|
||||||
|
RUNTIME DESTINATION bin COMPONENT Runtime
|
||||||
|
)
|
||||||
|
INSTALL(PROGRAMS package/linux/MultiMC DESTINATION .)
|
||||||
|
|
||||||
|
ELSEIF(WIN32) ## WINDOWS
|
||||||
INSTALL(TARGETS MultiMC
|
INSTALL(TARGETS MultiMC
|
||||||
BUNDLE DESTINATION . COMPONENT Runtime
|
BUNDLE DESTINATION . COMPONENT Runtime
|
||||||
LIBRARY DESTINATION . COMPONENT Runtime
|
LIBRARY DESTINATION . COMPONENT Runtime
|
||||||
RUNTIME DESTINATION . COMPONENT Runtime
|
RUNTIME DESTINATION . COMPONENT Runtime
|
||||||
)
|
)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
IF(UNIX)
|
|
||||||
IF(APPLE)
|
|
||||||
INSTALL(TARGETS MultiMC
|
|
||||||
BUNDLE DESTINATION . COMPONENT Runtime
|
|
||||||
RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime
|
|
||||||
)
|
|
||||||
ELSE()
|
|
||||||
INSTALL(TARGETS MultiMC
|
|
||||||
BUNDLE DESTINATION . COMPONENT Runtime
|
|
||||||
RUNTIME DESTINATION bin COMPONENT Runtime
|
|
||||||
)
|
|
||||||
INSTALL(PROGRAMS package/linux/MultiMC DESTINATION .)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
|
#### Dist package logic ####
|
||||||
|
|
||||||
#### Plugins ####
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||||
|
|
||||||
OPTION(MultiMC_INSTALL_SHARED_LIBS "if set, Qt's shared libraries will be copied to the installation directory on install")
|
|
||||||
|
|
||||||
IF (MultiMC_INSTALL_SHARED_LIBS)
|
|
||||||
# Image formats
|
# Image formats
|
||||||
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime)
|
INSTALL(
|
||||||
|
DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
|
||||||
|
DESTINATION ${PLUGIN_DEST_DIR}
|
||||||
|
COMPONENT Runtime
|
||||||
|
REGEX "tga|svg|tiff|mng" EXCLUDE
|
||||||
|
)
|
||||||
|
|
||||||
# Platform plugins
|
# Platform plugins
|
||||||
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/platforms" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime)
|
INSTALL(
|
||||||
|
DIRECTORY "${QT_PLUGINS_DIR}/platforms"
|
||||||
|
DESTINATION ${PLUGIN_DEST_DIR}
|
||||||
|
COMPONENT Runtime
|
||||||
|
REGEX "minimal|linuxfb|offscreen" EXCLUDE
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# Image formats
|
||||||
|
INSTALL(
|
||||||
|
DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
|
||||||
|
DESTINATION ${PLUGIN_DEST_DIR}
|
||||||
|
COMPONENT Runtime
|
||||||
|
REGEX "tga|svg|tiff|mng" EXCLUDE
|
||||||
|
REGEX "d\\." EXCLUDE
|
||||||
|
REGEX "_debug\\." EXCLUDE
|
||||||
|
)
|
||||||
|
|
||||||
|
# Platform plugins
|
||||||
|
INSTALL(
|
||||||
|
DIRECTORY "${QT_PLUGINS_DIR}/platforms"
|
||||||
|
DESTINATION ${PLUGIN_DEST_DIR}
|
||||||
|
COMPONENT Runtime
|
||||||
|
REGEX "minimal|linuxfb|offscreen" EXCLUDE
|
||||||
|
REGEX "d\\." EXCLUDE
|
||||||
|
REGEX "_debug\\." EXCLUDE
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# qtconf
|
# qtconf
|
||||||
INSTALL(CODE "
|
INSTALL(
|
||||||
|
CODE "
|
||||||
FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/${QTCONF_DEST_DIR}/qt.conf\" \"\")
|
FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/${QTCONF_DEST_DIR}/qt.conf\" \"\")
|
||||||
" COMPONENT Runtime)
|
"
|
||||||
|
COMPONENT Runtime
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Dirs to look for dependencies.
|
INSTALL(
|
||||||
SET(DIRS "${QT_LIBRARY_DIRS}")
|
CODE "
|
||||||
|
FILE(GLOB_RECURSE QTPLUGINS \"\${CMAKE_INSTALL_PREFIX}/${PLUGIN_DEST_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
|
||||||
|
function(gp_resolved_file_type_override resolved_file type_var)
|
||||||
|
if(resolved_file MATCHES \"^/usr/lib/libQt\")
|
||||||
|
message(\"resolving \${resolved_file} as other\")
|
||||||
|
set(\${type_var} other PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
INSTALL(CODE "
|
|
||||||
file(GLOB_RECURSE QTPLUGINS
|
|
||||||
\"\${CMAKE_INSTALL_PREFIX}/${PLUGIN_DEST_DIR}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
|
|
||||||
include(BundleUtilities)
|
include(BundleUtilities)
|
||||||
fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
|
fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
|
||||||
" COMPONENT Runtime)
|
"
|
||||||
ENDIF()
|
COMPONENT Runtime
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
######## Package ########
|
######## Package ########
|
||||||
@ -596,14 +627,12 @@ include_directories(${PROJECT_BINARY_DIR}/include)
|
|||||||
file (GLOB TRANSLATIONS_FILES translations/*.ts)
|
file (GLOB TRANSLATIONS_FILES translations/*.ts)
|
||||||
|
|
||||||
option (UPDATE_TRANSLATIONS "Update source translation translations/*.ts files (WARNING: make clean will delete the source .ts files! Danger!)")
|
option (UPDATE_TRANSLATIONS "Update source translation translations/*.ts files (WARNING: make clean will delete the source .ts files! Danger!)")
|
||||||
if (UPDATE_TRANSLATIONS)
|
IF(UPDATE_TRANSLATIONS)
|
||||||
qt5_create_translation(QM_FILES ${FILES_TO_TRANSLATE} ${TRANSLATIONS_FILES})
|
qt5_create_translation(QM_FILES ${FILES_TO_TRANSLATE} ${TRANSLATIONS_FILES})
|
||||||
else (UPDATE_TRANSLATIONS)
|
ELSE()
|
||||||
qt5_add_translation(QM_FILES ${TRANSLATIONS_FILES})
|
qt5_add_translation(QM_FILES ${TRANSLATIONS_FILES})
|
||||||
endif (UPDATE_TRANSLATIONS)
|
ENDIF()
|
||||||
|
|
||||||
add_custom_target (translations DEPENDS ${QM_FILES})
|
add_custom_target (translations DEPENDS ${QM_FILES})
|
||||||
|
|
||||||
install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/translations)
|
install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/translations)
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,6 +189,9 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv),
|
|||||||
case QNetworkProxy::FtpCachingProxy:
|
case QNetworkProxy::FtpCachingProxy:
|
||||||
proxyDesc = "FTP caching: ";
|
proxyDesc = "FTP caching: ";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
proxyDesc = "DERP proxy: ";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
proxyDesc += QString("%3@%1:%2 pass %4")
|
proxyDesc += QString("%3@%1:%2 pass %4")
|
||||||
.arg(proxy.hostName())
|
.arg(proxy.hostName())
|
||||||
@ -326,6 +329,7 @@ void MultiMC::initGlobalSettings()
|
|||||||
|
|
||||||
|
|
||||||
m_settings->registerSetting(new Setting("InstSortMode", "Name"));
|
m_settings->registerSetting(new Setting("InstSortMode", "Name"));
|
||||||
|
m_settings->registerSetting(new Setting("SelectedInstance", QString()));
|
||||||
|
|
||||||
// Persistent value for the client ID
|
// Persistent value for the client ID
|
||||||
m_settings->registerSetting(new Setting("YggdrasilClientToken", ""));
|
m_settings->registerSetting(new Setting("YggdrasilClientToken", ""));
|
||||||
|
@ -58,18 +58,6 @@ struct KCategorizedView::Private::Item
|
|||||||
|
|
||||||
struct KCategorizedView::Private::Block
|
struct KCategorizedView::Private::Block
|
||||||
{
|
{
|
||||||
Block()
|
|
||||||
: topLeft ( QPoint() )
|
|
||||||
, height ( -1 )
|
|
||||||
, firstIndex ( QModelIndex() )
|
|
||||||
, quarantineStart ( QModelIndex() )
|
|
||||||
, items ( QList<Item>() )
|
|
||||||
, outOfQuarantine ( false )
|
|
||||||
, alternate ( false )
|
|
||||||
, collapsed ( false )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!= ( const Block &rhs ) const
|
bool operator!= ( const Block &rhs ) const
|
||||||
{
|
{
|
||||||
return firstIndex != rhs.firstIndex;
|
return firstIndex != rhs.firstIndex;
|
||||||
@ -83,7 +71,7 @@ struct KCategorizedView::Private::Block
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPoint topLeft;
|
QPoint topLeft;
|
||||||
int height;
|
int height = -1;
|
||||||
QPersistentModelIndex firstIndex;
|
QPersistentModelIndex firstIndex;
|
||||||
// if we have n elements on this block, and we inserted an element at position i. The quarantine
|
// if we have n elements on this block, and we inserted an element at position i. The quarantine
|
||||||
// will start at index (i, column, parent). This means that for all elements j where i <= j <= n, the
|
// will start at index (i, column, parent). This means that for all elements j where i <= j <= n, the
|
||||||
@ -97,25 +85,16 @@ struct KCategorizedView::Private::Block
|
|||||||
// this affects the whole block, not items separately. items contain the topLeft point relative
|
// this affects the whole block, not items separately. items contain the topLeft point relative
|
||||||
// to the block. Because of insertions or removals a whole block can be moved, so the whole block
|
// to the block. Because of insertions or removals a whole block can be moved, so the whole block
|
||||||
// will enter in quarantine, what is faster than moving all items in absolute terms.
|
// will enter in quarantine, what is faster than moving all items in absolute terms.
|
||||||
bool outOfQuarantine;
|
bool outOfQuarantine = false;
|
||||||
|
|
||||||
// should we alternate its color ? is just a hint, could not be used
|
// should we alternate its color ? is just a hint, could not be used
|
||||||
bool alternate;
|
bool alternate = false;
|
||||||
bool collapsed;
|
bool collapsed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
KCategorizedView::Private::Private ( KCategorizedView *q )
|
KCategorizedView::Private::Private ( KCategorizedView *q )
|
||||||
: q ( q )
|
: q ( q )
|
||||||
, proxyModel ( 0 )
|
|
||||||
, categoryDrawer ( 0 )
|
|
||||||
, categorySpacing ( 5 )
|
|
||||||
, alternatingBlockColors ( false )
|
|
||||||
, collapsibleBlocks ( false )
|
|
||||||
, hoveredBlock ( new Block() )
|
, hoveredBlock ( new Block() )
|
||||||
, hoveredIndex ( QModelIndex() )
|
|
||||||
, pressedPosition ( QPoint() )
|
|
||||||
, rubberBandRect ( QRect() )
|
|
||||||
, constantItemWidth( 0 )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,14 +137,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
void _k_slotCollapseOrExpandClicked(QModelIndex);
|
void _k_slotCollapseOrExpandClicked(QModelIndex);
|
||||||
|
|
||||||
KCategorizedView *q;
|
KCategorizedView *q = nullptr;
|
||||||
KCategorizedSortFilterProxyModel *proxyModel;
|
KCategorizedSortFilterProxyModel *proxyModel = nullptr;
|
||||||
KCategoryDrawer *categoryDrawer;
|
KCategoryDrawer *categoryDrawer = nullptr;
|
||||||
int categorySpacing;
|
int categorySpacing = 5;
|
||||||
bool alternatingBlockColors;
|
bool alternatingBlockColors = false;
|
||||||
bool collapsibleBlocks;
|
bool collapsibleBlocks = false;
|
||||||
bool constantItemWidth;
|
bool constantItemWidth = false;
|
||||||
|
|
||||||
|
// FIXME: this is some really weird logic. Investigate.
|
||||||
Block *hoveredBlock;
|
Block *hoveredBlock;
|
||||||
QString hoveredCategory;
|
QString hoveredCategory;
|
||||||
QModelIndex hoveredIndex;
|
QModelIndex hoveredIndex;
|
||||||
|
@ -42,9 +42,9 @@ public:
|
|||||||
~Private()
|
~Private()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
KCategorizedView *view;
|
||||||
int leftMargin;
|
int leftMargin;
|
||||||
int rightMargin;
|
int rightMargin;
|
||||||
KCategorizedView *view;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
KCategoryDrawer::KCategoryDrawer(KCategorizedView *view)
|
KCategoryDrawer::KCategoryDrawer(KCategorizedView *view)
|
||||||
|
@ -79,7 +79,6 @@ void band::readData(int expectedLength)
|
|||||||
|
|
||||||
// Read one value to see what it might be.
|
// Read one value to see what it might be.
|
||||||
int XB = _meta_default;
|
int XB = _meta_default;
|
||||||
int cp1 = 0, cp2 = 0;
|
|
||||||
if (!is_BYTE1)
|
if (!is_BYTE1)
|
||||||
{
|
{
|
||||||
// must be a variable-length coding
|
// must be a variable-length coding
|
||||||
@ -109,7 +108,6 @@ void band::readData(int expectedLength)
|
|||||||
{
|
{
|
||||||
// Skip over the escape value.
|
// Skip over the escape value.
|
||||||
u->rp = xvs.rp;
|
u->rp = xvs.rp;
|
||||||
cp1 = 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,7 @@ struct bytes
|
|||||||
bytes res;
|
bytes res;
|
||||||
res.ptr = ptr + beg;
|
res.ptr = ptr + beg;
|
||||||
res.len = end - beg;
|
res.len = end - beg;
|
||||||
assert(res.len == 0 || inBounds(res.ptr) && inBounds(res.limit() - 1));
|
assert(res.len == 0 ||(inBounds(res.ptr) && inBounds(res.limit() - 1)));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
// building C strings inside byte buffers:
|
// building C strings inside byte buffers:
|
||||||
|
@ -121,7 +121,6 @@ coding *coding::init()
|
|||||||
this->min = this->umin = 0;
|
this->min = this->umin = 0;
|
||||||
if (S != 0 && range != 0)
|
if (S != 0 && range != 0)
|
||||||
{
|
{
|
||||||
int Smask = (1 << S) - 1;
|
|
||||||
int64_t maxPosCode = range - 1;
|
int64_t maxPosCode = range - 1;
|
||||||
int64_t maxNegCode = range - 1;
|
int64_t maxNegCode = range - 1;
|
||||||
while (IS_NEG_CODE(S, maxPosCode))
|
while (IS_NEG_CODE(S, maxPosCode))
|
||||||
|
@ -483,10 +483,6 @@ void unpacker::putu1ref(entry *e)
|
|||||||
putu1_at(put_space(1), oidx);
|
putu1_at(put_space(1), oidx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int total_cp_size[] = {0, 0};
|
|
||||||
static int largest_cp_ref[] = {0, 0};
|
|
||||||
static int hash_probes[] = {0, 0};
|
|
||||||
|
|
||||||
// Allocation of small and large blocks.
|
// Allocation of small and large blocks.
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -705,7 +701,7 @@ void unpacker::read_file_header()
|
|||||||
unpack_abort("impossible archive size"); // bad input data
|
unpack_abort("impossible archive size"); // bad input data
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (archive_size < header_size_1)
|
if (archive_size < (size_t)header_size_1)
|
||||||
{
|
{
|
||||||
unpack_abort("too much read-ahead"); // somehow we pre-fetched too much?
|
unpack_abort("too much read-ahead"); // somehow we pre-fetched too much?
|
||||||
return;
|
return;
|
||||||
@ -1316,8 +1312,6 @@ void unpacker::read_signature_values(entry *cpMap, int len)
|
|||||||
// Cf. PackageReader.readConstantPool
|
// Cf. PackageReader.readConstantPool
|
||||||
void unpacker::read_cp()
|
void unpacker::read_cp()
|
||||||
{
|
{
|
||||||
byte *rp0 = rp;
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (int k = 0; k < (int)N_TAGS_IN_ORDER; k++)
|
for (int k = 0; k < (int)N_TAGS_IN_ORDER; k++)
|
||||||
@ -1596,7 +1590,6 @@ band **unpacker::attr_definitions::buildBands(unpacker::layout_definition *lo)
|
|||||||
const char *unpacker::attr_definitions::parseIntLayout(const char *lp, band *&res, byte le_kind,
|
const char *unpacker::attr_definitions::parseIntLayout(const char *lp, band *&res, byte le_kind,
|
||||||
bool can_be_signed)
|
bool can_be_signed)
|
||||||
{
|
{
|
||||||
const char *lp0 = lp;
|
|
||||||
band *b = U_NEW(band, 1);
|
band *b = U_NEW(band, 1);
|
||||||
char le = *lp++;
|
char le = *lp++;
|
||||||
int spec = UNSIGNED5_spec;
|
int spec = UNSIGNED5_spec;
|
||||||
@ -1638,7 +1631,6 @@ const char *unpacker::attr_definitions::parseIntLayout(const char *lp, band *&re
|
|||||||
|
|
||||||
const char *unpacker::attr_definitions::parseNumeral(const char *lp, int &res)
|
const char *unpacker::attr_definitions::parseNumeral(const char *lp, int &res)
|
||||||
{
|
{
|
||||||
const char *lp0 = lp;
|
|
||||||
bool sgn = false;
|
bool sgn = false;
|
||||||
if (*lp == '0')
|
if (*lp == '0')
|
||||||
{
|
{
|
||||||
@ -1703,7 +1695,6 @@ band **unpacker::attr_definitions::popBody(int bs_base)
|
|||||||
|
|
||||||
const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res, int curCble)
|
const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res, int curCble)
|
||||||
{
|
{
|
||||||
const char *lp0 = lp;
|
|
||||||
int bs_base = band_stack.length();
|
int bs_base = band_stack.length();
|
||||||
bool top_level = (bs_base == 0);
|
bool top_level = (bs_base == 0);
|
||||||
band *b;
|
band *b;
|
||||||
@ -3135,8 +3126,6 @@ unpacker::read_bcs()
|
|||||||
|
|
||||||
void unpacker::read_bands()
|
void unpacker::read_bands()
|
||||||
{
|
{
|
||||||
byte *rp0 = rp;
|
|
||||||
|
|
||||||
read_file_header();
|
read_file_header();
|
||||||
|
|
||||||
if (cp.nentries == 0)
|
if (cp.nentries == 0)
|
||||||
@ -3312,7 +3301,7 @@ void constant_pool::initMemberIndexes()
|
|||||||
|
|
||||||
// Get the pre-existing indexes:
|
// Get the pre-existing indexes:
|
||||||
int nclasses = tag_count[CONSTANT_Class];
|
int nclasses = tag_count[CONSTANT_Class];
|
||||||
entry *classes = tag_base[CONSTANT_Class] + entries;
|
// entry *classes = tag_base[CONSTANT_Class] + entries; // UNUSED
|
||||||
int nfields = tag_count[CONSTANT_Fieldref];
|
int nfields = tag_count[CONSTANT_Fieldref];
|
||||||
entry *fields = tag_base[CONSTANT_Fieldref] + entries;
|
entry *fields = tag_base[CONSTANT_Fieldref] + entries;
|
||||||
int nmethods = tag_count[CONSTANT_Methodref];
|
int nmethods = tag_count[CONSTANT_Methodref];
|
||||||
@ -3563,8 +3552,6 @@ void unpacker::start(void *packptr, size_t len)
|
|||||||
|
|
||||||
void unpacker::check_options()
|
void unpacker::check_options()
|
||||||
{
|
{
|
||||||
const char *strue = "true";
|
|
||||||
const char *sfalse = "false";
|
|
||||||
if (deflate_hint_or_zero != 0)
|
if (deflate_hint_or_zero != 0)
|
||||||
{
|
{
|
||||||
bool force_deflate_hint = (deflate_hint_or_zero > 0);
|
bool force_deflate_hint = (deflate_hint_or_zero > 0);
|
||||||
|
@ -97,8 +97,6 @@ static int read_magic(unpacker *u, char peek[], int peeklen)
|
|||||||
void unpack_200(std::string input_path, std::string output_path)
|
void unpack_200(std::string input_path, std::string output_path)
|
||||||
{
|
{
|
||||||
unpacker u;
|
unpacker u;
|
||||||
int status = 0;
|
|
||||||
|
|
||||||
FILE *input = fopen(input_path.c_str(), "rb");
|
FILE *input = fopen(input_path.c_str(), "rb");
|
||||||
if (!input)
|
if (!input)
|
||||||
{
|
{
|
||||||
|
@ -1173,7 +1173,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
|
|||||||
if (password != NULL)
|
if (password != NULL)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
s->pcrc_32_tab = get_crc_table();
|
s->pcrc_32_tab = (const unsigned long*) get_crc_table();
|
||||||
init_keys(password,s->keys,s->pcrc_32_tab);
|
init_keys(password,s->keys,s->pcrc_32_tab);
|
||||||
if (ZSEEK(s->z_filefunc, s->filestream,
|
if (ZSEEK(s->z_filefunc, s->filestream,
|
||||||
s->pfile_in_zip_read->pos_in_zipfile +
|
s->pfile_in_zip_read->pos_in_zipfile +
|
||||||
|
@ -903,7 +903,7 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
|
|||||||
unsigned char bufHead[RAND_HEAD_LEN];
|
unsigned char bufHead[RAND_HEAD_LEN];
|
||||||
unsigned int sizeHead;
|
unsigned int sizeHead;
|
||||||
zi->ci.encrypt = 1;
|
zi->ci.encrypt = 1;
|
||||||
zi->ci.pcrc_32_tab = get_crc_table();
|
zi->ci.pcrc_32_tab = (const unsigned long*) get_crc_table();
|
||||||
/*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/
|
/*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/
|
||||||
|
|
||||||
crcForCrypting = (uLong)zi->ci.dosDate << 16; // ATTANTION! Without this row, you don't unpack your password protected archive in other app.
|
crcForCrypting = (uLong)zi->ci.dosDate << 16; // ATTANTION! Without this row, you don't unpack your password protected archive in other app.
|
||||||
|
@ -33,6 +33,11 @@
|
|||||||
class LIBSETTINGS_EXPORT Keyring
|
class LIBSETTINGS_EXPORT Keyring
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief virtual dtor
|
||||||
|
*/
|
||||||
|
virtual ~Keyring() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief the System Keyring instance
|
* @brief the System Keyring instance
|
||||||
* @return the Keyring instance
|
* @return the Keyring instance
|
||||||
|
@ -24,6 +24,11 @@
|
|||||||
class StubKeyring : public Keyring
|
class StubKeyring : public Keyring
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief virtual dtor
|
||||||
|
*/
|
||||||
|
virtual ~StubKeyring() {};
|
||||||
|
|
||||||
virtual bool storePassword(QString service, QString username, QString password);
|
virtual bool storePassword(QString service, QString username, QString password);
|
||||||
virtual QString getPassword(QString service, QString username);
|
virtual QString getPassword(QString service, QString username);
|
||||||
virtual bool hasPassword(QString service, QString username);
|
virtual bool hasPassword(QString service, QString username);
|
||||||
|
@ -58,13 +58,23 @@ void ConsoleWindow::writeColor(QString text, const char *color)
|
|||||||
ui->text->appendHtml(QString("<font color=\"%1\">%2</font>").arg(color).arg(text));
|
ui->text->appendHtml(QString("<font color=\"%1\">%2</font>").arg(color).arg(text));
|
||||||
else
|
else
|
||||||
ui->text->appendPlainText(text);
|
ui->text->appendPlainText(text);
|
||||||
// scroll down
|
|
||||||
QScrollBar *bar = ui->text->verticalScrollBar();
|
|
||||||
bar->setValue(bar->maximum());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleWindow::write(QString data, MessageLevel::Enum mode)
|
void ConsoleWindow::write(QString data, MessageLevel::Enum mode)
|
||||||
{
|
{
|
||||||
|
QScrollBar *bar = ui->text->verticalScrollBar();
|
||||||
|
int max_bar = bar->maximum();
|
||||||
|
int val_bar = bar->value();
|
||||||
|
if(m_scroll_active)
|
||||||
|
{
|
||||||
|
if(m_last_scroll_value > val_bar)
|
||||||
|
m_scroll_active = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_scroll_active = val_bar == max_bar;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.endsWith('\n'))
|
if (data.endsWith('\n'))
|
||||||
data = data.left(data.length() - 1);
|
data = data.left(data.length() - 1);
|
||||||
QStringList paragraphs = data.split('\n');
|
QStringList paragraphs = data.split('\n');
|
||||||
@ -93,6 +103,11 @@ void ConsoleWindow::write(QString data, MessageLevel::Enum mode)
|
|||||||
else
|
else
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
writeColor(iter.next());
|
writeColor(iter.next());
|
||||||
|
if(m_scroll_active)
|
||||||
|
{
|
||||||
|
bar->setValue(bar->maximum());
|
||||||
|
}
|
||||||
|
m_last_scroll_value = bar->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleWindow::clear()
|
void ConsoleWindow::clear()
|
||||||
|
@ -38,6 +38,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setMayClose(bool mayclose);
|
void setMayClose(bool mayclose);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief write a colored paragraph
|
||||||
|
* @param data the string
|
||||||
|
* @param color the css color name
|
||||||
|
* this will only insert a single paragraph.
|
||||||
|
* \n are ignored. a real \n is always appended.
|
||||||
|
*/
|
||||||
|
void writeColor(QString data, const char *color = nullptr);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void isClosing();
|
void isClosing();
|
||||||
|
|
||||||
@ -51,15 +61,6 @@ slots:
|
|||||||
*/
|
*/
|
||||||
void write(QString data, MessageLevel::Enum level = MessageLevel::MultiMC);
|
void write(QString data, MessageLevel::Enum level = MessageLevel::MultiMC);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief write a colored paragraph
|
|
||||||
* @param data the string
|
|
||||||
* @param color the css color name
|
|
||||||
* this will only insert a single paragraph.
|
|
||||||
* \n are ignored. a real \n is always appended.
|
|
||||||
*/
|
|
||||||
void writeColor(QString data, const char *color = nullptr);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief clear the text widget
|
* @brief clear the text widget
|
||||||
*/
|
*/
|
||||||
@ -82,4 +83,6 @@ private:
|
|||||||
Ui::ConsoleWindow *ui = nullptr;
|
Ui::ConsoleWindow *ui = nullptr;
|
||||||
MinecraftProcess *proc = nullptr;
|
MinecraftProcess *proc = nullptr;
|
||||||
bool m_mayclose = true;
|
bool m_mayclose = true;
|
||||||
|
int m_last_scroll_value = 0;
|
||||||
|
bool m_scroll_active = true;
|
||||||
};
|
};
|
||||||
|
@ -69,8 +69,9 @@
|
|||||||
#include "logic/lists/IconList.h"
|
#include "logic/lists/IconList.h"
|
||||||
#include "logic/lists/JavaVersionList.h"
|
#include "logic/lists/JavaVersionList.h"
|
||||||
|
|
||||||
#include "logic/auth/AuthenticateTask.h"
|
#include "logic/auth/flows/AuthenticateTask.h"
|
||||||
#include "logic/auth/ValidateTask.h"
|
#include "logic/auth/flows/RefreshTask.h"
|
||||||
|
#include "logic/auth/flows/ValidateTask.h"
|
||||||
|
|
||||||
#include "logic/BaseInstance.h"
|
#include "logic/BaseInstance.h"
|
||||||
#include "logic/InstanceFactory.h"
|
#include "logic/InstanceFactory.h"
|
||||||
@ -244,6 +245,28 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
connect(assets_downloader, SIGNAL(finished()), SLOT(assetsFinished()));
|
connect(assets_downloader, SIGNAL(finished()), SLOT(assetsFinished()));
|
||||||
assets_downloader->start();
|
assets_downloader->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString currentInstanceId = MMC->settings()->get("SelectedInstance").toString();
|
||||||
|
if (!currentInstanceId.isNull())
|
||||||
|
{
|
||||||
|
const QModelIndex index = MMC->instances()->getInstanceIndexById(currentInstanceId);
|
||||||
|
if (index.isValid())
|
||||||
|
{
|
||||||
|
const QModelIndex mappedIndex = proxymodel->mapFromSource(index);
|
||||||
|
view->setCurrentIndex(mappedIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view->setCurrentIndex(proxymodel->index(0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view->setCurrentIndex(proxymodel->index(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// removing this looks stupid
|
||||||
|
view->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -254,7 +277,6 @@ MainWindow::~MainWindow()
|
|||||||
delete assets_downloader;
|
delete assets_downloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::repopulateAccountsMenu()
|
void MainWindow::repopulateAccountsMenu()
|
||||||
{
|
{
|
||||||
accountMenu->clear();
|
accountMenu->clear();
|
||||||
@ -769,16 +791,16 @@ void MainWindow::doLaunchInst(BaseInstance* instance, MojangAccountPtr account)
|
|||||||
{
|
{
|
||||||
// We'll need to validate the access token to make sure the account is still logged in.
|
// We'll need to validate the access token to make sure the account is still logged in.
|
||||||
ProgressDialog progDialog(this);
|
ProgressDialog progDialog(this);
|
||||||
ValidateTask validateTask(account, &progDialog);
|
RefreshTask refreshtask(account, &progDialog);
|
||||||
progDialog.exec(&validateTask);
|
progDialog.exec(&refreshtask);
|
||||||
|
|
||||||
if (validateTask.successful())
|
if (refreshtask.successful())
|
||||||
{
|
{
|
||||||
prepareLaunch(m_selectedInstance, account);
|
prepareLaunch(m_selectedInstance, account);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YggdrasilTask::Error* error = validateTask.getError();
|
YggdrasilTask::Error *error = refreshtask.getError();
|
||||||
|
|
||||||
if (error != nullptr)
|
if (error != nullptr)
|
||||||
{
|
{
|
||||||
@ -790,7 +812,8 @@ void MainWindow::doLaunchInst(BaseInstance* instance, MojangAccountPtr account)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CustomMessageBox::selectable(this, tr("Access Token Validation Error"),
|
CustomMessageBox::selectable(
|
||||||
|
this, tr("Access Token Validation Error"),
|
||||||
tr("There was an error when trying to validate your access token.\n"
|
tr("There was an error when trying to validate your access token.\n"
|
||||||
"Details: %s").arg(error->getDisplayMessage()),
|
"Details: %s").arg(error->getDisplayMessage()),
|
||||||
QMessageBox::Warning, QMessageBox::Ok)->exec();
|
QMessageBox::Warning, QMessageBox::Ok)->exec();
|
||||||
@ -798,9 +821,11 @@ void MainWindow::doLaunchInst(BaseInstance* instance, MojangAccountPtr account)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CustomMessageBox::selectable(this, tr("Access Token Validation Error"),
|
CustomMessageBox::selectable(
|
||||||
|
this, tr("Access Token Validation Error"),
|
||||||
tr("There was an unknown error when trying to validate your access token."
|
tr("There was an unknown error when trying to validate your access token."
|
||||||
"The authentication server might be down, or you might not be connected to the Internet."),
|
"The authentication server might be down, or you might not be connected to "
|
||||||
|
"the Internet."),
|
||||||
QMessageBox::Warning, QMessageBox::Ok)->exec();
|
QMessageBox::Warning, QMessageBox::Ok)->exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -857,10 +882,7 @@ void MainWindow::launchInstance(BaseInstance *instance, MojangAccountPtr account
|
|||||||
console = new ConsoleWindow(proc);
|
console = new ConsoleWindow(proc);
|
||||||
connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded()));
|
connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded()));
|
||||||
|
|
||||||
// I think this will work...
|
proc->setLogin(account);
|
||||||
QString username = account->username();
|
|
||||||
QString session_id = account->accessToken();
|
|
||||||
proc->setLogin(username, session_id);
|
|
||||||
proc->launch();
|
proc->launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -983,10 +1005,14 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &
|
|||||||
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
||||||
auto ico = MMC->icons()->getIcon(iconKey);
|
auto ico = MMC->icons()->getIcon(iconKey);
|
||||||
ui->actionChangeInstIcon->setIcon(ico);
|
ui->actionChangeInstIcon->setIcon(ico);
|
||||||
|
|
||||||
|
MMC->settings()->set("SelectedInstance", m_selectedInstance->id());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
selectionBad();
|
selectionBad();
|
||||||
|
|
||||||
|
MMC->settings()->set("SelectedInstance", QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <logger/QsLog.h>
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
#include <logic/auth/AuthenticateTask.h>
|
#include <logic/auth/flows/AuthenticateTask.h>
|
||||||
#include <logic/net/NetJob.h>
|
#include <logic/net/NetJob.h>
|
||||||
|
|
||||||
#include <gui/dialogs/EditAccountDialog.h>
|
#include <gui/dialogs/EditAccountDialog.h>
|
||||||
@ -29,9 +29,8 @@
|
|||||||
|
|
||||||
#include <MultiMC.h>
|
#include <MultiMC.h>
|
||||||
|
|
||||||
AccountListDialog::AccountListDialog(QWidget *parent) :
|
AccountListDialog::AccountListDialog(QWidget *parent)
|
||||||
QDialog(parent),
|
: QDialog(parent), ui(new Ui::AccountListDialog)
|
||||||
ui(new Ui::AccountListDialog)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@ -44,8 +43,8 @@ AccountListDialog::AccountListDialog(QWidget *parent) :
|
|||||||
connect(selectionModel, &QItemSelectionModel::selectionChanged,
|
connect(selectionModel, &QItemSelectionModel::selectionChanged,
|
||||||
[this] (const QItemSelection& sel, const QItemSelection& dsel) { updateButtonStates(); });
|
[this] (const QItemSelection& sel, const QItemSelection& dsel) { updateButtonStates(); });
|
||||||
|
|
||||||
connect(m_accounts.get(), SIGNAL(listChanged), SLOT(listChanged));
|
connect(m_accounts.get(), SIGNAL(listChanged()), SLOT(listChanged()));
|
||||||
connect(m_accounts.get(), SIGNAL(activeAccountChanged), SLOT(listChanged));
|
connect(m_accounts.get(), SIGNAL(activeAccountChanged()), SLOT(listChanged()));
|
||||||
|
|
||||||
updateButtonStates();
|
updateButtonStates();
|
||||||
}
|
}
|
||||||
@ -60,7 +59,6 @@ void AccountListDialog::listChanged()
|
|||||||
updateButtonStates();
|
updateButtonStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AccountListDialog::on_addAccountBtn_clicked()
|
void AccountListDialog::on_addAccountBtn_clicked()
|
||||||
{
|
{
|
||||||
addAccount(tr("Please enter your Mojang or Minecraft account username and password to add your account."));
|
addAccount(tr("Please enter your Mojang or Minecraft account username and password to add your account."));
|
||||||
@ -146,4 +144,3 @@ void AccountListDialog::addAccount(const QString& errMsg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
#include "logic/lists/MojangAccountList.h"
|
#include "logic/lists/MojangAccountList.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class AccountListDialog;
|
class AccountListDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,4 +63,3 @@ slots:
|
|||||||
private:
|
private:
|
||||||
Ui::AccountListDialog *ui;
|
Ui::AccountListDialog *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,15 +20,14 @@
|
|||||||
|
|
||||||
#include <logger/QsLog.h>
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
#include <logic/auth/AuthenticateTask.h>
|
#include <logic/auth/flows/AuthenticateTask.h>
|
||||||
|
|
||||||
#include <gui/dialogs/ProgressDialog.h>
|
#include <gui/dialogs/ProgressDialog.h>
|
||||||
|
|
||||||
#include <MultiMC.h>
|
#include <MultiMC.h>
|
||||||
|
|
||||||
AccountSelectDialog::AccountSelectDialog(const QString& message, int flags, QWidget *parent) :
|
AccountSelectDialog::AccountSelectDialog(const QString &message, int flags, QWidget *parent)
|
||||||
QDialog(parent),
|
: QDialog(parent), ui(new Ui::AccountSelectDialog)
|
||||||
ui(new Ui::AccountSelectDialog)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@ -85,4 +84,3 @@ void AccountSelectDialog::on_buttonBox_rejected()
|
|||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
#include "logic/lists/MojangAccountList.h"
|
#include "logic/lists/MojangAccountList.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class AccountSelectDialog;
|
class AccountSelectDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,4 +88,3 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Ui::AccountSelectDialog *ui;
|
Ui::AccountSelectDialog *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "logic/BaseInstance.h"
|
#include "logic/BaseInstance.h"
|
||||||
|
|
||||||
CopyInstanceDialog::CopyInstanceDialog(BaseInstance *original, QWidget *parent)
|
CopyInstanceDialog::CopyInstanceDialog(BaseInstance *original, QWidget *parent)
|
||||||
: m_original(original), QDialog(parent), ui(new Ui::CopyInstanceDialog)
|
:QDialog(parent), ui(new Ui::CopyInstanceDialog), m_original(original)
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
#include "EditAccountDialog.h"
|
#include "EditAccountDialog.h"
|
||||||
#include "ui_EditAccountDialog.h"
|
#include "ui_EditAccountDialog.h"
|
||||||
|
|
||||||
EditAccountDialog::EditAccountDialog(const QString& text, QWidget *parent, int flags) :
|
EditAccountDialog::EditAccountDialog(const QString &text, QWidget *parent, int flags)
|
||||||
QDialog(parent),
|
: QDialog(parent), ui(new Ui::EditAccountDialog)
|
||||||
ui(new Ui::EditAccountDialog)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@ -43,4 +42,3 @@ QString EditAccountDialog::password() const
|
|||||||
{
|
{
|
||||||
return ui->passTextBox->text();
|
return ui->passTextBox->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class EditAccountDialog;
|
class EditAccountDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +27,8 @@ class EditAccountDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EditAccountDialog(const QString& text="", QWidget *parent = 0, int flags=UsernameField | PasswordField);
|
explicit EditAccountDialog(const QString &text = "", QWidget *parent = 0,
|
||||||
|
int flags = UsernameField | PasswordField);
|
||||||
~EditAccountDialog();
|
~EditAccountDialog();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -53,4 +55,3 @@ public:
|
|||||||
private:
|
private:
|
||||||
Ui::EditAccountDialog *ui;
|
Ui::EditAccountDialog *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
EditNotesDialog::EditNotesDialog(QString notes, QString name, QWidget *parent)
|
EditNotesDialog::EditNotesDialog(QString notes, QString name, QWidget *parent)
|
||||||
: m_instance_notes(notes), m_instance_name(name), QDialog(parent),
|
: QDialog(parent), ui(new Ui::EditNotesDialog), m_instance_name(name),
|
||||||
ui(new Ui::EditNotesDialog)
|
m_instance_notes(notes)
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent)
|
InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent)
|
||||||
: m_obj(obj), QDialog(parent), ui(new Ui::InstanceSettings)
|
: QDialog(parent), ui(new Ui::InstanceSettings), m_obj(obj)
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent)
|
LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent)
|
||||||
: m_inst(inst), QDialog(parent), ui(new Ui::LegacyModEditDialog)
|
: QDialog(parent), ui(new Ui::LegacyModEditDialog), m_inst(inst)
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include "logic/ForgeInstaller.h"
|
#include "logic/ForgeInstaller.h"
|
||||||
|
|
||||||
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
||||||
: m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog)
|
: QDialog(parent), ui(new Ui::OneSixModEditDialog), m_inst(inst)
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
|
|
||||||
// Origin: Qt
|
// Origin: Qt
|
||||||
static void viewItemTextLayout ( QTextLayout &textLayout, int lineWidth, qreal &height, qreal &widthUsed )
|
static void viewItemTextLayout(QTextLayout &textLayout, int lineWidth, qreal &height,
|
||||||
|
qreal &widthUsed)
|
||||||
{
|
{
|
||||||
height = 0;
|
height = 0;
|
||||||
widthUsed = 0;
|
widthUsed = 0;
|
||||||
@ -46,10 +47,10 @@ static void viewItemTextLayout ( QTextLayout &textLayout, int lineWidth, qreal &
|
|||||||
|
|
||||||
ListViewDelegate::ListViewDelegate(QObject *parent) : QStyledItemDelegate(parent)
|
ListViewDelegate::ListViewDelegate(QObject *parent) : QStyledItemDelegate(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawSelectionRect(QPainter *painter, const QStyleOptionViewItemV4 &option, const QRect &rect)
|
void drawSelectionRect(QPainter *painter, const QStyleOptionViewItemV4 &option,
|
||||||
|
const QRect &rect)
|
||||||
{
|
{
|
||||||
if ((option.state & QStyle::State_Selected))
|
if ((option.state & QStyle::State_Selected))
|
||||||
painter->fillRect(rect, option.palette.brush(QPalette::Highlight));
|
painter->fillRect(rect, option.palette.brush(QPalette::Highlight));
|
||||||
@ -59,7 +60,6 @@ void drawSelectionRect(QPainter *painter, const QStyleOptionViewItemV4 &option,
|
|||||||
backgroundColor.setAlpha(160);
|
backgroundColor.setAlpha(160);
|
||||||
painter->fillRect(rect, QBrush(backgroundColor));
|
painter->fillRect(rect, QBrush(backgroundColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawFocusRect(QPainter *painter, const QStyleOptionViewItemV4 &option, const QRect &rect)
|
void drawFocusRect(QPainter *painter, const QStyleOptionViewItemV4 &option, const QRect &rect)
|
||||||
@ -71,7 +71,8 @@ void drawFocusRect(QPainter *painter, const QStyleOptionViewItemV4 &option, cons
|
|||||||
opt.fontMetrics = option.fontMetrics;
|
opt.fontMetrics = option.fontMetrics;
|
||||||
opt.palette = option.palette;
|
opt.palette = option.palette;
|
||||||
opt.rect = rect;
|
opt.rect = rect;
|
||||||
//opt.state = option.state | QStyle::State_KeyboardFocusChange | QStyle::State_Item;
|
// opt.state = option.state | QStyle::State_KeyboardFocusChange |
|
||||||
|
// QStyle::State_Item;
|
||||||
auto col = option.state & QStyle::State_Selected ? QPalette::Highlight : QPalette::Base;
|
auto col = option.state & QStyle::State_Selected ? QPalette::Highlight : QPalette::Base;
|
||||||
opt.backgroundColor = option.palette.color(col);
|
opt.backgroundColor = option.palette.color(col);
|
||||||
// Apparently some widget styles expect this hint to not be set
|
// Apparently some widget styles expect this hint to not be set
|
||||||
@ -93,7 +94,8 @@ static QSize viewItemTextSize ( const QStyleOptionViewItemV4 *option )
|
|||||||
textLayout.setTextOption(textOption);
|
textLayout.setTextOption(textOption);
|
||||||
textLayout.setFont(option->font);
|
textLayout.setFont(option->font);
|
||||||
textLayout.setText(option->text);
|
textLayout.setText(option->text);
|
||||||
const int textMargin = style->pixelMetric ( QStyle::PM_FocusFrameHMargin, option, option->widget ) + 1;
|
const int textMargin =
|
||||||
|
style->pixelMetric(QStyle::PM_FocusFrameHMargin, option, option->widget) + 1;
|
||||||
QRect bounds(0, 0, 100 - 2 * textMargin, 600);
|
QRect bounds(0, 0, 100 - 2 * textMargin, 600);
|
||||||
qreal height = 0, widthUsed = 0;
|
qreal height = 0, widthUsed = 0;
|
||||||
viewItemTextLayout(textLayout, bounds.width(), height, widthUsed);
|
viewItemTextLayout(textLayout, bounds.width(), height, widthUsed);
|
||||||
@ -101,7 +103,8 @@ static QSize viewItemTextSize ( const QStyleOptionViewItemV4 *option )
|
|||||||
return QSize(size.width() + 2 * textMargin, size.height());
|
return QSize(size.width() + 2 * textMargin, size.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||||
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QStyleOptionViewItemV4 opt = option;
|
QStyleOptionViewItemV4 opt = option;
|
||||||
initStyleOption(&opt, index);
|
initStyleOption(&opt, index);
|
||||||
@ -128,7 +131,8 @@ void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& op
|
|||||||
|
|
||||||
// draw background
|
// draw background
|
||||||
{
|
{
|
||||||
QSize textSize = viewItemTextSize ( &opt );
|
// FIXME: unused
|
||||||
|
// QSize textSize = viewItemTextSize ( &opt );
|
||||||
QPalette::ColorGroup cg;
|
QPalette::ColorGroup cg;
|
||||||
QStyleOptionViewItemV4 opt2(opt);
|
QStyleOptionViewItemV4 opt2(opt);
|
||||||
|
|
||||||
@ -165,8 +169,10 @@ void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& op
|
|||||||
|
|
||||||
// if ( opt.state & QStyle::State_Selected )
|
// if ( opt.state & QStyle::State_Selected )
|
||||||
{
|
{
|
||||||
//QRect textRect = subElementRect ( QStyle::SE_ItemViewItemText, opt, opt.widget );
|
// QRect textRect = subElementRect ( QStyle::SE_ItemViewItemText, opt,
|
||||||
//painter->fillRect ( textHighlightRect, opt.palette.brush ( cg, QPalette::Highlight ) );
|
// opt.widget );
|
||||||
|
// painter->fillRect ( textHighlightRect, opt.palette.brush ( cg,
|
||||||
|
// QPalette::Highlight ) );
|
||||||
drawSelectionRect(painter, opt2, textHighlightRect);
|
drawSelectionRect(painter, opt2, textHighlightRect);
|
||||||
drawFocusRect(painter, opt2, textHighlightRect);
|
drawFocusRect(painter, opt2, textHighlightRect);
|
||||||
}
|
}
|
||||||
@ -186,7 +192,8 @@ void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& op
|
|||||||
opt.icon.paint(painter, iconbox, Qt::AlignCenter, mode, state);
|
opt.icon.paint(painter, iconbox, Qt::AlignCenter, mode, state);
|
||||||
}
|
}
|
||||||
// set the text colors
|
// set the text colors
|
||||||
QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
|
QPalette::ColorGroup cg =
|
||||||
|
opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
|
||||||
if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active))
|
if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active))
|
||||||
cg = QPalette::Inactive;
|
cg = QPalette::Inactive;
|
||||||
if (opt.state & QStyle::State_Selected)
|
if (opt.state & QStyle::State_Selected)
|
||||||
@ -213,7 +220,8 @@ void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& op
|
|||||||
|
|
||||||
const int lineCount = textLayout.lineCount();
|
const int lineCount = textLayout.lineCount();
|
||||||
|
|
||||||
const QRect layoutRect = QStyle::alignedRect ( opt.direction, opt.displayAlignment, QSize ( textRect.width(), int ( height ) ), textRect );
|
const QRect layoutRect = QStyle::alignedRect(
|
||||||
|
opt.direction, opt.displayAlignment, QSize(textRect.width(), int(height)), textRect);
|
||||||
const QPointF position = layoutRect.topLeft();
|
const QPointF position = layoutRect.topLeft();
|
||||||
for (int i = 0; i < lineCount; ++i)
|
for (int i = 0; i < lineCount; ++i)
|
||||||
{
|
{
|
||||||
@ -224,8 +232,8 @@ void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& op
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize ListViewDelegate::sizeHint(const QStyleOptionViewItem &option,
|
||||||
QSize ListViewDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QStyleOptionViewItemV4 opt = option;
|
QStyleOptionViewItemV4 opt = option;
|
||||||
initStyleOption(&opt, index);
|
initStyleOption(&opt, index);
|
||||||
@ -235,7 +243,8 @@ QSize ListViewDelegate::sizeHint ( const QStyleOptionViewItem & option, const QM
|
|||||||
opt.displayAlignment = Qt::AlignTop | Qt::AlignHCenter;
|
opt.displayAlignment = Qt::AlignTop | Qt::AlignHCenter;
|
||||||
|
|
||||||
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
|
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
|
||||||
const int textMargin = style->pixelMetric ( QStyle::PM_FocusFrameHMargin, &option, opt.widget ) + 1;
|
const int textMargin =
|
||||||
|
style->pixelMetric(QStyle::PM_FocusFrameHMargin, &option, opt.widget) + 1;
|
||||||
int height = 48 + textMargin * 2 + 5; // TODO: turn constants into variables
|
int height = 48 + textMargin * 2 + 5; // TODO: turn constants into variables
|
||||||
QSize szz = viewItemTextSize(&opt);
|
QSize szz = viewItemTextSize(&opt);
|
||||||
height += szz.height();
|
height += szz.height();
|
||||||
@ -243,4 +252,3 @@ QSize ListViewDelegate::sizeHint ( const QStyleOptionViewItem & option, const QM
|
|||||||
QSize sz(100, height);
|
QSize sz(100, height);
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
BaseInstance::BaseInstance(BaseInstancePrivate *d_in, const QString &rootDir,
|
BaseInstance::BaseInstance(BaseInstancePrivate *d_in, const QString &rootDir,
|
||||||
SettingsObject *settings_obj, QObject *parent)
|
SettingsObject *settings_obj, QObject *parent)
|
||||||
: inst_d(d_in), QObject(parent)
|
: QObject(parent), inst_d(d_in)
|
||||||
{
|
{
|
||||||
I_D(BaseInstance);
|
I_D(BaseInstance);
|
||||||
d->m_settings = settings_obj;
|
d->m_settings = settings_obj;
|
||||||
|
@ -133,16 +133,12 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne
|
|||||||
{
|
{
|
||||||
case NoLoadError:
|
case NoLoadError:
|
||||||
return NoCreateError;
|
return NoCreateError;
|
||||||
|
case NotAnInstance:
|
||||||
|
rootDir.removeRecursively();
|
||||||
|
return CantCreateDir;
|
||||||
|
default:
|
||||||
case UnknownLoadError:
|
case UnknownLoadError:
|
||||||
{
|
|
||||||
rootDir.removeRecursively();
|
rootDir.removeRecursively();
|
||||||
return UnknownCreateError;
|
return UnknownCreateError;
|
||||||
}
|
}
|
||||||
case NotAnInstance:
|
|
||||||
{
|
|
||||||
rootDir.removeRecursively();
|
|
||||||
return CantCreateDir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ JavaChecker::JavaChecker(QObject *parent) : QObject(parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int JavaChecker::performCheck(QString path)
|
void JavaChecker::performCheck(QString path)
|
||||||
{
|
{
|
||||||
if(QFile::exists(CHECKER_FILE))
|
if(QFile::exists(CHECKER_FILE))
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ class JavaChecker : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit JavaChecker(QObject *parent = 0);
|
explicit JavaChecker(QObject *parent = 0);
|
||||||
int performCheck(QString path);
|
void performCheck(QString path);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void checkFinished(JavaCheckResult result);
|
void checkFinished(JavaCheckResult result);
|
||||||
|
@ -274,7 +274,6 @@ bool LegacyInstance::setIntendedVersionId(QString version)
|
|||||||
|
|
||||||
bool LegacyInstance::shouldUpdate() const
|
bool LegacyInstance::shouldUpdate() const
|
||||||
{
|
{
|
||||||
I_D(LegacyInstance);
|
|
||||||
QVariant var = settings().get("ShouldUpdate");
|
QVariant var = settings().get("ShouldUpdate");
|
||||||
if (!var.isValid() || var.toBool() == false)
|
if (!var.isValid() || var.toBool() == false)
|
||||||
{
|
{
|
||||||
|
@ -71,6 +71,26 @@ void MinecraftProcess::setWorkdir(QString path)
|
|||||||
m_prepostlaunchprocess.setWorkingDirectory(mcDir.absolutePath());
|
m_prepostlaunchprocess.setWorkingDirectory(mcDir.absolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MinecraftProcess::censorPrivateInfo(QString in)
|
||||||
|
{
|
||||||
|
if(!m_account)
|
||||||
|
return in;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString sessionId = m_account->sessionId();
|
||||||
|
QString accessToken = m_account->accessToken();
|
||||||
|
QString clientToken = m_account->clientToken();
|
||||||
|
QString profileId = m_account->currentProfile()->id();
|
||||||
|
QString profileName = m_account->currentProfile()->name();
|
||||||
|
in.replace(sessionId, "<SESSION ID>");
|
||||||
|
in.replace(accessToken, "<ACCESS TOKEN>");
|
||||||
|
in.replace(clientToken, "<CLIENT TOKEN>");
|
||||||
|
in.replace(profileId, "<PROFILE ID>");
|
||||||
|
in.replace(profileName, "<PROFILE NAME>");
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// console window
|
// console window
|
||||||
void MinecraftProcess::on_stdErr()
|
void MinecraftProcess::on_stdErr()
|
||||||
{
|
{
|
||||||
@ -83,8 +103,7 @@ void MinecraftProcess::on_stdErr()
|
|||||||
for (int i = 0; i < lines.size() - 1; i++)
|
for (int i = 0; i < lines.size() - 1; i++)
|
||||||
{
|
{
|
||||||
QString &line = lines[i];
|
QString &line = lines[i];
|
||||||
emit log(line /*.replace(username, "<Username>").replace(sessionID, "<Session ID>")*/,
|
emit log(censorPrivateInfo(line), getLevel(line, MessageLevel::Error));
|
||||||
getLevel(line, MessageLevel::Error));
|
|
||||||
}
|
}
|
||||||
if (!complete)
|
if (!complete)
|
||||||
m_err_leftover = lines.last();
|
m_err_leftover = lines.last();
|
||||||
@ -101,8 +120,7 @@ void MinecraftProcess::on_stdOut()
|
|||||||
for (int i = 0; i < lines.size() - 1; i++)
|
for (int i = 0; i < lines.size() - 1; i++)
|
||||||
{
|
{
|
||||||
QString &line = lines[i];
|
QString &line = lines[i];
|
||||||
emit log(line.replace(username, "<Username>").replace(sessionID, "<Session ID>"),
|
emit log(censorPrivateInfo(line), getLevel(line, MessageLevel::Message));
|
||||||
getLevel(line, MessageLevel::Message));
|
|
||||||
}
|
}
|
||||||
if (!complete)
|
if (!complete)
|
||||||
m_out_leftover = lines.last();
|
m_out_leftover = lines.last();
|
||||||
@ -173,8 +191,8 @@ void MinecraftProcess::launch()
|
|||||||
emit log(QString("Minecraft folder is: '%1'").arg(workingDirectory()));
|
emit log(QString("Minecraft folder is: '%1'").arg(workingDirectory()));
|
||||||
QString JavaPath = m_instance->settings().get("JavaPath").toString();
|
QString JavaPath = m_instance->settings().get("JavaPath").toString();
|
||||||
emit log(QString("Java path: '%1'").arg(JavaPath));
|
emit log(QString("Java path: '%1'").arg(JavaPath));
|
||||||
emit log(QString("Arguments: '%1'").arg(
|
QString allArgs = m_args.join("' '");
|
||||||
m_args.join("' '").replace(username, "<Username>").replace(sessionID, "<Session ID>")));
|
emit log(QString("Arguments: '%1'").arg(censorPrivateInfo(allArgs)));
|
||||||
start(JavaPath, m_args);
|
start(JavaPath, m_args);
|
||||||
if (!waitForStarted())
|
if (!waitForStarted())
|
||||||
{
|
{
|
||||||
|
@ -69,10 +69,9 @@ public:
|
|||||||
|
|
||||||
void killMinecraft();
|
void killMinecraft();
|
||||||
|
|
||||||
inline void setLogin(QString user, QString sid)
|
inline void setLogin(MojangAccountPtr account)
|
||||||
{
|
{
|
||||||
username = user;
|
m_account = account;
|
||||||
sessionID = sid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -104,11 +103,13 @@ signals:
|
|||||||
void log(QString text, MessageLevel::Enum level = MessageLevel::MultiMC);
|
void log(QString text, MessageLevel::Enum level = MessageLevel::MultiMC);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseInstance *m_instance;
|
BaseInstance *m_instance = nullptr;
|
||||||
QStringList m_args;
|
QStringList m_args;
|
||||||
QString m_err_leftover;
|
QString m_err_leftover;
|
||||||
QString m_out_leftover;
|
QString m_out_leftover;
|
||||||
QProcess m_prepostlaunchprocess;
|
QProcess m_prepostlaunchprocess;
|
||||||
|
bool killed = false;
|
||||||
|
MojangAccountPtr m_account;
|
||||||
|
|
||||||
protected
|
protected
|
||||||
slots:
|
slots:
|
||||||
@ -117,8 +118,7 @@ slots:
|
|||||||
void on_stdOut();
|
void on_stdOut();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool killed;
|
QString censorPrivateInfo(QString in);
|
||||||
MessageLevel::Enum getLevel(const QString &message, MessageLevel::Enum defaultLevel);
|
MessageLevel::Enum getLevel(const QString &message, MessageLevel::Enum defaultLevel);
|
||||||
QString sessionID;
|
|
||||||
QString username;
|
|
||||||
};
|
};
|
||||||
|
@ -39,19 +39,27 @@ void ModList::startWatching()
|
|||||||
{
|
{
|
||||||
is_watching = m_watcher->addPath(m_dir.absolutePath());
|
is_watching = m_watcher->addPath(m_dir.absolutePath());
|
||||||
if (is_watching)
|
if (is_watching)
|
||||||
|
{
|
||||||
QLOG_INFO() << "Started watching " << m_dir.absolutePath();
|
QLOG_INFO() << "Started watching " << m_dir.absolutePath();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
QLOG_INFO() << "Failed to start watching " << m_dir.absolutePath();
|
QLOG_INFO() << "Failed to start watching " << m_dir.absolutePath();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ModList::stopWatching()
|
void ModList::stopWatching()
|
||||||
{
|
{
|
||||||
is_watching = !m_watcher->removePath(m_dir.absolutePath());
|
is_watching = !m_watcher->removePath(m_dir.absolutePath());
|
||||||
if (!is_watching)
|
if (!is_watching)
|
||||||
|
{
|
||||||
QLOG_INFO() << "Stopped watching " << m_dir.absolutePath();
|
QLOG_INFO() << "Stopped watching " << m_dir.absolutePath();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
QLOG_INFO() << "Failed to stop watching " << m_dir.absolutePath();
|
QLOG_INFO() << "Failed to stop watching " << m_dir.absolutePath();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ModList::update()
|
bool ModList::update()
|
||||||
{
|
{
|
||||||
@ -64,7 +72,6 @@ bool ModList::update()
|
|||||||
bool orderWasInvalid = false;
|
bool orderWasInvalid = false;
|
||||||
|
|
||||||
// first, process the ordered items (if any)
|
// first, process the ordered items (if any)
|
||||||
int currentOrderIndex = 0;
|
|
||||||
QStringList listOrder = readListFile();
|
QStringList listOrder = readListFile();
|
||||||
for (auto item : listOrder)
|
for (auto item : listOrder)
|
||||||
{
|
{
|
||||||
@ -363,6 +370,7 @@ QVariant ModList::headerData(int section, Qt::Orientation orientation, int role)
|
|||||||
case 2:
|
case 2:
|
||||||
return QString("Minecraft");
|
return QString("Minecraft");
|
||||||
}
|
}
|
||||||
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags ModList::flags(const QModelIndex &index) const
|
Qt::ItemFlags ModList::flags(const QModelIndex &index) const
|
||||||
|
@ -235,7 +235,6 @@ void OneSixInstance::setShouldUpdate(bool val)
|
|||||||
|
|
||||||
bool OneSixInstance::shouldUpdate() const
|
bool OneSixInstance::shouldUpdate() const
|
||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
|
||||||
QVariant var = settings().get("ShouldUpdate");
|
QVariant var = settings().get("ShouldUpdate");
|
||||||
if (!var.isValid() || var.toBool() == false)
|
if (!var.isValid() || var.toBool() == false)
|
||||||
{
|
{
|
||||||
|
@ -198,7 +198,6 @@ void OneSixUpdate::jarlibStart()
|
|||||||
|
|
||||||
auto metacache = MMC->metacache();
|
auto metacache = MMC->metacache();
|
||||||
QList<ForgeXzDownloadPtr> ForgeLibs;
|
QList<ForgeXzDownloadPtr> ForgeLibs;
|
||||||
bool already_forge_xz = false;
|
|
||||||
for (auto lib : libs)
|
for (auto lib : libs)
|
||||||
{
|
{
|
||||||
if (lib->hint() == "local")
|
if (lib->hint() == "local")
|
||||||
|
@ -23,8 +23,7 @@
|
|||||||
|
|
||||||
#include <logger/QsLog.h>
|
#include <logger/QsLog.h>
|
||||||
|
|
||||||
MojangAccount::MojangAccount(const QString& username, QObject* parent) :
|
MojangAccount::MojangAccount(const QString &username, QObject *parent) : QObject(parent)
|
||||||
QObject(parent)
|
|
||||||
{
|
{
|
||||||
// Generate a client token.
|
// Generate a client token.
|
||||||
m_clientToken = QUuid::createUuid().toString();
|
m_clientToken = QUuid::createUuid().toString();
|
||||||
@ -35,8 +34,8 @@ MojangAccount::MojangAccount(const QString& username, QObject* parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
MojangAccount::MojangAccount(const QString &username, const QString &clientToken,
|
MojangAccount::MojangAccount(const QString &username, const QString &clientToken,
|
||||||
const QString& accessToken, QObject* parent) :
|
const QString &accessToken, QObject *parent)
|
||||||
QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
m_username = username;
|
m_username = username;
|
||||||
m_clientToken = clientToken;
|
m_clientToken = clientToken;
|
||||||
@ -55,7 +54,6 @@ MojangAccount::MojangAccount(const MojangAccount& other, QObject* parent)
|
|||||||
m_currentProfile = other.m_currentProfile;
|
m_currentProfile = other.m_currentProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString MojangAccount::username() const
|
QString MojangAccount::username() const
|
||||||
{
|
{
|
||||||
return m_username;
|
return m_username;
|
||||||
@ -71,7 +69,6 @@ void MojangAccount::setClientToken(const QString& clientToken)
|
|||||||
m_clientToken = clientToken;
|
m_clientToken = clientToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString MojangAccount::accessToken() const
|
QString MojangAccount::accessToken() const
|
||||||
{
|
{
|
||||||
return m_accessToken;
|
return m_accessToken;
|
||||||
@ -217,4 +214,7 @@ QString AccountProfile::name() const
|
|||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MojangAccount::propagateChange()
|
||||||
|
{
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QPair>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -27,7 +28,6 @@ class MojangAccount;
|
|||||||
typedef std::shared_ptr<MojangAccount> MojangAccountPtr;
|
typedef std::shared_ptr<MojangAccount> MojangAccountPtr;
|
||||||
Q_DECLARE_METATYPE(MojangAccountPtr)
|
Q_DECLARE_METATYPE(MojangAccountPtr)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that represents a profile within someone's Mojang account.
|
* Class that represents a profile within someone's Mojang account.
|
||||||
*
|
*
|
||||||
@ -43,14 +43,21 @@ public:
|
|||||||
|
|
||||||
QString id() const;
|
QString id() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef QList<AccountProfile> ProfileList;
|
typedef QList<AccountProfile> ProfileList;
|
||||||
|
|
||||||
|
struct User
|
||||||
|
{
|
||||||
|
QString id;
|
||||||
|
// pair of key:value
|
||||||
|
// we don't know if the keys:value mapping is 1:1, so a list is used.
|
||||||
|
QList<QPair<QString, QString>> properties;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object that stores information about a certain Mojang account.
|
* Object that stores information about a certain Mojang account.
|
||||||
@ -71,7 +78,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Constructs a new MojangAccount with the given username, client token, and access token.
|
* Constructs a new MojangAccount with the given username, client token, and access token.
|
||||||
*/
|
*/
|
||||||
explicit MojangAccount(const QString& username, const QString& clientToken, const QString& accessToken, QObject* parent = 0);
|
explicit MojangAccount(const QString &username, const QString &clientToken,
|
||||||
|
const QString &accessToken, QObject *parent = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new MojangAccount matching the given account.
|
* Constructs a new MojangAccount matching the given account.
|
||||||
@ -88,6 +96,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
QJsonObject saveToJson();
|
QJsonObject saveToJson();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the account on disk and lists (it changed, for whatever reason)
|
||||||
|
* This is called by various Yggdrasil tasks.
|
||||||
|
*/
|
||||||
|
void propagateChange();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This MojangAccount's username. May be an email address if the account is migrated.
|
* This MojangAccount's username. May be an email address if the account is migrated.
|
||||||
@ -143,12 +156,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
void loadProfiles(const ProfileList &profiles);
|
void loadProfiles(const ProfileList &profiles);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* This isgnal is emitted whrn the account changes
|
||||||
|
*/
|
||||||
|
void changed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_username;
|
QString m_username;
|
||||||
QString m_clientToken;
|
QString m_clientToken;
|
||||||
QString m_accessToken; // Blank if not logged in.
|
QString m_accessToken; // Blank if not logged in.
|
||||||
int m_currentProfile; // Index of the selected profile within the list of available profiles. -1 if nothing is selected.
|
int m_currentProfile; // Index of the selected profile within the list of available
|
||||||
|
// profiles. -1 if nothing is selected.
|
||||||
ProfileList m_profiles; // List of available profiles.
|
ProfileList m_profiles; // List of available profiles.
|
||||||
|
User m_user; // the user structure, whatever it is.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ YggdrasilTask::YggdrasilTask(MojangAccountPtr account, QObject* parent) : Task(p
|
|||||||
m_account = account;
|
m_account = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
YggdrasilTask::~YggdrasilTask()
|
YggdrasilTask::~YggdrasilTask()
|
||||||
{
|
{
|
||||||
if (m_error)
|
if (m_error)
|
||||||
@ -53,7 +52,8 @@ void YggdrasilTask::executeTask()
|
|||||||
QNetworkRequest netRequest(reqUrl);
|
QNetworkRequest netRequest(reqUrl);
|
||||||
netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
|
|
||||||
m_netReply = worker->post(netRequest, doc.toJson());
|
QByteArray requestData = doc.toJson();
|
||||||
|
m_netReply = worker->post(netRequest, requestData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YggdrasilTask::processReply(QNetworkReply *reply)
|
void YggdrasilTask::processReply(QNetworkReply *reply)
|
||||||
@ -76,7 +76,6 @@ void YggdrasilTask::processReply(QNetworkReply* reply)
|
|||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
QByteArray replyData = reply->readAll();
|
QByteArray replyData = reply->readAll();
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(replyData, &jsonError);
|
QJsonDocument doc = QJsonDocument::fromJson(replyData, &jsonError);
|
||||||
|
|
||||||
// Check the response code.
|
// Check the response code.
|
||||||
int responseCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int responseCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
|
||||||
@ -93,7 +92,8 @@ void YggdrasilTask::processReply(QNetworkReply* reply)
|
|||||||
if (err)
|
if (err)
|
||||||
emitFailed(err->getErrorMessage());
|
emitFailed(err->getErrorMessage());
|
||||||
else
|
else
|
||||||
emitFailed(tr("An unknown error occurred when processing the response from the authentication server."));
|
emitFailed(tr("An unknown error occurred when processing the response "
|
||||||
|
"from the authentication server."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -166,4 +166,3 @@ MojangAccountPtr YggdrasilTask::getMojangAccount() const
|
|||||||
{
|
{
|
||||||
return this->m_account;
|
return this->m_account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Yggdrasil task is a task that performs an operation on a given mojang account.
|
* A Yggdrasil task is a task that performs an operation on a given mojang account.
|
||||||
*/
|
*/
|
||||||
@ -49,7 +48,10 @@ public:
|
|||||||
QString getCause() const { return m_cause; }
|
QString getCause() const { return m_cause; }
|
||||||
|
|
||||||
/// Gets the string to display in the GUI for describing this error.
|
/// Gets the string to display in the GUI for describing this error.
|
||||||
QString getDisplayMessage() { return getErrorMessage(); }
|
QString getDisplayMessage()
|
||||||
|
{
|
||||||
|
return getErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_shortError;
|
QString m_shortError;
|
||||||
@ -124,7 +126,7 @@ protected:
|
|||||||
|
|
||||||
Error *m_error;
|
Error *m_error;
|
||||||
|
|
||||||
protected slots:
|
protected
|
||||||
|
slots:
|
||||||
void processReply(QNetworkReply *reply);
|
void processReply(QNetworkReply *reply);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <logic/auth/AuthenticateTask.h>
|
#include <logic/auth/flows/AuthenticateTask.h>
|
||||||
|
|
||||||
#include <logic/auth/MojangAccount.h>
|
#include <logic/auth/MojangAccount.h>
|
||||||
|
|
||||||
@ -26,8 +26,9 @@
|
|||||||
|
|
||||||
#include "logger/QsLog.h"
|
#include "logger/QsLog.h"
|
||||||
|
|
||||||
AuthenticateTask::AuthenticateTask(MojangAccountPtr account, const QString& password, QObject* parent) :
|
AuthenticateTask::AuthenticateTask(MojangAccountPtr account, const QString &password,
|
||||||
YggdrasilTask(account, parent), m_password(password)
|
QObject *parent)
|
||||||
|
: YggdrasilTask(account, parent), m_password(password)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,13 +45,15 @@ QJsonObject AuthenticateTask::getRequestContent() const
|
|||||||
// unmigrated accounts
|
// unmigrated accounts
|
||||||
* "password": "mojang account password",
|
* "password": "mojang account password",
|
||||||
* "clientToken": "client identifier" // optional
|
* "clientToken": "client identifier" // optional
|
||||||
|
* "requestUser": true/false // request the user structure
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
QJsonObject req;
|
QJsonObject req;
|
||||||
|
|
||||||
{
|
{
|
||||||
QJsonObject agent;
|
QJsonObject agent;
|
||||||
// C++ makes string literals void* for some stupid reason, so we have to tell it QString... Thanks Obama.
|
// C++ makes string literals void* for some stupid reason, so we have to tell it
|
||||||
|
// QString... Thanks Obama.
|
||||||
agent.insert("name", QString("Minecraft"));
|
agent.insert("name", QString("Minecraft"));
|
||||||
agent.insert("version", 1);
|
agent.insert("version", 1);
|
||||||
req.insert("agent", agent);
|
req.insert("agent", agent);
|
||||||
@ -58,6 +61,7 @@ QJsonObject AuthenticateTask::getRequestContent() const
|
|||||||
|
|
||||||
req.insert("username", getMojangAccount()->username());
|
req.insert("username", getMojangAccount()->username());
|
||||||
req.insert("password", m_password);
|
req.insert("password", m_password);
|
||||||
|
req.insert("requestUser", true);
|
||||||
|
|
||||||
// If we already have a client token, give it to the server.
|
// If we already have a client token, give it to the server.
|
||||||
// Otherwise, let the server give us one.
|
// Otherwise, let the server give us one.
|
||||||
@ -69,10 +73,12 @@ QJsonObject AuthenticateTask::getRequestContent() const
|
|||||||
|
|
||||||
bool AuthenticateTask::processResponse(QJsonObject responseData)
|
bool AuthenticateTask::processResponse(QJsonObject responseData)
|
||||||
{
|
{
|
||||||
// Read the response data. We need to get the client token, access token, and the selected profile.
|
// Read the response data. We need to get the client token, access token, and the selected
|
||||||
|
// profile.
|
||||||
QLOG_DEBUG() << "Processing authentication response.";
|
QLOG_DEBUG() << "Processing authentication response.";
|
||||||
|
|
||||||
// If we already have a client token, make sure the one the server gave us matches our existing one.
|
// If we already have a client token, make sure the one the server gave us matches our
|
||||||
|
// existing one.
|
||||||
QLOG_DEBUG() << "Getting client token.";
|
QLOG_DEBUG() << "Getting client token.";
|
||||||
QString clientToken = responseData.value("clientToken").toString("");
|
QString clientToken = responseData.value("clientToken").toString("");
|
||||||
if (clientToken.isEmpty())
|
if (clientToken.isEmpty())
|
||||||
@ -82,16 +88,17 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
|
|||||||
QLOG_ERROR() << "Server didn't send a client token.";
|
QLOG_ERROR() << "Server didn't send a client token.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getMojangAccount()->clientToken().isEmpty() && clientToken != getMojangAccount()->clientToken())
|
if (!getMojangAccount()->clientToken().isEmpty() &&
|
||||||
|
clientToken != getMojangAccount()->clientToken())
|
||||||
{
|
{
|
||||||
// The server changed our client token! Obey its wishes, but complain. That's what I do for my parents, so...
|
// The server changed our client token! Obey its wishes, but complain. That's what I do
|
||||||
|
// for my parents, so...
|
||||||
QLOG_WARN() << "Server changed our client token to '" << clientToken
|
QLOG_WARN() << "Server changed our client token to '" << clientToken
|
||||||
<< "'. This shouldn't happen, but it isn't really a big deal.";
|
<< "'. This shouldn't happen, but it isn't really a big deal.";
|
||||||
}
|
}
|
||||||
// Set the client token.
|
// Set the client token.
|
||||||
getMojangAccount()->setClientToken(clientToken);
|
getMojangAccount()->setClientToken(clientToken);
|
||||||
|
|
||||||
|
|
||||||
// Now, we set the access token.
|
// Now, we set the access token.
|
||||||
QLOG_DEBUG() << "Getting access token.";
|
QLOG_DEBUG() << "Getting access token.";
|
||||||
QString accessToken = responseData.value("accessToken").toString("");
|
QString accessToken = responseData.value("accessToken").toString("");
|
||||||
@ -104,7 +111,6 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
|
|||||||
// Set the access token.
|
// Set the access token.
|
||||||
getMojangAccount()->setAccessToken(accessToken);
|
getMojangAccount()->setAccessToken(accessToken);
|
||||||
|
|
||||||
|
|
||||||
// Now we load the list of available profiles.
|
// Now we load the list of available profiles.
|
||||||
// Mojang hasn't yet implemented the profile system,
|
// Mojang hasn't yet implemented the profile system,
|
||||||
// but we might as well support what's there so we
|
// but we might as well support what's there so we
|
||||||
@ -124,7 +130,8 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
|
|||||||
// This should never happen, but we might as well
|
// This should never happen, but we might as well
|
||||||
// warn about it if it does so we can debug it easily.
|
// warn about it if it does so we can debug it easily.
|
||||||
// You never know when Mojang might do something truly derpy.
|
// You never know when Mojang might do something truly derpy.
|
||||||
QLOG_WARN() << "Found entry in available profiles list with missing ID or name field. Ignoring it.";
|
QLOG_WARN() << "Found entry in available profiles list with missing ID or name "
|
||||||
|
"field. Ignoring it.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, add a new AccountProfile entry to the list.
|
// Now, add a new AccountProfile entry to the list.
|
||||||
@ -133,8 +140,6 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
|
|||||||
// Put the list of profiles we loaded into the MojangAccount object.
|
// Put the list of profiles we loaded into the MojangAccount object.
|
||||||
getMojangAccount()->loadProfiles(loadedProfiles);
|
getMojangAccount()->loadProfiles(loadedProfiles);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Finally, we set the current profile to the correct value. This is pretty simple.
|
// Finally, we set the current profile to the correct value. This is pretty simple.
|
||||||
// We do need to make sure that the current profile that the server gave us
|
// We do need to make sure that the current profile that the server gave us
|
||||||
// is actually in the available profiles list.
|
// is actually in the available profiles list.
|
||||||
@ -151,39 +156,11 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
|
|||||||
if (!getMojangAccount()->setProfile(currentProfileId))
|
if (!getMojangAccount()->setProfile(currentProfileId))
|
||||||
{
|
{
|
||||||
// TODO: Set an error to display to the user.
|
// TODO: Set an error to display to the user.
|
||||||
QLOG_ERROR() << "Server specified a selected profile that wasn't in the available profiles list.";
|
QLOG_ERROR() << "Server specified a selected profile that wasn't in the available "
|
||||||
|
"profiles list.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public class User
|
|
||||||
{
|
|
||||||
private String id;
|
|
||||||
private List<Property> properties;
|
|
||||||
|
|
||||||
public String getId()
|
|
||||||
{
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Property> getProperties() {
|
|
||||||
return this.properties;
|
|
||||||
}
|
|
||||||
public class Property {
|
|
||||||
private String name;
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
public Property() { }
|
|
||||||
public String getKey() { return this.name; }
|
|
||||||
|
|
||||||
public String getValue()
|
|
||||||
{
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// this is what the vanilla launcher passes to the userProperties launch param
|
// this is what the vanilla launcher passes to the userProperties launch param
|
||||||
// doesn't seem to be used for anything so far? I don't get any of this data on my account
|
// doesn't seem to be used for anything so far? I don't get any of this data on my account
|
||||||
// (peterixxx)
|
// (peterixxx)
|
||||||
@ -204,7 +181,8 @@ public class User
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We've made it through the minefield of possible errors. Return true to indicate that we've succeeded.
|
// We've made it through the minefield of possible errors. Return true to indicate that
|
||||||
|
// we've succeeded.
|
||||||
QLOG_DEBUG() << "Finished reading authentication response.";
|
QLOG_DEBUG() << "Finished reading authentication response.";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -226,5 +204,3 @@ QString AuthenticateTask::getStateMessage(const YggdrasilTask::State state) cons
|
|||||||
return YggdrasilTask::getStateMessage(state);
|
return YggdrasilTask::getStateMessage(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,7 +22,8 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The authenticate task takes a MojangAccount with no access token and password and attempts to authenticate with Mojang's servers.
|
* The authenticate task takes a MojangAccount with no access token and password and attempts to
|
||||||
|
* authenticate with Mojang's servers.
|
||||||
* If successful, it will set the MojangAccount's access token.
|
* If successful, it will set the MojangAccount's access token.
|
||||||
*/
|
*/
|
||||||
class AuthenticateTask : public YggdrasilTask
|
class AuthenticateTask : public YggdrasilTask
|
||||||
@ -43,4 +44,3 @@ protected:
|
|||||||
private:
|
private:
|
||||||
QString m_password;
|
QString m_password;
|
||||||
};
|
};
|
||||||
|
|
0
logic/auth/flows/InvalidateTask.cpp
Normal file
0
logic/auth/flows/InvalidateTask.cpp
Normal file
0
logic/auth/flows/InvalidateTask.h
Normal file
0
logic/auth/flows/InvalidateTask.h
Normal file
156
logic/auth/flows/RefreshTask.cpp
Normal file
156
logic/auth/flows/RefreshTask.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 <logic/auth/flows/RefreshTask.h>
|
||||||
|
|
||||||
|
#include <logic/auth/MojangAccount.h>
|
||||||
|
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "logger/QsLog.h"
|
||||||
|
|
||||||
|
RefreshTask::RefreshTask(MojangAccountPtr account, QObject *parent)
|
||||||
|
: YggdrasilTask(account, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject RefreshTask::getRequestContent() const
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* {
|
||||||
|
* "clientToken": "client identifier"
|
||||||
|
* "accessToken": "current access token to be refreshed"
|
||||||
|
* "selectedProfile": // specifying this causes errors
|
||||||
|
* {
|
||||||
|
* "id": "profile ID"
|
||||||
|
* "name": "profile name"
|
||||||
|
* }
|
||||||
|
* "requestUser": true/false // request the user structure
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
auto account = getMojangAccount();
|
||||||
|
QJsonObject req;
|
||||||
|
req.insert("clientToken", account->clientToken());
|
||||||
|
req.insert("accessToken", account->accessToken());
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
auto currentProfile = account->currentProfile();
|
||||||
|
QJsonObject profile;
|
||||||
|
profile.insert("id", currentProfile->id());
|
||||||
|
profile.insert("name", currentProfile->name());
|
||||||
|
req.insert("selectedProfile", profile);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
req.insert("requestUser", true);
|
||||||
|
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RefreshTask::processResponse(QJsonObject responseData)
|
||||||
|
{
|
||||||
|
auto account = getMojangAccount();
|
||||||
|
|
||||||
|
// Read the response data. We need to get the client token, access token, and the selected
|
||||||
|
// profile.
|
||||||
|
QLOG_DEBUG() << "Processing authentication response.";
|
||||||
|
|
||||||
|
// If we already have a client token, make sure the one the server gave us matches our
|
||||||
|
// existing one.
|
||||||
|
QString clientToken = responseData.value("clientToken").toString("");
|
||||||
|
if (clientToken.isEmpty())
|
||||||
|
{
|
||||||
|
// Fail if the server gave us an empty client token
|
||||||
|
// TODO: Set an error properly to display to the user.
|
||||||
|
QLOG_ERROR() << "Server didn't send a client token.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!account->clientToken().isEmpty() && clientToken != account->clientToken())
|
||||||
|
{
|
||||||
|
// The server changed our client token! Obey its wishes, but complain. That's what I do
|
||||||
|
// for my parents, so...
|
||||||
|
QLOG_ERROR() << "Server changed our client token to '" << clientToken
|
||||||
|
<< "'. This shouldn't happen, but it isn't really a big deal.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now, we set the access token.
|
||||||
|
QLOG_DEBUG() << "Getting new access token.";
|
||||||
|
QString accessToken = responseData.value("accessToken").toString("");
|
||||||
|
if (accessToken.isEmpty())
|
||||||
|
{
|
||||||
|
// Fail if the server didn't give us an access token.
|
||||||
|
// TODO: Set an error properly to display to the user.
|
||||||
|
QLOG_ERROR() << "Server didn't send an access token.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we validate that the server responded right. (our current profile = returned current
|
||||||
|
// profile)
|
||||||
|
QJsonObject currentProfile = responseData.value("selectedProfile").toObject();
|
||||||
|
QString currentProfileId = currentProfile.value("id").toString("");
|
||||||
|
if (account->currentProfile()->id() != currentProfileId)
|
||||||
|
{
|
||||||
|
// TODO: Set an error to display to the user.
|
||||||
|
QLOG_ERROR() << "Server didn't specify the same selected profile as ours.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is what the vanilla launcher passes to the userProperties launch param
|
||||||
|
if (responseData.contains("user"))
|
||||||
|
{
|
||||||
|
auto obj = responseData.value("user").toObject();
|
||||||
|
auto userId = obj.value("id").toString();
|
||||||
|
auto propArray = obj.value("properties").toArray();
|
||||||
|
QLOG_DEBUG() << "User ID: " << userId;
|
||||||
|
QLOG_DEBUG() << "User Properties: ";
|
||||||
|
for (auto prop : propArray)
|
||||||
|
{
|
||||||
|
auto propTuple = prop.toObject();
|
||||||
|
auto name = propTuple.value("name").toString();
|
||||||
|
auto value = propTuple.value("value").toString();
|
||||||
|
QLOG_DEBUG() << name << " : " << value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We've made it through the minefield of possible errors. Return true to indicate that
|
||||||
|
// we've succeeded.
|
||||||
|
QLOG_DEBUG() << "Finished reading refresh response.";
|
||||||
|
// Reset the access token.
|
||||||
|
account->setAccessToken(accessToken);
|
||||||
|
account->propagateChange();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RefreshTask::getEndpoint() const
|
||||||
|
{
|
||||||
|
return "refresh";
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RefreshTask::getStateMessage(const YggdrasilTask::State state) const
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case STATE_SENDING_REQUEST:
|
||||||
|
return tr("Refreshing: Sending request.");
|
||||||
|
case STATE_PROCESSING_RESPONSE:
|
||||||
|
return tr("Refreshing: Processing response.");
|
||||||
|
default:
|
||||||
|
return YggdrasilTask::getStateMessage(state);
|
||||||
|
}
|
||||||
|
}
|
43
logic/auth/flows/RefreshTask.h
Normal file
43
logic/auth/flows/RefreshTask.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/* 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 <logic/auth/YggdrasilTask.h>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The authenticate task takes a MojangAccount with a possibly timed-out access token
|
||||||
|
* and attempts to authenticate with Mojang's servers.
|
||||||
|
* If successful, it will set the new access token. The token is considered validated.
|
||||||
|
*/
|
||||||
|
class RefreshTask : public YggdrasilTask
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
RefreshTask(MojangAccountPtr account, QObject *parent = 0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual QJsonObject getRequestContent() const;
|
||||||
|
|
||||||
|
virtual QString getEndpoint() const;
|
||||||
|
|
||||||
|
virtual bool processResponse(QJsonObject responseData);
|
||||||
|
|
||||||
|
QString getStateMessage(const YggdrasilTask::State state) const;
|
||||||
|
};
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <logic/auth/ValidateTask.h>
|
#include <logic/auth/flows/ValidateTask.h>
|
||||||
|
|
||||||
#include <logic/auth/MojangAccount.h>
|
#include <logic/auth/MojangAccount.h>
|
||||||
|
|
||||||
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
#include "logger/QsLog.h"
|
#include "logger/QsLog.h"
|
||||||
|
|
||||||
ValidateTask::ValidateTask(MojangAccountPtr account, QObject* parent) :
|
ValidateTask::ValidateTask(MojangAccountPtr account, QObject *parent)
|
||||||
YggdrasilTask(account, parent)
|
: YggdrasilTask(account, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,5 +62,3 @@ QString ValidateTask::getStateMessage(const YggdrasilTask::State state) const
|
|||||||
return YggdrasilTask::getStateMessage(state);
|
return YggdrasilTask::getStateMessage(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,4 +41,3 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
@ -281,14 +281,6 @@ InstanceList::InstListError InstanceList::loadList()
|
|||||||
auto &loader = InstanceFactory::get();
|
auto &loader = InstanceFactory::get();
|
||||||
auto error = loader.loadInstance(instPtr, subDir);
|
auto error = loader.loadInstance(instPtr, subDir);
|
||||||
|
|
||||||
switch (error)
|
|
||||||
{
|
|
||||||
case InstanceFactory::NoLoadError:
|
|
||||||
break;
|
|
||||||
case InstanceFactory::NotAnInstance:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error != InstanceFactory::NoLoadError && error != InstanceFactory::NotAnInstance)
|
if (error != InstanceFactory::NoLoadError && error != InstanceFactory::NotAnInstance)
|
||||||
{
|
{
|
||||||
QString errorMsg = QString("Failed to load instance %1: ")
|
QString errorMsg = QString("Failed to load instance %1: ")
|
||||||
@ -362,8 +354,13 @@ int InstanceList::add(InstancePtr t)
|
|||||||
return count() - 1;
|
return count() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancePtr InstanceList::getInstanceById(QString instId)
|
InstancePtr InstanceList::getInstanceById(QString instId) const
|
||||||
{
|
{
|
||||||
|
if (m_instances.isEmpty())
|
||||||
|
{
|
||||||
|
return InstancePtr();
|
||||||
|
}
|
||||||
|
|
||||||
QListIterator<InstancePtr> iter(m_instances);
|
QListIterator<InstancePtr> iter(m_instances);
|
||||||
InstancePtr inst;
|
InstancePtr inst;
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
@ -378,7 +375,12 @@ InstancePtr InstanceList::getInstanceById(QString instId)
|
|||||||
return iter.peekPrevious();
|
return iter.peekPrevious();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstanceList::getInstIndex(BaseInstance *inst)
|
QModelIndex InstanceList::getInstanceIndexById(const QString &id) const
|
||||||
|
{
|
||||||
|
return index(getInstIndex(getInstanceById(id).get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int InstanceList::getInstIndex(BaseInstance *inst) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_instances.count(); i++)
|
for (int i = 0; i < m_instances.count(); i++)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,9 @@ public:
|
|||||||
int add(InstancePtr t);
|
int add(InstancePtr t);
|
||||||
|
|
||||||
/// Get an instance by ID
|
/// Get an instance by ID
|
||||||
InstancePtr getInstanceById(QString id);
|
InstancePtr getInstanceById(QString id) const;
|
||||||
|
|
||||||
|
QModelIndex getInstanceIndexById(const QString &id) const;
|
||||||
signals:
|
signals:
|
||||||
void dataIsInvalid();
|
void dataIsInvalid();
|
||||||
|
|
||||||
@ -106,7 +108,7 @@ slots:
|
|||||||
void groupChanged();
|
void groupChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int getInstIndex(BaseInstance *inst);
|
int getInstIndex(BaseInstance *inst) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_instDir;
|
QString m_instDir;
|
||||||
|
@ -44,7 +44,6 @@ MojangAccountPtr MojangAccountList::findAccount(const QString &username) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const MojangAccountPtr MojangAccountList::at(int i) const
|
const MojangAccountPtr MojangAccountList::at(int i) const
|
||||||
{
|
{
|
||||||
return MojangAccountPtr(m_accounts.at(i));
|
return MojangAccountPtr(m_accounts.at(i));
|
||||||
@ -53,6 +52,7 @@ const MojangAccountPtr MojangAccountList::at(int i) const
|
|||||||
void MojangAccountList::addAccount(const MojangAccountPtr account)
|
void MojangAccountList::addAccount(const MojangAccountPtr account)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
connect(account.get(), SIGNAL(changed()), SLOT(accountChanged()));
|
||||||
m_accounts.append(account);
|
m_accounts.append(account);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
onListChanged();
|
onListChanged();
|
||||||
@ -81,7 +81,6 @@ void MojangAccountList::removeAccount(QModelIndex index)
|
|||||||
onListChanged();
|
onListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MojangAccountPtr MojangAccountList::activeAccount() const
|
MojangAccountPtr MojangAccountList::activeAccount() const
|
||||||
{
|
{
|
||||||
if (m_activeAccount.isEmpty())
|
if (m_activeAccount.isEmpty())
|
||||||
@ -109,6 +108,11 @@ void MojangAccountList::setActiveAccount(const QString& username)
|
|||||||
onActiveChanged();
|
onActiveChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MojangAccountList::accountChanged()
|
||||||
|
{
|
||||||
|
// the list changed. there is no doubt.
|
||||||
|
onListChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void MojangAccountList::onListChanged()
|
void MojangAccountList::onListChanged()
|
||||||
{
|
{
|
||||||
@ -127,13 +131,11 @@ void MojangAccountList::onActiveChanged()
|
|||||||
emit activeAccountChanged();
|
emit activeAccountChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int MojangAccountList::count() const
|
int MojangAccountList::count() const
|
||||||
{
|
{
|
||||||
return m_accounts.count();
|
return m_accounts.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant MojangAccountList::data(const QModelIndex &index, int role) const
|
QVariant MojangAccountList::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
@ -223,7 +225,8 @@ void MojangAccountList::updateListData(QList<MojangAccountPtr> versions)
|
|||||||
bool MojangAccountList::loadList(const QString &filePath)
|
bool MojangAccountList::loadList(const QString &filePath)
|
||||||
{
|
{
|
||||||
QString path = filePath;
|
QString path = filePath;
|
||||||
if (path.isEmpty()) path = m_listFilePath;
|
if (path.isEmpty())
|
||||||
|
path = m_listFilePath;
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << "Can't load Mojang account list. No file path given and no default set.";
|
QLOG_ERROR() << "Can't load Mojang account list. No file path given and no default set.";
|
||||||
@ -286,6 +289,7 @@ bool MojangAccountList::loadList(const QString& filePath)
|
|||||||
MojangAccountPtr account = MojangAccount::loadFromJson(accountObj);
|
MojangAccountPtr account = MojangAccount::loadFromJson(accountObj);
|
||||||
if (account.get() != nullptr)
|
if (account.get() != nullptr)
|
||||||
{
|
{
|
||||||
|
connect(account.get(), SIGNAL(changed()), SLOT(accountChanged()));
|
||||||
m_accounts.append(account);
|
m_accounts.append(account);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -304,7 +308,8 @@ bool MojangAccountList::loadList(const QString& filePath)
|
|||||||
bool MojangAccountList::saveList(const QString &filePath)
|
bool MojangAccountList::saveList(const QString &filePath)
|
||||||
{
|
{
|
||||||
QString path(filePath);
|
QString path(filePath);
|
||||||
if (path.isEmpty()) path = m_listFilePath;
|
if (path.isEmpty())
|
||||||
|
path = m_listFilePath;
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << "Can't save Mojang account list. No file path given and no default set.";
|
QLOG_ERROR() << "Can't save Mojang account list. No file path given and no default set.";
|
||||||
@ -337,7 +342,6 @@ bool MojangAccountList::saveList(const QString& filePath)
|
|||||||
// Create a JSON document object to convert our JSON to bytes.
|
// Create a JSON document object to convert our JSON to bytes.
|
||||||
QJsonDocument doc(root);
|
QJsonDocument doc(root);
|
||||||
|
|
||||||
|
|
||||||
// Now that we're done building the JSON object, we can write it to the file.
|
// Now that we're done building the JSON object, we can write it to the file.
|
||||||
QLOG_DEBUG() << "Writing account list to file.";
|
QLOG_DEBUG() << "Writing account list to file.";
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
@ -362,6 +366,5 @@ bool MojangAccountList::saveList(const QString& filePath)
|
|||||||
void MojangAccountList::setListFilePath(QString path, bool autosave)
|
void MojangAccountList::setListFilePath(QString path, bool autosave)
|
||||||
{
|
{
|
||||||
m_listFilePath = path;
|
m_listFilePath = path;
|
||||||
autosave = autosave;
|
m_autosave = autosave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include "logic/auth/MojangAccount.h"
|
#include "logic/auth/MojangAccount.h"
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief List of available Mojang accounts.
|
* \brief List of available Mojang accounts.
|
||||||
* This should be loaded in the background by MultiMC on startup.
|
* This should be loaded in the background by MultiMC on startup.
|
||||||
@ -129,7 +128,8 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
/*!
|
/*!
|
||||||
* Signal emitted to indicate that the account list has changed.
|
* Signal emitted to indicate that the account list has changed.
|
||||||
* This will also fire if the value of an element in the list changes (will be implemented later).
|
* This will also fire if the value of an element in the list changes (will be implemented
|
||||||
|
* later).
|
||||||
*/
|
*/
|
||||||
void listChanged();
|
void listChanged();
|
||||||
|
|
||||||
@ -138,6 +138,13 @@ signals:
|
|||||||
*/
|
*/
|
||||||
void activeAccountChanged();
|
void activeAccountChanged();
|
||||||
|
|
||||||
|
public
|
||||||
|
slots:
|
||||||
|
/**
|
||||||
|
* This is called when one of the accounts changes and the list needs to be updated
|
||||||
|
*/
|
||||||
|
void accountChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*!
|
/*!
|
||||||
* Called whenever the list changes.
|
* Called whenever the list changes.
|
||||||
@ -166,7 +173,7 @@ protected:
|
|||||||
* If true, the account list will automatically save to the account list path when it changes.
|
* If true, the account list will automatically save to the account list path when it changes.
|
||||||
* Ignored if m_listFilePath is blank.
|
* Ignored if m_listFilePath is blank.
|
||||||
*/
|
*/
|
||||||
bool m_autosave;
|
bool m_autosave = false;
|
||||||
|
|
||||||
protected
|
protected
|
||||||
slots:
|
slots:
|
||||||
@ -184,4 +191,3 @@ slots:
|
|||||||
*/
|
*/
|
||||||
virtual void updateListData(QList<MojangAccountPtr> versions);
|
virtual void updateListData(QList<MojangAccountPtr> versions);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
60
test.cpp
60
test.cpp
@ -1,60 +0,0 @@
|
|||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "keyring.h"
|
|
||||||
#include "cmdutils.h"
|
|
||||||
|
|
||||||
using namespace Util::Commandline;
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
QCoreApplication app(argc, argv);
|
|
||||||
app.setApplicationName("MMC Keyring test");
|
|
||||||
app.setOrganizationName("Orochimarufan");
|
|
||||||
|
|
||||||
Parser p;
|
|
||||||
p.addArgument("user", false);
|
|
||||||
p.addArgument("password", false);
|
|
||||||
p.addSwitch("set");
|
|
||||||
p.addSwitch("get");
|
|
||||||
p.addSwitch("list");
|
|
||||||
p.addOption("service", "Test");
|
|
||||||
p.addShortOpt("service", 's');
|
|
||||||
|
|
||||||
QHash<QString, QVariant> args;
|
|
||||||
try {
|
|
||||||
args = p.parse(app.arguments());
|
|
||||||
} catch (ParsingError) {
|
|
||||||
std::cout << "Syntax error." << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args["set"].toBool()) {
|
|
||||||
if (args["user"].isNull() || args["password"].isNull()) {
|
|
||||||
std::cout << "set operation needs bot user and password set" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Keyring::instance()->storePassword(args["service"].toString(),
|
|
||||||
args["user"].toString(), args["password"].toString());
|
|
||||||
} else if (args["get"].toBool()) {
|
|
||||||
if (args["user"].isNull()) {
|
|
||||||
std::cout << "get operation needs user set" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "Password: " << qPrintable(Keyring::instance()->getPassword(args["service"].toString(),
|
|
||||||
args["user"].toString())) << std::endl;
|
|
||||||
return 0;
|
|
||||||
} else if (args["list"].toBool()) {
|
|
||||||
QStringList accounts = Keyring::instance()->getStoredAccounts(args["service"].toString());
|
|
||||||
std::cout << "stored accounts:" << std::endl << '\t' << qPrintable(accounts.join("\n\t")) << std::endl;
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
std::cout << "No operation given!" << std::endl;
|
|
||||||
std::cout << qPrintable(p.compileHelp(argv[0])) << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user