diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 00:43:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 00:43:50 +0000 |
commit | ceea23677c61f20759ae986bd77b0d5c4d673edb (patch) | |
tree | 3fcec1702eaf9c14d1dd736e594f5df08dab4001 /plugins | |
download | kbfx-ceea23677c61f20759ae986bd77b0d5c4d673edb.tar.gz kbfx-ceea23677c61f20759ae986bd77b0d5c4d673edb.zip |
Added old KDE3 version of kbfx
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kbfx@1091549 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/applications/CMakeLists.txt | 44 | ||||
-rw-r--r-- | plugins/applications/kbfxplasmadataplugin.cpp | 224 | ||||
-rw-r--r-- | plugins/common/CMakeLists.txt | 3 | ||||
-rw-r--r-- | plugins/common/kbfxplasmadataplugin-common.h | 37 | ||||
-rw-r--r-- | plugins/plasmoids/CMakeLists.txt | 44 | ||||
-rw-r--r-- | plugins/plasmoids/kbfxplasmadatapluginplosmoid.cpp | 152 | ||||
-rw-r--r-- | plugins/recentstuff/CMakeLists.txt | 44 | ||||
-rw-r--r-- | plugins/recentstuff/kbfxplasmarecentstuff.cpp | 150 | ||||
-rw-r--r-- | plugins/settings/CMakeLists.txt | 44 | ||||
-rw-r--r-- | plugins/settings/kbfxplasmadatapluginsettings.cpp | 189 | ||||
-rw-r--r-- | plugins/strigi/CMakeLists.txt | 46 | ||||
-rw-r--r-- | plugins/strigi/kbfxstrigiplugin.cpp | 225 | ||||
-rw-r--r-- | plugins/strigi/kbfxstrigiplugin.h | 42 |
13 files changed, 1244 insertions, 0 deletions
diff --git a/plugins/applications/CMakeLists.txt b/plugins/applications/CMakeLists.txt new file mode 100644 index 0000000..6a717fd --- /dev/null +++ b/plugins/applications/CMakeLists.txt @@ -0,0 +1,44 @@ +SET(libkbfxplasmadatastubsrc + kbfxplasmadataplugin.cpp + ) + +FILE(GLOB HEADERS *.h) + +IF (NOT USE_KDE4) + KDE3_AUTOMOC(${libkbfxplasmadatastubsrc}) + + ADD_LIBRARY(kbfxplasmadatastub SHARED ${libkbfxplasmadatastubsrc}) + SET_TARGET_PROPERTIES(kbfxplasmadatastub + PROPERTIES + COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) + # SET_TARGET_PROPERTIES(kbfxplasmadatastub PROPERTIES + # SOVERSION ${LIB_MAJOR} + # VERSION ${APPLICATION_VERSION}) + TARGET_LINK_LIBRARIES(kbfxplasmadatastub + kbfxdata + ${QT_AND_KDECORE_LIBS} + ${KDE3_KIO_LIBRARY} + ${KDE3_UI_LIBRARY} + ${KDE3_KHTML_LIBRARY} + ${M_LIBRARY} + ) + + KDE3_INSTALL_LIBTOOL_FILE(kbfxplasmadatastub ${LIB_INSTALL_DIR}/kbfx/plugins) +ELSE (NOT USE_KDE4) + KDE4_AUTOMOC(${libkbfxplasmadatastubsrc}) + + KDE4_ADD_LIBRARY(kbfxplasmadatastub SHARED ${libkbfxplasmadatastubsrc}) + TARGET_LINK_LIBRARIES(kbfxplasmadatastub + kbfxdata + ${KDE4_KDECORE_LIBS} + ${KDE4_KIO_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KHTML_LIBS} + ${M_LIBRARY} + ) + + KDE4_INSTALL_LIBTOOL_FILE(kbfxplasmadatastub ${LIB_INSTALL_DIR}/kbfx/plugins) +ENDIF (NOT USE_KDE4) + +INSTALL(TARGETS kbfxplasmadatastub DESTINATION ${LIB_INSTALL_DIR}/kbfx/plugins) +INSTALL(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/kbfx/plugins) diff --git a/plugins/applications/kbfxplasmadataplugin.cpp b/plugins/applications/kbfxplasmadataplugin.cpp new file mode 100644 index 0000000..cffb72f --- /dev/null +++ b/plugins/applications/kbfxplasmadataplugin.cpp @@ -0,0 +1,224 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <[email protected]> + * PhobosK <[email protected]> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <dcopref.h> +#include <kapplication.h> +#include <kdebug.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <krun.h> +#include <kservice.h> +#include <kservicegroup.h> + +#include <kbfxconfig.h> + +#include <kbfxplasmadataplugin-common.h> + + +void +browseApp ( KServiceGroup::Ptr service, KbfxDataGroupList * glist, + KbfxDataGroup * appGroup ) +{ + if ( !service || !service->isValid () ) + return; + + + KServiceGroup::List list = service->entries ( true, true, false, true ); + + + if ( service->noDisplay () == true ) + return; + + /* + if (list.count () <= 0) + return; + */ + + appGroup = new KbfxDataGroup (); + appGroup->setName ( service->caption () ); + + for ( KServiceGroup::List::ConstIterator it = list.begin (); + it != list.end (); it++ ) + { + KSycocaEntry *p = ( *it ); + if ( p->isType ( KST_KService ) ) + { + KService *s = static_cast < KService * > ( p ); + KbfxDataSource *data = new KbfxDataSource (); + data->setDesktopPath ( s->desktopEntryPath () ); + appGroup->addItem ( data ); + } + else if ( p->isType ( KST_KServiceGroup ) ) + { + KServiceGroup *g = static_cast < KServiceGroup * > ( p ); + if ( g->childCount () > 0 ) + { + glist->addGroup ( appGroup ); + appGroup = new KbfxDataGroup (); + appGroup->setName ( g->caption () ); + browseApp ( g, glist, appGroup ); + } + + } + } + glist->addGroup ( appGroup ); + +} + + + + + + +KbfxDataStack * +view () +{ + KbfxDataGroup *appGroup = new KbfxDataGroup (); + KbfxDataGroupList *glist = new KbfxDataGroupList (); + KbfxDataStack *gstack = new KbfxDataStack (); + + KServiceGroup::Ptr service = KServiceGroup::group ( "/" ); + if ( service == NULL) + { + int messageBoxUserResReturn = KMessageBox::questionYesNo ( 0, + tr2i18n ( "<p align='center'>There is a problem in KDE Menu services!<br>KBFX can try to autorepair this problem.<br>Should KBFX autorepair this problem?</p>" ), + tr2i18n ( "Problem in KDE Menu Services" ), + tr2i18n ( "Do Autorepair" ), + tr2i18n ( "Do NOT Autorepair" ) ); + if ( messageBoxUserResReturn == KMessageBox::Yes ) + { + KRun::runCommand ( "kbuildsycoca" ); +// if ( ! ConfigInit().m_KbfxWatcher ) +// { + DCOPRef m_kickerPanel("kicker", "kicker"); + m_kickerPanel.call("restart()"); +// } + } + return new KbfxDataStack(); + } + + service->setShowEmptyMenu ( false ); + + glist->setName ( "Applications" ); + appGroup->setName ( service->caption () ); + + KServiceGroup::List list = service->entries ( true, true, false, false ); + + if ( list.count() <= 0) + { + return new KbfxDataStack(); + } + + + for ( KServiceGroup::List::ConstIterator it = list.begin (); + it != list.end (); it++ ) + { + KSycocaEntry *p = ( *it ); + if ( p->isType ( KST_KService ) ) + {} + else if ( p->isType ( KST_KServiceGroup ) ) + { + KServiceGroup *g = static_cast < KServiceGroup * > ( p ); + g->setShowEmptyMenu ( false ); + + if ( g->childCount () > 0 ) + { + glist = new KbfxDataGroupList (); + glist->setName ( g->caption () ); + glist->setIcon ( g->icon () ); + browseApp ( g, glist, appGroup ); + gstack->addGroupList ( glist ); + } + + } + } + + gstack->setName ( "Applications" ); + + + return gstack; + +} + +QString +name () +{ + return QString ( "Applications" ); +} + +QString +type () +{ + return QString ( "Stub Type" ); +} + + +uint +id () +{ + return 1; //TODO see what can be done... manybe rand()? +} + +#include <ktrader.h> + +KbfxDataGroup * +search ( QString _keyword ) +{ + + + KbfxDataGroup *g = new KbfxDataGroup (); + g->setName ( "Applications" ); + + + KTrader::OfferList offers = KTrader::self ()->query ( "Application" ); + + int *count = new int; + *count = 0; + QValueListIterator < KService::Ptr > s = offers.begin (); + + for ( ; s != offers.end (); ++s ) + { + if ( s == NULL ) + continue; + if ( (*s)->noDisplay () == true ) + continue; + + QString *sPtr = new QString (); + + ( *sPtr ) = ( *s )->name () + ( *s )->genericName () + ( *s )->comment (); + if ( ( !sPtr->isNull () ) && sPtr->contains ( _keyword, false ) > 0 ) + { + KbfxDataSource *data = new KbfxDataSource (); + data->setName ( ( *s )->name () ); + data->setDesktopPath ( ( *s )->desktopEntryPath () ); + + g->addItem ( data ); + ( *count ) ++; + if ( ( *count ) == 10 ) + break; + + } + if ( sPtr != 0 ) + delete sPtr; + } + delete count; + return g; +} diff --git a/plugins/common/CMakeLists.txt b/plugins/common/CMakeLists.txt new file mode 100644 index 0000000..96b4a77 --- /dev/null +++ b/plugins/common/CMakeLists.txt @@ -0,0 +1,3 @@ +FILE(GLOB HEADERS *.h) + +INSTALL(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/kbfx/plugins) diff --git a/plugins/common/kbfxplasmadataplugin-common.h b/plugins/common/kbfxplasmadataplugin-common.h new file mode 100644 index 0000000..d446ef8 --- /dev/null +++ b/plugins/common/kbfxplasmadataplugin-common.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <[email protected]> + * PhobosK <[email protected]> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KBFX_PLASMA_DATA_PLUGIN_COMMON_H +#define KBFX_PLASMA_DATA_PLUGIN_COMMON_H + +#include "kbfxdatastack.h" + +extern "C" +{ +// static QString check = "Static Check for Plugin"; + KbfxDataStack * view(); + QString name(); //Name of the Plugin My Music .if TOM Create..Configure .. + QString type(); //Type of the plugin ex: Application : Amork : kio ..etc + uint id(); //A id for menus + KbfxDataGroup * search ( QString str ); +} + +#endif diff --git a/plugins/plasmoids/CMakeLists.txt b/plugins/plasmoids/CMakeLists.txt new file mode 100644 index 0000000..abb1167 --- /dev/null +++ b/plugins/plasmoids/CMakeLists.txt @@ -0,0 +1,44 @@ +SET(libkbfxplasmadataplasmoidsrc + kbfxplasmadatapluginplosmoid.cpp + ) + +FILE(GLOB HEADERS *.h) + +IF (NOT USE_KDE4) + KDE3_AUTOMOC(${libkbfxplasmadataplasmoidsrc}) + + ADD_LIBRARY(kbfxplasmadataplasmoid SHARED ${libkbfxplasmadataplasmoidsrc} ) + SET_TARGET_PROPERTIES(kbfxplasmadataplasmoid + PROPERTIES + COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) + # SET_TARGET_PROPERTIES(kbfxplasmadataplasmoid PROPERTIES + # SOVERSION ${LIB_MAJOR} + # VERSION ${APPLICATION_VERSION}) + TARGET_LINK_LIBRARIES(kbfxplasmadataplasmoid + kbfxdata + ${QT_AND_KDECORE_LIBS} + ${KDE3_KIO_LIBRARY} + ${KDE3_UI_LIBRARY} + ${KDE3_KHTML_LIBRARY} + ${M_LIBRARY} + ) + + KDE3_INSTALL_LIBTOOL_FILE(kbfxplasmadataplasmoid ${LIB_INSTALL_DIR}/kbfx/plugins) +ELSE (NOT USE_KDE4) + KDE4_AUTOMOC(${libkbfxplasmadataplasmoidsrc}) + + KDE4_ADD_LIBRARY(kbfxplasmadataplasmoid SHARED ${libkbfxplasmadataplasmoidsrc} ) + TARGET_LINK_LIBRARIES(kbfxplasmadataplasmoid + kbfxdata + ${KDE4_KDECORE_LIBS} + ${KDE4_KIO_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KHTML_LIBS} + ${M_LIBRARY} + ) + + KDE4_INSTALL_LIBTOOL_FILE(kbfxplasmadataplasmoid ${LIB_INSTALL_DIR}/kbfx/plugins) +ENDIF (NOT USE_KDE4) + +INSTALL(TARGETS kbfxplasmadataplasmoid DESTINATION ${LIB_INSTALL_DIR}/kbfx/plugins) +INSTALL(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/kbfx/plugins) diff --git a/plugins/plasmoids/kbfxplasmadatapluginplosmoid.cpp b/plugins/plasmoids/kbfxplasmadatapluginplosmoid.cpp new file mode 100644 index 0000000..998fafb --- /dev/null +++ b/plugins/plasmoids/kbfxplasmadatapluginplosmoid.cpp @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <[email protected]> + * PhobosK <[email protected]> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <kapplication.h> +#include <kservice.h> +#include <kservicegroup.h> +#include <kdebug.h> +#include <kstandarddirs.h> +#include <qdir.h> +#include <qfileinfo.h> +#include <kbfxplasmadataplugin-common.h> + + + + + + + +KbfxDataStack * +view () +{ + + KbfxDataGroup *appGroup = new KbfxDataGroup (); + KbfxDataGroupList *glist = new KbfxDataGroupList (); + KbfxDataStack *gstack = new KbfxDataStack (); + + + glist->setName ( "Browse" ); + glist->setIcon ( "plasmagik" ); + appGroup->setName ( "Plasmoids" ); + + QString path = locate ( "data", "kicker/applets/lockout.desktop" ); + path.remove ( "lockout.desktop" ); + + + + QDir d ( path ); + d.setFilter ( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); + d.setSorting ( QDir::Size | QDir::Reversed ); + d.setNameFilter ( "*.desktop" ); + + const QFileInfoList *list = d.entryInfoList (); + QFileInfoListIterator it ( *list ); + QFileInfo *fi; + while ( ( fi = it.current () ) != 0 ) + { + + KDesktopFile *desktop = new KDesktopFile ( fi->filePath () ); + + KbfxDataSource *src = new KbfxDataSource (); + + src->setName ( desktop->readName () ); + src->setContentPath ( fi->filePath () ); + src->setIconPath ( desktop->readIcon () ); + src->setCommand ( "dcop kicker Panel addApplet " + fi->filePath () ); + appGroup->addItem ( src ); + + + ++it; + } + + + gstack->setName ( "Plasmoids" ); + + glist->addGroup ( appGroup ); + gstack->addGroupList ( glist ); + return gstack; + + +} + +QString +name () +{ + return QString ( "Plasmoids" ); +} + +QString +type () +{ + return QString ( "Stub Type" ); +} + + +uint +id () +{ + return 1; //TODO see what can be done... manybe rand()? +} + + +#include <ktrader.h> + +KbfxDataGroup * +search ( QString _keyword ) +{ + KbfxDataGroup *appGroup = new KbfxDataGroup (); + + + QString path = locate ( "data", "kicker/applets/lockout.desktop" ); + path.remove ( "lockout.desktop" ); + + + + QDir d ( path ); + d.setFilter ( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); + d.setSorting ( QDir::Size | QDir::Reversed ); + d.setNameFilter ( "*.desktop" ); + + const QFileInfoList *list = d.entryInfoList (); + QFileInfoListIterator it ( *list ); + QFileInfo *fi; + + while ( ( fi = it.current () ) != 0 ) + { + if ( fi->fileName ().contains ( _keyword ) > 0 ) + { + KDesktopFile *desktop = new KDesktopFile ( fi->filePath () ); + + KbfxDataSource *src = new KbfxDataSource (); + + src->setName ( desktop->readName () ); + src->setContentPath ( fi->filePath () ); + src->setIconPath ( desktop->readIcon () ); + src->setCommand ( "dcop kicker Panel addApplet " + fi->filePath () ); + appGroup->addItem ( src ); + } + + ++it; + } + + + return appGroup; +} diff --git a/plugins/recentstuff/CMakeLists.txt b/plugins/recentstuff/CMakeLists.txt new file mode 100644 index 0000000..787fbd8 --- /dev/null +++ b/plugins/recentstuff/CMakeLists.txt @@ -0,0 +1,44 @@ +SET(libkbfxplasmarecentstuffsrc + kbfxplasmarecentstuff.cpp + ) + +FILE(GLOB HEADERS *.h) + +IF (NOT USE_KDE4) + KDE3_AUTOMOC(${libkbfxplasmarecentstuffsrc}) + + ADD_LIBRARY(kbfxplasmarecentstuff SHARED ${libkbfxplasmarecentstuffsrc} ) + SET_TARGET_PROPERTIES(kbfxplasmarecentstuff + PROPERTIES + COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) + # SET_TARGET_PROPERTIES(kbfxplasmarecentstuff PROPERTIES + # SOVERSION ${LIB_MAJOR} + # VERSION ${APPLICATION_VERSION}) + TARGET_LINK_LIBRARIES(kbfxplasmarecentstuff + kbfxdata + ${QT_AND_KDECORE_LIBS} + ${KDE3_KIO_LIBRARY} + ${KDE3_UI_LIBRARY} + ${KDE3_KHTML_LIBRARY} + ${M_LIBRARY} + ) + + KDE3_INSTALL_LIBTOOL_FILE(kbfxplasmarecentstuff ${LIB_INSTALL_DIR}/kbfx/plugins) +ELSE (NOT USE_KDE4) + KDE4_AUTOMOC(${libkbfxplasmarecentstuffsrc}) + + KDE4_ADD_LIBRARY(kbfxplasmarecentstuff SHARED ${libkbfxplasmarecentstuffsrc} ) + TARGET_LINK_LIBRARIES(kbfxplasmarecentstuff + kbfxdata + ${KDE4_KDECORE_LIBS} + ${KDE4_KIO_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KHTML_LIBS} + ${M_LIBRARY} + ) + + KDE4_INSTALL_LIBTOOL_FILE(kbfxplasmarecentstuff ${LIB_INSTALL_DIR}/kbfx/plugins) +ENDIF (NOT USE_KDE4) + +INSTALL(TARGETS kbfxplasmarecentstuff DESTINATION ${LIB_INSTALL_DIR}/kbfx/plugins) +INSTALL(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/kbfx/plugins) diff --git a/plugins/recentstuff/kbfxplasmarecentstuff.cpp b/plugins/recentstuff/kbfxplasmarecentstuff.cpp new file mode 100644 index 0000000..b0c4f8c --- /dev/null +++ b/plugins/recentstuff/kbfxplasmarecentstuff.cpp @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <[email protected]> + * PhobosK <[email protected]> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <kapplication.h> +#include <kservice.h> +#include <kservicegroup.h> +#include <kdebug.h> +#include <kstandarddirs.h> +#include <qdir.h> +#include <qfileinfo.h> +#include <kbfxplasmadataplugin-common.h> +#include <kstandarddirs.h> + +KbfxDataStack * +view () +{ + + KbfxDataGroup *appGroup = new KbfxDataGroup (); + KbfxDataGroupList *glist = new KbfxDataGroupList (); + KbfxDataStack *gstack = new KbfxDataStack (); + + + glist->setName ( "List" ); + glist->setIcon ( "newstuff" ); + appGroup->setName ( "RecentStuff" ); + + QString path = + KStandardDirs ().localkdedir () + "/share/apps/RecentDocuments/"; + + + + QDir d ( path ); + d.setFilter ( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); + d.setSorting ( QDir::Size | QDir::Reversed ); + d.setNameFilter ( "*.desktop" ); + + const QFileInfoList *list = d.entryInfoList (); + QFileInfoListIterator it ( *list ); + QFileInfo *fi; + + while ( ( fi = it.current () ) != 0 ) + { + + KDesktopFile *desktop = new KDesktopFile ( fi->filePath () ); + + KbfxDataSource *src = new KbfxDataSource (); + + src->setName ( desktop->readName () ); + src->setContentPath ( fi->filePath () ); + src->setIconPath ( desktop->readIcon () ); + src->setCommand ( "kfmclient exec " + desktop->readEntry ( "URL" ) ); + + appGroup->addItem ( src ); + + delete desktop; + ++it; + } + + + gstack->setName ( "RecentStuff" ); + + glist->addGroup ( appGroup ); + gstack->addGroupList ( glist ); + return gstack; + + +} + +QString +name () +{ + return QString ( "RecentStuff" ); +} + +QString +type () +{ + return QString ( "Stub Type" ); +} + + +uint +id () +{ + return 1; //TODO see what can be done... manybe rand()? +} + + +#include <ktrader.h> + +KbfxDataGroup * +search ( QString _keyword ) +{ + KbfxDataGroup *appGroup = new KbfxDataGroup (); +// KbfxDataGroupList *glist = new KbfxDataGroupList (); +// KbfxDataStack *gstack = new KbfxDataStack (); + + + + QString path = + KStandardDirs ().localkdedir () + "/share/apps/RecentDocuments/"; + + QDir d ( path ); + d.setFilter ( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); + d.setSorting ( QDir::Size | QDir::Reversed ); + d.setNameFilter ( "*.desktop" ); + + const QFileInfoList *list = d.entryInfoList (); + QFileInfoListIterator it ( *list ); + QFileInfo *fi; + + while ( ( fi = it.current () ) != 0 ) + { + if ( fi->fileName ().contains ( _keyword ) > 0 ) + { + KDesktopFile *desktop = new KDesktopFile ( fi->filePath () ); + + KbfxDataSource *src = new KbfxDataSource (); + + src->setName ( desktop->readName () ); + src->setContentPath ( fi->filePath () ); + src->setIconPath ( desktop->readIcon () ); + src->setCommand ( "kfmclient exec " + desktop->readEntry ( "URL" ) ); + appGroup->addItem ( src ); + delete desktop; + } + + ++it; + } + + return appGroup; +} diff --git a/plugins/settings/CMakeLists.txt b/plugins/settings/CMakeLists.txt new file mode 100644 index 0000000..2ef6f02 --- /dev/null +++ b/plugins/settings/CMakeLists.txt @@ -0,0 +1,44 @@ +SET(libkbfxplasmadatasettingssrc + kbfxplasmadatapluginsettings.cpp + ) + +FILE(GLOB HEADERS *.h) + +IF (NOT USE_KDE4) + KDE3_AUTOMOC(${libkbfxplasmadatasettingssrc}) + + ADD_LIBRARY(kbfxplasmadatasettings SHARED ${libkbfxplasmadatasettingssrc}) + SET_TARGET_PROPERTIES(kbfxplasmadatasettings + PROPERTIES + COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) + # SET_TARGET_PROPERTIES(kbfxplasmadatasettings PROPERTIES + # SOVERSION ${LIB_MAJOR} + # VERSION ${APPLICATION_VERSION}) + TARGET_LINK_LIBRARIES(kbfxplasmadatasettings + kbfxdata + ${QT_AND_KDECORE_LIBS} + ${KDE3_KIO_LIBRARY} + ${KDE3_UI_LIBRARY} + ${KDE3_KHTML_LIBRARY} + ${M_LIBRARY} + ) + + KDE3_INSTALL_LIBTOOL_FILE(kbfxplasmadatasettings ${LIB_INSTALL_DIR}/kbfx/plugins) +ELSE (NOT USE_KDE4) + KDE4_AUTOMOC(${libkbfxplasmadatasettingssrc}) + + KDE4_ADD_LIBRARY(kbfxplasmadatasettings SHARED ${libkbfxplasmadatasettingssrc}) + TARGET_LINK_LIBRARIES(kbfxplasmadatasettings + kbfxdata + ${KDE4_KDECORE_LIBS} + ${KDE4_KIO_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KHTML_LIBS} + ${M_LIBRARY} + ) + + KDE4_INSTALL_LIBTOOL_FILE(kbfxplasmadatasettings ${LIB_INSTALL_DIR}/kbfx/plugins) +ENDIF (NOT USE_KDE4) + +INSTALL(TARGETS kbfxplasmadatasettings DESTINATION ${LIB_INSTALL_DIR}/kbfx/plugins) +INSTALL(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/kbfx/plugins) diff --git a/plugins/settings/kbfxplasmadatapluginsettings.cpp b/plugins/settings/kbfxplasmadatapluginsettings.cpp new file mode 100644 index 0000000..bc02003 --- /dev/null +++ b/plugins/settings/kbfxplasmadatapluginsettings.cpp @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <[email protected]> + * PhobosK <[email protected]> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <dcopref.h> +#include <kapplication.h> +#include <kdebug.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <krun.h> +#include <kservice.h> +#include <kservicegroup.h> + +#include <kbfxconfig.h> + +#include <kbfxplasmadataplugin-common.h> + + +void +browseApp ( KServiceGroup::Ptr service, KbfxDataGroupList * glist, + KbfxDataGroup * appGroup ) +{ + if ( !service || !service->isValid () ) + return; + + + KServiceGroup::List list = service->entries ( true, true, false, true ); + + /* + if (service->noDisplay () == true) + return; + + + if (list.count () <= 0) + return; + */ + + appGroup = new KbfxDataGroup (); + appGroup->setName ( service->caption () ); + + for ( KServiceGroup::List::ConstIterator it = list.begin (); + it != list.end (); it++ ) + { + KSycocaEntry *p = ( *it ); + if ( p->isType ( KST_KService ) ) + { + KService *s = static_cast < KService * > ( p ); + KbfxDataSource *data = new KbfxDataSource (); + data->setDesktopPath ( s->desktopEntryPath () ); + appGroup->addItem ( data ); + } + else if ( p->isType ( KST_KServiceGroup ) ) + { + KServiceGroup *g = static_cast < KServiceGroup * > ( p ); + if ( g->childCount () > 0 ) + { + glist->addGroup ( appGroup ); + appGroup = new KbfxDataGroup (); + appGroup->setName ( g->caption () ); + browseApp ( g, glist, appGroup ); + } + + } + } +//if(appGroup->count() >0) + glist->addGroup ( appGroup ); + +} + + + + + + +KbfxDataStack * +view () +{ + KbfxDataGroup *appGroup = new KbfxDataGroup (); + KbfxDataGroupList *glist = new KbfxDataGroupList (); + KbfxDataStack *gstack = new KbfxDataStack (); + + KServiceGroup::Ptr service = KServiceGroup::baseGroup ( "settings" );//KServiceGroup::group ("/"); + if ( service == NULL) + { + int messageBoxUserResReturn = KMessageBox::questionYesNo ( 0, + tr2i18n ( "<p align='center'>There is a problem in KDE Menu services!<br>KBFX can try to autorepair this problem.<br>Should KBFX autorepair this problem?</p>" ), + tr2i18n ( "Problem in KDE Menu Services" ), + tr2i18n ( "Do Autorepair" ), + tr2i18n ( "Do NOT Autorepair" ) ); + if ( messageBoxUserResReturn == KMessageBox::Yes ) + { + KRun::runCommand ( "kbuildsycoca" ); +// if ( ! ConfigInit().m_KbfxWatcher ) +// { + DCOPRef m_kickerPanel("kicker", "kicker"); + m_kickerPanel.call("restart()"); +// } + } + return new KbfxDataStack(); + } + + service->setShowEmptyMenu ( false ); + + glist->setName ( "Settings" ); + appGroup->setName ( service->caption () ); + + + KServiceGroup::List list = service->entries ( true, true, false, false ); + + if ( list.count() <= 0) + { + return new KbfxDataStack(); + } + + for ( KServiceGroup::List::ConstIterator it = list.begin (); + it != list.end (); it++ ) + { + KSycocaEntry *p = ( *it ); + if ( p->isType ( KST_KService ) ) + {} + else if ( p->isType ( KST_KServiceGroup ) ) + { + KServiceGroup *g = static_cast < KServiceGroup * > ( p ); + g->setShowEmptyMenu ( false ); + + if ( g->childCount () > 0 ) + { + glist = new KbfxDataGroupList (); + glist->setName ( g->caption () ); + glist->setIcon ( g->icon () ); + browseApp ( g, glist, appGroup ); + gstack->addGroupList ( glist ); + } + + } + } + + gstack->setName ( "Settings" ); + + + return gstack; + +} + +QString +name () +{ + return QString ( "Settings" ); +} + +QString +type () +{ + return QString ( "Stub Type" ); +} + +uint +id () +{ + return 1; //TODO see what can be done... manybe rand()? +} + + + +KbfxDataGroup * +search ( QString _keyword ) +{ + _keyword = _keyword; + return new KbfxDataGroup(); + +} + diff --git a/plugins/strigi/CMakeLists.txt b/plugins/strigi/CMakeLists.txt new file mode 100644 index 0000000..29289b0 --- /dev/null +++ b/plugins/strigi/CMakeLists.txt @@ -0,0 +1,46 @@ +SET(libkbfxstrigiclientsrc + kbfxstrigiplugin.cpp + ) + +FILE(GLOB HEADERS *.h) + +IF (NOT USE_KDE4) + KDE3_AUTOMOC(${libkbfxstrigiclientsrc}) + + ADD_LIBRARY(kbfxstrigiclient SHARED ${libkbfxstrigiclientsrc}) + SET_TARGET_PROPERTIES(kbfxstrigiclient + PROPERTIES + COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) + # SET_TARGET_PROPERTIES(kbfxstrigiclient PROPERTIES + # SOVERSION ${LIB_MAJOR} + # VERSION ${APPLICATION_VERSION}) + TARGET_LINK_LIBRARIES(kbfxstrigiclient + kbfxdata + ${QT_AND_KDECORE_LIBS} + ${KDE3_KIO_LIBRARY} + ${KDE3_UI_LIBRARY} + ${KDE3_KHTML_LIBRARY} + ${M_LIBRARY} + ${STRIGICLIENT_LIBRARY} + ) + + KDE3_INSTALL_LIBTOOL_FILE(kbfxstrigiclient ${LIB_INSTALL_DIR}/kbfx/plugins) +ELSE (NOT USE_KDE4) + KDE4_AUTOMOC(${libkbfxstrigiclientsrc}) + + KDE4_ADD_LIBRARY(kbfxstrigiclient SHARED ${libkbfxstrigiclientsrc}) + TARGET_LINK_LIBRARIES(kbfxstrigiclient + kbfxdata + ${KDE4_KDECORE_LIBS} + ${KDE4_KIO_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KHTML_LIBS} + ${M_LIBRARY} + ${STRIGICLIENT_LIBRARY} + ) + + KDE4_INSTALL_LIBTOOL_FILE(kbfxstrigiclient ${LIB_INSTALL_DIR}/kbfx/plugins) +ENDIF (NOT USE_KDE4) + +INSTALL(TARGETS kbfxstrigiclient DESTINATION ${LIB_INSTALL_DIR}/kbfx/plugins) +INSTALL(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/kbfx/plugins) diff --git a/plugins/strigi/kbfxstrigiplugin.cpp b/plugins/strigi/kbfxstrigiplugin.cpp new file mode 100644 index 0000000..dd9471b --- /dev/null +++ b/plugins/strigi/kbfxstrigiplugin.cpp @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <[email protected]> + * PhobosK <[email protected]> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <kapplication.h> +#include <kservice.h> +#include <kservicegroup.h> +#include <kdebug.h> +#include <qdir.h> +#include <qfileinfo.h> +#include <kurl.h> + +#include "kbfxstrigiplugin.h" + + + +bool +stopDaemon () +{ + return true; +} + +bool +startDaemon () +{ + stopDaemon (); + +// TODO: add the actual code to start the daemon process + return true; +} + +void +init () +{} + +void +poll () +{ +} + + +KbfxDataStack * +view () +{ + KbfxDataGroup *appGroup = new KbfxDataGroup (); + KbfxDataGroupList *glist = new KbfxDataGroupList (); + KbfxDataStack *gstack = new KbfxDataStack (); + + init (); + glist->setName ( "Configure" ); + appGroup->setName ( "Strigi Options" ); + KbfxDataSource *m_source = new KbfxDataSource (); + m_source->setName ( "Start Indexing" ); + m_source->setCommand ( "kfmclient exec strigi:/status/startindexing" ); + m_source->setComment ( "Starts Building an Index" ); + m_source->setIconPath ( "enhanced_browsing.png" ); + appGroup->addItem ( m_source ); + + m_source = new KbfxDataSource (); + m_source->setName ( "Stop Indexing" ); + m_source->setCommand ( "kfmclient exec strigi:/status/stopindexing" ); + m_source->setComment ( "Stop Index Building Process" ); + m_source->setIconPath ( "enhanced_browsing.png" ); + appGroup->addItem ( m_source ); + m_source = new KbfxDataSource (); + m_source->setName ( "Stop Daemon" ); + m_source->setCommand ( "kfmclient exec strigi:/status/stop" ); + m_source->setComment ( "Stop Search Engine" ); + m_source->setIconPath ( "enhanced_browsing.png" ); + appGroup->addItem ( m_source ); + + m_source = new KbfxDataSource (); + m_source->setName ( "Advanced Searching" ); + m_source->setCommand ( "kfmclient exec strigi:/" ); + m_source->setComment ( "Detailed Search Results" ); + m_source->setIconPath ( "enhanced_browsing.png" ); + appGroup->addItem ( m_source ); + m_source = new KbfxDataSource (); + m_source->setName ( "Start Daemon" ); + m_source->setCommand ( "kfmclient exec strigi:/status/start" ); + m_source->setComment ( "Start Search Engine" ); + m_source->setIconPath ( "enhanced_browsing.png" ); + appGroup->addItem ( m_source ); + + glist->addGroup ( appGroup ); + gstack->addGroupList ( glist ); + gstack->setName ( "Strigi" ); + + return gstack; +} + + +QString +name () +{ + return QString ( "Strigi" ); +} + +QString +type () +{ + return QString ( "Stub Type" ); +} + + +uint +id () +{ + return 1; //TODO see what can be done... maybe rand()? +} + + + +KbfxDataGroup * +search ( QString _keyword ) +{ + + KbfxDataGroup *datagroup = new KbfxDataGroup (); + datagroup->setName ( "Strigi" ); + + QString socketpath = QDir::homeDirPath () + "/.strigi/socket"; + startDaemon (); + kdDebug() << socketpath << endl; + AsyncSocketClient socket; + ClientInterface::Hits hits; + + + socket.setSocketPath ( ( const char * ) socketpath.utf8 () ); + bool ok = socket.query ( _keyword.ascii (), 5, 0 ); + + if ( ok == true ) + { + while ( !socket.statusChanged () ) + { + struct timespec sleeptime; + sleeptime.tv_sec = 0; + sleeptime.tv_nsec = 1; + nanosleep ( &sleeptime, 0 ); + } + hits = socket.getHits (); + + jstreams::IndexedDocument hit; +// int last = ( hits.hits.size () > 5 ) ? 5 : hits.hits.size (); + + + for ( uint i = 0; i < socket.getHits ().hits.size (); ++i ) + { + jstreams::IndexedDocument hit = hits.hits[i]; + KbfxDataSource *data = new KbfxDataSource (); + + QString name; + std::map < std::string, std::string >::const_iterator it = + hits.hits[i].properties.find ( "title" ); + + QString filename ( hits.hits[i].uri.c_str () ); + + if ( filename.contains ( ".tar." ) > 0 ) + { + filename = "tar:" + filename; + kdDebug() << filename << endl; + } + + if ( it != hits.hits[i].properties.end () ) + { + name = it->second; + } + else + { + uint pos = hits.hits[i].uri.rfind ( '/' ); + if ( pos == std::string::npos ) + { + name = hits.hits[i].uri; + } + else + { + name = hits.hits[i].uri.substr ( pos + 1 ); + } + } + + + data->setName ( name ); + + + + data->setCommand ( "kfmclient exec " + filename ); + + + + QString iconname = + KMimeType::mimeType ( hits.hits[i].mimetype.c_str () )-> + icon ( QString::null, 0 ); + data->setIconPath ( iconname ); + datagroup->addItem ( data ); + + } + } + else + { + KbfxDataSource *data = new KbfxDataSource (); + data->setName ( "Start Strigi" ); + data->setComment ( "Strigi Daemon down" ); + data->setCommand ( "strigidaemon &" ); + } + + return datagroup; + + +} diff --git a/plugins/strigi/kbfxstrigiplugin.h b/plugins/strigi/kbfxstrigiplugin.h new file mode 100644 index 0000000..a2e3137 --- /dev/null +++ b/plugins/strigi/kbfxstrigiplugin.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <[email protected]> + * PhobosK <[email protected]> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KBFX_STRIGI_PLUGIN_H +#define KBFX_STRIGI_PLUGIN_H + +//#include "kbfxplasmacanvasstack.h" +//#include "kbfxplasmacanvasitemwrapper.h" +#include "kbfxdatastack.h" +#include <asyncsocketclient.h> +#include <kiconloader.h> +#include <kmimetype.h> + +extern "C" +{ + KbfxDataStack * view(); + QString name(); //Name of the Plugin My Music .if TOM Create..Configure .. + QString type(); //Type of the plugin ex: Application : Amork : kio ..etc + uint id(); //A id for menus + KbfxDataGroup * search ( QString str ); +// KbfxPlasmaCanvasGroup * search(QString _keyword,QCanvas * canvas); //search and return a group +} + +#endif |