Ejemplo n.º 1
0
bool
PlatformUdisks2::udisk2Enabled()
{
    QDBusInterface remoteApp("org.freedesktop.UDisks2",
                             "/org/freedesktop/UDisks2/Manager",
                             "org.freedesktop.UDisks2.Manager",
                             QDBusConnection::systemBus());
    QVariant reply = remoteApp.property("Version");
    if (reply.isNull())
        return false;
    return true;
}
Ejemplo n.º 2
0
QVariantMap
PlatformUdisks2::getBlockDeviceProperties(const QString &blockDevice)
{
    QVariantMap properties;

    QDBusInterface remoteApp("org.freedesktop.UDisks2",
                             blockDevice,
                             "org.freedesktop.UDisks2.Block",
                             QDBusConnection::systemBus());
    QDBusObjectPath objectPath = qvariant_cast<QDBusObjectPath>(remoteApp.property("Drive"));
    QString path = objectPath.path();
    properties.insert("drivePath", path);
    properties.insert("path", QString(remoteApp.property("Device").toByteArray()));
    properties.insert("size", remoteApp.property("Size"));
    return properties;
}
Ejemplo n.º 3
0
QVariantMap
PlatformUdisks2::getDriveProperties(const QString &drivePath)
{
    QVariantMap properties;
    QDBusInterface remoteApp("org.freedesktop.UDisks2",
                             drivePath,
                             "org.freedesktop.UDisks2.Drive",
                             QDBusConnection::systemBus());
    properties.insert("removable", remoteApp.property("Removable"));
    properties.insert("vendor", remoteApp.property("Vendor"));
    properties.insert("serial", remoteApp.property("Serial"));
    properties.insert("model", remoteApp.property("Model"));

    if (remoteApp.property("ConnectionBus").toString().toLower() == "usb")
        properties.insert("isUSB", true);
    else
        properties.insert("isUSB", false);


    return properties;
}
Ejemplo n.º 4
0
int runKMyMoney(KApplication *a, KStartupLogo *splash)
{
  int rc = 0;
  do {
    if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kmymoney")) {
      const QList<QString> instances = kmymoney->instanceList();
      if (instances.count() > 0) {

        // If the user launches a second copy of the app and includes a file to
        // open, they are probably attempting a "WebConnect" session.  In this case,
        // we'll check to make sure it's an importable file that's passed in, and if so, we'll
        // notify the primary instance of the file and kill ourselves.

        if (args->count() > 0) {
          KUrl url = args->url(0);
          if (kmymoney->isImportableFile(url.path())) {
            // if there are multiple instances, we'll send this to the first one
            QString primary = instances[0];

            // send a message to the primary client to import this file
            QDBusInterface remoteApp(primary, "/KMymoney", "org.kde.kmymoney");
            remoteApp.call("webConnect", url.path(), kapp->startupId());

            // Before we delete the application, we make sure that we destroy all
            // widgets by running the event loop for some time to catch all those
            // widgets that are requested to be destroyed using the deleteLater() method.
            QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 10);

            delete kmymoney;
            delete splash;
            break;
          }
        }

        if (KMessageBox::questionYesNo(0, i18n("Another instance of KMyMoney is already running. Do you want to quit?")) == KMessageBox::Yes) {
          rc = 1;
          delete kmymoney;
          delete splash;
          break;
        }
      }
    } else {
      qDebug("D-Bus registration failed. Some functions are not available.");
    }
    kmymoney->show();
    kmymoney->centralWidget()->setEnabled(false);

    delete splash;

    // force complete paint of widgets
    qApp->processEvents();

    QString importfile;
    KUrl url;
    // make sure, we take the file provided on the command
    // line before we go and open the last one used
    if (args->count() > 0) {
      url = args->url(0);

      // Check to see if this is an importable file, as opposed to a loadable
      // file.  If it is importable, what we really want to do is load the
      // last used file anyway and then immediately import this file.  This
      // implements a "web connect" session where there is not already an
      // instance of the program running.

      if (kmymoney->isImportableFile(url.path())) {
        importfile = url.path();
        url = kmymoney->readLastUsedFile();
      }

    } else {
      url = kmymoney->readLastUsedFile();
    }

    KTipDialog::showTip(kmymoney, "", false);
    if (url.isValid() && !args->isSet("n")) {
      kmymoney->slotFileOpenRecent(url);
    } else if (KMyMoneyGlobalSettings::firstTimeRun()) {
      kmymoney->slotFileNew();
    }
    KMyMoneyGlobalSettings::setFirstTimeRun(false);

    if (! importfile.isEmpty())
      kmymoney->webConnect(importfile, kapp->startupId());

    if (kmymoney != 0) {
      kmymoney->updateCaption();
      args->clear();
      kmymoney->centralWidget()->setEnabled(true);
      rc = a->exec();
    }
  } while (0);
  return rc;
}