~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/lib/audiosettingsmodel.cpp

  • Committer: Package Import Robot
  • Author(s): Francois Marier, Francois Marier, Mark Purcell
  • Date: 2014-10-18 15:08:50 UTC
  • mfrom: (1.1.12)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20141018150850-2exfk34ckb15pcwi
Tags: 1.4.1-0.1
[ Francois Marier ]
* Non-maintainer upload
* New upstream release (closes: #759576, #741130)
  - debian/rules +PJPROJECT_VERSION := 2.2.1
  - add upstream patch to fix broken TLS support
  - add patch to fix pjproject regression

[ Mark Purcell ]
* Build-Depends:
  - sflphone-daemon + libavformat-dev, libavcodec-dev, libswscale-dev,
  libavdevice-dev, libavutil-dev
  - sflphone-gnome + libclutter-gtk-1.0-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 m_pOutputDeviceModel(nullptr)
29
29
{
30
30
   m_pRingtoneDeviceModel = new RingtoneDeviceModel (this);
 
31
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
 
32
   connect(&configurationManager,SIGNAL(volumeChanged(QString,double)),this,SLOT(slotVolumeChanged(QString,double)));
31
33
}
32
34
 
33
35
///Destructor
166
168
   return DBus::ConfigurationManager::instance().isCaptureMuted();
167
169
}
168
170
 
 
171
///Set where the call recordings will be saved
 
172
void AudioSettingsModel::setRecordPath(const QUrl& path)
 
173
{
 
174
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
 
175
   configurationManager.setRecordPath(path.toString());
 
176
}
 
177
 
 
178
///Return the path where recordings are going to be saved
 
179
QUrl AudioSettingsModel::recordPath() const
 
180
{
 
181
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
 
182
   return QUrl(configurationManager.getRecordPath());
 
183
}
 
184
 
 
185
///are all calls recorded by default
 
186
bool AudioSettingsModel::isAlwaysRecording() const
 
187
{
 
188
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
 
189
   return configurationManager.getIsAlwaysRecording();
 
190
}
 
191
 
 
192
///Set if all calls needs to be recorded
 
193
void AudioSettingsModel::setAlwaysRecording(bool record)
 
194
{
 
195
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
 
196
   configurationManager.setIsAlwaysRecording   ( record );
 
197
}
 
198
 
169
199
int AudioSettingsModel::playbackVolume() const
170
200
{
171
201
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
204
234
   return DBus::ConfigurationManager::instance().isDtmfMuted();
205
235
}
206
236
 
 
237
///Called when the volume change for external reasons
 
238
void AudioSettingsModel::slotVolumeChanged(const QString& str, double volume)
 
239
{
 
240
   if (str == AudioSettingsModel::DeviceKey::CAPTURE)
 
241
      emit captureVolumeChanged(static_cast<int>(volume*100));
 
242
   else if (str == AudioSettingsModel::DeviceKey::PLAYBACK)
 
243
      emit playbackVolumeChanged(static_cast<int>(volume*100));
 
244
   else
 
245
      qDebug() << "Unknown audio device" << str;
 
246
}
 
247
 
 
248
 
207
249
/****************************************************************
208
250
 *                                                              *
209
251
 *                        AlsaPluginModel                       *
355
397
{
356
398
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
357
399
   const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex();
358
 
   const int idx = currentDevices[AudioSettingsModel::DeviceIndex::INPUT].toInt();
 
400
   const int idx = currentDevices[static_cast<int>(AudioSettingsModel::DeviceIndex::INPUT)].toInt();
359
401
   if (idx >= m_lDeviceList.size())
360
402
      return QModelIndex();
361
403
   return index(idx,0);
446
488
{
447
489
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
448
490
   const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex();
449
 
   const int         idx            = currentDevices[AudioSettingsModel::DeviceIndex::OUTPUT].toInt();
 
491
   const int         idx            = currentDevices[static_cast<int>(AudioSettingsModel::DeviceIndex::OUTPUT)].toInt();
450
492
 
451
493
   if (idx >= m_lDeviceList.size())
452
494
      return QModelIndex();
486
528
///Constructor
487
529
AudioManagerModel::AudioManagerModel(QObject* parent) : QAbstractListModel(parent)
488
530
{
489
 
   m_lDeviceList << "ALSA" << "Pulse Audio";
 
531
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
 
532
   const QStringList managers = configurationManager.getSupportedAudioManagers();
 
533
   foreach(const QString& m,managers) {
 
534
      if (m == ManagerName::PULSEAUDIO) {
 
535
         m_lSupportedManagers << Manager::PULSE;
 
536
         m_lDeviceList << "Pulse Audio";
 
537
      }
 
538
      else if (m == ManagerName::ALSA) {
 
539
         m_lSupportedManagers << Manager::ALSA;
 
540
         m_lDeviceList<< "ALSA";
 
541
      }
 
542
      else if (m == ManagerName::JACK) {
 
543
         m_lSupportedManagers << Manager::JACK;
 
544
         m_lDeviceList<< "Jack";
 
545
      }
 
546
      else
 
547
         qDebug() << "Unsupported audio manager" << m;
 
548
   }
490
549
}
491
550
 
492
551
///Destructor
535
594
 * Return the current audio manager
536
595
 * @warning Changes to the current index model will invalid Input/Output/Ringtone devices models
537
596
 */
