Fix URL handling of media/builtin-* mimetypes

This partially resolves Bug 976
Add missing ACL support to CMake build files
pull/16/head
Timothy Pearson 12 years ago
parent a37d43794f
commit 30b0af1f01

@ -174,6 +174,7 @@ check_include_file( "stdlib.h" HAVE_STDLIB_H )
check_include_file( "strings.h" HAVE_STRINGS_H ) check_include_file( "strings.h" HAVE_STRINGS_H )
check_include_file( "string.h" HAVE_STRING_H ) check_include_file( "string.h" HAVE_STRING_H )
check_include_file( "sysent.h" HAVE_SYSENT_H ) check_include_file( "sysent.h" HAVE_SYSENT_H )
check_include_file( "sys/acl.h" HAVE_SYS_ACL_H )
check_include_file( "sys/bitypes.h" HAVE_SYS_BITYPES_H ) check_include_file( "sys/bitypes.h" HAVE_SYS_BITYPES_H )
check_include_file( "sys/dir.h" HAVE_SYS_DIR_H ) check_include_file( "sys/dir.h" HAVE_SYS_DIR_H )
check_include_file( "sys/filio.h" HAVE_SYS_FILIO_H ) check_include_file( "sys/filio.h" HAVE_SYS_FILIO_H )
@ -190,7 +191,7 @@ check_include_file( "sys/stat.h" HAVE_SYS_STAT_H )
check_include_file( "sys/stropts.h" HAVE_SYS_STROPTS_H ) check_include_file( "sys/stropts.h" HAVE_SYS_STROPTS_H )
check_include_file( "sys/types.h" HAVE_SYS_TYPES_H ) check_include_file( "sys/types.h" HAVE_SYS_TYPES_H )
check_include_file( "sys/ucred.h" HAVE_SYS_UCRED_H ) check_include_file( "sys/ucred.h" HAVE_SYS_UCRED_H )
check_include_file( "sys/xattr.h" sys/xattr.h ) check_include_file( "sys/xattr.h" HAVE_SYS_XATTR_H )
check_include_file( "termios.h" HAVE_TERMIOS_H ) check_include_file( "termios.h" HAVE_TERMIOS_H )
check_include_file( "termio.h" HAVE_TERMIO_H ) check_include_file( "termio.h" HAVE_TERMIO_H )
check_include_file( "unistd.h" HAVE_UNISTD_H ) check_include_file( "unistd.h" HAVE_UNISTD_H )
@ -204,6 +205,12 @@ if( HAVE_SYS_TIME_H AND HAVE_TIME_H )
set( TIME_WITH_SYS_TIME 1 ) set( TIME_WITH_SYS_TIME 1 )
endif( HAVE_SYS_TIME_H AND HAVE_TIME_H ) endif( HAVE_SYS_TIME_H AND HAVE_TIME_H )
if( HAVE_SYS_ACL_H )
set( USE_POSIX_ACL 1 )
endif( HAVE_SYS_ACL_H )
check_include_file( "acl/libacl.h" HAVE_NON_POSIX_ACL_EXTENSIONS )
check_include_file( "valgrind/memcheck.h" HAVE_VALGRIND_MEMCHECK_H ) check_include_file( "valgrind/memcheck.h" HAVE_VALGRIND_MEMCHECK_H )
check_include_file( "values.h" HAVE_VALUES_H ) check_include_file( "values.h" HAVE_VALUES_H )
check_include_file( "X11/extensions/shape.h" HAVE_X11_EXTENSIONS_SHAPE_H ) check_include_file( "X11/extensions/shape.h" HAVE_X11_EXTENSIONS_SHAPE_H )

