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; }
void MediaImpl::createMediumEntry(KIO::UDSEntry &entry, const Medium &medium) { kdDebug(1219) << "MediaProtocol::createMedium" << endl; QString url = "media:/" + medium.name(); kdDebug(1219) << "url = " << url << ", mime = " << medium.mimeType() << endl; entry.clear(); addAtom(entry, KIO::UDS_URL, 0, url); QString label = KIO::encodeFileName(medium.prettyLabel()); addAtom(entry, KIO::UDS_NAME, 0, label); addAtom(entry, KIO::UDS_FILE_TYPE, S_IFDIR); addAtom(entry, KIO::UDS_MIME_TYPE, 0, medium.mimeType()); addAtom(entry, KIO::UDS_GUESSED_MIME_TYPE, 0, "inode/directory"); if(!medium.iconName().isEmpty()) { addAtom(entry, KIO::UDS_ICON_NAME, 0, medium.iconName()); } else { QString mime = medium.mimeType(); QString icon = KMimeType::mimeType(mime)->icon(mime, false); addAtom(entry, KIO::UDS_ICON_NAME, 0, icon); } if(medium.needMounting()) { addAtom(entry, KIO::UDS_ACCESS, 0400); } else { KURL url = medium.prettyBaseURL(); entry += extractUrlInfos(url); } }