From 3b422b54aa13be4eb59c80b1f7bb2a514aac583f Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 18 Jan 2013 12:15:59 -0600 Subject: Re-added settings files to project. --- data/settingsmacros.h | 35 ----------------------------------- data/settingsmacrosundef.h | 26 -------------------------- 2 files changed, 61 deletions(-) delete mode 100644 data/settingsmacros.h delete mode 100644 data/settingsmacrosundef.h (limited to 'data') diff --git a/data/settingsmacros.h b/data/settingsmacros.h deleted file mode 100644 index 94e52155..00000000 --- a/data/settingsmacros.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SETTINGSMACROS_H -#define SETTINGSMACROS_H - -#define STR_VAL(val) # val - -#define DEFINE_SETTING(funcName, name, defVal, typeName, toFunc) \ - virtual typeName Get ## funcName() const { return value(name). ## toFunc(); } \ - virtual void Set ## funcName(typeName value) { setValue(name, value); } \ - virtual void Reset ## funcName() { - -#define DEFINE_SETTING_STR(name, defVal) \ - DEFINE_SETTING(name, STR_VAL(name), defVal, QString, toString) - -#define DEFINE_SETTING_BOOL(name, defVal) \ - DEFINE_SETTING(name, STR_VAL(name), defVal, bool, toBool) - -#define DEFINE_SETTING_INT(name, defVal) \ - DEFINE_SETTING(name, STR_VAL(name), defVal, int, toInt) - -#endif // SETTINGSMACROS_H diff --git a/data/settingsmacrosundef.h b/data/settingsmacrosundef.h deleted file mode 100644 index 85b13bac..00000000 --- a/data/settingsmacrosundef.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SETTINGSMACROSUNDEF_H -#define SETTINGSMACROSUNDEF_H - -#undef DEFINE_SETTING -#undef DEFINE_SETTING_STR -#undef DEFINE_SETTING_BOOL -#undef DEFINE_SETTING_INT - -#undef STR_VAL - -#endif // SETTINGSMACROSUNDEF_H -- cgit From a25bedd7706b14cdae91556e4a577e410745f29a Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 28 Jan 2013 15:35:09 -0600 Subject: Implemented settings dialog. --- data/appsettings.cpp | 22 +++++++++++-- data/appsettings.h | 89 +++++++++++++++++++++++++++++++++++++++++++++++++-- data/settingsbase.cpp | 22 ------------- data/settingsbase.h | 33 ------------------- data/stdinstance.cpp | 4 +-- data/stdinstance.h | 2 +- 6 files changed, 110 insertions(+), 62 deletions(-) delete mode 100644 data/settingsbase.cpp delete mode 100644 data/settingsbase.h (limited to 'data') diff --git a/data/appsettings.cpp b/data/appsettings.cpp index 525def6e..1d9c4312 100644 --- a/data/appsettings.cpp +++ b/data/appsettings.cpp @@ -15,8 +15,26 @@ #include "appsettings.h" -AppSettings::AppSettings(QString fileName) : - SettingsBase(fileName) +AppSettings* settings; + +SettingsBase::SettingsBase(QObject *parent) : + QObject(parent) +{ + +} + +AppSettings::AppSettings(QObject *parent) : + SettingsBase(parent) { } + +QVariant AppSettings::getValue(const QString& name, QVariant defVal) const +{ + return config.value(name, defVal); +} + +void AppSettings::setValue(const QString& name, QVariant val) +{ + config.setValue(name, val); +} diff --git a/data/appsettings.h b/data/appsettings.h index f8c7ff73..eff22b11 100644 --- a/data/appsettings.h +++ b/data/appsettings.h @@ -16,12 +16,97 @@ #ifndef APPSETTINGS_H #define APPSETTINGS_H -#include "settingsbase.h" +#include +#include +#include + +#include "util/apputils.h" +#include "util/osutils.h" + +#if WINDOWS +#define JPATHKEY "JavaPathWindows" +#elif OSX +#define JPATHKEY "JavaPathOSX" +#else +#define JPATHKEY "JavaPathLinux" +#endif + +#define DEFINE_SETTING_ADVANCED(funcName, name, valType, defVal) \ + virtual valType get ## funcName() const { return getValue(name, defVal).value(); } \ + virtual void set ## funcName(valType value) { setValue(name, value); } + +#define DEFINE_SETTING(name, valType, defVal) \ + DEFINE_SETTING_ADVANCED(name, STR_VAL(name), valType, defVal) + +#define DEFINE_OVERRIDE_SETTING(overrideName) \ + + +class SettingsBase : public QObject +{ + Q_OBJECT +public: + explicit SettingsBase(QObject *parent = 0); + + // Updates + DEFINE_SETTING(UseDevBuilds, bool, false) + DEFINE_SETTING(AutoUpdate, bool, true) + + // Folders + DEFINE_SETTING(InstanceDir, QString, "instances") + DEFINE_SETTING(CentralModsDir, QString, "mods") + DEFINE_SETTING(LWJGLDir, QString, "lwjgl") + + // Console + DEFINE_SETTING(ShowConsole, bool, true) + DEFINE_SETTING(AutoCloseConsole, bool, true) + + // Console Colors + DEFINE_SETTING(SysMessageColor, QColor, QColor(Qt::blue)) + DEFINE_SETTING(StdOutColor, QColor, QColor(Qt::black)) + DEFINE_SETTING(StdErrColor, QColor, QColor(Qt::red)) + + // Window Size + DEFINE_SETTING(LaunchCompatMode, bool, false) + DEFINE_SETTING(LaunchMaximized, bool, false) + DEFINE_SETTING(MinecraftWinWidth, int, 854) + DEFINE_SETTING(MinecraftWinHeight, int, 480) + + // Auto login + DEFINE_SETTING(AutoLogin, bool, false) + + // Memory + DEFINE_SETTING(MinMemAlloc, int, 512) + DEFINE_SETTING(MaxMemAlloc, int, 1024) + + // Java Settings + DEFINE_SETTING_ADVANCED(JavaPath, JPATHKEY, QString, "java") + DEFINE_SETTING(JvmArgs, QString, "") + + // Custom Commands + DEFINE_SETTING(PreLaunchCommand, QString, "") + DEFINE_SETTING(PostExitCommand, QString, "") + +protected: + virtual QVariant getValue(const QString& name, QVariant defVal = QVariant()) const = 0; + virtual void setValue(const QString& name, QVariant val) = 0; +}; class AppSettings : public SettingsBase { + Q_OBJECT public: - AppSettings(QString fileName); + explicit AppSettings(QObject *parent = 0); + +protected: + virtual QVariant getValue(const QString &name, QVariant defVal = QVariant()) const; + virtual void setValue(const QString& name, QVariant val); + + QSettings config; }; +#undef DEFINE_SETTING_ADVANCED +#undef DEFINE_SETTING + +extern AppSettings* settings; + #endif // APPSETTINGS_H diff --git a/data/settingsbase.cpp b/data/settingsbase.cpp deleted file mode 100644 index 66195603..00000000 --- a/data/settingsbase.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "settingsbase.h" - -SettingsBase::SettingsBase(QString fileName) : - QSettings(fileName, QSettings::IniFormat) -{ - -} diff --git a/data/settingsbase.h b/data/settingsbase.h deleted file mode 100644 index 71f0e30d..00000000 --- a/data/settingsbase.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SETTINGSBASE_H -#define SETTINGSBASE_H - -#include - -#include "settingsmacros.h" - -class SettingsBase : public QSettings -{ -public: - SettingsBase(QString fileName); - - -}; - -#include "settingsmacrosundef.h" - -#endif // SETTINGSBASE_H diff --git a/data/stdinstance.cpp b/data/stdinstance.cpp index 1324b510..4618f5ca 100644 --- a/data/stdinstance.cpp +++ b/data/stdinstance.cpp @@ -15,8 +15,8 @@ #include "stdinstance.h" -StdInstance::StdInstance(QString rootDir) : - InstanceBase(rootDir) +StdInstance::StdInstance(QString rootDir, QObject* parent) : + InstanceBase(rootDir, parent) { } diff --git a/data/stdinstance.h b/data/stdinstance.h index 59b1c8ab..79b87601 100644 --- a/data/stdinstance.h +++ b/data/stdinstance.h @@ -22,7 +22,7 @@ class StdInstance : public InstanceBase { public: - explicit StdInstance(QString rootDir); + explicit StdInstance(QString rootDir, QObject *parent = 0); }; #endif // STDINSTANCE_H -- cgit From 3a0367a79c53c59e670ee50927247885fe4807cb Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 28 Jan 2013 18:01:20 -0600 Subject: Resized main window and added version info. --- data/version.cpp | 38 ++++++++++++++++++++++++++++++++++++++ data/version.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 data/version.cpp create mode 100644 data/version.h (limited to 'data') diff --git a/data/version.cpp b/data/version.cpp new file mode 100644 index 00000000..905402fd --- /dev/null +++ b/data/version.cpp @@ -0,0 +1,38 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "version.h" + +#include "config.h" + +Version Version::current = Version(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD); + +Version::Version(int major, int minor, int revision, int build, QObject *parent) : + QObject(parent) +{ + this->major = major; + this->minor = minor; + this->revision = revision; + this->build = build; +} + +QString Version::toString() const +{ + return QString("%1.%2.%3.%4").arg( + QString::number(major), + QString::number(minor), + QString::number(revision), + QString::number(build)); +} diff --git a/data/version.h b/data/version.h new file mode 100644 index 00000000..37c0fd68 --- /dev/null +++ b/data/version.h @@ -0,0 +1,38 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef VERSION_H +#define VERSION_H + +#include + +class Version : public QObject +{ + Q_OBJECT +public: + explicit Version(int major = 0, int minor = 0, int revision = 0, + int build = 0, QObject *parent = 0); + + QString toString() const; + + int major; + int minor; + int revision; + int build; + + static Version current; +}; + +#endif // VERSION_H -- cgit From dcc21b7e649f79fa0cac75507ba9a314735744d9 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 29 Jan 2013 13:01:04 -0600 Subject: Changed group list loading to use Qt JSON instead of boost. --- data/instancemodel.cpp | 132 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 93 insertions(+), 39 deletions(-) (limited to 'data') diff --git a/data/instancemodel.cpp b/data/instancemodel.cpp index 239be5c5..4fbcebc2 100644 --- a/data/instancemodel.cpp +++ b/data/instancemodel.cpp @@ -16,15 +16,18 @@ #include "instancemodel.h" #include + #include +#include #include -#include "stdinstance.h" - -#include "../util/pathutils.h" +#include -#include -#include +#include +#include +#include +#include "data/stdinstance.h" +#include "util/pathutils.h" #define GROUP_FILE_FORMAT_VERSION 1 @@ -65,47 +68,98 @@ void InstanceModel::initialLoad(QString dir) // temporary map from instance ID to group name QMap groupMap; - using namespace boost::property_tree; - ptree pt; - - try + if (QFileInfo(groupFile).exists()) { - read_json(groupFile.toStdString(), pt); - - if (pt.get_optional("formatVersion") != GROUP_FILE_FORMAT_VERSION) + QFile groupFile(groupFile); + + if (!groupFile.open(QIODevice::ReadOnly)) { - // TODO: Discard old formats. + // An error occurred. Ignore it. + qDebug("Failed to read instance group file."); + goto groupParseFail; } - - BOOST_FOREACH(const ptree::value_type& vp, pt.get_child("groups")) + + QTextStream in(&groupFile); + QString jsonStr = in.readAll(); + groupFile.close(); + + QJsonParseError error; + QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonStr.toUtf8(), &error); + + if (error.error != QJsonParseError::NoError) { - ptree gPt = vp.second; - QString groupName = QString::fromUtf8(vp.first.c_str()); - - InstanceGroup *group = new InstanceGroup(groupName, this); - groups.push_back(group); - - if (gPt.get_child_optional("hidden")) - group->setHidden(gPt.get("hidden")); - - QVector groupInstances; - BOOST_FOREACH(const ptree::value_type& v, gPt.get_child("instances")) + qWarning(QString("Failed to parse instance group file: %1 at offset %2"). + arg(error.errorString(), QString::number(error.offset)).toUtf8()); + goto groupParseFail; + } + + if (!jsonDoc.isObject()) + { + qWarning("Invalid group file. Root entry should be an object."); + goto groupParseFail; + } + + QJsonObject rootObj = jsonDoc.object(); + + // Make sure the format version matches. + if (rootObj.value("formatVersion").toVariant().toInt() == GROUP_FILE_FORMAT_VERSION) + { + // Get the group list. + if (!rootObj.value("groups").isObject()) { - QString key = QString::fromUtf8(v.second.data().c_str()); - groupMap[key] = groupName; + qWarning("Invalid group list JSON: 'groups' should be an object."); + goto groupParseFail; + } + + // Iterate through the list. + QJsonObject groupList = rootObj.value("groups").toObject(); + + for (QJsonObject::iterator iter = groupList.begin(); + iter != groupList.end(); iter++) + { + QString groupName = iter.key(); + + // If not an object, complain and skip to the next one. + if (!iter.value().isObject()) + { + qWarning(QString("Group '%1' in the group list should " + "be an object.").arg(groupName).toUtf8()); + continue; + } + + QJsonObject groupObj = iter.value().toObject(); + + // Create the group object. + InstanceGroup *group = new InstanceGroup(groupName, this); + groups.push_back(group); + + // If 'hidden' isn't a bool value, just assume it's false. + if (groupObj.value("hidden").isBool() && groupObj.value("hidden").toBool()) + { + group->setHidden(groupObj.value("hidden").toBool()); + } + + if (!groupObj.value("instances").isArray()) + { + qWarning(QString("Group '%1' in the group list is invalid. " + "It should contain an array " + "called 'instances'.").arg(groupName).toUtf8()); + continue; + } + + // Iterate through the list of instances in the group. + QJsonArray instancesArray = groupObj.value("instances").toArray(); + + for (QJsonArray::iterator iter2 = instancesArray.begin(); + iter2 != instancesArray.end(); iter2++) + { + groupMap[(*iter2).toString()] = groupName; + } } } } - catch (json_parser_error e) - { - qDebug("Failed to read group list. JSON parser error."); -// wxLogError(_(), -// e.line(), wxStr(e.message()).c_str()); - } - catch (ptree_error e) - { - qDebug("Failed to read group list. Unknown ptree error."); - } + +groupParseFail: qDebug("Loading instances"); QDir instDir(dir); @@ -400,4 +454,4 @@ QVariant InstanceGroup::data ( int role ) const default: return QVariant(); } -} \ No newline at end of file +} -- cgit From 90764f97d94a52517d735ed96d26bb52a2d75de1 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 29 Jan 2013 23:52:37 -0600 Subject: Add instance toolbar. --- data/appsettings.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'data') diff --git a/data/appsettings.h b/data/appsettings.h index eff22b11..a9068bfd 100644 --- a/data/appsettings.h +++ b/data/appsettings.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "util/apputils.h" #include "util/osutils.h" @@ -60,6 +61,10 @@ public: DEFINE_SETTING(ShowConsole, bool, true) DEFINE_SETTING(AutoCloseConsole, bool, true) + // Toolbar settings + DEFINE_SETTING(InstanceToolbarVisible, bool, true) + DEFINE_SETTING(InstanceToolbarPosition, QPoint, QPoint()) + // Console Colors DEFINE_SETTING(SysMessageColor, QColor, QColor(Qt::blue)) DEFINE_SETTING(StdOutColor, QColor, QColor(Qt::black)) @@ -97,6 +102,8 @@ class AppSettings : public SettingsBase public: explicit AppSettings(QObject *parent = 0); + QSettings& getConfig() { return config; } + protected: virtual QVariant getValue(const QString &name, QVariant defVal = QVariant()) const; virtual void setValue(const QString& name, QVariant val); -- cgit From 2d05e901964d3d6a5cf4806298653655d8b2d2ee Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 31 Jan 2013 16:46:31 -0600 Subject: Fix naming issue in instance model class. --- data/instancemodel.cpp | 6 +++--- data/instancemodel.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'data') diff --git a/data/instancemodel.cpp b/data/instancemodel.cpp index 4fbcebc2..fbdb8212 100644 --- a/data/instancemodel.cpp +++ b/data/instancemodel.cpp @@ -61,16 +61,16 @@ void InstanceGroup::addInstance ( InstanceBase* inst ) void InstanceModel::initialLoad(QString dir) { - groupFile = dir + "/instgroups.json"; + groupFileName = dir + "/instgroups.json"; implicitGroup = new InstanceGroup("Ungrouped", this); groups.append(implicitGroup); // temporary map from instance ID to group name QMap groupMap; - if (QFileInfo(groupFile).exists()) + if (QFileInfo(groupFileName).exists()) { - QFile groupFile(groupFile); + QFile groupFile(groupFileName); if (!groupFile.open(QIODevice::ReadOnly)) { diff --git a/data/instancemodel.h b/data/instancemodel.h index 7b6cb8c6..4bd34831 100644 --- a/data/instancemodel.h +++ b/data/instancemodel.h @@ -129,7 +129,7 @@ signals: public slots: private: - QString groupFile; + QString groupFileName; QVector groups; InstanceGroup * implicitGroup; }; -- cgit From ffe49e9c1a54daad2007e2456e75180d5f59f59f Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 31 Jan 2013 16:54:06 -0600 Subject: Add copy constructor for version class. --- data/version.cpp | 10 +++++++++- data/version.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'data') diff --git a/data/version.cpp b/data/version.cpp index 905402fd..eec50e13 100644 --- a/data/version.cpp +++ b/data/version.cpp @@ -17,7 +17,7 @@ #include "config.h" -Version Version::current = Version(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD); +Version Version::current(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD); Version::Version(int major, int minor, int revision, int build, QObject *parent) : QObject(parent) @@ -28,6 +28,14 @@ Version::Version(int major, int minor, int revision, int build, QObject *parent) this->build = build; } +Version::Version(const Version& ver) +{ + this->major = ver.major; + this->minor = ver.minor; + this->revision = ver.revision; + this->build = ver.build; +} + QString Version::toString() const { return QString("%1.%2.%3.%4").arg( diff --git a/data/version.h b/data/version.h index 37c0fd68..321b1680 100644 --- a/data/version.h +++ b/data/version.h @@ -25,6 +25,8 @@ public: explicit Version(int major = 0, int minor = 0, int revision = 0, int build = 0, QObject *parent = 0); + Version(const Version& ver); + QString toString() const; int major; -- cgit From a416c58a93dd9d108f4c4fa968b9431e30834c5c Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Feb 2013 16:34:20 -0600 Subject: Started working on task system and login system. --- data/loginresponse.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ data/loginresponse.h | 39 +++++++++++++++++++++++++++++++++++++++ data/userinfo.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ data/userinfo.h | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 176 insertions(+) create mode 100644 data/loginresponse.cpp create mode 100644 data/loginresponse.h create mode 100644 data/userinfo.cpp create mode 100644 data/userinfo.h (limited to 'data') diff --git a/data/loginresponse.cpp b/data/loginresponse.cpp new file mode 100644 index 00000000..a3647114 --- /dev/null +++ b/data/loginresponse.cpp @@ -0,0 +1,49 @@ +/* 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 "loginresponse.h" + +LoginResponse::LoginResponse(const QString& username, const QString& sessionID, QObject *parent) : + QObject(parent) +{ + this->username = username; + this->sessionID = sessionID; +} + +LoginResponse::LoginResponse(const LoginResponse &other) +{ + this->username = other.username; + this->sessionID = other.sessionID; +} + +QString LoginResponse::getUsername() const +{ + return username; +} + +void LoginResponse::setUsername(const QString& username) +{ + this->username = username; +} + +QString LoginResponse::getSessionID() const +{ + return sessionID; +} + +void LoginResponse::setSessionID(const QString& sessionID) +{ + this->sessionID = sessionID; +} diff --git a/data/loginresponse.h b/data/loginresponse.h new file mode 100644 index 00000000..e780750f --- /dev/null +++ b/data/loginresponse.h @@ -0,0 +1,39 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LOGINRESPONSE_H +#define LOGINRESPONSE_H + +#include + +class LoginResponse : public QObject +{ + Q_OBJECT +public: + explicit LoginResponse(const QString &username, const QString &sessionID, QObject *parent = 0); + LoginResponse(const LoginResponse& other); + + QString getUsername() const; + void setUsername(const QString& username); + + QString getSessionID() const; + void setSessionID(const QString& sessionID); + +private: + QString username; + QString sessionID; +}; + +#endif // LOGINRESPONSE_H diff --git a/data/userinfo.cpp b/data/userinfo.cpp new file mode 100644 index 00000000..907f93a2 --- /dev/null +++ b/data/userinfo.cpp @@ -0,0 +1,49 @@ +/* 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 "userinfo.h" + +UserInfo::UserInfo(const QString &username, const QString &password, QObject *parent) : + QObject(parent) +{ + this->username = username; + this->password = password; +} + +UserInfo::UserInfo(const UserInfo &other) +{ + this->username = other.username; + this->password = other.password; +} + +QString UserInfo::getUsername() const +{ + return username; +} + +void UserInfo::setUsername(const QString &username) +{ + this->username = username; +} + +QString UserInfo::getPassword() const +{ + return password; +} + +void UserInfo::setPassword(const QString &password) +{ + this->password = password; +} diff --git a/data/userinfo.h b/data/userinfo.h new file mode 100644 index 00000000..ccfc741e --- /dev/null +++ b/data/userinfo.h @@ -0,0 +1,39 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef USERINFO_H +#define USERINFO_H + +#include + +class UserInfo : public QObject +{ + Q_OBJECT +public: + explicit UserInfo(const QString& username, const QString& password, QObject *parent = 0); + explicit UserInfo(const UserInfo& other); + + QString getUsername() const; + void setUsername(const QString& username); + + QString getPassword() const; + void setPassword(const QString& password); + +protected: + QString username; + QString password; +}; + +#endif // USERINFO_H -- cgit From e475f5d51251ae57da0480bbadc9cb32a8bc72b2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 5 Feb 2013 19:22:19 -0600 Subject: Implemented login system. --- data/loginresponse.cpp | 26 +++++++++++++++++++++++--- data/loginresponse.h | 10 +++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'data') diff --git a/data/loginresponse.cpp b/data/loginresponse.cpp index a3647114..44bc80eb 100644 --- a/data/loginresponse.cpp +++ b/data/loginresponse.cpp @@ -15,17 +15,27 @@ #include "loginresponse.h" -LoginResponse::LoginResponse(const QString& username, const QString& sessionID, QObject *parent) : +LoginResponse::LoginResponse(const QString& username, const QString& sessionID, + qint64 latestVersion, QObject *parent) : QObject(parent) { this->username = username; this->sessionID = sessionID; + this->latestVersion = latestVersion; +} + +LoginResponse::LoginResponse() +{ + this->username = ""; + this->sessionID = ""; + this->latestVersion = 0; } LoginResponse::LoginResponse(const LoginResponse &other) { - this->username = other.username; - this->sessionID = other.sessionID; + this->username = other.getUsername(); + this->sessionID = other.getSessionID(); + this->latestVersion = other.getLatestVersion(); } QString LoginResponse::getUsername() const @@ -47,3 +57,13 @@ void LoginResponse::setSessionID(const QString& sessionID) { this->sessionID = sessionID; } + +qint64 LoginResponse::getLatestVersion() const +{ + return latestVersion; +} + +void LoginResponse::setLatestVersion(qint64 v) +{ + this->latestVersion = v; +} diff --git a/data/loginresponse.h b/data/loginresponse.h index e780750f..bcb77d56 100644 --- a/data/loginresponse.h +++ b/data/loginresponse.h @@ -22,7 +22,9 @@ class LoginResponse : public QObject { Q_OBJECT public: - explicit LoginResponse(const QString &username, const QString &sessionID, QObject *parent = 0); + explicit LoginResponse(const QString &username, const QString &sessionID, + qint64 latestVersion, QObject *parent = 0); + LoginResponse(); LoginResponse(const LoginResponse& other); QString getUsername() const; @@ -31,9 +33,15 @@ public: QString getSessionID() const; void setSessionID(const QString& sessionID); + qint64 getLatestVersion() const; + void setLatestVersion(qint64 v); + private: QString username; QString sessionID; + qint64 latestVersion; }; +Q_DECLARE_METATYPE(LoginResponse) + #endif // LOGINRESPONSE_H -- cgit