| 1079 | } |
| 1080 | |
| 1081 | void Application::messageReceived(const QByteArray& message) |
| 1082 | { |
| 1083 | if(status() != Initialized) |
| 1084 | { |
| 1085 | qDebug() << "Received message" << message << "while still initializing. It will be ignored."; |
| 1086 | return; |
| 1087 | } |
| 1088 | |
| 1089 | ApplicationMessage received; |
| 1090 | received.parse(message); |
| 1091 | |
| 1092 | auto & command = received.command; |
| 1093 | |
| 1094 | if(command == "activate") |
| 1095 | { |
| 1096 | showMainWindow(); |
| 1097 | } |
| 1098 | else if(command == "import") |
| 1099 | { |
| 1100 | QString path = received.args["path"]; |
| 1101 | if(path.isEmpty()) |
| 1102 | { |
| 1103 | qWarning() << "Received" << command << "message without a zip path/URL."; |
| 1104 | return; |
| 1105 | } |
| 1106 | m_mainWindow->droppedURLs({ QUrl(path) }); |
| 1107 | } |
| 1108 | else if(command == "launch") |
| 1109 | { |
| 1110 | QString id = received.args["id"]; |
| 1111 | QString server = received.args["server"]; |
| 1112 | QString profile = received.args["profile"]; |
| 1113 | |
| 1114 | InstancePtr instance; |
| 1115 | if(!id.isEmpty()) { |
| 1116 | instance = instances()->getInstanceById(id); |
| 1117 | if(!instance) { |
| 1118 | qWarning() << "Launch command requires an valid instance ID. " << id << "resolves to nothing."; |
| 1119 | return; |
| 1120 | } |
| 1121 | } |
| 1122 | else { |
| 1123 | qWarning() << "Launch command called without an instance ID..."; |
| 1124 | return; |
| 1125 | } |
| 1126 | |
| 1127 | MinecraftServerTargetPtr serverObject = nullptr; |
| 1128 | if(!server.isEmpty()) { |
| 1129 | serverObject = std::make_shared<MinecraftServerTarget>(MinecraftServerTarget::parse(server)); |
| 1130 | } |
| 1131 | |
| 1132 | MinecraftAccountPtr accountObject; |
| 1133 | if(!profile.isEmpty()) { |
| 1134 | accountObject = accounts()->getAccountByProfileName(profile); |
| 1135 | if(!accountObject) { |
| 1136 | qWarning() << "Launch command requires the specified profile to be valid. " << profile << "does not resolve to any account."; |
| 1137 | return; |
| 1138 | } |
nothing calls this directly
no test coverage detected