void KJumpingCube::saveGame(bool saveAs) { if(saveAs || gameURL.isEmpty()) { int result=0; KURL url; do { url = KFileDialog::getSaveURL(gameURL.url(),"*.kjc",this,0); if(url.isEmpty()) return; // check filename QRegExp pattern("*.kjc",true,true); if(!pattern.exactMatch(url.filename())) { url.setFileName( url.filename()+".kjc" ); } if(KIO::NetAccess::exists(url,false,this)) { QString mes=i18n("The file %1 exists.\n" "Do you want to overwrite it?").arg(url.url()); result = KMessageBox::warningContinueCancel(this, mes, QString::null, i18n("Overwrite")); if(result==KMessageBox::Cancel) return; } } while(result==KMessageBox::No); gameURL=url; } KTempFile tempFile; tempFile.setAutoDelete(true); KSimpleConfig config(tempFile.name()); config.setGroup("KJumpingCube"); config.writeEntry("Version",KJC_VERSION); config.setGroup("Game"); view->saveGame(&config); config.sync(); if(KIO::NetAccess::upload( tempFile.name(),gameURL,this )) { QString s=i18n("game saved as %1"); s=s.arg(gameURL.url()); statusBar()->message(s,MESSAGE_TIME); } else { KMessageBox::sorry(this,i18n("There was an error in saving file\n%1").arg(gameURL.url())); } }
void KSubtitleRipperView::createSRT() { // TODO check if srttool is executable if ( !askIfModified() ) return; KURL url = KFileDialog::getSaveURL( srtName, "*.srt|" + i18n("SRT Subtitles"), this, i18n( "Save Subtitles" ) ); if ( url.isEmpty() || !url.isValid() ) return; /*QString extension = QFileInfo( url.path() ).extension( false ).lower(); if ( extension != "srt" && ( !url.isLocalFile() || !QFile::exists( url.path() ) ) ) url = url.url() + ".srt"; */ QString text = "A file named \"%1\" already exists.\nAre you sure you want to overwrite it?"; if ( url.isLocalFile() && QFile::exists( url.path() ) && KMessageBox::warningContinueCancel( this, i18n( text ).arg( url.filename() ), i18n( "Overwrite File?" ), i18n( "Overwrite" ) ) == KMessageBox::Cancel ) return; newSrt = new KURL( url ); if ( url.isLocalFile() ) { tmpSrt = QString::null; CreateSRT *createSrt = new CreateSRT( project, url.path() ); connect(createSrt, SIGNAL(success( CreateSRT* )), this, SLOT(createSrtSuccess( CreateSRT* ) ) ); connect(createSrt, SIGNAL(failed( CreateSRT*, const QString& )), this, SLOT(createSrtFailed( CreateSRT*, const QString& ) ) ); createSrt->saveSRT(); } else {
void MetabarFunctions::handleRequest(const KURL &url) { QString function = url.host(); QStringList params = QStringList::split(',', url.filename()); if(function == "toggle") { if(params.size() == 1) { toggle(params.first()); } } else if(function == "adjustSize") { if(params.size() == 1) { adjustSize(params.first()); } } else if(function == "show") { if(params.size() == 1) { show(params.first()); } } else if(function == "hide") { if(params.size() == 1) { hide(params.first()); } } }
void KBabelMailer::sendOneFile( const KURL& url) { #if KDE_IS_VERSION( 3, 5, 0) const KURL localUrl( KIO::NetAccess::mostLocalURL( url, m_parent ) ); #else const KURL localUrl( url ); #endif if ( localUrl.isLocalFile() ) { sendOneFile( localUrl.path() ); return; } if (!singleFileCompression) { QString fileName( url.filename() ); if ( fileName.isEmpty() ) { fileName = "attachment"; } // ### TODO: the current implementation has the default to possibly overwrite an already existing temporary file QString tempName( m_tempDir.name() ); tempName += fileName; if ( KIO::NetAccess::download( url, tempName, m_parent ) ) kapp->invokeMailer("", "", "", "", "", "", fileName); else { KMessageBox::error( m_parent, i18n("Error while trying to download file %1.").arg( url.prettyURL() ) ); } } else { const QString archive ( createArchive( QStringList( url.url() ), url.filename() ) ); if ( !archive.isEmpty() ) { kapp->invokeMailer("", "", "", "", "", "", archive); } } }
void Groupwise::get(const KURL &url) { kdDebug(7000) << "Groupwise::get()" << endl; kdDebug(7000) << " URL: " << url.url() << endl; #if 1 kdDebug(7000) << " Path: " << url.path() << endl; kdDebug(7000) << " Query: " << url.query() << endl; kdDebug(7000) << " Protocol: " << url.protocol() << endl; kdDebug(7000) << " Filename: " << url.filename() << endl; #endif mimeType("text/plain"); QString path = url.path(); debugMessage("Path: " + path); if(path.contains("/freebusy")) { getFreeBusy(url); } else if(path.contains("/calendar")) { getCalendar(url); } else if(path.contains("/addressbook")) { if(url.query().contains("update=true")) updateAddressbook(url); else getAddressbook(url); } else { QString error = i18n("Unknown path. Known paths are '/freebusy/', " "'/calendar/' and '/addressbook/'.") + QString(" path was %1").arg(url.url()); errorMessage(error); } kdDebug(7000) << "Groupwise::get() done" << endl; }
bool PlaylistSaver::metalist(const KURL &url) { kdDebug(66666) << k_funcinfo << "url=" << url.url() << endl; QString end=url.filename().right(3).lower(); /* if (end=="mp3" || end=="ogg") // we want to download streams only { kdDebug(66666) << k_funcinfo << "I can only load playlists" << endl; return false; } */ /* .wax audio/x-ms-wax Metafiles that reference Windows Media files with the .asf, .wma or .wax file extensions. .wvx video/x-ms-wvx Metafiles that reference Windows Media files with the .wma, .wmv, .wvx or .wax file extensions. .asx video/x-ms-asf Metafiles that reference Windows Media files with the .wma, .wax, .wmv, .wvx, .asf, or .asx file extensions. */ // it's actually a stream! if (end!="pls" && end!="m3u" && end!="wax" && // windows mediaplayer metafile end!="wvx" && // windows mediaplayer metafile end!="asx" && // windows mediaplayer metafile url.protocol().lower()=="http") { KMimeType::Ptr mimetype = KMimeType::findByURL(url); QString type=mimetype->name(); if (type!="application/octet-stream") return false; QMap<QString,QString> map; map["playObject"]="Arts::StreamPlayObject"; map["title"] = i18n("Stream from %1").arg(url.host()); KURL u(url); if (!u.hasPath()) u.setPath("/"); map["stream_"] = map["url"] = u.url(); reset(); readItem(map); return true; } // it is a pls, m3u or ms-media-player file by now if(loadXML(url, XMLPlaylist)) return true; if(loadXML(url,ASX)) return true; if(loadPLS(url)) return true; if(loadM3U(url)) return true; return false; }
void DolphinContextMenu::openItemContextMenu() { // Parts of the following code have been taken // from the class KonqOperations located in // libqonq/konq_operations.h of Konqueror. // (Copyright (C) 2000 David Faure <*****@*****.**>) assert(m_fileInfo != 0); KPopupMenu* popup = new KPopupMenu(m_dolphinView); Dolphin& dolphin = Dolphin::mainWin(); const KURL::List urls = m_dolphinView->selectedURLs(); const KURL& url = dolphin.activeView()->url(); if (url.protocol() == "trash") { popup->insertItem(i18n("&Restore"), restoreID); } // insert 'Cut', 'Copy' and 'Paste' const KStdAction::StdAction actionNames[] = { KStdAction::Cut, KStdAction::Copy, KStdAction::Paste }; const int count = sizeof(actionNames) / sizeof(KStdAction::StdAction); for (int i = 0; i < count; ++i) { KAction* action = dolphin.actionCollection()->action(KStdAction::stdName(actionNames[i])); if (action != 0) { action->plug(popup); } } popup->insertSeparator(); // insert 'Rename' KAction* renameAction = dolphin.actionCollection()->action("rename"); renameAction->plug(popup); // insert 'Move to Trash' for local URLs, otherwise insert 'Delete' if (url.isLocalFile()) { KAction* moveToTrashAction = dolphin.actionCollection()->action("move_to_trash"); moveToTrashAction->plug(popup); } else { KAction* deleteAction = dolphin.actionCollection()->action("delete"); deleteAction->plug(popup); } // insert 'Bookmark this folder...' entry // urls is a list of selected items, so insert boolmark menu if // urls contains only one item, i.e. no multiple selection made if (m_fileInfo->isDir() && (urls.count() == 1)) { popup->insertItem(i18n("Bookmark this folder"), bookmarkID); } popup->insertSeparator(); // Insert 'Open With...' sub menu QValueVector<KService::Ptr> openWithVector; const int openWithID = insertOpenWithItems(popup, openWithVector); // Insert 'Actions' sub menu QValueVector<KDEDesktopMimeType::Service> actionsVector; insertActionItems(popup, actionsVector); // insert 'Properties...' entry popup->insertSeparator(); KAction* propertiesAction = dolphin.actionCollection()->action("properties"); propertiesAction->plug(popup); int id = popup->exec(m_pos); if (id == restoreID ) { KonqOperations::restoreTrashedItems(urls); } else if (id == bookmarkID) { const KURL selectedURL(m_fileInfo->url()); KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add folder as bookmark"), selectedURL.filename(), selectedURL, "bookmark"); if (!bookmark.isNull()) { KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager(); KBookmarkGroup root = manager->root(); root.addBookmark(manager, bookmark); manager->emitChanged(root); } } else if (id >= actionsIDStart) { // one of the 'Actions' items has been selected KDEDesktopMimeType::executeService(urls, actionsVector[id - actionsIDStart]); } else if (id >= openWithIDStart) { // one of the 'Open With' items has been selected if (id == openWithID) { // the item 'Other...' has been selected KRun::displayOpenWithDialog(urls); } else { KService::Ptr servicePtr = openWithVector[id - openWithIDStart]; KRun::run(*servicePtr, urls); } } openWithVector.clear(); actionsVector.clear(); popup->deleteLater(); }
void Groupwise::getFreeBusy(const KURL &url) { QString file = url.filename(); if(file.right(4) != ".ifb") { QString error = i18n("Illegal filename. File has to have '.ifb' suffix."); errorMessage(error); } else { QString email = file.left(file.length() - 4); debugMessage("Email: " + email); // Sanitise local Nuernberg email addresses kdDebug() << "Email before sanitizing: " << email << endl; email = email.replace(QRegExp("\\.EMEA5-1\\.EMEA5"), ""); email = email.replace(QRegExp("\\.Suse.INTERNET"), ""); kdDebug() << "Email after sanitizing: " << email << endl; QString u = soapUrl(url); QString user = url.user(); QString pass = url.pass(); debugMessage("URL: " + u); debugMessage("User: "******"Password: "******"Need username and password to read Free/Busy information.")); } else { GroupwiseServer server(u, user, pass, 0); // FIXME: Read range from configuration or URL parameters. QDate start = QDate::currentDate().addDays(-3); QDate end = QDate::currentDate().addDays(60); fb->setDtStart(start); fb->setDtEnd(end); kdDebug() << "Login" << endl; if(!server.login()) { errorMessage(i18n("Unable to login: "******"Read free/busy" << endl; if(!server.readFreeBusy(email, start, end, fb)) { errorMessage(i18n("Unable to read free/busy data: ") + server.errorText()); } kdDebug() << "Read free/busy" << endl; server.logout(); } } #if 0 QDateTime s = QDateTime(QDate(2004, 9, 27), QTime(10, 0)); QDateTime e = QDateTime(QDate(2004, 9, 27), QTime(11, 0)); fb->addPeriod(s, e); #endif // FIXME: This does not take into account the time zone! KCal::ICalFormat format; QString ical = format.createScheduleMessage(fb, KCal::Scheduler::Publish); data(ical.utf8()); finished(); } }
bool MediaNotifier::execAutoopen(const KFileItem &medium, const QString &path, const QString &autoopenFile) { // An Autoopen file MUST contain a single relative path that points // to a non-executable file contained on the medium. [...] QFile file(path + "/" + autoopenFile); file.open(IO_ReadOnly); QTextStream stream(&file); QString relative_path = stream.readLine().stripWhiteSpace(); // The relative path MUST NOT contain path components that // refer to a parent directory ( ../ ) if(relative_path.startsWith("/") || relative_path.contains("../")) { return false; } // The desktop environment MUST verify that the relative path points // to a file that is actually located on the medium [...] QString resolved_path = KStandardDirs::realFilePath(path + "/" + relative_path); if(!resolved_path.startsWith(path)) { return false; } QFile document(resolved_path); // TODO: What about FAT all files are executable... // If the relative path points to an executable file then the desktop // environment MUST NOT execute the file. if(!document.exists() /*|| QFileInfo(document).isExecutable()*/) { return false; } KURL url = medium.url(); url.addPath(relative_path); // The desktop environment MUST prompt the user for confirmation // before opening the file. QString mediumType = medium.mimeTypePtr()->name(); QString filename = url.filename(); QString text = i18n( "An autoopen file has been found on your '%1'." " Do you want to open '%2'?\n" "Note that opening a file on a medium may compromise" " your system's security") .arg(mediumType) .arg(filename); QString caption = i18n("Autoopen - %1").arg(medium.url().prettyURL()); KGuiItem yes = KStdGuiItem::yes(); KGuiItem no = KStdGuiItem::no(); int options = KMessageBox::Notify | KMessageBox::Dangerous; int answer = KMessageBox::warningYesNo(0L, text, caption, yes, no, QString::null, options); // TODO: Take case of the "UNLESS" part? // When an Autoopen file has been detected and the user has confirmed // that the file indicated in the Autoopen file should be opened then // the file indicated in the Autoopen file MUST be opened in the // application normally preferred by the user for files of its kind // UNLESS the user instructed otherwise. if(answer == KMessageBox::Yes) { (void)new KRun(url); } return true; }