feat(ios): add AppIntents for API reload and country selection#2751
Open
alexl2004games wants to merge 3 commits into
Open
feat(ios): add AppIntents for API reload and country selection#2751alexl2004games wants to merge 3 commits into
alexl2004games wants to merge 3 commits into
Conversation
This introduces iOS 16+ AppIntents to allow reloading the API configuration and connecting to specific countries via the Shortcuts app. It uses standard C interoperability to bridge Swift AppIntents with the Qt CoreController, avoiding complex bridging headers.
There was a problem hiding this comment.
Pull request overview
Adds iOS 16+ AppIntents/Shortcuts support to trigger API config reload and connect to a selected country by bridging Swift AppIntents to the existing Qt CoreController via C-callable callbacks.
Changes:
- Introduces Swift AppIntents (
Reload API Config,Connect to Country) and anAppShortcutsProvider. - Adds iOS-only
CoreControllerandAmneziaApplicationentry points to service intents (reload/connect/list countries). - Wires the new Swift source into the iOS CMake target.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| client/platforms/ios/AmneziaAppIntents.swift | Adds AppIntents, entity/query for countries, and callback bridging setup. |
| client/core/controllers/coreController.h | Declares iOS-only intent entry points on CoreController. |
| client/core/controllers/coreController.cpp | Implements iOS-only intent handlers (reload/connect/get countries). |
| client/cmake/ios.cmake | Adds the new Swift file to iOS target sources. |
| client/amneziaApplication.h | Declares iOS-only intent handler slots on the application object. |
| client/amneziaApplication.cpp | Registers Swift callbacks and implements handlers that forward to CoreController. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+17
to
+21
| if #available(iOS 16.0, *) { | ||
| IntentCallbacks.reload = reloadCallback | ||
| IntentCallbacks.connect = connectCallback | ||
| IntentCallbacks.getCountries = getCountriesCallback | ||
| } |
Comment on lines
+29
to
+35
| #if defined(Q_OS_IOS) | ||
| #include <QJsonDocument> | ||
| #include <QJsonArray> | ||
| #include <QJsonObject> | ||
| #include "core/models/api/apiV2ServerConfig.h" | ||
| #include "core/controllers/api/subscriptionUiController.h" | ||
| #include "core/controllers/serversUiController.h" |
| } | ||
|
|
||
| static const char* intent_get_countries() { | ||
| static QByteArray lastJson; |
Comment on lines
+368
to
+373
| void CoreController::intentReload() | ||
| { | ||
| if (m_subscriptionUiController && m_serversUiController) { | ||
| m_subscriptionUiController->updateServiceFromGateway(m_serversUiController->processedServerId(), "", "", true); | ||
| } | ||
| } |
Comment on lines
+375
to
+380
| void CoreController::intentConnect(const QString &countryCode) | ||
| { | ||
| if (m_subscriptionUiController && m_serversUiController) { | ||
| m_subscriptionUiController->updateServiceFromGateway(m_serversUiController->processedServerId(), countryCode, "", true); | ||
| } | ||
| } |
Comment on lines
+74
to
+81
| if let data = jsonString.data(using: .utf8), | ||
| let array = try? JSONSerialization.jsonObject(with: data, options: []) as? [[String: String]] { | ||
| for item in array { | ||
| if let code = item["code"], let name = item["name"] { | ||
| options.append(CountryOption(id: code, name: name)) | ||
| } | ||
| } | ||
| } |
Comment on lines
+51
to
+62
| static const char* intent_get_countries() { | ||
| thread_local static QByteArray lastJson; | ||
| if (g_amnApp) { | ||
| // Query synchronously from g_amnApp | ||
| // But since this might be called on a background thread by AppIntents, we can safely just fetch it if data is protected, or use invokeMethod with BlockingQueuedConnection | ||
| QString jsonStr; | ||
| QMetaObject::invokeMethod(g_amnApp, "handleIntentGetCountries", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, jsonStr)); | ||
| lastJson = jsonStr.toUtf8(); | ||
| return lastJson.constData(); | ||
| } | ||
| return "[]"; | ||
| } |
Comment on lines
+364
to
+366
| #include <QJsonDocument> | ||
| #include <QJsonArray> | ||
| #include <QJsonObject> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduces iOS 16+ AppIntents to allow reloading the API configuration and connecting to specific countries via the Shortcuts app. It uses standard C interoperability to bridge Swift AppIntents with the Qt CoreController, avoiding complex bridging headers.