~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to src/devices/devicemanager.cpp

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "devicemanager.h"
22
22
#include "devicestatefiltermodel.h"
23
23
#include "filesystemdevice.h"
 
24
#include "core/logging.h"
24
25
#include "core/musicstorage.h"
25
26
#include "core/taskmanager.h"
26
27
#include "core/utilities.h"
27
28
#include "ui/iconloader.h"
28
29
 
 
30
#ifdef HAVE_AUDIOCD
 
31
#  include "cddalister.h"
 
32
#  include "cddadevice.h"
 
33
#endif
 
34
 
29
35
#ifdef Q_OS_DARWIN
30
36
#  include "macdevicelister.h"
31
37
#endif
182
188
  connected_devices_model_ = new DeviceStateFilterModel(this);
183
189
  connected_devices_model_->setSourceModel(this);
184
190
 
 
191
  // CD devices are detected via the DiskArbitration framework instead on Darwin.
 
192
#if defined(HAVE_AUDIOCD) && !defined(Q_OS_DARWIN)
 
193
  AddLister(new CddaLister);
 
194
#endif
185
195
#ifdef HAVE_DEVICEKIT
186
196
  AddLister(new DeviceKitLister);
187
197
#endif
202
212
 
203
213
  AddDeviceClass<FilesystemDevice>();
204
214
 
 
215
#ifdef HAVE_AUDIOCD
 
216
  AddDeviceClass<CddaDevice>();
 
217
#endif
 
218
 
205
219
#ifdef HAVE_LIBGPOD
206
220
  AddDeviceClass<GPodDevice>();
207
221
#endif
240
254
 
241
255
      if (info.size_)
242
256
        text = text + QString(" (%1)").arg(Utilities::PrettySize(info.size_));
 
257
      if (info.device_.get())
 
258
        info.device_->Refresh();
243
259
      return text;
244
260
    }
245
261
 
246
262
    case Qt::DecorationRole: {
247
263
      QPixmap pixmap = info.icon_.pixmap(kDeviceIconSize);
248
264
 
249
 
      if (!info.BestBackend()->lister_) {
 
265
      if (info.backends_.isEmpty() || !info.BestBackend()->lister_) {
250
266
        // Disconnected but remembered
251
267
        QPainter p(&pixmap);
252
268
        p.drawPixmap(kDeviceIconSize - kDeviceIconOverlaySize,
302
318
      if (!info.device_) {
303
319
        if (info.database_id_ == -1 &&
304
320
            !info.BestBackend()->lister_->DeviceNeedsMount(info.BestBackend()->unique_id_)) {
305
 
          boost::scoped_ptr<QMessageBox> dialog(new QMessageBox(
306
 
              QMessageBox::Information, tr("Connect device"),
307
 
              tr("This is the first time you have connected this device.  Clementine will now scan the device to find music files - this may take some time."),
308
 
              QMessageBox::Cancel));
309
 
          QPushButton* connect =
310
 
              dialog->addButton(tr("Connect device"), QMessageBox::AcceptRole);
311
 
          dialog->exec();
312
 
 
313
 
          if (dialog->clickedButton() != connect)
314
 
            return QVariant();
 
321
 
 
322
          if (info.BestBackend()->lister_->AskForScan(info.BestBackend()->unique_id_)) {
 
323
            boost::scoped_ptr<QMessageBox> dialog(new QMessageBox(
 
324
                QMessageBox::Information, tr("Connect device"),
 
325
                tr("This is the first time you have connected this device.  Clementine will now scan the device to find music files - this may take some time."),
 
326
                QMessageBox::Cancel));
 
327
            QPushButton* connect =
 
328
                dialog->addButton(tr("Connect device"), QMessageBox::AcceptRole);
 
329
            dialog->exec();
 
330
 
 
331
            if (dialog->clickedButton() != connect)
 
332
              return QVariant();
 
333
          }
315
334
        }
316
335
 
317
336
        const_cast<DeviceManager*>(this)->Connect(index.row());
389
408
void DeviceManager::PhysicalDeviceAdded(const QString &id) {
390
409
  DeviceLister* lister = qobject_cast<DeviceLister*>(sender());
391
410
 
392
 
  qDebug() << "Device added:" << id;
 
411
  qLog(Info) << "Device added:" << id;
393
412
 
394
413
  // Do we have this device already?
395
414
  int i = FindDeviceById(id);
438
457
void DeviceManager::PhysicalDeviceRemoved(const QString &id) {
439
458
  DeviceLister* lister = qobject_cast<DeviceLister*>(sender());
440
459
 
441
 
  qDebug() << "Device removed:" << id;
 
460
  qLog(Info) << "Device removed:" << id;
442
461
 
443
462
  int i = FindDeviceById(id);
444
463
  if (i == -1) {
533
552
  // Take the first URL that we have a handler for
534
553
  QUrl device_url;
535
554
  foreach (const QUrl& url, urls) {
536
 
    qDebug() << "Connecting" << url;
 
555
    qLog(Info) << "Connecting" << url;
537
556
 
538
557
    // Find a device class for this URL's scheme
539
558
    if (device_classes_.contains(url.scheme())) {
578
597
  ret.reset(static_cast<ConnectedDevice*>(instance));
579
598
 
580
599
  if (!ret) {
581
 
    qWarning() << "Could not create device for" << device_url.toString();
 
600
    qLog(Warning) << "Could not create device for" << device_url.toString();
582
601
  } else {
583
602
    ret->Init();
584
603