@ -360,7 +360,7 @@
#undef HAVE_NL_TYPES_H #undef HAVE_NL_TYPES_H
/* Define if system has non-POSIX extensions to the ACL support. */ /* Define if system has non-POSIX extensions to the ACL support. */
#undef HAVE_NON_POSIX_ACL_EXTENSIONS #cmakedefine HAVE_NON_POSIX_ACL_EXTENSIONS 1
/* Define if your system needs _NSGetEnviron to set up the environment */ /* Define if your system needs _NSGetEnviron to set up the environment */
#undef HAVE_NSGETENVIRON #undef HAVE_NSGETENVIRON
@ -823,7 +823,7 @@
#cmakedefine TIME_WITH_SYS_TIME 1 #cmakedefine TIME_WITH_SYS_TIME 1
/* Define if system has POSIX ACL support. */ /* Define if system has POSIX ACL support. */
#undef USE_POSIX_ACL #cmakedefine USE_POSIX_ACL 1
/* Version number of package */ /* Version number of package */
#define VERSION "@VERSION@" #define VERSION "@VERSION@"

@ -55,6 +55,10 @@ if( HAVE_ELFICON )
set( ELFICON_STATIC_LIB tdelficon-static ) set( ELFICON_STATIC_LIB tdelficon-static )
endif( HAVE_ELFICON ) endif( HAVE_ELFICON )
if( HAVE_NON_POSIX_ACL_EXTENSIONS )
set( ACL_LIBRARIES acl )
endif( HAVE_NON_POSIX_ACL_EXTENSIONS )
##### libtdeio #################################### ##### libtdeio ####################################
@ -66,6 +70,6 @@ tde_add_library( ${target} SHARED
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp
VERSION 4.2.0 VERSION 4.2.0
EMBED kssl-static tdeiocore-static tdesycoca-static kbookmarks-static tdefile-static ${ELFICON_STATIC_LIB} EMBED kssl-static tdeiocore-static tdesycoca-static kbookmarks-static tdefile-static ${ELFICON_STATIC_LIB}
LINK ltdlc-static tdeui-shared tdesu-shared tdewalletclient-shared ${LIBR_LIBRARIES} LINK ltdlc-static tdeui-shared tdesu-shared tdewalletclient-shared ${LIBR_LIBRARIES} ${ACL_LIBRARIES}
DESTINATION ${LIB_INSTALL_DIR} DESTINATION ${LIB_INSTALL_DIR}
) )