538
 
QModelIndex AudioManagerModel::currentManager() const
 
597
QModelIndex AudioManagerModel::currentManagerIndex() const
539
598
{
540
599
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
541
600
   const QString manager = configurationManager.getAudioManager();
543
602
         return index((int)Manager::PULSE,0);
544
603
      else if (manager == ManagerName::ALSA)
545
604
         return index((int)Manager::ALSA,0);
 
605
      else if (manager == ManagerName::JACK)
 
606
         return index((int)Manager::JACK,0);
546
607
      return QModelIndex();
547
608
}
548
609
 
 
610
AudioManagerModel::Manager AudioManagerModel::currentManager() const
 
611
{
 
612
   return m_lSupportedManagers[currentManagerIndex().row()];
 
613
}
 
614
 
549
615
///Set current audio manager
550
 
void AudioManagerModel::setCurrentManager(const QModelIndex& idx)
 
616
bool AudioManagerModel::setCurrentManager(const QModelIndex& idx)
551
617
{
552
618
   if (!idx.isValid())
553
 
      return;
 
619
      return false;
554
620
 
 
621
   bool ret = true;
555
622
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
556
 
   switch (static_cast<Manager>(idx.row())) {
 
623
   switch (m_lSupportedManagers[idx.row()]) {
557
624
      case Manager::PULSE:
558
 
         configurationManager.setAudioManager(ManagerName::PULSEAUDIO);
 
625
         ret = configurationManager.setAudioManager(ManagerName::PULSEAUDIO);
559
626
         AudioSettingsModel::instance()->reload();
560
627
         break;
561
628
      case Manager::ALSA:
562
 
         configurationManager.setAudioManager(ManagerName::ALSA);
 
629
         ret = configurationManager.setAudioManager(ManagerName::ALSA);
 
630
         AudioSettingsModel::instance()->reload();
 
631
         break;
 
632
      case Manager::JACK:
 
633
         ret = configurationManager.setAudioManager(ManagerName::JACK);
563
634
         AudioSettingsModel::instance()->reload();
564
635
         break;
565
636
   };
 
637
   if (!ret) {
 
638
      const QModelIndex& newIdx = currentManagerIndex();
 
639
      emit currentManagerChanged(currentManager());
 
640
      emit currentManagerChanged(newIdx);
 
641
      emit currentManagerChanged(newIdx.row());
 
642
   }
 
643
   return ret;
566
644
}
567
645
 
568
646
///QCombobox -> QModelIndex shim
569
 
void AudioManagerModel::setCurrentManager(int idx)
 
647
bool AudioManagerModel::setCurrentManager(int idx)
570
648
{
571
 
   setCurrentManager(index(idx,0));
 
649
   return setCurrentManager(index(idx,0));
572
650
}
573
651
 
574
652
/****************************************************************
631
709
{
632
710
   ConfigurationManagerInterface& configurationManager = DBus::ConfigurationManager::instance();
633
711
   const QStringList currentDevices = configurationManager.getCurrentAudioDevicesIndex();
634
 
   const int         idx            = currentDevices[AudioSettingsModel::DeviceIndex::RINGTONE].toInt();
 
712
   const int         idx            = currentDevices[static_cast<int>(AudioSettingsModel::DeviceIndex::RINGTONE)].toInt();
635
713
   if (idx >= m_lDeviceList.size())
636
714
      return QModelIndex();
637
715
   return index(idx,0);