MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / setupProfile

Method setupProfile

launcher/ui/dialogs/ProfileSetupDialog.cpp:199–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void ProfileSetupDialog::setupProfile(const QString &profileName) {
200 if(isWorking) {
201 return;
202 }
203
204 auto token = m_accountToSetup->accessToken();
205
206 auto url = QString("https://api.minecraftservices.com/minecraft/profile");
207 QNetworkRequest request = QNetworkRequest(url);
208 request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
209 request.setRawHeader("Accept", "application/json");
210 request.setRawHeader("Authorization", QString("Bearer %1").arg(token).toUtf8());
211
212 QString payloadTemplate("{\"profileName\":\"%1\"}");
213 auto data = payloadTemplate.arg(profileName).toUtf8();
214
215 AuthRequest *requestor = new AuthRequest(this);
216 connect(requestor, &AuthRequest::finished, this, &ProfileSetupDialog::setupProfileFinished);
217 requestor->post(request, data);
218 isWorking = true;
219
220 auto button = ui->buttonBox->button(QDialogButtonBox::Cancel);
221 button->setEnabled(false);
222}
223
224namespace {
225

Callers

nothing calls this directly

Calls 4

QStringClass · 0.85
postMethod · 0.80
setEnabledMethod · 0.80
accessTokenMethod · 0.45

Tested by

no test coverage detected