Skip to content

feat(ios): add AppIntents for API reload and country selection#2751

Open
alexl2004games wants to merge 3 commits into
amnezia-vpn:devfrom
alexl2004games:dev
Open

feat(ios): add AppIntents for API reload and country selection#2751
alexl2004games wants to merge 3 commits into
amnezia-vpn:devfrom
alexl2004games:dev

Conversation

@alexl2004games

Copy link
Copy Markdown

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.

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.
Copilot AI review requested due to automatic review settings June 18, 2026 15:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 an AppShortcutsProvider.
  • Adds iOS-only CoreController and AmneziaApplication entry 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 thread client/amneziaApplication.cpp Outdated
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"
Comment thread client/amneziaApplication.cpp Outdated
}

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);
}
}

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants