mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
dialer: don't hardcode the account name to be account0
instead loop through available accounts and select the account which supports either ofono or tel protocol
This commit is contained in:
parent
f75b55699e
commit
3b33ffc49c
1 changed files with 24 additions and 3 deletions
|
|
@ -29,6 +29,9 @@
|
||||||
#include <TelepathyQt/ChannelClassSpec>
|
#include <TelepathyQt/ChannelClassSpec>
|
||||||
#include <TelepathyQt/ChannelFactory>
|
#include <TelepathyQt/ChannelFactory>
|
||||||
#include <TelepathyQt/Account>
|
#include <TelepathyQt/Account>
|
||||||
|
#include <TelepathyQt/AccountSet>
|
||||||
|
#include <TelepathyQt/AccountManager>
|
||||||
|
#include <TelepathyQt/PendingReady>
|
||||||
|
|
||||||
#include <klocalizedstring.h>
|
#include <klocalizedstring.h>
|
||||||
#include <qcommandlineparser.h>
|
#include <qcommandlineparser.h>
|
||||||
|
|
@ -136,11 +139,29 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
Tp::ClientRegistrarPtr registrar = Tp::ClientRegistrar::create(accountFactory, connectionFactory,
|
Tp::ClientRegistrarPtr registrar = Tp::ClientRegistrar::create(accountFactory, connectionFactory,
|
||||||
channelFactory, contactFactory);
|
channelFactory, contactFactory);
|
||||||
|
QEventLoop loop;
|
||||||
|
Tp::AccountManagerPtr manager = Tp::AccountManager::create();
|
||||||
|
Tp::PendingReady *ready = manager->becomeReady();
|
||||||
|
QObject::connect(ready, &Tp::PendingReady::finished, &loop, &QEventLoop::quit);
|
||||||
|
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||||
|
|
||||||
Tp::AccountPtr simAccount = Tp::Account::create(TP_QT_ACCOUNT_MANAGER_BUS_NAME, QStringLiteral("/org/freedesktop/Telepathy/Account/ofono/ofono/account0"),
|
Tp::AccountPtr simAccount;
|
||||||
connectionFactory, channelFactory);
|
const Tp::AccountSetPtr accountSet = manager->validAccounts();
|
||||||
|
for (const Tp::AccountPtr &account : accountSet->accounts()) {
|
||||||
|
static const QStringList supportedProtocols = {
|
||||||
|
QLatin1String("ofono"),
|
||||||
|
QLatin1String("tel"),
|
||||||
|
};
|
||||||
|
if (supportedProtocols.contains(account->protocolName())) {
|
||||||
|
simAccount = account;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (simAccount.isNull()) {
|
||||||
|
qCritical() << "Unable to get SIM account";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
const QString packagePath("org.kde.phone.dialer");
|
const QString packagePath("org.kde.phone.dialer");
|
||||||
|
|
||||||
//usually we have an ApplicationWindow here, so we do not need to create a window by ourselves
|
//usually we have an ApplicationWindow here, so we do not need to create a window by ourselves
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue