~phablet-team/telephony-service/qml-start-chat

« back to all changes in this revision

Viewing changes to libtelephonyservice/telepathyhelper.cpp

merge parent

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
 
97
97
    mClientRegistrar = Tp::ClientRegistrar::create(mAccountManager);
98
98
    connect(GreeterContacts::instance(), SIGNAL(phoneSettingsChanged(QString)), this, SLOT(onPhoneSettingsChanged(QString)));
 
99
    connect(GreeterContacts::instance(), SIGNAL(soundSettingsChanged(QString)), this, SLOT(onPhoneSettingsChanged(QString)));
99
100
    connect(&mFlightModeInterface, SIGNAL(FlightModeChanged(bool)), this, SIGNAL(flightModeChanged()));
100
101
 
101
102
    mMmsEnabled = GreeterContacts::instance()->mmsEnabled();
329
330
    if (name.isEmpty()) {
330
331
        name = "TelephonyPluginObserver";
331
332
    }
332
 
 
333
333
    if (mChannelObserver) {
334
334
        unregisterClient(mChannelObserver);
335
335
    }
337
337
    mChannelObserver = new ChannelObserver(this);
338
338
    mChannelObserverPtr = Tp::AbstractClientPtr(mChannelObserver);
339
339
    if (registerClient(mChannelObserver, name)) {
340
 
        // messages
341
 
        connect(mChannelObserver, SIGNAL(textChannelAvailable(Tp::TextChannelPtr)),
342
 
                ChatManager::instance(), SLOT(onTextChannelAvailable(Tp::TextChannelPtr)));
 
340
        // we don't connect managers in handler, as they query the handler and cause a deadlock
 
341
        if (QCoreApplication::applicationName() != "telephony-service-handler") {
 
342
            // messages
 
343
            connect(mChannelObserver, SIGNAL(textChannelAvailable(Tp::TextChannelPtr)),
 
344
                    ChatManager::instance(), SLOT(onTextChannelAvailable(Tp::TextChannelPtr)));
343
345
 
344
 
        // calls
345
 
        connect(mChannelObserver, SIGNAL(callChannelAvailable(Tp::CallChannelPtr)),
346
 
                CallManager::instance(), SLOT(onCallChannelAvailable(Tp::CallChannelPtr)));
 
346
            // calls
 
347
            connect(mChannelObserver, SIGNAL(callChannelAvailable(Tp::CallChannelPtr)),
 
348
                    CallManager::instance(), SLOT(onCallChannelAvailable(Tp::CallChannelPtr)));
 
349
        }
347
350
 
348
351
        Q_EMIT channelObserverCreated(mChannelObserver);
349
352
    }
467
470
 
468
471
void TelepathyHelper::onNewAccount(const Tp::AccountPtr &account)
469
472
{
 
473
    if (!ProtocolManager::instance()->protocolByName(account->protocolName())) {
 
474
       return;
 
475
    }
470
476
    AccountEntry *accountEntry = AccountEntryFactory::createEntry(account, this);
471
477
    setupAccountEntry(accountEntry);
472
478
    mAccounts.append(accountEntry);
586
592
    return false;
587
593
}
588
594
 
 
595
bool TelepathyHelper::dialpadSoundsEnabled() const
 
596
{
 
597
    return GreeterContacts::instance()->dialpadSoundsEnabled();
 
598
}
 
599
 
 
600
void TelepathyHelper::setDialpadSoundsEnabled(bool enabled)
 
601
{
 
602
    GreeterContacts::instance()->setDialpadSoundsEnabled(enabled);
 
603
}
 
604
 
589
605
void TelepathyHelper::onPhoneSettingsChanged(const QString &key)
590
606
{
591
607
    if (key == "DefaultSimForMessages") {
607
623
        mDefaultMessagingAccount = NULL;
608
624
        Q_EMIT defaultMessagingAccountChanged();
609
625
    } else if (key == "DefaultSimForCalls") {
 
626
        // if there is a VOIP account configured, use that by default
 
627
        // FIXME: revisit the topic and maybe discuss with designers what is best here?
 
628
        Q_FOREACH(AccountEntry *account, TelepathyHelper::instance()->qmlVoiceAccounts()->activeAccounts()) {
 
629
            if (account->type() != AccountEntry::PhoneAccount) {
 
630
                mDefaultCallAccount = account;
 
631
                Q_EMIT defaultCallAccountChanged();
 
632
                return;
 
633
            }
 
634
        }
 
635
 
 
636
        // if no VOIP account, get the default modem setting
610
637
        QString defaultSim = GreeterContacts::instance()->defaultSimForCalls();
611
638
        if (defaultSim == "ask") {
612
639
            mDefaultCallAccount = NULL;
630
657
    } else if (key == "SimNames") {
631
658
        mSimNames = GreeterContacts::instance()->simNames();
632
659
        Q_EMIT simNamesChanged();
 
660
    } else if (key == "DialpadSoundsEnabled") {
 
661
        Q_EMIT dialpadSoundsEnabledChanged();
633
662
    }
634
663
}
635
664