Ticket #37087: plasma-active-patches.patch
File plasma-active-patches.patch, 111.4 KB (added by yue.liu@…, 12 years ago) |
---|
-
ConfigureChecks.cmake
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index b8cd421..2729adb 100644
a b check_include_files(fstab.h HAVE_FSTAB_H) # kio, kd 47 47 check_include_files(limits.h HAVE_LIMITS_H) # various 48 48 check_include_files(mntent.h HAVE_MNTENT_H) # solid, kio, kdecore 49 49 check_include_files(sysent.h HAVE_SYSENT_H) # kdecore 50 check_include_files("sys/types.h;sys/mman.h" HAVE_SYS_MMAN_H) # kdecore51 50 check_include_files(sys/stat.h HAVE_SYS_STAT_H) # various 52 51 check_include_files(sys/ucred.h HAVE_SYS_UCRED_H) # kio 53 52 check_include_files(sys/types.h HAVE_SYS_TYPES_H) # various … … check_include_files(sys/mntent.h HAVE_SYS_MNTENT_H) # solid, 58 57 check_include_files("sys/param.h;sys/mount.h" HAVE_SYS_MOUNT_H) # kio, kdecore 59 58 check_include_files(unistd.h HAVE_UNISTD_H) # various 60 59 check_include_files(stdint.h HAVE_STDINT_H) # various 61 check_include_files("sys/types.h;netinet/in.h" HAVE_NETINET_IN_H) # kio62 60 check_include_files(paths.h HAVE_PATHS_H) # kdecore, kio 63 61 64 62 check_include_files(errno.h HAVE_ERRNO_H) # kjs, errno.h is used in many places, but only guarded in kjs/ … … check_include_files(valgrind/memcheck.h HAVE_VALGRIND_MEMCHECK_H) # khtml 67 65 check_include_files(crtdbg.h HAVE_CRTDBG_H) # kjs 68 66 check_include_files(langinfo.h HAVE_LANGINFO_H) # kdecore 69 67 70 check_include_files(arpa/nameser_compat.h HAVE_ARPA_NAMESER_COMPAT_H) # kio71 check_include_files(arpa/nameser8_compat.h HAVE_ARPA_NAMESER8_COMPAT_H) # kio72 73 68 macro_bool_to_01(X11_XTest_FOUND HAVE_XTEST) # kdecore 74 69 macro_bool_to_01(X11_Xcursor_FOUND HAVE_XCURSOR) # kdeui 75 70 macro_bool_to_01(X11_Xfixes_FOUND HAVE_XFIXES) # kdeui … … if(NOT APPLE) 99 94 endif(NOT APPLE) 100 95 check_function_exists(mmap HAVE_MMAP) # kdecore, khtml 101 96 102 if(NOT WIN32)103 # we don't have it on windows but need to export it to be backward compatible104 # can be removed when 4.1 is out105 check_function_exists(readdir_r HAVE_READDIR_R) # kio106 endif(NOT WIN32)107 97 check_function_exists(sendfile HAVE_SENDFILE) # kioslave 108 98 check_function_exists(srandom HAVE_SRANDOM) # config.h 109 99 check_function_exists(_NSGetEnviron HAVE_NSGETENVIRON) # kinit, config.h … … check_prototype_exists(unsetenv stdlib.h HAVE_UNSETENV_PROTO) 254 244 check_prototype_exists(usleep unistd.h HAVE_USLEEP_PROTO) 255 245 check_prototype_exists(initgroups "unistd.h;sys/types.h;unistd.h;grp.h" HAVE_INITGROUPS_PROTO) 256 246 check_prototype_exists(setreuid unistd.h HAVE_SETREUID_PROTO) 257 check_prototype_exists(seteuid unistd.h HAVE_SETEUID_PROTO)258 247 check_prototype_exists(trunc math.h HAVE_TRUNC) 259 248 260 249 # check for existing datatypes -
cmake/modules/FindNepomuk.cmake
diff --git a/cmake/modules/FindNepomuk.cmake b/cmake/modules/FindNepomuk.cmake index 10c995c..b822aee 100644
a b include(FindPackageHandleStandardArgs) 79 79 if(NOT WINCE) 80 80 find_package_handle_standard_args(Nepomuk DEFAULT_MSG 81 81 NEPOMUK_LIBRARIES NEPOMUK_INCLUDE_DIR NEPOMUK_ADDONTOLOGYCLASSES_FILE 82 Soprano_FOUND SOPRANO_PLUGIN_RAPTORPARSER_FOUND SOPRANO_PLUGIN_REDLANDBACKEND_FOUND82 Soprano_FOUND 83 83 SHAREDDESKTOPONTOLOGIES_FOUND 84 84 ) 85 85 else(NOT WINCE) -
config.h.cmake
diff --git a/config.h.cmake b/config.h.cmake index d5708aa..86ca906 100644
a b 50 50 #cmakedefine HAVE_FSTAB_H 1 51 51 #cmakedefine HAVE_LIMITS_H 1 52 52 #cmakedefine HAVE_MNTENT_H 1 53 #cmakedefine HAVE_NETINET_IN_H 154 53 #cmakedefine HAVE_PATHS_H 1 55 #cmakedefine HAVE_SYS_MMAN_H 156 54 #cmakedefine HAVE_UNISTD_H 1 57 #cmakedefine HAVE_ARPA_NAMESER_COMPAT_H58 #cmakedefine HAVE_ARPA_NAMESER8_COMPAT_H59 55 60 56 #cmakedefine HAVE_XTEST 1 61 57 … … 79 75 #cmakedefine HAVE_MKSTEMP 1 80 76 #cmakedefine HAVE_MKDTEMP 1 81 77 #cmakedefine HAVE_RANDOM 1 82 #cmakedefine HAVE_READDIR_R 183 78 #cmakedefine HAVE_SENDFILE 1 84 79 #cmakedefine HAVE_SETENV 1 85 80 #cmakedefine HAVE_SETEUID 1 -
kdecore/CMakeLists.txt
diff --git a/kdecore/CMakeLists.txt b/kdecore/CMakeLists.txt index 550ec30..5525901 100644
a b configure_file(auth/BackendsConfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/BackendsC 44 44 # Configure checks for localization 45 45 configure_file(localization/config-localization.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-localization.h) 46 46 47 # Configure checks for util 48 include(util/ConfigureChecks.cmake) 49 configure_file(util/config-util.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-util.h) 50 51 47 52 include_directories( ${KDE4_KDECORE_INCLUDES} ) 48 53 include_directories( ${ZLIB_INCLUDE_DIR} ) 49 54 include_directories( ${QT_INCLUDES} ) -
kdecore/io/kmountpoint.cpp
diff --git a/kdecore/io/kmountpoint.cpp b/kdecore/io/kmountpoint.cpp index aa7a6b1..e5df5dc 100644
a b KMountPoint::Ptr KMountPoint::List::findByDevice(const QString& device) const 513 513 514 514 bool KMountPoint::probablySlow() const 515 515 { 516 bool nfs = d->mountType == QLatin1String("nfs");516 bool nfs = d->mountType == QLatin1String("nfs"); 517 517 bool autofs = d->mountType == QLatin1String("autofs") || d->mountType == QLatin1String("subfs"); 518 bool fuse = d->mountType.startsWith(QLatin1String("fuse.")); 518 519 //bool pid = d->mountPoint.contains(":(pid"); 519 520 // The "pid" thing was in kde3's KIO::probably_slow_mounted, with obscure logic 520 521 // (looks like it used state from the previous line or something...) 521 522 // This needs to be revised once we have a testcase or explanation about it. 522 523 // But autofs works already, it shows nfs as mountType in mtab. 523 if (nfs || autofs ) {524 if (nfs || autofs || fuse) { 524 525 return true; 525 526 } 526 527 return false; -
kdecore/sonnet/globals.cpp
diff --git a/kdecore/sonnet/globals.cpp b/kdecore/sonnet/globals.cpp index ef57aa7..bf4f504 100644
a b QString detectLanguage(const QString &sentence) 83 83 return max.key(); 84 84 } 85 85 86 // SLOW!!! 87 // TODO: cache this value! And then use some dbus signal to notify all apps when 88 // changing the default language changes. 86 89 QString defaultLanguageName() 87 90 { 88 91 Loader *loader = Loader::openLoader(); -
new file kdecore/util/ConfigureChecks.cmake
diff --git a/kdecore/util/ConfigureChecks.cmake b/kdecore/util/ConfigureChecks.cmake new file mode 100644 index 0000000..fe9f47e
- + 1 include(CheckIncludeFiles) 2 check_include_files("sys/types.h;sys/mman.h" HAVE_SYS_MMAN_H) 3 4 -
new file kdecore/util/config-util.h.cmake
diff --git a/kdecore/util/config-util.h.cmake b/kdecore/util/config-util.h.cmake new file mode 100644 index 0000000..83ccdf7
- + 1 #cmakedefine01 HAVE_SYS_MMAN_H 2 -
kdecore/util/kshareddatacache_p.h
diff --git a/kdecore/util/kshareddatacache_p.h b/kdecore/util/kshareddatacache_p.h index 8bf9cf6..931de4d 100644
a b 20 20 #ifndef KSHAREDDATACACHE_P_H 21 21 #define KSHAREDDATACACHE_P_H 22 22 23 #include <config .h> // HAVE_SYS_MMAN_H23 #include <config-util.h> // HAVE_SYS_MMAN_H 24 24 25 25 #include <QtCore/QSharedPointer> 26 26 #include <QtCore/QBasicAtomicInt> … … int ksdcArea(); 82 82 #endif 83 83 84 84 // BSD/Mac OS X compat 85 #if defHAVE_SYS_MMAN_H85 #if HAVE_SYS_MMAN_H 86 86 #include <sys/mman.h> 87 87 #endif 88 88 #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -
kdeui/actions/kstandardaction.cpp
diff --git a/kdeui/actions/kstandardaction.cpp b/kdeui/actions/kstandardaction.cpp index 2b20078..7de0c6f 100644
a b KToggleAction *showStatusbar(const QObject *recvr, const char *slot, QObject *pa 544 544 KToggleAction *ret = new KToggleAction(i18n( "Show St&atusbar" ), parent); 545 545 ret->setObjectName(name(ShowStatusbar)); 546 546 547 ret->setWhatsThis( i18n( "Show Statusbar< br /><br />"548 "Shows the statusbar, which is the bar at the bottom of the window used for status information. " ) );547 ret->setWhatsThis( i18n( "Show Statusbar<p>" 548 "Shows the statusbar, which is the bar at the bottom of the window used for status information.</p>" ) ); 549 549 550 550 ret->setChecked( true ); 551 551 -
kdeui/fonts/kfontchooser.cpp
diff --git a/kdeui/fonts/kfontchooser.cpp b/kdeui/fonts/kfontchooser.cpp index 819dc1d..d243574 100644
a b KFontChooser::KFontChooser( QWidget *parent, 295 295 } 296 296 // Populate usual styles, to determine minimum list width; 297 297 // will be replaced later with correct styles. 298 d->styleListBox->addItem( i18nc("@item font","Regular"));298 d->styleListBox->addItem(I18NC_NOX("QFontDatabase", "Normal")); 299 299 d->styleListBox->addItem(i18nc("@item font","Italic")); 300 300 d->styleListBox->addItem(i18nc("@item font","Oblique")); 301 301 d->styleListBox->addItem(i18nc("@item font","Bold")); … … void KFontChooser::Private::_k_family_chosen_slot(const QString& family) 628 628 if (style == I18NC_NOX("QFontDatabase", "Normal")) 629 629 styleMod = i18nc("@item font", "Regular"); 630 630 631 631 632 // i18n: Filtering message, so that translators can script the 632 633 // style string according to the font family name (e.g. may need 633 634 // noun-adjective congruence wrt. gender of the family name). 634 635 // The message provides the dynamic context 'family', which is 635 636 // the family name to which the style string corresponds. 636 QString fstyle = ki18nc("@item Font style", "%1").subs(style Mod).inContext("family", pureFamily).toString();637 QString fstyle = ki18nc("@item Font style", "%1").subs(style).inContext("family", pureFamily).toString(); 637 638 if (!filteredStyles.contains(fstyle)) { 638 639 filteredStyles.append(fstyle); 639 640 qtStyles.insert(fstyle, style); … … void KFontChooser::Private::_k_family_chosen_slot(const QString& family) 644 645 styleListBox->addItems(filteredStyles); 645 646 646 647 // Try to set the current style in the listbox to that previous. 647 int listPos = filteredStyles.indexOf(selectedStyle.isEmpty() ? i18nc("@item font", "Regular") : selectedStyle);648 int listPos = filteredStyles.indexOf(selectedStyle.isEmpty() ? I18NC_NOX("QFontDatabase", "Normal") : selectedStyle); 648 649 if (listPos < 0) { 649 650 // Make extra effort to have Italic selected when Oblique was chosen, 650 651 // and vice versa, as that is what the user would probably want. -
kdeui/kernel/kstartupinfo.cpp
diff --git a/kdeui/kernel/kstartupinfo.cpp b/kdeui/kernel/kstartupinfo.cpp index bdc8972..87548c2 100644
a b bool KStartupInfoId::operator<( const KStartupInfoId& id_P ) const 1140 1140 return id() < id_P.id(); 1141 1141 } 1142 1142 1143 // KDE5 TODO: rename to isNull ? 1143 1144 bool KStartupInfoId::none() const 1144 1145 { 1145 1146 return d->id.isEmpty() || d->id == "0"; -
kdeui/widgets/klineedit.cpp
diff --git a/kdeui/widgets/klineedit.cpp b/kdeui/widgets/klineedit.cpp index 9756ef7..d96c1c4 100644
a b void KLineEdit::updateClearButtonIcon(const QString& text) 336 336 return; 337 337 } 338 338 339 int clearButtonState = KIconLoader::DefaultState; 339 // set proper icon if necessary 340 if (d->clearButton->pixmap().isNull()) { 341 const int clearButtonState = KIconLoader::DefaultState; 342 if (layoutDirection() == Qt::LeftToRight) { 343 d->clearButton->setPixmap(SmallIcon("edit-clear-locationbar-rtl", 0, clearButtonState)); 344 } else { 345 d->clearButton->setPixmap(SmallIcon("edit-clear-locationbar-ltr", 0, clearButtonState)); 346 } 347 } 340 348 349 // trigger animation 341 350 if (d->wideEnoughForClear && text.length() > 0) { 342 351 d->clearButton->animateVisible(true); 343 352 } else { 344 353 d->clearButton->animateVisible(false); 345 354 } 346 347 if (!d->clearButton->pixmap().isNull()) {348 return;349 }350 351 if (layoutDirection() == Qt::LeftToRight) {352 d->clearButton->setPixmap(SmallIcon("edit-clear-locationbar-rtl", 0, clearButtonState));353 } else {354 d->clearButton->setPixmap(SmallIcon("edit-clear-locationbar-ltr", 0, clearButtonState));355 }356 357 d->clearButton->setVisible(text.length() > 0);358 355 } 359 356 360 357 // Determine geometry of clear button. Called initially, and on resizeEvent. -
kdeui/widgets/klineedit_p.h
diff --git a/kdeui/widgets/klineedit_p.h b/kdeui/widgets/klineedit_p.h index 95016bd..f7df463 100644
a b public: 56 56 void animateVisible(bool visible) 57 57 { 58 58 if (visible) { 59 if (m_animation->direction() == QPropertyAnimation::Forward ) {59 if (m_animation->direction() == QPropertyAnimation::Forward && m_opacity == 255) { 60 60 return; 61 61 } 62 62 … … public: 64 64 m_animation->setDuration(150); 65 65 show(); 66 66 } else { 67 if (m_animation->direction() == QPropertyAnimation::Backward ) {67 if (m_animation->direction() == QPropertyAnimation::Backward && m_opacity == 0) { 68 68 return; 69 69 } 70 70 -
kio/kfile/kpropertiesdialog.cpp
diff --git a/kio/kfile/kpropertiesdialog.cpp b/kio/kfile/kpropertiesdialog.cpp index feb0c9e..223ac7c 100644
a b KFilePropsPlugin::KFilePropsPlugin( KPropertiesDialog *_props ) 945 945 QLabel *l; 946 946 if (!mimeComment.isEmpty() && !isTrash) { 947 947 l = new QLabel(i18n("Type:"), d->m_frame ); 948 grid->addWidget(l, curRow, 0, Qt::AlignRight | Qt::AlignTop); 948 949 949 grid->addWidget(l, curRow, 0, Qt::AlignRight); 950 951 KHBox *box = new KHBox(d->m_frame); 952 box->setSpacing(20); // ### why 20? 950 KVBox *box = new KVBox(d->m_frame); 951 box->setSpacing(2); // without that spacing the button literally “sticks” to the label ;) 953 952 l = new QLabel(mimeComment, box ); 953 grid->addWidget(box, curRow++, 2); 954 954 955 955 QPushButton *button = new QPushButton(box); 956 956 button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); // Minimum still makes the button grow to the entire layout width 957 957 button->setIcon( KIcon(QString::fromLatin1("configure")) ); 958 const int pixmapSize = button->style()->pixelMetric(QStyle::PM_SmallIconSize); 959 button->setFixedSize( pixmapSize+8, pixmapSize+8 ); 958 960 959 if ( d->mimeType == KMimeType::defaultMimeType() ) 961 button->setT oolTip(i18n("Create new file type"));960 button->setText(i18n("Create New File Type")); 962 961 else 963 button->setT oolTip(i18n("Edit file type"));962 button->setText(i18n("File Type Options")); 964 963 965 964 connect( button, SIGNAL(clicked()), SLOT(slotEditFileType())); 966 965 967 966 if (!KAuthorized::authorizeKAction("editfiletype")) 968 967 button->hide(); 969 970 grid->addWidget(box, curRow++, 2);971 968 } 972 969 973 970 if ( !magicMimeComment.isEmpty() && magicMimeComment != mimeComment ) -
kio/misc/kpac/CMakeLists.txt
diff --git a/kio/misc/kpac/CMakeLists.txt b/kio/misc/kpac/CMakeLists.txt index 3c21e13..81fa79a 100644
a b if(NOT KPAC_NO_SOLID) 12 12 endif(NOT KPAC_NO_SOLID) 13 13 14 14 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}") 15 15 include(ConfigureChecks.cmake) 16 16 configure_file(config-kpac.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kpac.h) 17 17 18 18 ########### next target ############### -
new file kio/misc/kpac/ConfigureChecks.cmake
diff --git a/kio/misc/kpac/ConfigureChecks.cmake b/kio/misc/kpac/ConfigureChecks.cmake new file mode 100644 index 0000000..47994b4
- + 1 include(CheckIncludeFiles) 2 check_include_files(arpa/nameser_compat.h HAVE_ARPA_NAMESER_COMPAT_H) 3 check_include_files(arpa/nameser8_compat.h HAVE_ARPA_NAMESER8_COMPAT_H) 4 check_include_files("sys/types.h;netinet/in.h" HAVE_NETINET_IN_H) -
kio/misc/kpac/config-kpac.h.cmake
diff --git a/kio/misc/kpac/config-kpac.h.cmake b/kio/misc/kpac/config-kpac.h.cmake index 58356e6..5a53614 100644
a b 1 1 #cmakedefine KPAC_NO_SOLID 2 #cmakedefine HAVE_ARPA_NAMESER_COMPAT_H 3 #cmakedefine HAVE_ARPA_NAMESER8_COMPAT_H 4 #cmakedefine HAVE_NETINET_IN_H 1 -
kio/misc/kpac/discovery.cpp
diff --git a/kio/misc/kpac/discovery.cpp b/kio/misc/kpac/discovery.cpp index a196879..b2266f8 100644
a b 19 19 20 20 21 21 #include <config.h> 22 22 #include <config-kpac.h> 23 23 #include <netdb.h> 24 24 #include <unistd.h> 25 25 -
kparts/CMakeLists.txt
diff --git a/kparts/CMakeLists.txt b/kparts/CMakeLists.txt index 2eab2e8..60f17ef 100644
a b set(kparts_LIB_SRCS 30 30 textextension.cpp 31 31 htmlextension.cpp 32 32 fileinfoextension.cpp 33 34 # Private classes from libkactivities 35 private/libkactivities/manager_p.cpp 36 private/libkactivities/resourceinstance.cpp 37 33 38 listingextension.cpp 34 39 ) 35 40 41 42 # D-Bus connection to the activity manager 43 qt4_add_dbus_interface( 44 kparts_LIB_SRCS 45 private/libkactivities/org.kde.ActivityManager.xml 46 activitymanager_interface 47 ) 48 49 36 50 kde4_add_library(kparts ${LIBRARY_TYPE} ${kparts_LIB_SRCS}) 37 51 38 52 target_link_libraries(kparts ${KDE4_KDECORE_LIBS} kdeui kio) … … if(HAVE_NEPOMUK) 42 56 target_link_libraries(kparts LINK_INTERFACE_LIBRARIES nepomuk nepomukutils ) 43 57 endif(HAVE_NEPOMUK) 44 58 45 set_target_properties(kparts PROPERTIES VERSION ${GENERIC_LIB_VERSION} 46 SOVERSION ${GENERIC_LIB_SOVERSION} 59 set_target_properties(kparts PROPERTIES VERSION ${GENERIC_LIB_VERSION} 60 SOVERSION ${GENERIC_LIB_SOVERSION} 47 61 ) 48 62 49 63 -
kparts/part.cpp
diff --git a/kparts/part.cpp b/kparts/part.cpp index f74bd78..a5769f5 100644
a b 26 26 #include "partmanager.h" 27 27 #include "browserextension.h" 28 28 29 // the activity manager feeder (kamd) 30 #include "private/libkactivities/resourceinstance.h" 31 29 32 #include <QtGui/QApplication> 30 33 #include <QtCore/QFile> 31 34 #include <QtCore/QFileInfo> … … public: 380 383 m_duringSaveAs = false; 381 384 m_bTemp = false; 382 385 m_bAutoDetectedMime = false; 386 m_resourceInstance = 0; 383 387 } 384 388 385 389 ~ReadOnlyPartPrivate() … … public: 389 393 void _k_slotJobFinished( KJob * job ); 390 394 void _k_slotStatJobFinished(KJob * job); 391 395 void _k_slotGotMimeType(KIO::Job *job, const QString &mime); 396 void _k_slotOpeningCompleted(); 397 void _k_slotWindowCaptionChanged(const QString & caption); 392 398 bool openLocalFile(); 393 399 void openRemoteFile(); 394 400 … … public: 421 427 QString m_file; 422 428 423 429 OpenUrlArguments m_arguments; 430 431 /** 432 * Class for talking to the activity manager (kamd) 433 */ 434 KActivities::ResourceInstance * m_resourceInstance; 435 QString m_resourceCaption; 436 424 437 }; 425 438 426 439 class ReadWritePartPrivate: public ReadOnlyPartPrivate … … public: 450 463 ReadOnlyPart::ReadOnlyPart( QObject *parent ) 451 464 : Part( *new ReadOnlyPartPrivate(this), parent ) 452 465 { 466 QObject::connect( 467 this, SIGNAL(completed()), 468 this, SLOT(_k_slotOpeningCompleted()) 469 ); 470 QObject::connect( 471 this, SIGNAL(setWindowCaption(QString)), 472 this, SLOT(_k_slotWindowCaptionChanged(QString)) 473 ); 453 474 } 454 475 455 476 ReadOnlyPart::ReadOnlyPart( ReadOnlyPartPrivate &dd, QObject *parent ) 456 477 : Part( dd, parent ) 457 478 { 479 QObject::connect( 480 this, SIGNAL(completed()), 481 this, SLOT(_k_slotOpeningCompleted()) 482 ); 458 483 } 459 484 460 485 ReadOnlyPart::~ReadOnlyPart() … … void ReadOnlyPart::setUrl(const KUrl &url) 473 498 { 474 499 Q_D(ReadOnlyPart); 475 500 501 if (d->m_resourceInstance) { 502 d->m_resourceInstance->setUri(url); 503 } 504 476 505 d->m_url = url; 477 506 } 478 507 … … bool ReadOnlyPart::closeUrl() 658 687 // It always succeeds for a read-only part, 659 688 // but the return value exists for reimplementations 660 689 // (e.g. pressing cancel for a modified read-write part) 690 691 // Feeding the data to the activity manager (kamd) 692 kDebug(1000) 693 << "A component named" 694 << KGlobal::mainComponent().componentName() 695 << "has closed the" 696 << url(); 697 delete d->m_resourceInstance; 698 d->m_resourceInstance = 0; // just in case 699 // Finished with the activity manager 700 661 701 return true; 662 702 } 663 703 … … void ReadOnlyPartPrivate::_k_slotJobFinished( KJob * job ) 697 737 } 698 738 } 699 739 740 void ReadOnlyPartPrivate::_k_slotOpeningCompleted() 741 { 742 Q_Q(ReadOnlyPart); 743 744 // Feeding the data to the activity manager (kamd) 745 kDebug(1000) 746 << "A component named" 747 << KGlobal::mainComponent().componentName() 748 << "is opening the" 749 << q->url() 750 << ( q->widget() ? q->widget()->topLevelWidget()->winId() : 0 ) 751 << "mime" 752 << m_arguments.mimeType() 753 << "title" 754 << m_resourceCaption; 755 756 // deleting the previous one 757 delete m_resourceInstance; 758 759 m_resourceInstance = new KActivities::ResourceInstance( 760 ( q->widget() ? q->widget()->topLevelWidget()->winId() : 0 ), // wid 761 q->url(), // resourceUri 762 m_arguments.mimeType(), // mimetype 763 m_resourceCaption, // title 764 KActivities::ResourceInstance::User, // accessReason 765 KGlobal::mainComponent().componentName(), // application 766 q // parent 767 ); 768 // Finished with the activity manager 769 } 770 771 void ReadOnlyPartPrivate::_k_slotWindowCaptionChanged(const QString & caption) 772 { 773 kDebug(1000) << "This is the new caption" << caption; 774 775 m_resourceCaption = caption; 776 777 if (m_resourceInstance) { 778 kDebug(1000) << "KAMD: resource caption" << caption; 779 m_resourceInstance->setTitle(caption); 780 } 781 } 782 700 783 void ReadOnlyPartPrivate::_k_slotGotMimeType(KIO::Job *job, const QString &mime) 701 784 { 702 kDebug(1000) << mime; 785 kDebug(1000) << "This is the mime type we got" << mime; 786 703 787 Q_ASSERT(job == m_job); Q_UNUSED(job) 704 788 // set the mimetype only if it was not already set (for example, by the host application) 705 789 if (m_arguments.mimeType().isEmpty()) { … … bool ReadOnlyPart::openStream( const QString& mimeType, const KUrl& url ) 731 815 return false; 732 816 d->m_arguments = args; 733 817 d->m_url = url; 818 819 kDebug(1000) 820 << "A component named" 821 << KGlobal::mainComponent().componentName() 822 << "is opening the stream" 823 << url << mimeType; 824 734 825 return doOpenStream( mimeType ); 735 826 } 736 827 … … void ReadWritePart::setModified( bool modified ) 796 887 kError(1000) << "Can't set a read-only document to 'modified' !" << endl; 797 888 return; 798 889 } 890 891 if ( modified && d->m_resourceInstance ) { 892 kDebug(1000) << "Notifying kamd of the change"; 893 d->m_resourceInstance->notifyModified(); 894 } 895 799 896 d->m_bModified = modified; 800 897 } 801 898 -
kparts/part.h
diff --git a/kparts/part.h b/kparts/part.h index 56b64da..f62f2d7 100644
a b private: 717 717 Q_PRIVATE_SLOT(d_func(), void _k_slotStatJobFinished(KJob*)) 718 718 Q_PRIVATE_SLOT(d_func(), void _k_slotGotMimeType(KIO::Job *job, const QString &mime)) 719 719 720 Q_PRIVATE_SLOT(d_func(), void _k_slotOpeningCompleted()) 721 Q_PRIVATE_SLOT(d_func(), void _k_slotWindowCaptionChanged(const QString & caption)) 722 720 723 Q_DISABLE_COPY(ReadOnlyPart) 721 724 }; 722 725 class ReadWritePartPrivate; -
new file kparts/private/libkactivities/CMakeLists.txt
diff --git a/kparts/private/libkactivities/CMakeLists.txt b/kparts/private/libkactivities/CMakeLists.txt new file mode 100644 index 0000000..e164126
- + 1 project(kactivities) 2 3 cmake_minimum_required(VERSION 2.8) 4 5 FIND_PACKAGE(KDE4 REQUIRED) 6 INCLUDE(KDE4Defaults) 7 INCLUDE(MacroLibrary) 8 INCLUDE(MacroOptionalAddSubdirectory) 9 INCLUDE(FindPackageHandleStandardArgs) 10 11 # ======================================================= 12 # Information to update before to release this library. 13 14 # Library version history: 15 # API ABI 16 # 0.1.0 => 0.1.0 17 # 0.1.1 => 0.1.1 18 # 0.2.0 => 0.2.0 19 20 # Library API version 21 SET(KACTIVITIES_LIB_MAJOR_VERSION "6") 22 SET(KACTIVITIES_LIB_MINOR_VERSION "0") 23 SET(KACTIVITIES_LIB_PATCH_VERSION "0") 24 25 # Suffix to add at end of version string. Usual values are: 26 # "-git" : alpha code unstable from git. Do not use in production 27 # "-beta1" : beta1 release. 28 # "-beta2" : beta2 release. 29 # "-beta3" : beta3 release. 30 # "-rc" : release candidate. 31 # "" : final relase. Can be used in production. 32 SET(KACTIVITIES_LIB_SUFFIX_VERSION "") 33 34 # Library ABI version used by linker. 35 # For details : http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info 36 SET(KACTIVITIES_LIB_SO_CUR_VERSION "6") 37 SET(KACTIVITIES_LIB_SO_REV_VERSION "0") 38 SET(KACTIVITIES_LIB_SO_AGE_VERSION "0") 39 40 # ======================================================= 41 # Set env. variables accordinly. 42 43 set(KACTIVITIES_INCLUDE_DIR 44 "${CMAKE_CURRENT_SOURCE_DIR}/.." 45 "${CMAKE_CURRENT_SOURCE_DIR}/" 46 CACHE STRING 47 "Location of libkactivities headers" FORCE) 48 set(KACTIVITIES_LIBS 49 "kactivities" 50 CACHE STRING 51 "Location of libkactivities binary" FORCE) 52 53 SET(KACTIVITIES_LIB_VERSION_STRING "${KACTIVITIES_LIB_MAJOR_VERSION}.${KACTIVITIES_LIB_MINOR_VERSION}.${KACTIVITIES_LIB_PATCH_VERSION}${KACTIVITIES_LIB_SUFFIX_VERSION}") 54 SET(KACTIVITIES_LIB_VERSION_ID "0x0${KACTIVITIES_LIB_MAJOR_VERSION}0${KACTIVITIES_LIB_MINOR_VERSION}0${KACTIVITIES_LIB_PATCH_VERSION}") 55 SET(KACTIVITIES_LIB_SO_VERSION_STRING "${KACTIVITIES_LIB_SO_CUR_VERSION}.${KACTIVITIES_LIB_SO_REV_VERSION}.${KACTIVITIES_LIB_SO_AGE_VERSION}") 56 57 ADD_DEFINITIONS (${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS} ${KDE4_DEFINITIONS}) 58 INCLUDE_DIRECTORIES (${QDBUS_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES}) 59 60 include_directories( 61 ${CMAKE_SOURCE_DIR} 62 ${CMAKE_BINARY_DIR} 63 ${KDE4_INCLUDES} 64 ${KDE4_KIO_INCLUDES} 65 ) 66 67 set( 68 kactivities_LIB_SRCS 69 70 consumer.cpp 71 controller.cpp 72 info.cpp 73 manager_p.cpp 74 resourceinstance.cpp 75 ) 76 77 qt4_add_dbus_interface( 78 kactivities_LIB_SRCS 79 80 org.kde.ActivityManager.xml 81 activitymanager_interface 82 ) 83 84 85 kde4_add_library( 86 kactivities SHARED 87 ${kactivities_LIB_SRCS} 88 ) 89 90 91 set_target_properties( 92 kactivities 93 PROPERTIES 94 VERSION ${KACTIVITIES_LIB_SO_VERSION_STRING} 95 SOVERSION ${KACTIVITIES_LIB_SO_CUR_VERSION} 96 ) 97 98 target_link_libraries( 99 kactivities 100 ${KDE4_KDECORE_LIBS} 101 ) 102 103 ## install 104 105 set( 106 kactivities_LIB_HEADERS 107 consumer.h 108 controller.h 109 info.h 110 resourceinstance.h 111 ) 112 113 set( 114 kactivities_LIB_PRETTY_HEADERS 115 includes/KActivities/Consumer 116 includes/KActivities/Controller 117 includes/KActivities/Info 118 includes/KActivities/ResourceInstance 119 ) 120 121 install( 122 FILES ${kactivities_LIB_HEADERS} 123 DESTINATION ${INCLUDE_INSTALL_DIR}/kactivities 124 COMPONENT Devel 125 ) 126 127 install( 128 FILES ${kactivities_LIB_PRETTY_HEADERS} 129 DESTINATION ${INCLUDE_INSTALL_DIR}/KDE/KActivities 130 COMPONENT Devel 131 ) 132 133 install( 134 TARGETS kactivities 135 EXPORT kdelibsLibraryTargets 136 ${INSTALL_TARGETS_DEFAULT_ARGS} 137 ) 138 139 IF(NOT WIN32) 140 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libkactivities.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libkactivities.pc) 141 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libkactivities.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig ) 142 ENDIF(NOT WIN32) 143 144 CONFIGURE_FILE( 145 KActivitiesConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/KActivitiesConfig.cmake @ONLY 146 ) 147 148 INSTALL( 149 FILES ${CMAKE_CURRENT_BINARY_DIR}/KActivitiesConfig.cmake 150 DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/cmake/KActivities 151 ) 152 -
new file kparts/private/libkactivities/manager_p.cpp
diff --git a/kparts/private/libkactivities/manager_p.cpp b/kparts/private/libkactivities/manager_p.cpp new file mode 100644 index 0000000..e71aec8
- + 1 /* 2 * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2, 6 * or (at your option) any later version, as published by the Free 7 * Software Foundation 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details 13 * 14 * You should have received a copy of the GNU General Public 15 * License along with this program; if not, write to the 16 * Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #include "manager_p.h" 21 22 #include <QDBusConnection> 23 24 #include <ktoolinvocation.h> 25 #include <kdebug.h> 26 27 namespace KActivities { 28 29 Manager * Manager::s_instance = NULL; 30 31 // #define ACTIVITY_MANAGER_DBUS_PATH "org.kde.ActivityManager" 32 #define ACTIVITY_MANAGER_DBUS_PATH "org.kde.kactivitymanagerd" 33 #define ACTIVITY_MANAGER_DBUS_OBJECT "/ActivityManager" 34 35 Manager::Manager() 36 : org::kde::ActivityManager( 37 ACTIVITY_MANAGER_DBUS_PATH, 38 ACTIVITY_MANAGER_DBUS_OBJECT, 39 QDBusConnection::sessionBus() 40 ) 41 { 42 connect(&m_watcher, SIGNAL(serviceOwnerChanged(const QString &, const QString &, const QString &)), 43 this, SLOT(serviceOwnerChanged(const QString &, const QString &, const QString &))); 44 } 45 46 Manager * Manager::self() 47 { 48 if (!s_instance) { 49 // check if the activity manager is already running 50 if (!isActivityServiceRunning()) { 51 52 // not running, trying to launch it 53 QString error; 54 55 int ret = KToolInvocation::startServiceByDesktopPath("kactivitymanagerd.desktop", QStringList(), &error); 56 if (ret > 0) { 57 kDebug() << "Activity: Couldn't start kactivitymanagerd: " << error << endl; 58 } 59 60 if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(ACTIVITY_MANAGER_DBUS_PATH)) { 61 kDebug() << "Activity: The kactivitymanagerd service is still not registered"; 62 } else { 63 kDebug() << "Activity: The kactivitymanagerd service has been registered"; 64 } 65 } 66 67 // creating a new instance of the class 68 s_instance = new Manager(); 69 } 70 71 return s_instance; 72 } 73 74 bool Manager::isActivityServiceRunning() 75 { 76 return QDBusConnection::sessionBus().interface()->isServiceRegistered(ACTIVITY_MANAGER_DBUS_PATH); 77 } 78 79 void Manager::serviceOwnerChanged(const QString & serviceName, const QString & oldOwner, const QString & newOwner) 80 { 81 Q_UNUSED(oldOwner) 82 83 if (serviceName == ACTIVITY_MANAGER_DBUS_PATH) { 84 emit presenceChanged(!newOwner.isEmpty()); 85 } 86 } 87 88 } // namespace KActivities 89 -
new file kparts/private/libkactivities/manager_p.h
diff --git a/kparts/private/libkactivities/manager_p.h b/kparts/private/libkactivities/manager_p.h new file mode 100644 index 0000000..b92a94f
- + 1 /* 2 * Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2, 6 * or (at your option) any later version, as published by the Free 7 * Software Foundation 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details 13 * 14 * You should have received a copy of the GNU General Public 15 * License along with this program; if not, write to the 16 * Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef ACTIVITIES_MANAGER_P_ 21 #define ACTIVITIES_MANAGER_P_ 22 23 #include "activitymanager_interface.h" 24 25 #include <QDBusServiceWatcher> 26 27 namespace KActivities { 28 29 class Manager: public org::kde::ActivityManager { 30 Q_OBJECT 31 public: 32 static Manager * self(); 33 34 static bool isActivityServiceRunning(); 35 36 public Q_SLOTS: 37 void serviceOwnerChanged(const QString & serviceName, const QString & oldOwner, const QString & newOwner); 38 39 Q_SIGNALS: 40 void presenceChanged(bool present); 41 42 private: 43 Manager(); 44 45 QDBusServiceWatcher m_watcher; 46 47 static Manager * s_instance; 48 }; 49 50 } // namespace KActivities 51 52 #endif // ACTIVITIES_MANAGER_P_ -
new file kparts/private/libkactivities/org.kde.ActivityManager.xml
diff --git a/kparts/private/libkactivities/org.kde.ActivityManager.xml b/kparts/private/libkactivities/org.kde.ActivityManager.xml new file mode 100644 index 0000000..07a5b34
- + 1 <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> 2 <node> 3 <interface name="org.kde.ActivityManager"> 4 <signal name="CurrentActivityChanged"> 5 <arg name="id" type="s" direction="out"/> 6 </signal> 7 <signal name="ActivityAdded"> 8 <arg name="id" type="s" direction="out"/> 9 </signal> 10 <signal name="ActivityStarted"> 11 <arg name="id" type="s" direction="out"/> 12 </signal> 13 <signal name="ActivityStopped"> 14 <arg name="id" type="s" direction="out"/> 15 </signal> 16 <signal name="ActivityRemoved"> 17 <arg name="id" type="s" direction="out"/> 18 </signal> 19 <signal name="ActivityChanged"> 20 <arg name="id" type="s" direction="out"/> 21 </signal> 22 <signal name="ActivityStateChanged"> 23 <arg name="id" type="s" direction="out"/> 24 <arg name="state" type="i" direction="out"/> 25 </signal> 26 <method name="Start"> 27 </method> 28 <method name="Stop"> 29 </method> 30 <method name="CurrentActivity"> 31 <arg type="s" direction="out"/> 32 </method> 33 <method name="SetCurrentActivity"> 34 <arg type="b" direction="out"/> 35 <arg name="id" type="s" direction="in"/> 36 </method> 37 <method name="AddActivity"> 38 <arg type="s" direction="out"/> 39 <arg name="name" type="s" direction="in"/> 40 </method> 41 <method name="StartActivity"> 42 <arg name="id" type="s" direction="in"/> 43 </method> 44 <method name="StopActivity"> 45 <arg name="id" type="s" direction="in"/> 46 </method> 47 <method name="ActivityState"> 48 <arg type="i" direction="out"/> 49 <arg name="id" type="s" direction="in"/> 50 </method> 51 <method name="RemoveActivity"> 52 <arg name="id" type="s" direction="in"/> 53 </method> 54 <method name="ListActivities"> 55 <arg type="as" direction="out"/> 56 </method> 57 <method name="ListActivities"> 58 <arg type="as" direction="out"/> 59 <arg name="state" type="i" direction="in"/> 60 </method> 61 <method name="ActivityName"> 62 <arg type="s" direction="out"/> 63 <arg name="id" type="s" direction="in"/> 64 </method> 65 <method name="SetActivityName"> 66 <arg name="id" type="s" direction="in"/> 67 <arg name="name" type="s" direction="in"/> 68 </method> 69 <method name="ActivityDescription"> 70 <arg type="s" direction="out"/> 71 <arg name="id" type="s" direction="in"/> 72 </method> 73 <method name="SetActivityDescription"> 74 <arg name="id" type="s" direction="in"/> 75 <arg name="description" type="s" direction="in"/> 76 </method> 77 <method name="ActivityIcon"> 78 <arg type="s" direction="out"/> 79 <arg name="id" type="s" direction="in"/> 80 </method> 81 <method name="SetActivityIcon"> 82 <arg name="id" type="s" direction="in"/> 83 <arg name="icon" type="s" direction="in"/> 84 </method> 85 <method name="IsBackstoreAvailable"> 86 <arg type="b" direction="out"/> 87 </method> 88 <method name="RegisterResourceEvent"> 89 <arg name="application" type="s" direction="in"/> 90 <arg name="windowId" type="u" direction="in"/> 91 <arg name="uri" type="s" direction="in"/> 92 <arg name="event" type="u" direction="in"/> 93 <arg name="reason" type="u" direction="in"/> 94 </method> 95 <method name="RegisterResourceMimeType"> 96 <arg name="uri" type="s" direction="in"/> 97 <arg name="mimetype" type="s" direction="in"/> 98 </method> 99 <method name="RegisterResourceTitle"> 100 <arg name="uri" type="s" direction="in"/> 101 <arg name="title" type="s" direction="in"/> 102 </method> 103 <method name="LinkResourceToActivity"> 104 <arg name="uri" type="s" direction="in"/> 105 <arg name="activity" type="s" direction="in"/> 106 </method> 107 <method name="LinkResourceToActivity"> 108 <arg name="uri" type="s" direction="in"/> 109 </method> 110 <!-- <method name="UnlinkResourceFromActivity"> --> 111 <!-- <arg name="uri" type="s" direction="in"/> --> 112 <!-- <arg name="activity" type="s" direction="in"/> --> 113 <!-- </method> --> 114 <!-- <method name="UnlinkResourceFromActivity"> --> 115 <!-- <arg name="uri" type="s" direction="in"/> --> 116 <!-- </method> --> 117 </interface> 118 </node> -
new file kparts/private/libkactivities/resourceinstance.cpp
diff --git a/kparts/private/libkactivities/resourceinstance.cpp b/kparts/private/libkactivities/resourceinstance.cpp new file mode 100644 index 0000000..6bf3925
- + 1 /* 2 * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2, 6 * or (at your option) any later version, as published by the Free 7 * Software Foundation 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details 13 * 14 * You should have received a copy of the GNU General Public 15 * License along with this program; if not, write to the 16 * Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #include "resourceinstance.h" 21 #include "manager_p.h" 22 23 #include <QCoreApplication> 24 25 namespace KActivities { 26 27 #ifdef Q_OS_WIN64 28 __inline int toInt(WId wid) 29 { 30 return (int)((__int64)wid); 31 } 32 33 #else 34 __inline int toInt(WId wid) 35 { 36 return (int)wid; 37 } 38 #endif 39 40 class ResourceInstancePrivate { 41 public: 42 WId wid; 43 ResourceInstance::AccessReason reason; 44 QUrl uri; 45 QString mimetype; 46 QString title; 47 QString application; 48 49 void closeResource(); 50 void openResource(); 51 52 enum Type { 53 Accessed = 0, 54 Opened = 1, 55 Modified = 2, 56 Closed = 3, 57 FocusedIn = 4, 58 FocusedOut = 5 59 }; 60 61 static void registerResourceEvent(const QString &application, WId wid, const QUrl &uri, Type event, ResourceInstance::AccessReason reason) 62 { 63 Manager::self()->RegisterResourceEvent(application, toInt(wid), uri.toString(), uint(event), uint(reason)); 64 } 65 }; 66 67 void ResourceInstancePrivate::closeResource() 68 { 69 registerResourceEvent(application, wid, uri, Closed, reason); 70 } 71 72 void ResourceInstancePrivate::openResource() 73 { 74 registerResourceEvent(application, wid, uri, Opened, reason); 75 } 76 77 ResourceInstance::ResourceInstance(WId wid, AccessReason reason, const QString &application, QObject *parent) 78 : QObject(parent), d(new ResourceInstancePrivate()) 79 { 80 d->wid = wid; 81 d->reason = reason; 82 d->application = application.isEmpty() ? QCoreApplication::instance()->applicationName() : application; 83 84 } 85 86 ResourceInstance::ResourceInstance(WId wid, QUrl resourceUri, const QString &mimetype, const QString &title, AccessReason reason, const QString &application, QObject *parent) 87 : QObject(parent), d(new ResourceInstancePrivate()) 88 { 89 d->wid = wid; 90 d->reason = reason; 91 d->uri = resourceUri; 92 d->mimetype = mimetype; 93 d->title = title; 94 d->application = application.isEmpty() ? QCoreApplication::instance()->applicationName() : application; 95 96 d->openResource(); 97 } 98 99 ResourceInstance::~ResourceInstance() 100 { 101 d->closeResource(); 102 delete d; 103 } 104 105 void ResourceInstance::notifyModified() 106 { 107 d->registerResourceEvent(d->application, d->wid, d->uri, ResourceInstancePrivate::Modified, d->reason); 108 } 109 110 void ResourceInstance::notifyFocusedIn() 111 { 112 d->registerResourceEvent(d->application, d->wid, d->uri, ResourceInstancePrivate::FocusedIn, d->reason); 113 } 114 115 void ResourceInstance::notifyFocusedOut() 116 { 117 d->registerResourceEvent(d->application, d->wid, d->uri, ResourceInstancePrivate::FocusedOut, d->reason); 118 } 119 120 void ResourceInstance::setUri(const QUrl &newUri) 121 { 122 if (d->uri == newUri) 123 return; 124 125 if (!d->uri.isEmpty()) { 126 d->closeResource(); 127 } 128 129 d->uri = newUri; 130 131 d->openResource(); 132 } 133 134 void ResourceInstance::setMimetype(const QString &mimetype) 135 { 136 d->mimetype = mimetype; 137 // TODO: update the service info 138 Manager::self()->RegisterResourceMimeType(d->uri.toString(), mimetype); 139 } 140 141 void ResourceInstance::setTitle(const QString &title) 142 { 143 d->title = title; 144 // TODO: update the service info 145 Manager::self()->RegisterResourceTitle(d->uri.toString(), title); 146 } 147 148 QUrl ResourceInstance::uri() const 149 { 150 return d->uri; 151 } 152 153 QString ResourceInstance::mimetype() const 154 { 155 return d->mimetype; 156 } 157 158 QString ResourceInstance::title() const 159 { 160 return d->title; 161 } 162 163 WId ResourceInstance::winId() const 164 { 165 return d->wid; 166 } 167 168 ResourceInstance::AccessReason ResourceInstance::accessReason() const 169 { 170 return d->reason; 171 } 172 173 void ResourceInstance::notifyAccessed(const QUrl &uri, const QString &application) 174 { 175 ResourceInstancePrivate::registerResourceEvent( 176 application.isEmpty() ? QCoreApplication::instance()->applicationName() : application, 177 0, uri, ResourceInstancePrivate::Accessed, User); 178 } 179 180 } // namespace KActivities -
new file kparts/private/libkactivities/resourceinstance.h
diff --git a/kparts/private/libkactivities/resourceinstance.h b/kparts/private/libkactivities/resourceinstance.h new file mode 100644 index 0000000..d1cbab4
- + 1 /* 2 * Copyright (C) 2011 Ivan Cukic <ivan.cukic(at)kde.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2, 6 * or (at your option) any later version, as published by the Free 7 * Software Foundation 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details 13 * 14 * You should have received a copy of the GNU General Public 15 * License along with this program; if not, write to the 16 * Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef ACTIVITIES_RESOURCEINSTANCE_H_ 21 #define ACTIVITIES_RESOURCEINSTANCE_H_ 22 23 #include <QObject> 24 #include <QWidget> 25 #include <QUrl> 26 27 #include <kdemacros.h> 28 29 namespace KActivities { 30 31 class ResourceInstancePrivate; 32 33 /** 34 * This class is used to notify the system that a file, web page 35 * or some other resource has been accessed. 36 * 37 * It provides methods to notify the system when the resource was 38 * opened, modified and closed, along with in what window the 39 * resource is shown. 40 * 41 * You should create an instance of this class for every resource 42 * you open. 43 * 44 * "The system" in this case can be the backend for tracking 45 * and automatically scoring files that are being accessed, the 46 * system to show the open files per window in the taskbar, 47 * the share-like-connect, etc. 48 * 49 * The user of this class shouldn't care about the backend 50 * systems - everything is done under-the-hood automatically. 51 * 52 */ 53 class KDE_EXPORT ResourceInstance: public QObject 54 { 55 Q_OBJECT 56 57 Q_PROPERTY(QUrl uri READ uri WRITE setUri) 58 Q_PROPERTY(QString mimetype READ mimetype WRITE setMimetype) 59 Q_PROPERTY(QString title READ title WRITE setTitle) 60 Q_PROPERTY(WId winId READ winId) 61 Q_PROPERTY(AccessReason accessReason READ accessReason) 62 63 public: 64 /*** 65 * The reason for opening the resource 66 */ 67 enum AccessReason { 68 User = 0, ///< Due to an explicit user request 69 Scheduled = 1, ///< As a result of a user-scheduled action 70 Heuristic = 2, ///< Deduced from user's activity, or indirectly requested 71 System = 3, ///< Due to a system event 72 World = 4 ///< Due to an action performed by an external entity 73 }; 74 Q_ENUMS(AccessReason) 75 76 /** 77 * Creates a new resource instance 78 * @param wid id of the window that will show the resource 79 * @param reason reason for opening the resource 80 * @param application application's name (the name used for the .desktop file). 81 * If not specified, QCoreApplication::applicationName is used 82 * @param parent pointer to the parent object 83 */ 84 ResourceInstance(WId wid, AccessReason reason = User, const QString &application = QString(), QObject *parent = 0); 85 86 /** 87 * Creates a new resource instance and automatically 88 * notifies the system that it was opened. 89 * 90 * In some special cases, where the URI of the resource is 91 * being constantly changed (for example, in the world globe, 92 * street map applications) you have two options: 93 * - to pass an empty resourceUri while passing the mimetype 94 * - to update the uri from time to time (in the example of 95 * the world map - to send URIs for major objects - cities 96 * or main streets. 97 * and in both cases reimplementing the currentUri() method 98 * which will return the exact URI shown at that specific moment. 99 * 100 * @param wid window id in which the resource is shown 101 * @param resourceUri URI of the resource that is shown 102 * @param mimetype the mime type of the resource 103 * @param title the title of the resource 104 * @param reason reason for opening the resource 105 * @param application application's name (the name used for the .desktop file). 106 * If not specified, QCoreApplication::applicationName is used 107 * @param parent pointer to the parent object 108 */ 109 ResourceInstance(WId wid, QUrl resourceUri, const QString &mimetype = QString(), const QString &title = QString(), AccessReason reason = User, const QString &application = QString(), QObject *parent = 0); 110 111 /** 112 * Destroys the ResourceInstance and notifies the system 113 * that the resource has been closed 114 */ 115 ~ResourceInstance(); 116 117 public Q_SLOTS: 118 /** 119 * Call this method to notify the system that you modified 120 * (the contents of) the resource 121 */ 122 void notifyModified(); 123 124 /** 125 * Call this method to notify the system that the resource 126 * has the focus in your application 127 * @note You only need to call this in MDI applications 128 */ 129 void notifyFocusedIn(); 130 131 /** 132 * Call this method to notify the system that the resource 133 * lost the focus in your application 134 * @note You only need to call this in MDI applications 135 */ 136 void notifyFocusedOut(); 137 138 /** 139 * This is a convenience method that sets the new URI. 140 * This is usually handled by sending the close event for 141 * the previous URI, and an open event for the new one. 142 */ 143 void setUri(const QUrl &newUri); 144 145 /** 146 * Sets the mimetype for this resource 147 */ 148 void setMimetype(const QString &mimetype); 149 150 /** 151 * Sets the title for this resource 152 */ 153 void setTitle(const QString &title); 154 155 Q_SIGNALS: 156 /** 157 * Emitted when the system wants to show the resource 158 * represented by this ResourceInstance. 159 * 160 * You should listen to this signal if you have multiple 161 * resources shown in one window (MDI). On catching it, show 162 * the resource and give it focus. 163 */ 164 void requestsFocus(); 165 166 public: 167 /** 168 * @returns the current uri 169 * The default implementation returns the URI that was passed 170 * to the constructor. 171 * You need to reimplement it only for the applications with 172 * frequently updated URIs. 173 */ 174 virtual QUrl uri() const; 175 176 /** 177 * @returns mimetype of the resource 178 */ 179 QString mimetype() const; 180 181 /** 182 * @returns title of the resource 183 */ 184 QString title() const; 185 186 /** 187 * @returns the window id 188 */ 189 WId winId() const; 190 191 /** 192 * @returns the reason for accessing the resource 193 */ 194 AccessReason accessReason() const; 195 196 /** 197 * If there's no way to tell for how long an application is keeping 198 * the resource open, you can just call this static method - it 199 * will notify the system that the application has accessed the 200 * resource 201 * @param uri URI of the resource 202 * @param application application's name (the name used for the .desktop file). 203 * If not specified, QCoreApplication::applicationName is used 204 * 205 */ 206 static void notifyAccessed(const QUrl &uri, const QString &application = QString()); 207 208 private: 209 ResourceInstancePrivate * const d; 210 }; 211 212 } 213 214 #endif // ACTIVITIES_RESOURCEINSTANCE_H_ -
nepomuk/query/queryserviceclient.cpp
diff --git a/nepomuk/query/queryserviceclient.cpp b/nepomuk/query/queryserviceclient.cpp index ddabff7..7d3ef0f 100644
a b public: 100 100 void _k_entriesRemoved( const QStringList& ); 101 101 void _k_finishedListing(); 102 102 void _k_handleQueryReply(QDBusPendingCallWatcher*); 103 void _k_serviceRegistered( const QString& ); 104 void _k_serviceUnregistered( const QString& ); 103 105 104 106 org::kde::nepomuk::QueryService* queryServiceInterface; 105 107 org::kde::nepomuk::Query* queryInterface; 108 QDBusServiceWatcher *queryServiceWatcher; 106 109 107 110 QueryServiceClient* q; 108 111 … … void Nepomuk::Query::QueryServiceClient::Private::_k_handleQueryReply(QDBusPendi 169 172 } 170 173 171 174 175 void Nepomuk::Query::QueryServiceClient::Private::_k_serviceRegistered(const QString &service) 176 { 177 if (service == "org.kde.nepomuk.services.nepomukqueryservice") { 178 delete queryServiceInterface; 179 queryServiceInterface = new org::kde::nepomuk::QueryService( "org.kde.nepomuk.services.nepomukqueryservice", 180 "/nepomukqueryservice", 181 dbusConnection ); 182 emit q->serviceAvailabilityChanged(true); 183 } 184 } 185 186 187 void Nepomuk::Query::QueryServiceClient::Private::_k_serviceUnregistered(const QString &service) 188 { 189 if (service == "org.kde.nepomuk.services.nepomukqueryservice") { 190 emit q->serviceAvailabilityChanged(false); 191 } 192 } 193 194 195 172 196 173 197 Nepomuk::Query::QueryServiceClient::QueryServiceClient( QObject* parent ) 174 198 : QObject( parent ), … … Nepomuk::Query::QueryServiceClient::QueryServiceClient( QObject* parent ) 182 206 d->queryServiceInterface = new org::kde::nepomuk::QueryService( "org.kde.nepomuk.services.nepomukqueryservice", 183 207 "/nepomukqueryservice", 184 208 d->dbusConnection ); 209 d->queryServiceWatcher = new QDBusServiceWatcher(QLatin1String("org.kde.nepomuk.services.nepomukqueryservice"), 210 QDBusConnection::sessionBus(), 211 QDBusServiceWatcher::WatchForOwnerChange, 212 this); 213 connect(d->queryServiceWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(_k_serviceRegistered(QString))); 214 connect(d->queryServiceWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(_k_serviceUnregistered(QString))); 185 215 } 186 216 187 217 -
nepomuk/query/queryserviceclient.h
diff --git a/nepomuk/query/queryserviceclient.h b/nepomuk/query/queryserviceclient.h index 234d4b0..d41bfc0 100644
a b namespace Nepomuk { 320 320 */ 321 321 void error( const QString& errorMessage ); 322 322 323 /** 324 * Emitted when the availability of the query service changes 325 * 326 * \since 4.8 327 */ 328 void serviceAvailabilityChanged( bool running ); 329 323 330 private: 324 331 class Private; 325 332 Private* const d; … … namespace Nepomuk { 327 334 Q_PRIVATE_SLOT( d, void _k_entriesRemoved( const QStringList& ) ) 328 335 Q_PRIVATE_SLOT( d, void _k_finishedListing() ) 329 336 Q_PRIVATE_SLOT( d, void _k_handleQueryReply(QDBusPendingCallWatcher*) ) 337 Q_PRIVATE_SLOT( d, void _k_serviceRegistered( const QString& ) ) 338 Q_PRIVATE_SLOT( d, void _k_serviceUnregistered( const QString& ) ) 330 339 }; 331 340 } 332 341 } -
plasma/CMakeLists.txt
diff --git a/plasma/CMakeLists.txt b/plasma/CMakeLists.txt index c179882..982c590 100644
a b if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION) 6 6 set(PLASMA_NO_KNEWSTUFF TRUE) 7 7 set(PLASMA_NO_SOLID TRUE) 8 8 set(PLASMA_NO_KIO TRUE) 9 set(PLASMA_NO_PACKAGEKIT TRUE) 9 10 set(PLASMA_NO_KUTILS TRUE) 10 11 set(PLASMA_NO_GLOBAL_SHORTCUTS TRUE) 11 12 endif(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION) 12 13 14 if(NOT Q_WS_X11) 15 set(PLASMA_NO_PACKAGEKIT TRUE) 16 endif(NOT Q_WS_X11) 17 13 18 include_directories(${CMAKE_CURRENT_SOURCE_DIR} 14 19 ${KDE4_KDECORE_INCLUDES} 15 20 ${KDE4_KDEUI_INCLUDES} … … if(NOT PLASMA_NO_SOLID) 44 49 set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} ${KDE4_SOLID_LIBS}) 45 50 endif(NOT PLASMA_NO_SOLID) 46 51 52 if(NOT PLASMA_NO_PACKAGEKIT) 53 add_definitions(-DPLASMA_ENABLE_PACKAGEKIT_SUPPORT=1) 54 set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} ${QT_QTDBUS_LIBRARY}) 55 endif(NOT PLASMA_NO_PACKAGEKIT) 56 47 57 if (NOT PLASMA_NO_KUTILS) 48 58 include_directories(${CMAKE_SOURCE_DIR}/kutils) 49 59 set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} ${KDE4_KUTILS_LIBS}) … … set(plasma_LIB_SRCS 117 127 private/animablegraphicswebview.cpp 118 128 private/applethandle.cpp 119 129 private/associatedapplicationmanager.cpp 130 private/componentinstaller.cpp 120 131 private/datacontainer_p.cpp 121 132 private/dataenginebindings.cpp 122 133 private/dataengineconsumer.cpp -
plasma/dataenginemanager.cpp
diff --git a/plasma/dataenginemanager.cpp b/plasma/dataenginemanager.cpp index f6dabf0..49df135 100644
a b 29 29 30 30 #include "datacontainer.h" 31 31 #include "pluginloader.h" 32 #include "private/componentinstaller_p.h" 32 33 #include "private/dataengine_p.h" 33 34 #include "private/datacontainer_p.h" 34 35 #include "scripting/scriptengine.h" … … Plasma::DataEngine *DataEngineManager::loadEngine(const QString &name) 130 131 131 132 DataEngine *engine = PluginLoader::pluginLoader()->loadDataEngine(name); 132 133 if (!engine) { 134 // Try installing the engine. However, it's too late for this request. 135 ComponentInstaller::self()->installMissingComponent("dataengine", name); 136 133 137 return d->nullEngine(); 134 138 } 135 139 -
new file plasma/private/componentinstaller.cpp
diff --git a/plasma/private/componentinstaller.cpp b/plasma/private/componentinstaller.cpp new file mode 100644 index 0000000..870667f
- + 1 /* 2 * Copyright 2011 Kevin Kofler <kevin.kofler@chello.at> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Library General Public License as 6 * published by the Free Software Foundation; either version 2, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this program; if not, write to the 16 * Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #include "private/componentinstaller_p.h" 21 22 #include <kglobal.h> 23 24 #ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT 25 #include <QSet> 26 #include <QDBusInterface> 27 #include <QDBusPendingCall> 28 #include <QWidget> 29 #include <QLatin1String> 30 #include <QStringList> 31 #endif 32 33 namespace Plasma 34 { 35 36 class ComponentInstallerPrivate 37 { 38 public: 39 #ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT 40 QSet<QString> alreadyPrompted; 41 #endif 42 }; 43 44 class ComponentInstallerSingleton 45 { 46 public: 47 ComponentInstaller self; 48 }; 49 50 K_GLOBAL_STATIC(ComponentInstallerSingleton, privateComponentInstallerSelf) 51 52 ComponentInstaller *ComponentInstaller::self() 53 { 54 return &privateComponentInstallerSelf->self; 55 } 56 57 ComponentInstaller::ComponentInstaller() 58 : d(new ComponentInstallerPrivate) 59 { 60 } 61 62 ComponentInstaller::~ComponentInstaller() 63 { 64 delete d; 65 } 66 67 void ComponentInstaller::installMissingComponent(const QString &type, 68 const QString &name, 69 QWidget *parent, bool force) 70 { 71 #ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT 72 QString searchString = type + '-' + name; 73 74 if (!force) { 75 if (d->alreadyPrompted.contains(searchString)) { 76 return; 77 } 78 } 79 80 d->alreadyPrompted.insert(searchString); 81 82 QDBusInterface packageKit(QLatin1String("org.freedesktop.PackageKit"), 83 QLatin1String("/org/freedesktop/PackageKit"), 84 QLatin1String("org.freedesktop.PackageKit.Modify")); 85 // We don't check packageKit.isValid() because the service is activated on 86 // demand, so it will show up as "not valid". 87 WId wid = 0; 88 if (parent) { 89 wid = parent->winId(); 90 } 91 QStringList resources; 92 resources.append(searchString); 93 packageKit.asyncCall(QLatin1String("InstallResources"), (unsigned int) wid, 94 QLatin1String("plasma-service"), resources, QString()); 95 #else 96 Q_UNUSED(type); 97 Q_UNUSED(name); 98 Q_UNUSED(parent); 99 Q_UNUSED(force); 100 #endif 101 } 102 103 } // namespace Plasma -
new file plasma/private/componentinstaller_p.h
diff --git a/plasma/private/componentinstaller_p.h b/plasma/private/componentinstaller_p.h new file mode 100644 index 0000000..f85cbb6
- + 1 /* 2 * Copyright 2011 Kevin Kofler <kevin.kofler@chello.at> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Library General Public License as 6 * published by the Free Software Foundation; either version 2, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this program; if not, write to the 16 * Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef PLASMA_COMPONENTINSTALLER_H 21 #define PLASMA_COMPONENTINSTALLER_H 22 23 class QString; 24 class QWidget; 25 26 namespace Plasma 27 { 28 29 class ComponentInstallerPrivate; 30 31 /** 32 * @class ComponentInstaller plasma/private/componentinstaller_p.h 33 * 34 * @short This class provides a generic API for installation of components. 35 * 36 * @internal 37 * 38 * Plasma::ComponentInstaller allows searching for a missing data or script 39 * engine by name, and allowing the user to install the missing service. 40 * Currently, PackageKit is supported as the mechanism to install components, 41 * but more mechanisms could be supported in the future through the same API. 42 * 43 * @since 4.8 44 */ 45 class ComponentInstaller 46 { 47 public: 48 /** 49 * Singleton pattern accessor. 50 */ 51 static ComponentInstaller *self(); 52 53 /** 54 * Installs a missing component asynchronously. 55 * 56 * By default, this method will cache requested components and not 57 * prompt again for the same engine in the same session. The force 58 * parameter can be used to disable this mechanism, e.g. when the user 59 * just installed a new widget written in a scripting language, and so 60 * is likely to want the script engine installed after all. 61 * 62 * In the case of on-demand installation, this will unfortunately not 63 * allow the call which triggered the missing component lookup to 64 * succeed, but we cannot afford to block all of Plasma until the 65 * mechanism is done installing the service. 66 * 67 * This function does nothing if PackageKit integration was disabled at 68 * compile time. 69 * 70 * @param type the type of the component, should be "scriptengine" or 71 * "dataengine" 72 * @param name the name of the component 73 * @param parent a parent widget, used to set the wid for PackageKit 74 * @param force whether to always prompt, even if recently prompted 75 */ 76 void installMissingComponent(const QString &type, const QString &name, 77 QWidget *parent = 0, bool force = false); 78 79 private: 80 /** 81 * Default constructor. The singleton method self() is the 82 * preferred access mechanism. 83 */ 84 ComponentInstaller(); 85 ~ComponentInstaller(); 86 87 ComponentInstallerPrivate *const d; 88 89 friend class ComponentInstallerSingleton; 90 }; 91 92 } // namespace Plasma 93 94 #endif // multiple inclusion guard -
plasma/scripting/scriptengine.cpp
diff --git a/plasma/scripting/scriptengine.cpp b/plasma/scripting/scriptengine.cpp index fb8cd1a..21f8a9a 100644
a b 27 27 #include "applet.h" 28 28 #include "dataengine.h" 29 29 #include "package.h" 30 #include "private/componentinstaller_p.h" 30 31 #include "scripting/appletscript.h" 31 32 #include "scripting/dataenginescript.h" 32 33 #include "scripting/runnerscript.h" … … ScriptEngine *loadEngine(const QString &language, ComponentType type, QObject *p 196 197 << "! error reported: " << error; 197 198 } 198 199 200 // Try installing the engine. However, it's too late for this request. 201 ComponentInstaller::self()->installMissingComponent("scriptengine", language); 202 199 203 return 0; 200 204 } 201 205 -
solid/solid/CMakeLists.txt
diff --git a/solid/solid/CMakeLists.txt b/solid/solid/CMakeLists.txt index 0aa7a43..623dd0a 100644
a b file(MAKE_DIRECTORY 42 42 ${CMAKE_CURRENT_BINARY_DIR}/backends/hal 43 43 ${CMAKE_CURRENT_BINARY_DIR}/backends/udev 44 44 ${CMAKE_CURRENT_BINARY_DIR}/backends/wmi 45 ${CMAKE_CURRENT_BINARY_DIR}/backends/fuse 45 46 ) 46 47 47 48 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${KDE4_C_FLAGS}") # enable -fvisibility=hidden for C sources … … if(NOT WIN32 AND NOT APPLE) 289 290 backends/fstab/fstabwatcher.cpp 290 291 ) 291 292 293 message(STATUS "Building Solid Fuse backend." ) 294 set(solid_LIB_SRCS ${solid_LIB_SRCS} 295 backends/fuse/fusemanager.cpp 296 backends/fuse/fusedevice.cpp 297 backends/fuse/fusestorageaccess.cpp 298 backends/fuse/fusestoragedrive.cpp 299 backends/fuse/fusestoragevolume.cpp 300 backends/fuse/fusehandling.cpp 301 backends/fuse/fusewatcher.cpp 302 ) 303 292 304 endif(NOT WIN32 AND NOT APPLE) 293 305 294 306 if(APPLE) -
new file solid/solid/backends/fuse/fusedevice.cpp
diff --git a/solid/solid/backends/fuse/fusedevice.cpp b/solid/solid/backends/fuse/fusedevice.cpp new file mode 100644 index 0000000..20a9783
- + 1 /* 2 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 3 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #include "fusedevice.h" 23 #include "fusehandling.h" 24 #include "fusestorageaccess.h" 25 #include "fusestoragedrive.h" 26 #include "fusestoragevolume.h" 27 #include "fuseservice.h" 28 #include <QtCore/QStringList> 29 #include <QDebug> 30 31 using namespace Solid::Backends::Fuse; 32 33 FuseDevice::FuseDevice(QString udi) : 34 Solid::Ifaces::Device(), 35 m_udi(udi) 36 { 37 qDebug() << "UDI:" << udi; 38 m_device = m_udi.mid(QString::fromLatin1(FUSE_UDI_PREFIX).length(), -1); 39 40 if (m_device.endsWith(":media")) { 41 m_device.chop(6); 42 } 43 44 m_product = m_device; 45 m_vendor = "FUSE"; 46 47 m_description = m_vendor + " on " + m_product; 48 qDebug() << "Info:" << m_device << m_product << m_vendor << m_description; 49 } 50 51 FuseDevice::~FuseDevice() 52 { 53 } 54 55 QString FuseDevice::udi() const 56 { 57 return m_udi; 58 } 59 60 QString FuseDevice::parentUdi() const 61 { 62 return udi(); 63 // return QString::fromLatin1(FUSE_UDI_PREFIX); 64 } 65 66 QString FuseDevice::vendor() const 67 { 68 return m_vendor; 69 } 70 71 QString FuseDevice::product() const 72 { 73 return m_product; 74 } 75 76 QString FuseDevice::icon() const 77 { 78 return QString::fromLatin1("drive-removable-media"); 79 } 80 81 QStringList FuseDevice::emblems() const 82 { 83 QStringList res; 84 const FuseStorageAccess accessIface(const_cast<FuseDevice *>(this)); 85 if (accessIface.isAccessible()) { 86 res << "emblem-mounted"; 87 } else { 88 res << "emblem-unmounted"; 89 } 90 91 return res; 92 } 93 94 QString FuseDevice::description() const 95 { 96 return m_description; 97 } 98 99 bool FuseDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type) const 100 { 101 switch (type) { 102 case Solid::DeviceInterface::StorageAccess: 103 case Solid::DeviceInterface::StorageVolume: 104 case Solid::DeviceInterface::StorageDrive: 105 return true; 106 107 default: 108 return false; 109 } 110 } 111 112 QObject* FuseDevice::createDeviceInterface(const Solid::DeviceInterface::Type &type) 113 { 114 switch (type) { 115 case Solid::DeviceInterface::StorageAccess: 116 return new FuseStorageAccess(this); 117 118 case Solid::DeviceInterface::StorageVolume: 119 return new FuseStorageVolume(this); 120 121 case Solid::DeviceInterface::StorageDrive: 122 return new FuseStorageDrive(this); 123 124 default: 125 return 0; 126 } 127 } 128 129 QString FuseDevice::device() const 130 { 131 return m_device; 132 } 133 134 void FuseDevice::onMtabChanged(const QString& device) 135 { 136 if (m_device == device) 137 emit mtabChanged(device); 138 } -
new file solid/solid/backends/fuse/fusedevice.h
diff --git a/solid/solid/backends/fuse/fusedevice.h b/solid/solid/backends/fuse/fusedevice.h new file mode 100644 index 0000000..913da39
- + 1 /* 2 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 3 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef SOLID_BACKENDS_FUSE_FUSE_DEVICE_H 23 #define SOLID_BACKENDS_FUSE_FUSE_DEVICE_H 24 25 #include <solid/ifaces/device.h> 26 #include <QtCore/QStringList> 27 28 namespace Solid 29 { 30 namespace Backends 31 { 32 namespace Fuse 33 { 34 35 class FuseDevice: public Solid::Ifaces::Device 36 { 37 Q_OBJECT 38 39 public: 40 FuseDevice(QString udi); 41 42 virtual ~FuseDevice(); 43 44 virtual QString udi() const; 45 46 virtual QString parentUdi() const; 47 48 virtual QString vendor() const; 49 50 virtual QString product() const; 51 52 virtual QString icon() const; 53 54 virtual QStringList emblems() const; 55 56 virtual QString description() const; 57 58 virtual bool queryDeviceInterface(const Solid::DeviceInterface::Type &type) const; 59 60 virtual QObject *createDeviceInterface(const Solid::DeviceInterface::Type &type); 61 62 QString device() const; 63 64 Q_SIGNALS: 65 void mtabChanged(const QString& device); 66 67 private Q_SLOTS: 68 void onMtabChanged(const QString& device); 69 70 private: 71 QString m_udi; 72 QString m_device; 73 QString m_product; 74 QString m_vendor; 75 QString m_description; 76 }; 77 78 } 79 } 80 } 81 #endif // SOLID_BACKENDS_UPNP_UPNP_DEVICE_H -
new file solid/solid/backends/fuse/fusehandling.cpp
diff --git a/solid/solid/backends/fuse/fusehandling.cpp b/solid/solid/backends/fuse/fusehandling.cpp new file mode 100644 index 0000000..f2e57e3
- + 1 /* 2 Copyright 2006-2010 Kevin Ottens <ervin@kde.org> 3 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 4 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License as published by the Free Software Foundation; either 9 version 2.1 of the License, or (at your option) version 3, or any 10 later version accepted by the membership of KDE e.V. (or its 11 successor approved by the membership of KDE e.V.), which shall 12 act as a proxy defined in Section 6 of version 3 of the license. 13 14 This library is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public 20 License along with this library. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #include "fusehandling.h" 24 25 #include <QtCore/QFile> 26 #include <QtCore/QObject> 27 #include <QtCore/QProcess> 28 #include <QtCore/QTextStream> 29 #include <QtCore/QTime> 30 31 #include <solid/soliddefs_p.h> 32 33 #include <config.h> 34 #include <stdlib.h> 35 36 #ifdef HAVE_SYS_MNTTAB_H 37 #include <sys/mnttab.h> 38 #endif 39 #ifdef HAVE_MNTENT_H 40 #include <mntent.h> 41 #elif defined(HAVE_SYS_MNTENT_H) 42 #include <sys/mntent.h> 43 #endif 44 45 // This is the *BSD branch 46 #ifdef HAVE_SYS_MOUNT_H 47 #ifdef HAVE_SYS_TYPES_H 48 #include <sys/types.h> 49 #endif 50 #ifdef HAVE_SYS_PARAM_H 51 #include <sys/param.h> 52 #endif 53 #include <sys/mount.h> 54 #endif 55 56 #ifndef HAVE_GETMNTINFO 57 # ifdef _PATH_MOUNTED 58 // On some Linux, MNTTAB points to /etc/fstab ! 59 # undef MNTTAB 60 # define MNTTAB _PATH_MOUNTED 61 # else 62 # ifndef MNTTAB 63 # ifdef MTAB_FILE 64 # define MNTTAB MTAB_FILE 65 # else 66 # define MNTTAB "/etc/mnttab" 67 # endif 68 # endif 69 # endif 70 #endif 71 72 // There are (at least) four kind of APIs: 73 // setmntent + getmntent + struct mntent (linux...) 74 // getmntent + struct mnttab 75 // mntctl + struct vmount (AIX) 76 // getmntinfo + struct statfs&flags (BSD 4.4 and friends) 77 // getfsent + char* (BSD 4.3 and friends) 78 79 #ifdef HAVE_SETMNTENT 80 #define SETMNTENT setmntent 81 #define ENDMNTENT endmntent 82 #define STRUCT_MNTENT struct mntent * 83 #define STRUCT_SETMNTENT FILE * 84 #define GETMNTENT(file, var) ((var = getmntent(file)) != 0) 85 #define MOUNTPOINT(var) var->mnt_dir 86 #define MOUNTTYPE(var) var->mnt_type 87 #define MOUNTOPTIONS(var) var->mnt_opts 88 #define FSNAME(var) var->mnt_fsname 89 #else 90 #define SETMNTENT fopen 91 #define ENDMNTENT fclose 92 #define STRUCT_MNTENT struct mnttab 93 #define STRUCT_SETMNTENT FILE * 94 #define GETMNTENT(file, var) (getmntent(file, &var) == 0) 95 #define MOUNTPOINT(var) var.mnt_mountp 96 #define MOUNTTYPE(var) var.mnt_fstype 97 #define MOUNTOPTIONS(var) var.mnt_mntopts 98 #define FSNAME(var) var.mnt_special 99 #endif 100 101 #include <QDebug> 102 103 SOLID_GLOBAL_STATIC(Solid::Backends::Fuse::FuseHandling, globalFuseCache) 104 105 Solid::Backends::Fuse::FuseHandling::FuseHandling() 106 : m_mtabCacheValid(false) 107 { } 108 109 bool _k_isFuseFileSystem(const QString &fstype, const QString &devName) 110 { 111 return fstype.startsWith("fuse."); 112 } 113 114 QStringList Solid::Backends::Fuse::FuseHandling::deviceList() 115 { 116 _k_updateMtabMountPointsCache(); 117 118 QStringList devices = globalFuseCache->m_mtabCache.values(); 119 return devices; 120 } 121 122 QStringList Solid::Backends::Fuse::FuseHandling::mountPoints(const QString &device) 123 { 124 _k_updateMtabMountPointsCache(); 125 126 return QStringList() << device; 127 } 128 129 QProcess *Solid::Backends::Fuse::FuseHandling::callSystemCommand(const QString &commandName, 130 const QStringList &args, 131 QObject *obj, const char *slot) 132 { 133 QStringList env = QProcess::systemEnvironment(); 134 env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=/sbin:/bin:/usr/sbin/:/usr/bin"); 135 136 QProcess *process = new QProcess(obj); 137 138 QObject::connect(process, SIGNAL(finished(int,QProcess::ExitStatus)), 139 obj, slot); 140 141 process->setEnvironment(env); 142 process->start(commandName, args); 143 144 if (process->waitForStarted()) { 145 return process; 146 } else { 147 delete process; 148 return 0; 149 } 150 } 151 152 QProcess *Solid::Backends::Fuse::FuseHandling::callSystemCommand(const QString &commandName, 153 const QString &device, 154 QObject *obj, const char *slot) 155 { 156 return callSystemCommand(commandName, QStringList() << device, obj, slot); 157 } 158 159 void Solid::Backends::Fuse::FuseHandling::_k_updateMtabMountPointsCache() 160 { 161 if (globalFuseCache->m_mtabCacheValid) 162 return; 163 164 globalFuseCache->m_mtabCache.clear(); 165 166 STRUCT_SETMNTENT mnttab; 167 if ((mnttab = SETMNTENT(MNTTAB, "r")) == 0) 168 return; 169 170 STRUCT_MNTENT fe; 171 while (GETMNTENT(mnttab, fe)) 172 { 173 QString type = QFile::decodeName(MOUNTTYPE(fe)); 174 if (_k_isFuseFileSystem(type, QString())) { 175 const QString device = QFile::decodeName(FSNAME(fe)); 176 const QString mountpoint = QFile::decodeName(MOUNTPOINT(fe)); 177 globalFuseCache->m_mtabCache << mountpoint; 178 } 179 } 180 ENDMNTENT(mnttab); 181 182 globalFuseCache->m_mtabCacheValid = true; 183 } 184 185 QStringList Solid::Backends::Fuse::FuseHandling::currentMountPoints(const QString &device) 186 { 187 _k_updateMtabMountPointsCache(); 188 return QStringList() << device; 189 } 190 191 void Solid::Backends::Fuse::FuseHandling::flushMtabCache() 192 { 193 globalFuseCache->m_mtabCacheValid = false; 194 } 195 -
new file solid/solid/backends/fuse/fusehandling.h
diff --git a/solid/solid/backends/fuse/fusehandling.h b/solid/solid/backends/fuse/fusehandling.h new file mode 100644 index 0000000..31662c8
- + 1 /* 2 Copyright 2006-2010 Kevin Ottens <ervin@kde.org> 3 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 4 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License as published by the Free Software Foundation; either 9 version 2.1 of the License, or (at your option) version 3, or any 10 later version accepted by the membership of KDE e.V. (or its 11 successor approved by the membership of KDE e.V.), which shall 12 act as a proxy defined in Section 6 of version 3 of the license. 13 14 This library is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public 20 License along with this library. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef SOLID_BACKENDS_FUSE_FUSEHANDLING_H 24 #define SOLID_BACKENDS_FUSE_FUSEHANDLING_H 25 26 #include <QtCore/QString> 27 #include <QtCore/QMultiHash> 28 29 #include <QString> 30 #include <QSet> 31 32 class QProcess; 33 class QObject; 34 35 namespace Solid 36 { 37 namespace Backends 38 { 39 namespace Fuse 40 { 41 42 class FuseHandling 43 { 44 public: 45 FuseHandling(); 46 47 static QStringList deviceList(); 48 static QStringList currentMountPoints(const QString &device); 49 static QStringList mountPoints(const QString &device); 50 static QProcess *callSystemCommand(const QString &commandName, 51 const QStringList &args, 52 QObject *obj, const char *slot); 53 static QProcess *callSystemCommand(const QString &commandName, 54 const QString &device, 55 QObject *obj, const char *slot); 56 static void flushMtabCache(); 57 static void flushFuseCache(); 58 59 private: 60 static void _k_updateMtabMountPointsCache(); 61 static void _k_updateFuseMountPointsCache(); 62 63 QSet<QString> m_mtabCache; 64 bool m_mtabCacheValid; 65 66 }; 67 68 } 69 } 70 } 71 72 #endif 73 74 -
new file solid/solid/backends/fuse/fusemanager.cpp
diff --git a/solid/solid/backends/fuse/fusemanager.cpp b/solid/solid/backends/fuse/fusemanager.cpp new file mode 100644 index 0000000..9011bd5
- + 1 /* 2 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 3 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #include "fusemanager.h" 23 #include "fusedevice.h" 24 #include "fusehandling.h" 25 #include "../shared/rootdevice.h" 26 #include "fuseservice.h" 27 #include "fusewatcher.h" 28 29 #include <QDebug> 30 31 using namespace Solid::Backends::Fuse; 32 using namespace Solid::Backends::Shared; 33 34 FuseManager::FuseManager(QObject *parent) 35 : Solid::Ifaces::DeviceManager(parent) 36 { 37 m_supportedInterfaces << Solid::DeviceInterface::StorageAccess; 38 39 m_deviceList = FuseHandling::deviceList(); 40 41 connect(FuseWatcher::instance(), SIGNAL(mtabChanged()), this, SLOT(onMtabChanged())); 42 } 43 44 QString FuseManager::udiPrefix() const 45 { 46 return QString::fromLatin1(FUSE_UDI_PREFIX); 47 } 48 49 QSet<Solid::DeviceInterface::Type> FuseManager::supportedInterfaces() const 50 { 51 return m_supportedInterfaces; 52 } 53 54 QStringList FuseManager::allDevices() 55 { 56 QStringList result; 57 58 result << udiPrefix(); 59 foreach (const QString &device, m_deviceList) { 60 result << udiPrefix() + device; 61 } 62 63 return result; 64 } 65 66 QStringList FuseManager::devicesFromQuery( const QString &parentUdi, 67 Solid::DeviceInterface::Type type) 68 { 69 qDebug() << "devicesFromQuery" << parentUdi << type; 70 71 if (type == Solid::DeviceInterface::StorageAccess 72 || type == Solid::DeviceInterface::StorageVolume 73 || type == Solid::DeviceInterface::StorageDrive) { 74 75 if (parentUdi.isEmpty() || parentUdi == udiPrefix()) { 76 QStringList list = allDevices(); 77 list.removeFirst(); 78 return list; 79 80 } else { 81 QStringList list; 82 list << parentUdi; 83 return list; 84 } 85 } 86 return QStringList(); 87 } 88 89 QObject *FuseManager::createDevice(const QString &udi) 90 { 91 qDebug() << "createDevice" << udi; 92 93 if (udi == udiPrefix()) { 94 qDebug() << "returning a root device"; 95 RootDevice *root = new RootDevice(FUSE_UDI_PREFIX); 96 97 root->setProduct(tr("FUSE mounts")); 98 root->setDescription(tr("FUSE mounts in your system")); 99 root->setIcon("folder-remote"); 100 101 return root; 102 103 } else { 104 // global device manager makes sure udi starts with udi prefix + '/' 105 QString internalName = udi.mid( udiPrefix().length(), -1 ); 106 qDebug() << "internalName" << internalName; 107 108 if (!m_deviceList.contains(internalName)) 109 return 0; 110 111 qDebug() << "Returning a FuseDevice for" << udi; 112 QObject* device = new FuseDevice(udi); 113 connect (this, SIGNAL(mtabChanged(QString)), device, SLOT(onMtabChanged(QString))); 114 return device; 115 116 } 117 } 118 119 void FuseManager::_k_updateDeviceList() 120 { 121 QStringList deviceList = FuseHandling::deviceList(); 122 QSet <QString> newlist = deviceList.toSet(); 123 QSet <QString> oldlist = m_deviceList.toSet(); 124 125 qDebug() << "old list" << oldlist << "new list" << newlist; 126 m_deviceList = deviceList; 127 128 foreach (const QString &device, newlist) { 129 if ( !oldlist.contains(device) ) { 130 emit deviceAdded(udiPrefix() + device); 131 } 132 } 133 134 foreach (const QString &device, oldlist) { 135 if ( !newlist.contains(device) ) { 136 emit deviceRemoved(udiPrefix() + device); 137 } 138 } 139 } 140 141 void FuseManager::onMtabChanged() 142 { 143 FuseHandling::flushMtabCache(); 144 145 _k_updateDeviceList(); 146 147 foreach (const QString &device, m_deviceList) { 148 // notify storageaccess objects via device ... 149 emit mtabChanged(device); 150 } 151 } 152 153 FuseManager::~FuseManager() 154 { 155 } -
new file solid/solid/backends/fuse/fusemanager.h
diff --git a/solid/solid/backends/fuse/fusemanager.h b/solid/solid/backends/fuse/fusemanager.h new file mode 100644 index 0000000..a0b3e57
- + 1 /* 2 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 3 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef SOLID_BACKENDS_FUSE_FUSEMANAGER_H 23 #define SOLID_BACKENDS_FUSE_FUSEMANAGER_H 24 25 #include <solid/ifaces/devicemanager.h> 26 #include <solid/deviceinterface.h> 27 #include <QtCore/QStringList> 28 #include <QtCore/QSet> 29 30 namespace Solid 31 { 32 namespace Backends 33 { 34 namespace Fuse 35 { 36 class AbstractDeviceFactory; 37 38 class FuseManager : public Solid::Ifaces::DeviceManager 39 { 40 Q_OBJECT 41 42 public: 43 explicit FuseManager(QObject *parent); 44 virtual ~FuseManager(); 45 46 virtual QString udiPrefix() const ; 47 virtual QSet<Solid::DeviceInterface::Type> supportedInterfaces() const; 48 virtual QStringList allDevices(); 49 virtual QStringList devicesFromQuery(const QString &parentUdi, Solid::DeviceInterface::Type type); 50 virtual QObject *createDevice(const QString &udi); 51 52 Q_SIGNALS: 53 void mtabChanged(const QString& device); 54 55 private Q_SLOTS: 56 void onMtabChanged(); 57 58 private: 59 QSet<Solid::DeviceInterface::Type> m_supportedInterfaces; 60 QStringList m_deviceList; 61 void _k_updateDeviceList(); 62 }; 63 64 } 65 } 66 } 67 68 #endif -
new file solid/solid/backends/fuse/fuseservice.h
diff --git a/solid/solid/backends/fuse/fuseservice.h b/solid/solid/backends/fuse/fuseservice.h new file mode 100644 index 0000000..22912dc
- + 1 /* 2 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 3 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef SOLID_BACKENDS_FUSE_SERVICE_H 23 #define SOLID_BACKENDS_FUSE_SERVICE_H 24 25 #define FUSE_UDI_PREFIX "/org/kde/fuse" 26 27 #endif // SOLID_BACKENDS_FUSE_H 28 -
new file solid/solid/backends/fuse/fusestorageaccess.cpp
diff --git a/solid/solid/backends/fuse/fusestorageaccess.cpp b/solid/solid/backends/fuse/fusestorageaccess.cpp new file mode 100644 index 0000000..cb68444
- + 1 /* 2 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 3 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #include "fusewatcher.h" 23 #include <solid/backends/fuse/fusedevice.h> 24 #include <solid/backends/fuse/fusehandling.h> 25 #include <solid/backends/fuse/fuseservice.h> 26 #include <solid/backends/fuse/fusestorageaccess.h> 27 #include <QtCore/QStringList> 28 29 #include <QTimer> 30 #include <QDebug> 31 32 #define MTAB "/etc/mtab" 33 34 using namespace Solid::Backends::Fuse; 35 36 FuseStorageAccess::FuseStorageAccess(Solid::Backends::Fuse::FuseDevice *device) : 37 QObject(device), 38 m_fuseDevice(device) 39 { 40 QStringList currentMountPoints = FuseHandling::currentMountPoints(device->device()); 41 if (currentMountPoints.isEmpty()) { 42 m_filePath = FuseHandling::mountPoints(device->device()).first(); 43 m_isAccessible = false; 44 } else { 45 m_filePath = currentMountPoints.first(); 46 m_isAccessible = true; 47 } 48 49 connect(device, SIGNAL(mtabChanged(QString)), this, SLOT(onMtabChanged(QString))); 50 QTimer::singleShot(0, this, SLOT(connectDBusSignals())); 51 52 // qDebug() << "TEST:" << 53 // QMetaObject::invokeMethod(this, "accessibilityChanged", Qt::QueuedConnection, 54 // Q_ARG(bool, true), Q_ARG(QString, device->udi())); 55 } 56 57 FuseStorageAccess::~FuseStorageAccess() 58 { 59 } 60 61 62 void FuseStorageAccess::connectDBusSignals() 63 { 64 m_fuseDevice->registerAction("setup", this, 65 SLOT(slotSetupRequested()), 66 SLOT(slotSetupDone(int,QString))); 67 68 m_fuseDevice->registerAction("teardown", this, 69 SLOT(slotTeardownRequested()), 70 SLOT(slotTeardownDone(int,QString))); 71 } 72 73 const Solid::Backends::Fuse::FuseDevice *FuseStorageAccess::fuseDevice() const 74 { 75 return m_fuseDevice; 76 } 77 78 bool FuseStorageAccess::isAccessible() const 79 { 80 return m_isAccessible; 81 } 82 83 QString FuseStorageAccess::filePath() const 84 { 85 return m_filePath; 86 } 87 88 bool FuseStorageAccess::isIgnored() const 89 { 90 return false; 91 } 92 93 bool FuseStorageAccess::setup() 94 { 95 if (filePath().isEmpty()) { 96 return false; 97 } 98 m_fuseDevice->broadcastActionRequested("setup"); 99 m_process = FuseHandling::callSystemCommand("mount", filePath(), 100 this, SLOT(slotSetupFinished(int,QProcess::ExitStatus))); 101 102 return m_process!=0; 103 } 104 105 void FuseStorageAccess::slotSetupRequested() 106 { 107 emit setupRequested(m_fuseDevice->udi()); 108 } 109 110 bool FuseStorageAccess::teardown() 111 { 112 if (filePath().isEmpty()) { 113 return false; 114 } 115 m_fuseDevice->broadcastActionRequested("teardown"); 116 m_process = FuseHandling::callSystemCommand("umount", filePath(), 117 this, SLOT(slotTeardownFinished(int,QProcess::ExitStatus))); 118 119 return m_process!=0; 120 } 121 122 void FuseStorageAccess::slotTeardownRequested() 123 { 124 emit teardownRequested(m_fuseDevice->udi()); 125 } 126 127 void FuseStorageAccess::slotSetupFinished(int exitCode, QProcess::ExitStatus /*exitStatus*/) 128 { 129 if (exitCode==0) { 130 m_fuseDevice->broadcastActionDone("setup", Solid::NoError, QString()); 131 } else { 132 m_fuseDevice->broadcastActionDone("setup", Solid::UnauthorizedOperation, m_process->readAllStandardError()); 133 } 134 delete m_process; 135 } 136 137 void FuseStorageAccess::slotSetupDone(int error, const QString &errorString) 138 { 139 emit setupDone(static_cast<Solid::ErrorType>(error), errorString, m_fuseDevice->udi()); 140 } 141 142 void FuseStorageAccess::slotTeardownFinished(int exitCode, QProcess::ExitStatus /*exitStatus*/) 143 { 144 if (exitCode==0) { 145 m_fuseDevice->broadcastActionDone("teardown", Solid::NoError, QString()); 146 } else { 147 m_fuseDevice->broadcastActionDone("teardown", Solid::UnauthorizedOperation, m_process->readAllStandardError()); 148 } 149 delete m_process; 150 } 151 152 void FuseStorageAccess::slotTeardownDone(int error, const QString &errorString) 153 { 154 emit teardownDone(static_cast<Solid::ErrorType>(error), errorString, m_fuseDevice->udi()); 155 } 156 157 void FuseStorageAccess::onMtabChanged(const QString& device) 158 { 159 QStringList currentMountPoints = FuseHandling::currentMountPoints(device); 160 if (currentMountPoints.isEmpty()) { 161 // device umounted 162 m_filePath = FuseHandling::mountPoints(device).first(); 163 m_isAccessible = false; 164 emit accessibilityChanged(false, QString(FUSE_UDI_PREFIX) + device); 165 } else { 166 // device added 167 m_filePath = currentMountPoints.first(); 168 m_isAccessible = true; 169 emit accessibilityChanged(true, QString(FUSE_UDI_PREFIX) + device); 170 } 171 } -
new file solid/solid/backends/fuse/fusestorageaccess.h
diff --git a/solid/solid/backends/fuse/fusestorageaccess.h b/solid/solid/backends/fuse/fusestorageaccess.h new file mode 100644 index 0000000..bd5fee3
- + 1 /* 2 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 3 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef SOLID_BACKENDS_FUSE_STORAGEACCESS_H 23 #define SOLID_BACKENDS_FUSE_STORAGEACCESS_H 24 25 #include <solid/ifaces/storageaccess.h> 26 27 #include <QtCore/QObject> 28 #include <QtCore/QProcess> 29 30 namespace Solid 31 { 32 namespace Backends 33 { 34 namespace Fuse 35 { 36 class FuseDevice; 37 class FuseStorageAccess : public QObject, public Solid::Ifaces::StorageAccess 38 { 39 Q_OBJECT 40 Q_INTERFACES(Solid::Ifaces::StorageAccess) 41 Q_INTERFACES(Solid::Ifaces::DeviceInterface) 42 43 public: 44 explicit FuseStorageAccess(Solid::Backends::Fuse::FuseDevice *device); 45 46 virtual ~FuseStorageAccess(); 47 48 virtual bool isAccessible() const; 49 50 virtual QString filePath() const; 51 52 virtual bool isIgnored() const; 53 54 virtual bool setup(); 55 56 virtual bool teardown(); 57 58 public: 59 const Solid::Backends::Fuse::FuseDevice* fuseDevice() const; 60 61 Q_SIGNALS: 62 void accessibilityChanged(bool accessible, const QString &udi); 63 64 void setupDone(Solid::ErrorType error, QVariant data, const QString &udi); 65 66 void teardownDone(Solid::ErrorType error, QVariant data, const QString &udi); 67 68 void setupRequested(const QString &udi); 69 70 void teardownRequested(const QString &udi); 71 72 private Q_SLOTS: 73 void slotSetupFinished(int exitCode, QProcess::ExitStatus exitStatus); 74 void slotTeardownFinished(int exitCode, QProcess::ExitStatus exitStatus); 75 void onMtabChanged(const QString& device); 76 void connectDBusSignals(); 77 78 void slotSetupRequested(); 79 void slotSetupDone(int error, const QString &errorString); 80 void slotTeardownRequested(); 81 void slotTeardownDone(int error, const QString &errorString); 82 83 private: 84 Solid::Backends::Fuse::FuseDevice *m_fuseDevice; 85 QProcess *m_process; 86 QString m_filePath; 87 bool m_isAccessible; 88 }; 89 90 } 91 } 92 } 93 94 #endif // SOLID_BACKENDS_FUSE_DEVICE_INTERFACE_H -
new file solid/solid/backends/fuse/fusestoragedrive.cpp
diff --git a/solid/solid/backends/fuse/fusestoragedrive.cpp b/solid/solid/backends/fuse/fusestoragedrive.cpp new file mode 100644 index 0000000..4910349
- + 1 /* 2 * Copyright (C) 2012 Ivan Cukic <ivan.cukic(at)kde.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2, 6 * or (at your option) any later version, as published by the Free 7 * Software Foundation 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details 13 * 14 * You should have received a copy of the GNU General Public 15 * License along with this program; if not, write to the 16 * Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #include "fusestoragedrive.h" 21 #include <QDebug> 22 23 namespace Solid 24 { 25 namespace Backends 26 { 27 namespace Fuse 28 { 29 30 FuseStorageDrive::FuseStorageDrive(FuseDevice *device) 31 : QObject(device) 32 { 33 qDebug() << "FuseStorageDrive constructor" << device->device(); 34 } 35 36 FuseStorageDrive::~FuseStorageDrive() 37 { 38 } 39 40 bool FuseStorageDrive::isHotpluggable() const 41 { 42 qDebug() << "isHotpluggable true"; 43 return true; 44 } 45 46 bool FuseStorageDrive::isRemovable() const 47 { 48 qDebug() << "isRemovable true"; 49 return true; 50 } 51 52 qulonglong FuseStorageDrive::size() const 53 { 54 // TODO: make this real 55 return 1024; 56 } 57 58 Solid::StorageDrive::Bus FuseStorageDrive::bus() const 59 { 60 return Solid::StorageDrive::Platform; 61 } 62 63 Solid::StorageDrive::DriveType FuseStorageDrive::driveType() const 64 { 65 return Solid::StorageDrive::HardDisk; 66 } 67 68 } 69 } 70 } -
new file solid/solid/backends/fuse/fusestoragedrive.h
diff --git a/solid/solid/backends/fuse/fusestoragedrive.h b/solid/solid/backends/fuse/fusestoragedrive.h new file mode 100644 index 0000000..2047ca5
- + 1 /* 2 Copyright 2010 Michael Zanetti <mzanetti@kde.org> 3 Copyright 2010 Lukas Tinkl <ltinkl@redhat.com> 4 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License as published by the Free Software Foundation; either 9 version 2.1 of the License, or (at your option) version 3, or any 10 later version accepted by the membership of KDE e.V. (or its 11 successor approved by the membership of KDE e.V.), which shall 12 act as a proxy defined in Section 6 of version 3 of the license. 13 14 This library is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public 20 License along with this library. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef FUSESTORAGEDRIVE_H 24 #define FUSESTORAGEDRIVE_H 25 26 #include <ifaces/storagedrive.h> 27 28 #include "fusedevice.h" 29 30 namespace Solid 31 { 32 namespace Backends 33 { 34 namespace Fuse 35 { 36 37 class FuseStorageDrive: public QObject, virtual public Solid::Ifaces::StorageDrive 38 { 39 Q_OBJECT 40 Q_INTERFACES(Solid::Ifaces::StorageDrive) 41 Q_INTERFACES(Solid::Ifaces::DeviceInterface) 42 43 public: 44 FuseStorageDrive(FuseDevice *device); 45 virtual ~FuseStorageDrive(); 46 47 virtual qulonglong size() const; 48 virtual bool isHotpluggable() const; 49 virtual bool isRemovable() const; 50 virtual Solid::StorageDrive::DriveType driveType() const; 51 virtual Solid::StorageDrive::Bus bus() const; 52 53 virtual QString device() const { return QString::fromLatin1("/dev/fuse"); } 54 virtual int deviceMajor() const { return 0; }; 55 virtual int deviceMinor() const { return 0; }; 56 57 58 }; 59 60 } 61 } 62 } 63 64 #endif // FUSESTORAGEDRIVE_H -
new file solid/solid/backends/fuse/fusestoragevolume.cpp
diff --git a/solid/solid/backends/fuse/fusestoragevolume.cpp b/solid/solid/backends/fuse/fusestoragevolume.cpp new file mode 100644 index 0000000..d7a1216
- + 1 /* 2 * Copyright (C) 2012 Ivan Cukic <ivan.cukic(at)kde.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2, 6 * or (at your option) any later version, as published by the Free 7 * Software Foundation 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details 13 * 14 * You should have received a copy of the GNU General Public 15 * License along with this program; if not, write to the 16 * Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #include "fusestoragevolume.h" 21 #include "fusedevice.h" 22 23 #include <QByteArray> 24 #include <QCryptographicHash> 25 #include <QDebug> 26 27 namespace Solid 28 { 29 namespace Backends 30 { 31 namespace Fuse 32 { 33 34 FuseStorageVolume::FuseStorageVolume(FuseDevice * device) 35 : QObject(), m_device(device) 36 { 37 } 38 39 FuseStorageVolume::~FuseStorageVolume() 40 { 41 } 42 43 bool FuseStorageVolume::isIgnored() const 44 { 45 return false; 46 } 47 48 QString FuseStorageVolume::encryptedContainerUdi() const 49 { 50 return QString(); 51 } 52 53 QString FuseStorageVolume::fsType() const 54 { 55 return QString::fromLatin1("fuse"); 56 } 57 58 QString FuseStorageVolume::label() const 59 { 60 return QString(); 61 } 62 63 QString FuseStorageVolume::uuid() const 64 { 65 if (!m_device) { 66 qDebug() << "DEVICE IS NULL!?"; 67 return QString(); 68 } 69 // We are using the mount path to generate the UUID 70 // it would be better if we could get the source URI, but 71 // fuse doesn't save that in mtab 72 // 73 // UUID will be version 3 - MD5 based instead of SHA1 (v 5) 74 75 QByteArray hash = QCryptographicHash::hash( 76 m_device->udi().toUtf8(), 77 QCryptographicHash::Md5); 78 79 // "90015098-3cd2-4fb0-d696-3f7d28e17f72" 80 // "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 81 // {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} 82 // 8 12 16 83 84 QString result(hash.toHex().insert(20, '-').insert(16, '-').insert(12, '-').insert(8, '-')); 85 86 qDebug() << "UUID is " << result; 87 88 return result; 89 } 90 91 qulonglong FuseStorageVolume::size() const 92 { 93 return 1024; 94 } 95 96 Solid::StorageVolume::UsageType FuseStorageVolume::usage() const 97 { 98 return Solid::StorageVolume::FileSystem; 99 } 100 101 102 } 103 } 104 } -
new file solid/solid/backends/fuse/fusestoragevolume.h
diff --git a/solid/solid/backends/fuse/fusestoragevolume.h b/solid/solid/backends/fuse/fusestoragevolume.h new file mode 100644 index 0000000..7a79a7d
- + 1 /* 2 Copyright 2010 Michael Zanetti <mzanetti@kde.org> 3 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef FUSESTORAGEVOLUME_H 23 #define FUSESTORAGEVOLUME_H 24 25 #include <ifaces/storagevolume.h> 26 27 28 namespace Solid 29 { 30 namespace Backends 31 { 32 namespace Fuse 33 { 34 35 class FuseDevice; 36 37 class FuseStorageVolume: public QObject, public Solid::Ifaces::StorageVolume 38 { 39 Q_OBJECT 40 Q_INTERFACES(Solid::Ifaces::StorageVolume) 41 Q_INTERFACES(Solid::Ifaces::DeviceInterface) 42 43 public: 44 FuseStorageVolume(FuseDevice *device); 45 virtual ~FuseStorageVolume(); 46 47 virtual QString encryptedContainerUdi() const; 48 virtual qulonglong size() const; 49 virtual QString uuid() const; 50 virtual QString label() const; 51 virtual QString fsType() const; 52 virtual Solid::StorageVolume::UsageType usage() const; 53 virtual bool isIgnored() const; 54 55 virtual QString device() const { return QString::fromLatin1("/dev/fuse"); } 56 virtual int deviceMajor() const { return 0; }; 57 virtual int deviceMinor() const { return 0; }; 58 59 private: 60 FuseDevice * m_device; 61 }; 62 63 } 64 } 65 } 66 67 #endif // FUSESTORAGEVOLUME_H -
new file solid/solid/backends/fuse/fusewatcher.cpp
diff --git a/solid/solid/backends/fuse/fusewatcher.cpp b/solid/solid/backends/fuse/fusewatcher.cpp new file mode 100644 index 0000000..902a41e
- + 1 /* 2 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 3 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #include "fusewatcher.h" 23 #include "soliddefs_p.h" 24 25 #include <QtCore/QCoreApplication> 26 #include <QtCore/QFileSystemWatcher> 27 #include <QtCore/QSocketNotifier> 28 #include <QtCore/QFile> 29 #include <QtCore/QStringList> 30 31 using namespace Solid::Backends::Fuse; 32 33 SOLID_GLOBAL_STATIC(FuseWatcher, globalFuseWatcher) 34 35 #define MTAB "/etc/mtab" 36 #ifdef Q_OS_SOLARIS 37 #define FSTAB "/etc/vfstab" 38 #else 39 #define FSTAB "/etc/fstab" 40 #endif 41 42 FuseWatcher::FuseWatcher() 43 : m_isRoutineInstalled(false) 44 , m_fileSystemWatcher(new QFileSystemWatcher(this)) 45 { 46 if (qApp) { 47 connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(orphanFileSystemWatcher())); 48 } 49 50 m_mtabFile = new QFile(MTAB, this); 51 if (m_mtabFile && m_mtabFile->symLinkTarget().startsWith("/proc/") 52 && m_mtabFile->open(QIODevice::ReadOnly) ) { 53 54 m_mtabSocketNotifier = new QSocketNotifier(m_mtabFile->handle(), 55 QSocketNotifier::Exception, this); 56 connect(m_mtabSocketNotifier, 57 SIGNAL(activated(int)), this, SIGNAL(mtabChanged()) ); 58 } else { 59 m_fileSystemWatcher->addPath(MTAB); 60 } 61 62 m_fileSystemWatcher->addPath(FSTAB); 63 connect(m_fileSystemWatcher, SIGNAL(fileChanged(QString)), this, SLOT(onFileChanged(QString))); 64 } 65 66 FuseWatcher::~FuseWatcher() 67 { 68 // The QFileSystemWatcher doesn't work correctly in a singleton 69 // The solution so far was to destroy the QFileSystemWatcher when the application quits 70 // But we have some crash with this solution. 71 // For the moment to workaround the problem, we detach the QFileSystemWatcher from the parent 72 // effectively leaking it on purpose. 73 74 #if 0 75 //qRemovePostRoutine(globalFuseWatcher.destroy); 76 #else 77 m_fileSystemWatcher->setParent(0); 78 #endif 79 } 80 81 void FuseWatcher::orphanFileSystemWatcher() 82 { 83 m_fileSystemWatcher->setParent(0); 84 } 85 86 FuseWatcher *FuseWatcher::instance() 87 { 88 #if 0 89 FuseWatcher *fstabWatcher = globalFuseWatcher; 90 91 if (fstabWatcher && !fstabWatcher->m_isRoutineInstalled) { 92 qAddPostRoutine(globalFuseWatcher.destroy); 93 fstabWatcher->m_isRoutineInstalled = true; 94 } 95 return fstabWatcher; 96 #else 97 return globalFuseWatcher; 98 #endif 99 } 100 101 102 void FuseWatcher::onFileChanged(const QString &path) 103 { 104 if (path == MTAB) { 105 emit mtabChanged(); 106 if (!m_fileSystemWatcher->files().contains(MTAB)) { 107 m_fileSystemWatcher->addPath(MTAB); 108 } 109 } 110 } 111 112 -
new file solid/solid/backends/fuse/fusewatcher.h
diff --git a/solid/solid/backends/fuse/fusewatcher.h b/solid/solid/backends/fuse/fusewatcher.h new file mode 100644 index 0000000..7aa742f
- + 1 /* 2 Copyright 2010 Mario Bensi <mbensi@ipsquad.net> 3 Copyright 2012 Ivan Cukic <ivan.cukic@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef SOLID_BACKENDS_FUSE_WATCHER_H 23 #define SOLID_BACKENDS_FUSE_WATCHER_H 24 25 #include <QObject> 26 27 class QFileSystemWatcher; 28 class QFile; 29 class QSocketNotifier; 30 31 namespace Solid 32 { 33 namespace Backends 34 { 35 namespace Fuse 36 { 37 38 class FuseWatcher : public QObject { 39 Q_OBJECT 40 public: 41 FuseWatcher(); 42 virtual ~FuseWatcher(); 43 44 static FuseWatcher *instance(); 45 46 Q_SIGNALS: 47 void mtabChanged(); 48 49 private Q_SLOTS: 50 void onFileChanged(const QString &path); 51 void orphanFileSystemWatcher(); 52 53 private: 54 bool m_isRoutineInstalled; 55 QFileSystemWatcher *m_fileSystemWatcher; 56 QSocketNotifier *m_mtabSocketNotifier; 57 QFile *m_mtabFile; 58 }; 59 } 60 } 61 } 62 #endif // SOLID_BACKENDS_FUSE_WATCHER_H 63 -
solid/solid/managerbase.cpp
diff --git a/solid/solid/managerbase.cpp b/solid/solid/managerbase.cpp index fb5a67c..ee189df 100644
a b 33 33 #include "backends/hal/halmanager.h" 34 34 #include "backends/udisks/udisksmanager.h" 35 35 #include "backends/upower/upowermanager.h" 36 #include "backends/fuse/fusemanager.h" 36 37 37 38 #if defined (HUPNP_FOUND) 38 39 #include "backends/upnp/upnpdevicemanager.h" … … void Solid::ManagerBasePrivate::loadBackends() 87 88 << new Solid::Backends::UPower::UPowerManager(0) 88 89 << new Solid::Backends::Fstab::FstabManager(0); 89 90 } 91 92 m_backends << new Solid::Backends::Fuse::FuseManager(0); 90 93 # endif 91 94 92 95 # if defined (HUPNP_FOUND)