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/strigi | |
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/strigi')
-rw-r--r-- | plugins/strigi/CMakeLists.txt | 46 | ||||
-rw-r--r-- | plugins/strigi/kbfxstrigiplugin.cpp | 225 | ||||
-rw-r--r-- | plugins/strigi/kbfxstrigiplugin.h | 42 |
3 files changed, 313 insertions, 0 deletions
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 <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * 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 <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * 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 |