@ -729,9 +729,10 @@ KFilePropsPlugin::KFilePropsPlugin( KPropertiesDialog *_props )
TQString magicMimeComment; TQString magicMimeComment;
if ( isLocal ) { if ( isLocal ) {
KMimeType::Ptr magicMimeType = KMimeType::findByFileContent( url.path() ); KMimeType::Ptr magicMimeType = KMimeType::findByFileContent( url.path() );
if ( magicMimeType->name() != KMimeType::defaultMimeType() ) if ( magicMimeType->name() != KMimeType::defaultMimeType() ) {
magicMimeComment = magicMimeType->comment(); magicMimeComment = magicMimeType->comment();
} }
}
// Those things only apply to 'single file' mode // Those things only apply to 'single file' mode
TQString filename = TQString::null; TQString filename = TQString::null;
@ -1312,8 +1313,9 @@ void tqt_leave_modal( TQWidget *widget );
void KFilePropsPlugin::applyChanges() void KFilePropsPlugin::applyChanges()
{ {
if ( d->dirSizeJob ) if ( d->dirSizeJob ) {
slotSizeStop(); slotSizeStop();
}
kdDebug(250) << "KFilePropsPlugin::applyChanges" << endl; kdDebug(250) << "KFilePropsPlugin::applyChanges" << endl;
@ -1345,17 +1347,20 @@ void KFilePropsPlugin::applyChanges()
properties->rename( newFileName ); properties->rename( newFileName );
// Update also relative path (for apps and mimetypes) // Update also relative path (for apps and mimetypes)
if ( !m_sRelativePath.isEmpty() ) if ( !m_sRelativePath.isEmpty() ) {
determineRelativePath( properties->kurl().path() ); determineRelativePath( properties->kurl().path() );
}
kdDebug(250) << "New URL = " << properties->kurl().url() << endl; kdDebug(250) << "New URL = " << properties->kurl().url() << endl;
kdDebug(250) << "old = " << oldurl.url() << endl; kdDebug(250) << "old = " << oldurl.url() << endl;
// Don't remove the template !! // Don't remove the template !!
if ( !m_bFromTemplate ) // (normal renaming) if ( !m_bFromTemplate ) { // (normal renaming)
job = TDEIO::move( oldurl, properties->kurl() ); job = TDEIO::move( oldurl, properties->kurl() );
else // Copying a template }
else { // Copying a template
job = TDEIO::copy( oldurl, properties->kurl() ); job = TDEIO::copy( oldurl, properties->kurl() );
}
connect( job, TQT_SIGNAL( result( TDEIO::Job * ) ), connect( job, TQT_SIGNAL( result( TDEIO::Job * ) ),
TQT_SLOT( slotCopyFinished( TDEIO::Job * ) ) ); TQT_SLOT( slotCopyFinished( TDEIO::Job * ) ) );
@ -1370,9 +1375,10 @@ void KFilePropsPlugin::applyChanges()
} }
properties->updateUrl(properties->kurl()); properties->updateUrl(properties->kurl());
// Update also relative path (for apps and mimetypes) // Update also relative path (for apps and mimetypes)
if ( !m_sRelativePath.isEmpty() ) if ( !m_sRelativePath.isEmpty() ) {
determineRelativePath( properties->kurl().path() ); determineRelativePath( properties->kurl().path() );
} }
}
// No job, keep going // No job, keep going
slotCopyFinished( 0L ); slotCopyFinished( 0L );
@ -2584,16 +2590,30 @@ KURLPropsPlugin::KURLPropsPlugin( KPropertiesDialog *_props )
TQString path = properties->kurl().path(); TQString path = properties->kurl().path();
TQFile f( path ); TQFile f( path );
if ( !f.open( IO_ReadOnly ) ) if ( !f.open( IO_ReadOnly ) ) {
return; return;
}
f.close(); f.close();
KSimpleConfig config( path ); KSimpleConfig config( path );
config.setDesktopGroup(); config.setDesktopGroup();
URLStr = config.readPathEntry( "URL" ); URLStr = config.readPathEntry( "URL" );
if ( !URLStr.isNull() ) KFileItem * item = properties->item();
if (item && item->mimetype() == "media/builtin-mydocuments") {
URLStr = TQString::null;
TDEConfig xdguserconfig( TQDir::homeDirPath()+"/.config/user-dirs.dirs" );
URLEdit->setMode(KFile::Directory);
URLEdit->setURL( xdguserconfig.readPathEntry( "XDG_DOCUMENTS_DIR", TQDir::homeDirPath() + "/Documents").remove( "\"" ));
}
else if (item && item->mimetype().startsWith("media/builtin-")) {
URLEdit->setEnabled(false);
}
if ( !URLStr.isNull() ) {
URLEdit->setURL( URLStr ); URLEdit->setURL( URLStr );
}
connect( URLEdit, TQT_SIGNAL( textChanged( const TQString & ) ), connect( URLEdit, TQT_SIGNAL( textChanged( const TQString & ) ),
this, TQT_SIGNAL( changed() ) ); this, TQT_SIGNAL( changed() ) );
@ -2628,6 +2648,24 @@ bool KURLPropsPlugin::supports( KFileItemList _items )
void KURLPropsPlugin::applyChanges() void KURLPropsPlugin::applyChanges()
{ {
TQString path = properties->kurl().path(); TQString path = properties->kurl().path();
KFileItem * item = properties->item();
if (item && item->mimetype() == "media/builtin-mydocuments") {
TDEConfig xdgconfig(TQDir::homeDirPath()+"/.config/user-dirs.dirs" );
if (xdgconfig.isReadOnly()) {
KMessageBox::sorry( 0, i18n("<qt>Could not save properties. You do not have "
"sufficient access to write to <b>%1</b>.</qt>").arg(path));
return;
}
else {
xdgconfig.writePathEntry( "XDG_DOCUMENTS_DIR", '"'+ URLEdit->url() + '"', true, false, false, false );
xdgconfig.sync();
return;
}
}
else if (item && item->mimetype().startsWith("media/builtin-")) {
return;
}
TQFile f( path ); TQFile f( path );
if ( !f.open( IO_ReadWrite ) ) { if ( !f.open( IO_ReadWrite ) ) {

Loading…
Cancel
Save