bool MediaImpl::listMedia(QValueList< KIO::UDSEntry > &list) { kdDebug(1219) << "MediaImpl::listMedia" << endl; DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call("fullList"); if(!reply.isValid()) { m_lastErrorCode = KIO::ERR_SLAVE_DEFINED; m_lastErrorMessage = i18n("The KDE mediamanager is not running."); return false; } Medium::List media = Medium::createList(reply); KIO::UDSEntry entry; Medium::List::iterator it = media.begin(); Medium::List::iterator end = media.end(); for(; it != end; ++it) { entry.clear(); createMediumEntry(entry, *it); list.append(entry); } return true; }
bool MediaImpl::statMedium(const QString &name, KIO::UDSEntry &entry) { kdDebug(1219) << "MediaImpl::statMedium: " << name << endl; DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call("properties", name); if(!reply.isValid()) { m_lastErrorCode = KIO::ERR_SLAVE_DEFINED; m_lastErrorMessage = i18n("The KDE mediamanager is not running."); return false; } Medium m = Medium::create(reply); if(m.id().isEmpty()) { entry.clear(); return false; } createMediumEntry(entry, m); return true; }
bool PropertiesPage::save() { TQStringList result; if (options.contains("ro")) result << TQString("ro=%1").arg(option_ro->isChecked() ? "true" : "false"); if (options.contains("quiet")) result << TQString("quiet=%1").arg(option_quiet->isChecked() ? "true" : "false"); if (options.contains("sync")) result << TQString("sync=%1").arg(option_sync->isChecked() ? "true" : "false"); if (options.contains("atime")) result << TQString("atime=%1").arg(option_atime->isChecked() ? "true" : "false"); if (options.contains("flush")) result << TQString("flush=%1").arg(option_flush->isChecked() ? "true" : "false"); if (options.contains("utf8")) result << TQString("utf8=%1").arg(option_utf8->isChecked() ? "true" : "false"); if (options.contains("uid")) result << TQString("uid=%1").arg(option_uid->isChecked() ? "true" : "false"); if (options.contains("shortname")) result << TQString("shortname=%1").arg(short_names[option_shortname->currentItem()]); if (options.contains("journaling")) result << TQString("journaling=%1").arg(journales[option_journaling->currentItem()]); TQString mp = option_mountpoint->text(); if (!mp.startsWith("/media/")) { KMessageBox::sorry(this, i18n("Mountpoint has to be below /media")); return false; } result << TQString("mountpoint=%1").arg(mp); result << TQString("automount=%1").arg(option_automount->isChecked() ? "true" : "false"); result << TQString("use_defaults=%1").arg(option_defaults->isChecked() ? "true" : "false"); kdDebug() << result << endl; DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call( "setMountoptions", id, result); if (reply.isValid()) return (bool)reply; else { KMessageBox::sorry(this, i18n("Saving the changes failed")); return false; } }
const Medium KFileMediaPlugin::askMedium(KFileMetaInfo &info) { DCOPRef mediamanager("kded", "mediamanager"); kdDebug() << "properties " << info.url() << endl; DCOPReply reply = mediamanager.call( "properties", info.url().url() ); if ( !reply.isValid() ) { return Medium(QString::null, QString::null); } return Medium::create(reply); }
bool MediaImpl::ensureMediumMounted(Medium &medium) { if(medium.id().isEmpty()) { m_lastErrorCode = KIO::ERR_COULD_NOT_MOUNT; m_lastErrorMessage = i18n("No such medium."); return false; } if(medium.needMounting()) { m_lastErrorCode = 0; mp_mounting = &medium; /* KIO::Job* job = KIO::mount(false, 0, medium.deviceNode(), medium.mountPoint()); job->setAutoWarningHandlingEnabled(false); connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotMountResult( KIO::Job * ) ) ); connect( job, SIGNAL( warning( KIO::Job *, const QString & ) ), this, SLOT( slotWarning( KIO::Job *, const QString & ) ) ); */ kapp->dcopClient()->connectDCOPSignal("kded", "mediamanager", "mediumChanged(QString, bool)", "mediaimpl", "slotMediumChanged(QString)", false); DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call("mount", medium.id()); if(reply.isValid()) reply.get(m_lastErrorMessage); else m_lastErrorMessage = i18n("Internal Error"); if(!m_lastErrorMessage.isEmpty()) m_lastErrorCode = KIO::ERR_SLAVE_DEFINED; else { qApp->eventLoop()->enterLoop(); } mp_mounting = 0L; kapp->dcopClient()->disconnectDCOPSignal("kded", "mediamanager", "mediumChanged(QString, bool)", "mediaimpl", "slotMediumChanged(QString)"); return m_lastErrorCode == 0; } return true; }
const Medium MediaImpl::findMediumByName(const QString &name, bool &ok) { DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call("properties", name); if(reply.isValid()) { ok = true; } else { m_lastErrorCode = KIO::ERR_SLAVE_DEFINED; m_lastErrorMessage = i18n("The KDE mediamanager is not running."); ok = false; } return Medium::create(reply); }
bool MediaImpl::setUserLabel(const QString &name, const QString &label) { kdDebug(1219) << "MediaImpl::setUserLabel: " << name << ", " << label << endl; DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call("nameForLabel", label); if(!reply.isValid()) { m_lastErrorCode = KIO::ERR_SLAVE_DEFINED; m_lastErrorMessage = i18n("The KDE mediamanager is not running."); return false; } else { QString returned_name = reply; if(!returned_name.isEmpty() && returned_name != name) { m_lastErrorCode = KIO::ERR_DIR_ALREADY_EXIST; m_lastErrorMessage = i18n("This media name already exists."); return false; } } reply = mediamanager.call("setUserLabel", name, label); if(!reply.isValid()) { m_lastErrorCode = KIO::ERR_SLAVE_DEFINED; m_lastErrorMessage = i18n("The KDE mediamanager is not running."); return false; } else { return true; } }
bool MediaImpl::statMediumByLabel(const QString &label, KIO::UDSEntry &entry) { kdDebug(1219) << "MediaImpl::statMediumByLabel: " << label << endl; DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call("nameForLabel", label); if(!reply.isValid()) { m_lastErrorCode = KIO::ERR_SLAVE_DEFINED; m_lastErrorMessage = i18n("The KDE mediamanager is not running."); return false; } QString name = reply; if(name.isEmpty()) { entry.clear(); return false; } return statMedium(name, entry); }
PropertiesPage::PropertiesPage(TQWidget* parent, const TQString &_id) : PropertiesPageGUI(parent), id(_id) { kdDebug() << "props page " << id << endl; DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call( "mountoptions", id); TQStringList list; if (reply.isValid()) list = reply; if (list.size()) { kdDebug() << "list " << list << endl; for (TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { TQString key = (*it).left((*it).find('=')); TQString value = (*it).mid((*it).find('=') + 1); kdDebug() << "key '" << key << "' value '" << value << "'\n"; options[key] = value; } if (!options.contains("ro")) option_ro->hide(); else option_ro->setChecked(options["ro"] == "true"); connect( option_ro, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); if (!options.contains("quiet")) option_quiet->hide(); else option_quiet->setChecked(options["quiet"] == "true"); connect( option_quiet, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); if (!options.contains("sync")) option_sync->hide(); else option_sync->setChecked(options["sync"] == "true"); connect( option_sync, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); if (!options.contains("atime")) option_atime->hide(); else option_atime->setChecked(options["atime"] == "true"); connect( option_atime, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); if (!options.contains("flush")) option_flush->hide(); else option_flush->setChecked(options["flush"] == "true"); connect( option_flush, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); if (!options.contains("utf8")) option_utf8->hide(); else option_utf8->setChecked(options["utf8"] == "true"); connect( option_utf8, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); if (!options.contains("uid")) option_uid->hide(); else option_uid->setChecked(options["uid"] == "true"); connect( option_uid, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); if (!options.contains("shortname")) { option_shortname->hide(); text_shortname->hide(); } else { for (int index = 0; short_names[index]; ++index) if (options["shortname"] == short_names[index]) { option_shortname->setCurrentItem(index); break; } connect( option_shortname, TQT_SIGNAL( activated(int) ), TQT_SIGNAL( changed() ) ); } if (!options.contains("journaling")) { text_journaling->hide(); option_journaling->hide(); } else { for (int index = 0; journales[index]; ++index) if (options["journaling"] == journales[index]) { option_journaling->setCurrentItem(index); break; } connect( option_journaling, TQT_SIGNAL( activated(int) ), TQT_SIGNAL( changed() ) ); } label_filesystem->setText(i18n("Filesystem: %1").arg(options["filesystem"])); option_mountpoint->setText(options["mountpoint"]); connect( option_mountpoint, TQT_SIGNAL( textChanged( const TQString &) ), TQT_SIGNAL( changed() ) ); option_automount->setChecked(options["automount"] == "true"); connect( option_automount, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); bool has_groupbox_specific = true; if (!options.contains("journaling") && !options.contains("shortname") && !options.contains("uid") && !options.contains("utf8") && !options.contains("flush")) { groupbox_specific->hide(); has_groupbox_specific = false; } // The order is important - we want groupboxes to hide automatically depending on use_defaults // but don't want to emit changed() until user actually changes something. connect( option_defaults, TQT_SIGNAL( toggled(bool) ), groupbox_generic, SLOT( setHidden(bool) ) ); if (has_groupbox_specific) connect( option_defaults, TQT_SIGNAL( toggled(bool) ), groupbox_specific, SLOT( setHidden(bool) ) ); option_defaults->setChecked(options["use_defaults"] == "true"); connect( option_defaults, TQT_SIGNAL( stateChanged(int) ), TQT_SIGNAL( changed() ) ); } else { groupbox_generic->setEnabled(false); groupbox_specific->setEnabled(false); label_filesystem->hide(); } }
bool ClearAllCookiesAction::action() { QDBusInterface mediamanager(QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/kcookiejar" ), QLatin1String( "org.kde.KCookieServer" )); QDBusReply<void> reply = mediamanager.call(QLatin1String( "deleteAllCookies" )); return reply.isValid(); }