MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / fetchOneDriveApps

Method fetchOneDriveApps

ui-linux/src/backend.cpp:1051–1104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1049}
1050
1051void Backend::fetchOneDriveApps(const QString &token)
1052{
1053 QUrl url(QString("https://graph.microsoft.com/v1.0/me/drive/root:/CloudRedirect/%1:/children")
1054 .arg(m_accountId));
1055 QUrlQuery params;
1056 params.addQueryItem("$select", "name,folder");
1057 url.setQuery(params);
1058
1059 QNetworkRequest req(url);
1060 req.setRawHeader("Authorization", ("Bearer " + token).toUtf8());
1061
1062 auto *reply = m_nam->get(req);
1063 connect(reply, &QNetworkReply::finished, this, [this, reply]() {
1064 reply->deleteLater();
1065 if (reply->error() != QNetworkReply::NoError) {
1066 fprintf(stderr, "[Backend] OneDrive: failed to list account folder: %s\n",
1067 reply->errorString().toUtf8().constData());
1068 emit remoteAppsFetched();
1069 return;
1070 }
1071
1072 QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
1073 QJsonArray items = doc.object().value("value").toArray();
1074 m_remoteAppIds.clear();
1075 for (const auto &val : items) {
1076 QJsonObject item = val.toObject();
1077 if (!item.contains("folder")) continue;
1078 QString name = item.value("name").toString();
1079 bool ok;
1080 uint appId = name.toUInt(&ok);
1081 if (ok && appId > 0 && !kHiddenAppIds.contains(appId))
1082 m_remoteAppIds.insert(appId);
1083 }
1084
1085 QSet<uint32_t> localAppIds;
1086 for (auto &app : m_apps) {
1087 localAppIds.insert(app.appId);
1088 if (m_remoteAppIds.contains(app.appId))
1089 app.isRemote = true;
1090 }
1091 for (uint32_t appId : m_remoteAppIds) {
1092 if (!localAppIds.contains(appId)) {
1093 QString name = m_nameCache.value(appId, QString("App %1").arg(appId));
1094 m_apps.append({appId, name, QString(), QString(), 0, 0, false, true});
1095 }
1096 }
1097
1098 fprintf(stderr, "[Backend] OneDrive remote apps: %d remote IDs, %d total apps\n",
1099 (int)m_remoteAppIds.size(), (int)m_apps.size());
1100 emit appsChanged();
1101 emit remoteAppsFetched();
1102 QTimer::singleShot(0, this, &Backend::resolveAppNames);
1103 });
1104}
1105
1106void Backend::deleteCloudAppData(uint appId)
1107{

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected