Drop deprecated kmrml code

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/58/head
Michele Calgaro 2 years ago
parent a9f6e5c5b2
commit fdd2249496
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -92,9 +92,6 @@ option( BUILD_KVIEW "Build kview" ${BUILD_ALL} )
option( BUILD_KVIEWSHELL "Build kviewshell" ${BUILD_ALL} )
option( BUILD_LIBKSCAN "Build libkscan" ${BUILD_ALL} )
# deprecated
option( BUILD_KMRML "Build kmrml" OFF )
##### configure checks ##########################
@ -146,9 +143,6 @@ tde_conditional_add_subdirectory( BUILD_LIBKSCAN libkscan )
tde_conditional_add_subdirectory( BUILD_TDEFILE_PLUGINS tdefile-plugins )
tde_conditional_add_subdirectory( BUILD_TDEICONEDIT tdeiconedit )
# deprecated
tde_conditional_add_subdirectory( BUILD_KMRML kmrml )
##### write configure files #####################
configure_file( config.h.cmake config.h @ONLY )

@ -41,9 +41,6 @@ tdegraphics is a collection of graphic oriented applications:
* tdeiconedit
An icon editor.
* kmrml
Connects to a MRML server and find similar images
* kooka
A raster image scan program, based on SANE and libkscan.

@ -54,10 +54,6 @@
#endif
#cmakedefine HAVE_FMIN 1
// kmrml
#cmakedefine HAVE_STDLIB_H 1
#cmakedefine HAVE_UNISTD_H 1
// ksnapshop
#cmakedefine HAVE_X11_EXTENSIONS_SHAPE_H 1

@ -1 +0,0 @@
Carsten Pfeiffer <pfeiffer@kde.org>

@ -1,3 +0,0 @@
##### create translation templates ##############
tde_l10n_auto_add_subdirectories( )

@ -1,24 +0,0 @@
#################################################
#
# (C) 2010-2011 Calvin Morrison
# mutantturkey@gmail.com
#
# Improvements and feedback are welcome
#
# This file is released under GPL >= 2
#
#################################################
message( AUTHOR_WARNING
" \n"
" ---------------------------------------------------------- \n"
" *** NOTE *** \n"
" Building kmrml is deprecated and should not be done. \n"
" kmrml will be dropped starting from R14.2.0. \n"
" Please contact the TDE development team on ML \n"
" if you wish kmrml to be continued. \n"
" ---------------------------------------------------------- \n")
include( ConfigureChecks.cmake )
add_subdirectory ( kmrml )

@ -1,28 +0,0 @@
Uh er, looks like I didn't add all the other changes lately :} Sorry...
Sun May 6 04:40:52 2001 Carsten Pfeiffer <pfeiffer@kde.org>
* UI is a bit nicer now (arrangement of thumbnail items)
* it's possible to search by example, i.e. by right-clicking
on one or more images and selecting "search for similar images"
* tiny bit of code cleanup
Sat May 5 02:30:21 2001 Carsten Pfeiffer <pfeiffer@kde.org>
* argh, fixed the bug that files couldn't get downloaded by
clicking on them and that the statusbar isn't updated.
casts suck :} That took me a lot of time to find out :(
* added middle-button -> create new window
* scroll to top when loading a new page
* show standard popupmenu on right-click on image
* schedule the slaves instead of creating all at once
Sam Apr 28 00:09:17 CEST 2001 - Carsten Pfeiffer <pfeiffer@kde.org>
o Initial Creation
didn't do any entries until something is actually working :)

@ -1,13 +0,0 @@
#################################################
#
# (C) 2010-2011 Serghei Amelian
# serghei (DOT) amelian (AT) gmail.com
#
# Improvements and feedback are welcome
#
# This file is released under GPL >= 2
#
#################################################
check_include_file( stdlib.h HAVE_STDLIB_H )
check_include_file( unistd.h HAVE_UNISTD_H )

@ -1 +0,0 @@
SUBDIRS = kmrml

@ -1,95 +0,0 @@
tdeio_mrml and mrml_part
Carsten Pfeiffer <pfeiffer@kde.org> 2001/05/03
----------------------------------------------------------------------
These are the sources for an mrml tdeioslave and an accompanying KPart.
How does it work in Konqueror?
==============================
For now, the MrmlPart is rather a proof of concept, than a full blown
MRML client.
You can start the MrmlPart by entering an appropriate URL into Konqueror,
e.g. mrml://user:pass@host.domain:port
user, pass and domain are optional, so if you're running a server locally
yourself, you can enter mrml://localhost to make Konqueror show the
MrmlPart. If you don't have a running GIFT-server, you can try out
mrml://viper.unige.ch:12790 as an example. Then, Konqueror will try to
connect the server at the given URL and show you a list of
image-collections the server has available. You can specify the number
of images a query should return and you can hit the Search-button
to actually start the query. If you don't give an image as example for
the query, it will return random images from the collection.
Shortly after hitting the Search-button, you will see a list of images
as thumbnails. Below every image is a small rectangle showing the
similarity of the image with the example image(s). The longer the
rectangle, the better the match.
Even easier than entering the mrml URL is right-clicking on an image
in Konqueror and selecting "Search for similar images..." in the context
menu. This will open up a new Konqueror window where the query will start
automatically. By default, this will try to contact a local server, i.e
mrml://localhost. You can configure different servers in the KControl
Module (System -> Advanced Search). The last chosen server will be used
for those queries.
Note that a remote server surely can't access an image from your home
direcory though. I have to think a little bit about the usability of
this :) The greatest use of this is when you've indexed your files
and running an own GIFT server anyway. Ideally, the server could be
started on demand, when a query comes up.
MrmlPart:
=========
This KPart makes use of the mrml ioslave to provide a full MRML
client. MRML, Multimedia Retrieval Markup Language (see
http://www.mrml.net) is a means to query CBIR (Content Based Image
Retrieval) servers. An OpenSource server is the GIFT (GNU Image
Finding Tool), see www.mrml.net for downloading the GIFT.
You can query for images by choosing one or more "example" images.
The server will search for images that have similarities to the
example(s) you gave. Queries can be refined by specifying relevance,
i.e. by including and excluding parts of the previous search result.
mrml ioslave:
=============
Basically this is not much more than a slave for asynchronous
transport of "data". With the URL, you can specify the user, password
and port, as well as the url of the server to connect to.
The data exchange of client <-> slave is done via metaData, with an
"mrml_data" key. The data that the slave sends to the client is sent
in one big chunk, after all the data has arrived at the slave. This
could be made configurable later.
With a little tuning, one could turn this into a generic slave
which can transport any kind of data.
[mrmlsearch]
This little baby is called from Konqueror's popupmenu, when you hit
"Search for similar images...". This program simply gets the URLs
from Konqueror and creates a query of the form
mrml://host.com/?relevant=url1;url2;url3;url4....
It will use the currently selected host in the KControl module
System -> Advanced Search to perform the query.
mrmlsearch will then invoke "kfmclient openURL query" to start open
a new Konqueror window and perform the query.
Thanks go to Wolfgang Müller <Wolfgang.Mueller@cui.unige.ch> for his
work on the GIFT and for making me write this frontend :) I really
had a WOW-effect about the GIFT, when MrmlPart returned the first
query results.
New versions of this package can be found at
http://devel-home.kde.org/~pfeiffer/kmrml/
See http://www.mrml.net for downloading the GIFT and more information.
Have fun,
Carsten Pfeiffer

@ -1,41 +0,0 @@
This file gives an overview of the structure of the kmrml package.
kmrml consists of the following:
- tdeio_mrml: an ioslave that is able to contact an mrml daemon (i.e. the GIFT)
and transports the data from the daemon to its master (i.e. the
MrmlPart) as XML (MRML, Multimedia Retrieval Markup Language)
- MrmlPart: the konqueror-embeddable controller and view
- mrmlsearch: a small tool that is e.g. called from Konqueror's ContextMenu
"Search for similar images" to start an image query.
- kcontrol/: a Trinity Control Center module for configuring parts of the GIFT,
i.e. indexing directories, specifying GIFT hosts, etc.
- server/: a kded module, i.e. a tiny little daemon, that can be told via
DCOP to start, restart upon failure and automatically/manually
stop services. It is completely independent of GIFT/kmrml.
It is used to have one centralized place where the gift server
is started (ensuring this happens only once, restarting it upon
failure and stopping the gift after all tdeio_mrml instances
have been killed.
lib/: common stuff used by more than one module
Useful URLs:
The MRML DTD:
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/gift/gift/dtd/mrml.dtd?rev=HEAD&content-type=text/plain
The GIFT Homepage:
http://www.gnu.org/software/gift
The fer-de-lance project homepage, under which the GIFT and kmrml are living
http://www.fer-de-lance.org
2002/08/08
Carsten Pfeiffer <pfeiffer@kde.org>

@ -1,15 +0,0 @@
- Konqueror Properties dialog for indexing directory? Or just a context menu entry?
- make use of BrowserExtension, provide the actions
- contextmenu
- better layouting?
- better keyboard support
- progress report from slave
- transfer mrml in chunks as data arrives?
- finish algorithm configuration
- integrate with KPaint so you can paint an example image
- integrate with kamera, so that images from your digicam will be indexed automatically
- create Konq ContextMenu plugin instead of the ServiceMenu thing (mrmlsearch binary)
- proper browserextension (restorestate/savestate, history, implement actions)
- a panel applet or tray app KDirWatching indexable dirs and re-indexing on demand
lots more probably

@ -1,142 +0,0 @@
<algorithm-list>
<algorithm
algorithm-name="Classical IDF"
algorithm-id="a-cidf"
algorithm-type="a-cidf" >
cui-block-texture-histogram="no"
collection-id="c-0-40-20-27-3-101-5-116-0"
cui-pr-percentage-of-features="70"
cui-block-texture-blocks="no"
cui-weighting-function="ClassicalIDF"
cui-base-type="inverted_file"
cui-block-color-histogram="no"
cui-block-color-blocks="no"
<query-paradigm-list>
<query-paradigm/>
</query-paradigm-list>
<property-sheet
send-type="none"
maxsubsetsize="1"
property-sheet-id="cui-p-1"
minsubsetsize="0"
property-sheet-type="subset" >
<property-sheet
caption="Modify default configuration"
send-type="none"
property-sheet-id="cui-p0"
property-sheet-type="set-element" >
<property-sheet
send-name="cui-pr-percentage-of-features"
send-value="70"
caption="Prune at % of features"
send-type="attribute"
from="20"
to="100"
step="5"
property-sheet-id="cui-p15"
property-sheet-type="numeric" />
<property-sheet
send-type="none"
maxsubsetsize="4"
property-sheet-id="cui-p1"
minsubsetsize="1"
property-sheet-type="subset" >
<property-sheet
send-name="cui-block-color-blocks"
send-value="yes"
caption="Colour blocks"
send-type="attribute"
property-sheet-id="cui-p12"
send-boolean-inverted="yes"
property-sheet-type="set-element" />
<property-sheet
send-name="cui-block-texture-blocks"
send-value="yes"
caption="Gabor blocks"
send-type="attribute"
property-sheet-id="cui-p14"
send-boolean-inverted="yes"
property-sheet-type="set-element" />
<property-sheet
send-name="cui-block-texture-histogram"
send-value="yes"
caption="Gabor histogram"
send-type="attribute"
property-sheet-id="cui-p13"
send-boolean-inverted="yes"
property-sheet-type="set-element" />
<property-sheet
send-name="cui-block-color-histogram"
send-value="yes"
caption="Colour histogram"
send-type="attribute"
property-sheet-id="cui-p11"
send-boolean-inverted="yes"
property-sheet-type="set-element" />
</property-sheet>
</property-sheet>
</property-sheet>
</algorithm>
<!-- -->
<algorithm cui-perl-query-function="processGIFTQueryCall" algorithm-id="a-perl" cui-perl-script-file="/home/gis/gift-embed-perl-modules.pl" cui-perl-package="CGIFTLink" collection-id="c-0-40-20-27-3-101-5-116-0" cui-perl-random-function="processGIFTRandomQueryCall" cui-weighting-function="ClassicalIDF" algorithm-name="Perl link" cui-base-type="perl" algorithm-type="a-perl" >
<query-paradigm-list>
<query-paradigm type="inverted-file" />
<query-paradigm type="perl-demo" />
</query-paradigm-list>
<property-sheet send-type="none" maxsubsetsize="1" property-sheet-id="cui-p-1" minsubsetsize="0" property-sheet-type="subset" >
<property-sheet caption="Modify default configuration" send-type="none" property-sheet-id="cui-p0" property-sheet-type="set-element" />
</property-sheet>
</algorithm>
<algorithm cui-block-texture-histogram="no" algorithm-id="adefault" collection-id="c-0-40-20-27-3-101-5-116-0" cui-pr-percentage-of-features="70" cui-block-texture-blocks="no" cui-weighting-function="ClassicalIDF" algorithm-name="Separate Normalisation" cui-base-type="multiple" cui-block-color-histogram="no" cui-block-color-blocks="no" algorithm-type="adefault" >
<algorithm cui-block-texture-histogram="yes" algorithm-id="sub1" cui-pr-percentage-of-features="100" cui-block-texture-blocks="yes" algorithm-name="sub1" cui-base-type="inverted_file" cui-block-color-blocks="yes" algorithm-type="sub1" />
<algorithm cui-block-texture-histogram="yes" algorithm-id="sub2" cui-block-texture-blocks="yes" algorithm-name="sub2" cui-base-type="inverted_file" cui-block-color-histogram="yes" algorithm-type="sub2" />
<algorithm algorithm-id="sub3" cui-pr-percentage-of-features="100" cui-block-texture-blocks="yes" algorithm-name="sub3" cui-base-type="inverted_file" cui-block-color-histogram="yes" cui-block-color-blocks="yes" algorithm-type="sub3" />
<algorithm cui-block-texture-histogram="yes" algorithm-id="sub4" algorithm-name="sub4" cui-base-type="inverted_file" cui-block-color-histogram="yes" cui-block-color-blocks="yes" algorithm-type="sub4" />
<query-paradigm-list>
<query-paradigm/>
</query-paradigm-list>
<property-sheet send-type="none" maxsubsetsize="1" property-sheet-id="cui-p-1" minsubsetsize="0" property-sheet-type="subset" >
<property-sheet caption="Modify default configuration" send-type="none" property-sheet-id="cui-p0" property-sheet-type="set-element" >
<property-sheet send-name="cui-pr-percentage-of-features" send-value="70" caption="Prune at % of features" send-type="attribute" from="20" to="100" step="5" property-sheet-id="cui-p15" property-sheet-type="numeric" />
<property-sheet send-type="none" maxsubsetsize="4" property-sheet-id="cui-p1" minsubsetsize="1" property-sheet-type="subset" >
<property-sheet send-name="cui-block-color-blocks" send-value="yes" caption="Colour blocks" send-type="attribute" property-sheet-id="cui-p12" send-boolean-inverted="yes" property-sheet-type="set-element" />
<property-sheet send-name="cui-block-texture-blocks" send-value="yes" caption="Gabor blocks" send-type="attribute" property-sheet-id="cui-p14" send-boolean-inverted="yes" property-sheet-type="set-element" />
<property-sheet send-name="cui-block-texture-histogram" send-value="yes" caption="Gabor histogram" send-type="attribute" property-sheet-id="cui-p13" send-boolean-inverted="yes" property-sheet-type="set-element" />
<property-sheet send-name="cui-block-color-histogram" send-value="yes" caption="Colour histogram" send-type="attribute" property-sheet-id="cui-p11" send-boolean-inverted="yes" property-sheet-type="set-element" />
</property-sheet>
</property-sheet>
</property-sheet>
</algorithm>
</algorithm-list>
<collection-list>
<collection
collection-name="images"
collection-id="c-0-40-20-27-3-101-5-116-0"
cui-inverted-file-location="InvertedFile.db"
cui-offset-file-location="InvertedFileOffset.db"
cui-algorithm-id-list-id="ail-inverted-file"
cui-feature-file-location="url2fts.xml"
cui-feature-description-location="InvertedFileFeatureDescription.db"
cui-base-dir="/home/gis/gift-indexing-data/images//"
cui-number-of-images="372" >
<query-paradigm-list>
<query-paradigm type="inverted-file" />
<query-paradigm type="perl-demo" />
</query-paradigm-list>
</collection>
</collection-list>

@ -1,62 +0,0 @@
%define version 0.3
%define release 1
%define serial 1
%define prefix /opt/trinity
Name: kmrml
Summary: MRML for KDE -- Content based image retrieval
Version: %{version}
Release: %{release}
Serial: %{serial}
Source: http://devel-home.kde.org/~pfeiffer/kmrml/kmrml-%{version}.tgz
URL: http://devel-home.kde.org/~pfeiffer/kmrml/
Copyright: GPL
Packager: Carsten Pfeiffer <pfeiffer@kde.org>
Group: X11/KDE/Utilities
BuildRoot: /tmp/kmrml-%{version}-root
Prefix: %{prefix}
%description
MRML is short for Multimedia Retrieval Markup Language,
which defines a protocol for querying a server for images
based on their content. See http://www.mrml.net about MRML
and the GNU Image Finding Tool (GIFT), an MRML server.
This package consists of an mrml tdeio-slave that handles
the communication with the MRML server and a KPart to
be embedded e.g. into Konqueror.
With those, you can search for images by giving an example
image and let the server look up similar images. The query
result can be refined by giving positive/negative feedback.
Install with '--prefix $TDEDIR' unless you have KDE in /opt/trinity
%prep
rm -rf $RPM_BUILD_ROOT
%setup -n kmrml-%{version}
%build
export TDEDIR=%{prefix}
CXXFLAGS="$RPM_OPT_FLAGS -fno-exceptions -malign-functions=2 -malign-jumps=2 -malign-loops=2 -pipe" LDFLAGS=-s ./configure --prefix=%{prefix} --enable-final --disable-debug
mkdir -p $RPM_BUILD_ROOT
make
%install
make install DESTDIR=$RPM_BUILD_ROOT
cd $RPM_BUILD_ROOT
find . -type d | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' > $RPM_BUILD_DIR/file.list.%{name}
find . -type f | sed 's,^\.,\%attr(-\,root\,root) ,' >> $RPM_BUILD_DIR/file.list.%{name}
find . -type l | sed 's,^\.,\%attr(-\,root\,root) ,' >> $RPM_BUILD_DIR/file.list.%{name}
%clean
rm -rf $RPM_BUILD_ROOT
rm -f $RPM_BUILD_DIR/file.list.%{name}
%files -f ../file.list.%{name}

@ -1,9 +0,0 @@
##### create translation templates ##############
tde_l10n_create_template( "kmrml" )
tde_l10n_create_template(
CATALOG "desktop_files/kmrml-desktops/"
SOURCES *.desktop
DESTINATION "${CMAKE_SOURCE_DIR}/translations"
)

@ -1,78 +0,0 @@
#################################################
#
# (C) 2010-2011 Calvin Morrison
# mutantturkey@gmail.com
#
# Improvements and feedback are welcome
#
# This file is released under GPL >= 2
#
#################################################
add_subdirectory( lib )
add_subdirectory( kcontrol )
add_subdirectory( server )
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/lib
${CMAKE_BINARY_DIR}
${TDE_INCLUDE_DIR}
${TQT_INCLUDE_DIRS}
)
link_directories(
${TQT_LIBRARY_DIRS}
)
#### other data #################################
install( FILES mrml.protocol DESTINATION ${SERVICES_INSTALL_DIR} )
tde_create_translated_desktop(
SOURCE mrml_part.desktop
DESTINATION ${SERVICES_INSTALL_DIR}
PO_DIR kmrml-desktops
)
tde_create_translated_desktop(
SOURCE mrml.desktop
DESTINATION ${MIME_INSTALL_DIR}/text
PO_DIR kmrml-desktops
)
tde_create_translated_desktop(
SOURCE mrml-servicemenu.desktop
DESTINATION ${DATA_INSTALL_DIR}/konqueror/servicemenus
PO_DIR kmrml-desktops
)
#### tdeio_mrml (module) ##########################
tde_add_kpart( tdeio_mrml AUTOMOC
SOURCES mrml.cpp
LINK kmrmlstuff-static tdeio-shared
DESTINATION ${PLUGIN_INSTALL_DIR}
)
##### libkmrmlpart (module) #######################
tde_add_kpart( libkmrmlpart AUTOMOC
SOURCES
mrml_part.cpp mrml_view.cpp loader.cpp mrml_elements.cpp
mrml_creator.cpp browser.cpp algorithmdialog.cpp collectioncombo.cpp
algorithmcombo.cpp propertysheet.cpp
LINK kmrmlstuff-static tdeparts-shared
DESTINATION ${PLUGIN_INSTALL_DIR}
)
##### mrmlsearch (tdeinit) ######################
tde_add_tdeinit_executable( mrmlsearch AUTOMOC
SOURCES mrmlsearch.cpp
LINK kmrmlstuff-static tdecore-shared
)

@ -1,41 +0,0 @@
SUBDIRS = server lib kcontrol
INCLUDES= -I$(top_srcdir)/kmrml/kmrml/lib $(all_includes)
METASOURCES = AUTO
LIB_KMRMLSTUFF = $(top_builddir)/kmrml/kmrml/lib/libkmrmlstuff.la
####### Files
kde_module_LTLIBRARIES = tdeio_mrml.la libkmrmlpart.la
tdeio_mrml_la_SOURCES = mrml.cpp
tdeio_mrml_la_LIBADD = $(LIB_KMRMLSTUFF) $(LIB_TDEIO)
tdeio_mrml_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
libkmrmlpart_la_SOURCES = mrml_part.cpp mrml_view.cpp loader.cpp \
mrml_elements.cpp mrml_creator.cpp browser.cpp algorithmdialog.cpp \
collectioncombo.cpp algorithmcombo.cpp propertysheet.cpp
libkmrmlpart_la_LIBADD = $(LIB_KMRMLSTUFF) $(LIB_TDEPARTS)
libkmrmlpart_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
services_DATA = mrml.protocol mrml_part.desktop
servicesdir = $(kde_servicesdir)
mimetypes_DATA = mrml.desktop
mimetypesdir = $(kde_mimedir)/text
servicemenu_DATA = mrml-servicemenu.desktop
servicemenudir = $(kde_datadir)/konqueror/servicemenus
#############################################
bin_PROGRAMS =
lib_LTLIBRARIES =
tdeinit_LTLIBRARIES = mrmlsearch.la
mrmlsearch_la_LIBADD = $(LIB_KMRMLSTUFF) $(LIB_TDECORE)
mrmlsearch_la_LDFLAGS = $(all_libraries) -module -avoid-version
mrmlsearch_la_SOURCES = mrmlsearch.cpp
messages:
$(EXTRACTRC) */*.ui > rc.cpp
$(XGETTEXT) *.h *.cpp */*.cpp */*.h -o $(podir)/kmrml.pot

@ -1,66 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "algorithmcombo.h"
#include <kdatastream.h>
using namespace KMrml;
// ### copycat of CollectionCombo... moc can't handle templates unfortunately..
// could use base-class MrmlElement....
AlgorithmCombo::AlgorithmCombo( TQWidget *parent, const char *name )
: KComboBox( false, parent, name ),
m_algorithms( 0L )
{
connect( this, TQT_SIGNAL( activated( const TQString& ) ),
TQT_SLOT( slotActivated( const TQString& ) ));
}
AlgorithmCombo::~AlgorithmCombo()
{
}
void AlgorithmCombo::setAlgorithms( const AlgorithmList *algorithms )
{
assert( algorithms != 0L );
clear();
m_algorithms = algorithms;
insertStringList( algorithms->itemNames() );
// #### block signals here?
}
void AlgorithmCombo::setCurrent( const Algorithm& coll )
{
setCurrentItem( coll.name() );
}
Algorithm AlgorithmCombo::current() const
{
return m_algorithms->findByName( currentText() );
}
void AlgorithmCombo::slotActivated( const TQString& name )
{
Algorithm coll = m_algorithms->findByName( name );
emit selected( coll );
}
#include "algorithmcombo.moc"

@ -1,55 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef ALGORITHMCOMBO_H
#define ALGORITHMCOMBO_H
#include <kcombobox.h>
#include "mrml_elements.h"
namespace KMrml
{
class AlgorithmCombo : public KComboBox
{
Q_OBJECT
public:
AlgorithmCombo( TQWidget *parent, const char *name = 0 );
~AlgorithmCombo();
void setAlgorithms( const AlgorithmList * algorithms );
void setCurrent( const Algorithm& coll );
Algorithm current() const;
signals:
void selected( const Algorithm& );
private slots:
void slotActivated( const TQString& );
private:
const AlgorithmList *m_algorithms;
};
}
#endif // ALGORITHMCOMBO_H

@ -1,132 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "algorithmdialog.h"
#include "algorithmcombo.h"
#include "collectioncombo.h"
#include <tqhbox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqscrollview.h>
#include <tqvbox.h>
#include <tqvgroupbox.h>
#include <tdelocale.h>
using namespace KMrml;
class ScrollView : public TQScrollView
{
public:
ScrollView(TQWidget* parent = 0, const char* name = 0)
: TQScrollView(parent, name)
{
setFrameStyle(TQFrame::NoFrame);
m_frame = new TQFrame(viewport(), "ScrollView::m_frame");
m_frame->setFrameStyle(TQFrame::NoFrame);
addChild(m_frame, 0, 0);
};
TQFrame* frame() {return m_frame;};
protected:
virtual void viewportResizeEvent(TQResizeEvent* ev)
{
TQScrollView::viewportResizeEvent(ev);
m_frame->resize( kMax(m_frame->sizeHint().width(), ev->size().width()),
kMax(m_frame->sizeHint().height(), ev->size().height()));
};
private:
TQFrame* m_frame;
};
AlgorithmDialog::AlgorithmDialog( const AlgorithmList& algorithms,
const CollectionList& collections,
const Collection& currentColl,
TQWidget *parent, const char *name )
: KDialogBase( parent, name, false, i18n("Configure Query Algorithms"),
Ok | Cancel, Ok, false ),
m_allAlgorithms( algorithms ),
m_collections( collections )
{
TQWidget *box = makeMainWidget();
TQVBoxLayout *mainLayout = new TQVBoxLayout( box, 0, KDialog::spacingHint(),
"mainLayout");
TQHBoxLayout *collectionLayout = new TQHBoxLayout( 0L, 0, 0, "coll layout");
collectionLayout->addWidget( new TQLabel( i18n("Collection: "), box ));
m_collectionCombo = new CollectionCombo( box, "collection combo" );
m_collectionCombo->setCollections( &m_collections );
collectionLayout->addWidget( m_collectionCombo );
mainLayout->addLayout( collectionLayout );
mainLayout->addSpacing( 14 );
TQHBox *algoHLayout = new TQHBox( box );
(void) new TQLabel( i18n("Algorithm: "), algoHLayout);
m_algoCombo = new AlgorithmCombo( algoHLayout, "algo combo" );
TQVGroupBox *groupBox = new TQVGroupBox( box, "groupBox" );
mainLayout->addWidget( groupBox );
algoHLayout->raise();
ScrollView *scrollView = new ScrollView( groupBox, "scroll view" );
m_view = scrollView->frame();
TQVBoxLayout *viewLayout = new TQVBoxLayout( scrollView );
viewLayout->setSpacing( KDialog::spacingHint() );
collectionChanged( currentColl );
connect( m_algoCombo, TQT_SIGNAL( selected( const Algorithm& ) ),
TQT_SLOT( initGUI( const Algorithm& ) ));
connect( m_collectionCombo, TQT_SIGNAL( selected( const Collection& ) ),
TQT_SLOT( collectionChanged( const Collection& ) ));
algoHLayout->adjustSize();
mainLayout->activate();
algoHLayout->move( groupBox->x() + 10, groupBox->y() - 12 );
box->setMinimumWidth( algoHLayout->sizeHint().width() +
4 * KDialog::spacingHint() );
}
AlgorithmDialog::~AlgorithmDialog()
{
}
void AlgorithmDialog::collectionChanged( const Collection& coll )
{
m_algosForCollection = m_allAlgorithms.algorithmsForCollection( coll );
m_algoCombo->setAlgorithms( &m_algosForCollection );
initGUI( m_algoCombo->current() );
}
void AlgorithmDialog::initGUI( const Algorithm& algo )
{
m_algo = algo;
}
#include "algorithmdialog.moc"

@ -1,61 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef ALGORITHMDIALOG_H
#define ALGORITHMDIALOG_H
#include <kdialogbase.h>
#include "mrml_elements.h"
namespace KMrml
{
class AlgorithmCombo;
class CollectionCombo;
class AlgorithmDialog : public KDialogBase
{
Q_OBJECT
public:
AlgorithmDialog( const AlgorithmList&, const CollectionList&,
const Collection& currentColl,
TQWidget *parent = 0, const char *name = 0 );
~AlgorithmDialog();
private slots:
void collectionChanged( const Collection& );
void initGUI( const Algorithm& algo );
private:
Algorithm m_algo;
AlgorithmList m_allAlgorithms;
AlgorithmList m_algosForCollection;
CollectionList m_collections;
CollectionCombo *m_collectionCombo;
AlgorithmCombo *m_algoCombo;
TQFrame *m_view;
};
}
#endif // ALGORITHMDIALOG_H

@ -1,63 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "browser.h"
#include "mrml_part.h"
#include <tqscrollview.h>
using namespace KMrml;
Browser::Browser( MrmlPart *parent, const char *name )
: KParts::BrowserExtension( parent, name ),
m_part( parent )
{
}
Browser::~Browser()
{
}
void Browser::saveState( TQDataStream& stream )
{
// BrowserExtension::saveState( stream );
m_part->saveState( stream );
}
void Browser::restoreState( TQDataStream& stream )
{
// BrowserExtension::restoreState( stream );
// ### BrowserExtension::restoreState() calls openURL() at the end (arghh).
m_part->restoreState( stream );
}
int Browser::xOffset()
{
return static_cast<TQScrollView*>( m_part->widget())->contentsX();
}
int Browser::yOffset()
{
return static_cast<TQScrollView*>( m_part->widget())->contentsY();
}
#include "browser.moc"

@ -1,49 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef BROWSER_H
#define BROWSER_H
#include <tdeparts/browserextension.h>
namespace KMrml
{
class MrmlPart;
class Browser : public KParts::BrowserExtension
{
Q_OBJECT
public:
Browser( MrmlPart *parent, const char *name );
~Browser();
virtual void saveState( TQDataStream& stream );
virtual void restoreState( TQDataStream& stream );
virtual int xOffset();
virtual int yOffset();
private:
MrmlPart *m_part;
};
}
#endif // BROWSER_H

@ -1,95 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "collectioncombo.h"
#include <kdatastream.h>
using namespace KMrml;
CollectionCombo::CollectionCombo( TQWidget *parent, const char *name )
: KComboBox( false, parent, name ),
m_collections( 0L )
{
connect( this, TQT_SIGNAL( activated( const TQString& ) ),
TQT_SLOT( slotActivated( const TQString& ) ));
}
CollectionCombo::~CollectionCombo()
{
}
void CollectionCombo::setCollections( const CollectionList *collections )
{
assert( collections != 0L );
clear();
m_collections = collections;
insertStringList( collections->itemNames() );
// #### block signals here?
}
void CollectionCombo::setCurrent( const Collection& coll )
{
setCurrentItem( coll.name() );
}
Collection CollectionCombo::current() const
{
return m_collections->findByName( currentText() );
}
void CollectionCombo::slotActivated( const TQString& name )
{
Collection coll = m_collections->findByName( name );
emit selected( coll );
}
TQDataStream& KMrml::operator<<( TQDataStream& stream,
const CollectionCombo& combo )
{
int count = combo.count();
stream << count;
for ( int i = 0; i < count; i++ )
stream << combo.text( i );
stream << combo.currentItem();
return stream;
}
TQDataStream& KMrml::operator>>( TQDataStream& stream, CollectionCombo& combo )
{
combo.clear();
int count;
stream >> count;
TQString text;
for ( int i = 0; i < count; i++ )
{
stream >> text;
combo.insertItem( text );
}
int current;
stream >> current;
combo.setCurrentItem( current );
return stream;
}
#include "collectioncombo.moc"

@ -1,58 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef COLLECTIONCOMBO_H
#define COLLECTIONCOMBO_H
#include <kcombobox.h>
#include "mrml_elements.h"
namespace KMrml
{
class CollectionCombo : public KComboBox
{
Q_OBJECT
public:
CollectionCombo( TQWidget *parent, const char *name = 0 );
~CollectionCombo();
void setCollections( const CollectionList * collections );
void setCurrent( const Collection& coll );
Collection current() const;
signals:
void selected( const Collection& );
private slots:
void slotActivated( const TQString& );
private:
const CollectionList *m_collections;
};
TQDataStream& operator<<( TQDataStream& stream, const CollectionCombo& );
TQDataStream& operator>>( TQDataStream& stream, CollectionCombo& );
}
#endif // COLLECTIONCOMBO_H

@ -1,41 +0,0 @@
#################################################
#
# (C) 2010-2011 Calvin Morrison
# mutantturkey@gmail.com
#
# Improvements and feedback are welcome
#
# This file is released under GPL >= 2
#
#################################################
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../lib
${CMAKE_BINARY_DIR}
${TDE_INCLUDE_DIR}
${TQT_INCLUDE_DIRS}
)
link_directories(
${TQT_LIBRARY_DIRS}
)
#### other data #################################
tde_create_translated_desktop(
SOURCE kcmkmrml.desktop
PO_DIR kmrml-desktops
)
#### kcm_kmrml (module) ###########################
tde_add_kpart( kcm_kmrml AUTOMOC
SOURCES
kcmkmrml.cpp mainpage.cpp indexer.cpp
serverconfigwidget.ui indexcleaner.cpp
LINK
kmrmlstuff-static tdeparts-shared tdeio-shared
DESTINATION ${PLUGIN_INSTALL_DIR}
)

@ -1,25 +0,0 @@
LIB_KMRMLSTUFF = $(top_builddir)/kmrml/kmrml/lib/libkmrmlstuff.la
kde_module_LTLIBRARIES = kcm_kmrml.la
kcm_kmrml_la_SOURCES = kcmkmrml.cpp mainpage.cpp indexer.cpp serverconfigwidget.ui indexcleaner.cpp
kcm_kmrml_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
kcm_kmrml_la_LIBADD = $(LIB_KMRMLSTUFF) $(LIB_TDEIO)
INCLUDES= -I$(top_srcdir)/kmrml/kmrml/lib $(all_includes)
kcm_kmrml_la_METASOURCES = AUTO
noinst_HEADERS = kcmkmrml.h mainpage.h serverconfigwidget.h indexer.h indexcleaner.h
xdg_apps_DATA = kcmkmrml.desktop
#check_PROGRAMS = indextest
#indextest_SOURCES = indextest.cpp indexer.cpp
#indextest_LDADD = $(LIB_KMRMLSTUFF) $(LIB_TDECORE)
#indextest_LDFLAGS = $(all_libraries)
#pics_DATA = play.png
#picsdir = $(kde_datadir)/kcontrol/pics

@ -1,96 +0,0 @@
#include <kdebug.h>
#include <kprocess.h>
#include <kmrml_config.h>
#include "indexcleaner.h"
#include <tdeversion.h>
#if TDE_VERSION < 306
#define QUOTE( x ) x
#else
#define QUOTE( x ) TDEProcess::quote( x )
#endif
using namespace KMrmlConfig;
IndexCleaner::IndexCleaner( const TQStringList& dirs,
const KMrml::Config *config,
TQObject *parent, const char *name )
: TQObject( parent, name ),
m_dirs( dirs ),
m_config( config ),
m_process( 0L )
{
m_stepSize = 100 / dirs.count();
}
IndexCleaner::~IndexCleaner()
{
if ( m_process )
{
m_process->kill();
delete m_process;
m_process = 0L;
}
}
void IndexCleaner::start()
{
startNext();
}
void IndexCleaner::slotExited( TDEProcess *proc )
{
emit advance( m_stepSize );
if ( !proc->normalExit() )
kdWarning() << "Error removing old indexed directory" << endl;
m_process = 0L;
startNext();
}
void IndexCleaner::startNext()
{
if ( m_dirs.isEmpty() )
{
emit advance( 100 );
emit finished();
return;
}
#if TDE_VERSION < 306
m_process = new KShellProcess();
#else
m_process = new TDEProcess();
m_process->setUseShell( true );
#endif
connect( m_process, TQT_SIGNAL( processExited( TDEProcess * )),
TQT_SLOT( slotExited( TDEProcess * ) ));
TQString cmd = m_config->removeCollectionCommandLine();
TQString dir = m_dirs.first();
m_dirs.pop_front();
int index = cmd.find( "%d" );
if ( index != -1 )
cmd.replace( index, 2, QUOTE( dir ) );
else // no %d? What else can we do?
cmd.append( TQString::fromLatin1(" ") + QUOTE( dir ) );
*m_process << cmd;
if ( !m_process->start() )
{
kdWarning() << "Error starting: " << cmd << endl;
delete m_process;
m_process = 0L;
startNext();
}
}
#include "indexcleaner.moc"

@ -1,54 +0,0 @@
/****************************************************************************
** $Id$
**
** Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
**
****************************************************************************/
#ifndef INDEXCLEANER_H
#define INDEXCLEANER_H
#include <tqobject.h>
#include <tqstringlist.h>
class TDEProcess;
namespace KMrml
{
class Config;
}
namespace KMrmlConfig
{
class IndexCleaner : public TQObject
{
Q_OBJECT
public:
IndexCleaner( const TQStringList& dirs, const KMrml::Config *config,
TQObject *parent = 0, const char *name = 0 );
~IndexCleaner();
void start();
signals:
void advance( int value );
void finished();
private slots:
void slotExited( TDEProcess * );
private:
int m_stepSize;
void startNext();
TQStringList m_dirs;
const KMrml::Config *m_config;
TDEProcess *m_process;
};
}
#endif // INDEXCLEANER_H

@ -1,190 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <tqfile.h>
#include <tqregexp.h>
#include <kdebug.h>
#include <tdelocale.h>
#include <tdeglobal.h>
#include <kprocio.h>
#include "indexer.h"
#include <tdeversion.h>
#if TDE_VERSION < 306
#define QUOTE( x ) x
#else
#define QUOTE( x ) TDEProcess::quote( x )
#endif
using namespace KMrmlConfig;
Indexer::Indexer( const KMrml::Config* config,
TQObject *parent, const char *name )
: TQObject( parent, name ),
m_config( config ),
m_dirCount( 0 )
{
m_process = new KProcIO();
#if TDE_VERSION >= 306
m_process->setUseShell( true );
#endif
m_process->setEnvironment( "LC_ALL", "C" );
connect( m_process, TQT_SIGNAL( processExited( TDEProcess * )),
TQT_SLOT( processFinished( TDEProcess * )));
connect( m_process, TQT_SIGNAL( readReady( KProcIO * )),
TQT_SLOT( slotCanRead( KProcIO * )) );
}
Indexer::~Indexer()
{
delete m_process;
}
void Indexer::startIndexing( const TQStringList& dirs )
{
if ( m_process->isRunning() )
return;
m_dirs = dirs;
m_dirCount = dirs.count();
processNext();
}
void Indexer::processFinished( TDEProcess *proc )
{
// still more directories to index?
if ( !m_dirs.isEmpty() )
processNext();
else
{
if ( proc->normalExit() )
emit finished( proc->exitStatus() );
else
emit finished( -1000 );
}
}
void Indexer::processNext()
{
m_currentDir = m_dirs.first();
m_dirs.pop_front();
while ( m_currentDir.endsWith( "/" ) )
m_currentDir.remove( m_currentDir.length() -1, 1 );
m_process->resetAll();
TQString cmd = m_config->addCollectionCommandLine().simplifyWhiteSpace().stripWhiteSpace();
// in the commandline, replace %d with the directory to process and
// %t with the thumbnail dir
int index = cmd.find( "%d" ); // ### TQFile::encodeName()?
if ( index != -1 )
cmd.replace( index, 2, QUOTE( m_currentDir ) );
index = cmd.find( "%t" );
if ( index != -1 )
cmd.replace( index, 2, QUOTE(m_currentDir + "_thumbnails") );
// tqDebug("****** command: %s", cmd.latin1());
#if TDE_VERSION >= 306
*m_process << cmd;
#else
TQStringList params = TQStringList::split( ' ', cmd );
TQStringList::Iterator it = params.begin();
for ( ; it != params.end(); ++it )
*m_process << *it;
#endif
emit progress( 0, i18n("<qt>Next Folder: <br><b>%1</b>").arg( m_currentDir ));
m_process->start();
}
void Indexer::slotCanRead( KProcIO *proc )
{
static const TQString& sprogress = TDEGlobal::staticQString("PROGRESS: ");
static const TQString& r1 = /* PROGRESS: 1 of 6 done (15%) */
TDEGlobal::staticQString( "(\\d+) of (\\d+) done \\((\\d+)%\\)" );
TQString line;
int bytes = -1;
while ( (bytes = proc->readln( line )) != -1 )
{
// examine the output.
// We're looking for lines like:
// PROGRESS: 1 of 6 done (15%)
// PROGRESS: 99%
// PROGRESS: 100%
if ( !line.startsWith( sprogress ) ) // uninteresting debug output
continue;
else // parse output
{
// cut off "PROGRESS: "
line = line.mid( sprogress.length() );
line = line.simplifyWhiteSpace().stripWhiteSpace();
// tqDebug("*** START LINE ***");
// tqDebug("%s", line.latin1());
// tqDebug("*** END LINE ***");
// case 1: image processing, below 99%
if ( line.at( line.length() -1 ) == ')' )
{
TQRegExp regxp( r1 );
int pos = regxp.search( line );
if ( pos > -1 )
{
TQString currentFile = regxp.cap( 1 );
TQString numFiles = regxp.cap( 2 );
TQString percent = regxp.cap( 3 );
// tqDebug( "current: %s, number: %s, percent: %s", currentFile.latin1(), numFiles.latin1(), percent.latin1());
bool ok = false;
int perc = percent.toInt( &ok );
if ( ok )
{
uint dirsLeft = m_dirs.count();
TQString message = i18n( "<qt>Processing folder %1 of %2: <br><b>%3</b><br>File %4 of %5.</qt>").arg( m_dirCount - dirsLeft ).arg( m_dirCount).arg( m_currentDir ).arg( currentFile ).arg( numFiles );
emit progress( perc, message );
}
}
}
// case 2: file writing, 99% or done, 100%
else
{
TQString percent = line.left( line.length() - 1 );
bool ok = false;
int number = percent.toInt( &ok );
if ( ok )
{
TQString message = (number == 100) ?
i18n("Finished.") : i18n("Writing data...");
emit progress( number, message );
}
else
kdDebug() << "Error while parsing gift-add-collection.pl output" << endl;
}
}
}
}
#include "indexer.moc"

@ -1,69 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef INDEXER_H
#define INDEXER_H
#include <tqobject.h>
#include <kmrml_config.h>
class TDEProcess;
class KProcIO;
namespace KMrmlConfig
{
class Indexer : public TQObject
{
Q_OBJECT
public:
Indexer( const KMrml::Config *config,
TQObject *parent = 0L, const char *name = 0 );
~Indexer();
void startIndexing( const TQStringList& dirs );
void stop();
signals:
void progress( int percent, const TQString& text );
void finished( int returnCode );
private slots:
void slotCanRead( KProcIO * );
void processFinished( TDEProcess * );
private:
void processNext();
KProcIO *m_process;
const KMrml::Config *m_config;
uint m_dirCount;
TQStringList m_dirs;
TQString m_currentDir;
};
}
#endif // INDEXER_H

@ -1,43 +0,0 @@
#include "indexer.h"
#include <kmrml_config.h>
#include "indextest.moc"
#include <tdeapplication.h>
#include <tdeconfig.h>
#include <tdeglobal.h>
using namespace KMrmlConfig;
IndexTest::IndexTest()
{
KMrml::Config *config = new KMrml::Config( TDEGlobal::config() );
Indexer *indexer = new Indexer( *config, this );
connect( indexer, TQT_SIGNAL( finished( bool )), TQT_SLOT( slotFinished( bool )));
connect( indexer, TQT_SIGNAL( progress( int, const TQString& )),
TQT_SLOT( slotProgress( int, const TQString& )));
indexer->startIndexing( "/home/gis/testcoll" );
}
IndexTest::~IndexTest()
{
}
void IndexTest::slotFinished( bool success )
{
tqDebug("##### FINISHED: %i", success );
}
void IndexTest::slotProgress( int percent, const TQString& message )
{
tqDebug("--- progress: %i: %s", percent, message.latin1());
}
int main( int argc, char **argv )
{
TDEApplication app( argc, argv, "indextest" );
IndexTest *test = new IndexTest();
return app.exec();
}

@ -1,27 +0,0 @@
/****************************************************************************
** $Id$
**
** Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
**
****************************************************************************/
#ifndef INDEXTEST_H
#define INDEXTEST_H
class IndexTest : public TQObject
{
Q_OBJECT
public:
IndexTest();
~IndexTest();
private slots:
void slotFinished( bool success );
void slotProgress( int percent, const TQString& message );
};
#endif // INDEXTEST_H

@ -1,146 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <tqlabel.h>
#include <tqlayout.h>
#include <tdeaboutdata.h>
#include <tdeapplication.h>
#include <kdebug.h>
#include <kdialog.h>
#include <tdeglobal.h>
#include <tdelocale.h>
#include <tdemessagebox.h>
#include <kgenericfactory.h>
#include <kstandarddirs.h>
#include <kurllabel.h>
#include "kcmkmrml.h"
#include <dcopclient.h>
#include "mainpage.h"
#include <version.h>
using namespace KMrmlConfig;
static const int COL_FILENAME = 1;
typedef KGenericFactory<KCMKMrml, TQWidget> MrmlFactory;
K_EXPORT_COMPONENT_FACTORY( kcm_kmrml, MrmlFactory("kmrml") )
KCMKMrml::KCMKMrml(TQWidget *parent, const char *name, const TQStringList & ):
TDECModule(MrmlFactory::instance(), parent, name)
{
TDEAboutData* ab = new TDEAboutData(
"kcmkmrml",
I18N_NOOP("KCMKMrml"),
KMRML_VERSION,
I18N_NOOP("Advanced Search Control Module"),
TDEAboutData::License_GPL,
I18N_NOOP( "Copyright 2002, Carsten Pfeiffer" ),
0,
"http://devel-home.kde.org/~pfeiffer/kmrml/" );
ab->addAuthor( "Carsten Pfeiffer", 0, "pfeiffer@kde.org" );
setAboutData( ab );
TQVBoxLayout *layout = new TQVBoxLayout( this );
layout->setSpacing( KDialog::spacingHint() );
m_mainPage = new MainPage( this, "main page" );
layout->addWidget( m_mainPage );
connect( m_mainPage, TQT_SIGNAL( changed( bool ) ), TQT_SIGNAL( changed( bool )));
checkGiftInstallation();
}
KCMKMrml::~KCMKMrml()
{
}
void KCMKMrml::checkGiftInstallation()
{
TQString giftExe = TDEGlobal::dirs()->findExe( "gift" );
TQString giftAddCollectionExe = TDEGlobal::dirs()->findExe( "gift-add-collection.pl" );
if ( giftExe.isEmpty() || giftAddCollectionExe.isEmpty() )
{
TQString errorMessage =
i18n("Cannot find executables \"gift\" and/or \"gift-add-collection.pl\" in the PATH.\n"
"Please install the \"GNU Image Finding Tool\".");
KMessageBox::error( this, errorMessage );
m_mainPage->hide();
TQLabel *errorLabel = new TQLabel( errorMessage, this );
errorLabel->setSizePolicy( TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Fixed ) );
KURLLabel *urlLabel = new KURLLabel( "http://www.gnu.org/software/gift", TQString(), this );
urlLabel->setSizePolicy( TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ) );
connect( urlLabel, TQT_SIGNAL( leftClickedURL( const TQString& )), kapp, TQT_SLOT( invokeBrowser( const TQString& )) );
TQLayout *l = layout();
l->addItem( new TQSpacerItem( 0, 10, TQSizePolicy::Minimum, TQSizePolicy::Expanding ) );
l->add( errorLabel );
l->add( urlLabel );
l->addItem( new TQSpacerItem( 0, 10, TQSizePolicy::Minimum, TQSizePolicy::Expanding ) );
errorLabel->show();
}
else
load();
}
void KCMKMrml::defaults()
{
if (KMessageBox::warningContinueCancel(this,
i18n("Do you really want the configuration to be reset "
"to the defaults?"), i18n("Reset Configuration"), KStdGuiItem::cont())
!= KMessageBox::Continue)
return;
m_mainPage->resetDefaults();
emit changed( true );
}
void KCMKMrml::load()
{
m_mainPage->load();
emit changed( true );
}
void KCMKMrml::save()
{
m_mainPage->save();
emit changed( false );
}
TQString KCMKMrml::quickHelp() const
{
return i18n("<h1>Image Index</h1>"
"TDE can make use of the GNU Image Finding Tool (GIFT) to "
"perform queries based not just on filenames, but on "
"file content."
"<p>For example, you can search for an image by giving an example "
"image that looks similar to the one you are looking for.</p>"
"<p>For this to work, your image directories need to be "
"indexed by, for example, the GIFT server.</p>"
"<p>Here you can configure the servers (you can also query "
"remote servers) and the directories to index.</p>"
);
}
#include "kcmkmrml.moc"

@ -1,15 +0,0 @@
[Desktop Entry]
Exec=tdecmshell kcmkmrml
Icon=folder_image
Type=Application
X-TDE-ModuleType=Library
X-TDE-Library=kmrml
Name=Image Index
Comment=Configuration for using the GNU Image Finding Tool
Keywords=Images;Search;Query;Find;Gift;kmrml;mrml;CBIR;
Categories=Qt;TDE;Settings;X-TDE-settings-system;

@ -1,53 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KCMKMRML_H
#define KCMKMRML_H
#include <tdecmodule.h>
class TDEAboutData;
class KURLRequester;
namespace KMrmlConfig
{
class MainPage;
class KCMKMrml : public TDECModule
{
Q_OBJECT
public:
KCMKMrml(TQWidget *parent, const char *name, const TQStringList &);
virtual ~KCMKMrml();
virtual void defaults();
virtual void load();
virtual void save();
virtual TQString quickHelp() const;
private:
void checkGiftInstallation();
MainPage *m_mainPage;
};
}
#endif

@ -1,501 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <tqcheckbox.h>
#include <tqlabel.h>
#include <tqsizepolicy.h>
#include <tqtooltip.h>
#include <tqwidget.h>
#include <tqvgroupbox.h>
#include <kcombobox.h>
#include <kdialog.h>
#include <keditlistbox.h>
#include <tdeglobalsettings.h>
#include <klineedit.h>
#include <tdelocale.h>
#include <tdemessagebox.h>
#include <knuminput.h>
#include <kprogress.h>
#include <kurlrequester.h>
#include <tdeversion.h>
#include <kdebug.h>
#include <tdeio/slaveconfig.h>
#include <tdeio/ioslave_defaults.h> // MAX_PORT_VALUE
#include "serverconfigwidget.h"
#include "mainpage.h"
#include "indexer.h"
#include "indexcleaner.h"
#include <limits.h>
#include <string.h>
using namespace KMrmlConfig;
MainPage::MainPage( TQWidget *parent, const char *name )
: TQVBox( parent, name ),
m_indexer( 0L ),
m_indexCleaner( 0L ),
m_progressDialog( 0L ),
m_performIndexing( false ),
m_locked( false )
{
m_config = new KMrml::Config();
setSpacing( KDialog::spacingHint() );
TQVGroupBox *gBox = new TQVGroupBox( i18n("Indexing Server Configuration"),
this );
m_serverWidget = new ServerConfigWidget( gBox, "server config widget" );
TQString tip = i18n("Hostname of the Indexing Server");
TQToolTip::add( m_serverWidget->m_hostLabel, tip );
TQToolTip::add( m_serverWidget->m_hostCombo, tip );
m_serverWidget->m_portInput->setRange( 0, MAX_PORT_VALUE );
#if TDE_VERSION >= 306
KURLRequester *requester = new KURLRequester( this, "dir requester" );
requester->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );
requester->setURL( TDEGlobalSettings::documentPath() );
connect( requester, TQT_SIGNAL( openFileDialog( KURLRequester * )),
TQT_SLOT( slotRequesterClicked( KURLRequester * )));
m_listBox = new KEditListBox( i18n("Folders to Be Indexed" ),
requester->customEditor(), this, "listbox",
false,
KEditListBox::Add | KEditListBox::Remove );
#else
m_listBox = new KEditListBox( i18n("Folders to Be Indexed" ),
this, "listbox", false,
KEditListBox::Add | KEditListBox::Remove );
#endif
connect( m_listBox, TQT_SIGNAL( changed() ), TQT_SLOT( slotDirectoriesChanged() ));
connect( m_serverWidget->m_hostCombo, TQT_SIGNAL( textChanged(const TQString&)),
TQT_SLOT( slotHostChanged() ));
connect( m_serverWidget->m_portInput, TQT_SIGNAL( valueChanged( int )),
TQT_SLOT( slotPortChanged( int ) ));
connect ( m_serverWidget->m_useAuth, TQT_SIGNAL( toggled(bool) ),
TQT_SLOT( slotUseAuthChanged( bool ) ));
connect( m_serverWidget->m_userEdit, TQT_SIGNAL( textChanged( const TQString&)),
TQT_SLOT( slotUserChanged( const TQString& ) ));
connect( m_serverWidget->m_passEdit, TQT_SIGNAL( textChanged( const TQString&)),
TQT_SLOT( slotPassChanged( const TQString& ) ));
connect( m_serverWidget->m_addButton, TQT_SIGNAL( clicked() ),
TQT_SLOT( slotAddClicked() ));
connect( m_serverWidget->m_removeButton, TQT_SIGNAL( clicked() ),
TQT_SLOT( slotRemoveClicked() ));
connect( m_serverWidget->m_hostCombo, TQT_SIGNAL( activated( const TQString& )),
TQT_SLOT( slotHostActivated( const TQString& )));
connect( m_serverWidget->m_hostCombo, TQT_SIGNAL( returnPressed() ),
TQT_SLOT( slotAddClicked() ));
connect( m_serverWidget->m_autoPort, TQT_SIGNAL( toggled( bool ) ),
TQT_SLOT( slotAutoPortChanged( bool ) ));
m_serverWidget->m_hostCombo->setTrapReturnKey( true );
m_serverWidget->m_hostCombo->setFocus();
}
MainPage::~MainPage()
{
delete m_config;
}
void MainPage::resetDefaults()
{
blockSignals( true );
initFromSettings( KMrml::ServerSettings::defaults() );
m_serverWidget->m_hostCombo->clear();
m_serverWidget->m_hostCombo->insertItem( m_settings.host );
m_listBox->clear();
// slotHostChanged(); not necessary, will be called by TQt signals
slotUseAuthChanged( m_serverWidget->m_useAuth->isChecked() );
blockSignals( false );
}
void MainPage::load()
{
blockSignals( true );
initFromSettings( m_config->defaultSettings() );
m_serverWidget->m_hostCombo->clear();
m_serverWidget->m_hostCombo->insertStringList( m_config->hosts() );
m_serverWidget->m_hostCombo->setCurrentItem( m_settings.host );
m_listBox->clear();
m_listBox->insertStringList( m_config->indexableDirectories() );
// slotHostChanged(); not necessary, will be called by TQt signals
slotUseAuthChanged( m_serverWidget->m_useAuth->isChecked() );
blockSignals( false );
}
void MainPage::save()
{
m_config->addSettings( m_settings );
m_config->setDefaultHost( m_settings.host );
TQStringList indexDirs = m_listBox->items();
TQStringList oldIndexDirs = m_config->indexableDirectories();
TQStringList removedDirs = difference( oldIndexDirs, indexDirs );
m_config->setIndexableDirectories( indexDirs );
if ( indexDirs.isEmpty() )
KMessageBox::information( this,
i18n("You did not specify any folders to "
"be indexed. This means you will be "
"unable to perform queries on your "
"computer."),
"kcmkmrml_no_directories_specified" );
if ( m_config->sync() )
TDEIO::SlaveConfig::self()->reset();
processIndexDirs( removedDirs );
}
TQStringList MainPage::difference( const TQStringList& oldIndexDirs,
const TQStringList& newIndexDirs ) const
{
TQStringList result;
TQString slash = TQString::fromLatin1("/");
TQStringList::ConstIterator oldIt = oldIndexDirs.begin();
TQString oldDir, newDir;
for ( ; oldIt != oldIndexDirs.end(); oldIt++ )
{
bool removed = true;
oldDir = *oldIt;
while ( oldDir.endsWith( slash ) ) // remove slashes
oldDir.remove( oldDir.length() - 1, 1 );
TQStringList::ConstIterator newIt = newIndexDirs.begin();
for ( ; newIt != newIndexDirs.end(); newIt++ )
{
newDir = *newIt;
while ( newDir.endsWith( slash ) ) // remove slashes
newDir.remove( newDir.length() - 1, 1 );
if ( oldDir == newDir )
{
removed = false;
break;
}
}
if ( removed )
result.append( *oldIt ); // not oldDir -- maybe gift needs slashes
}
return result;
}
void MainPage::initFromSettings( const KMrml::ServerSettings& settings )
{
m_settings = settings;
m_locked = true;
m_serverWidget->m_portInput->setValue( settings.configuredPort );
m_serverWidget->m_autoPort->setChecked( settings.autoPort );
m_serverWidget->m_useAuth->setChecked( settings.useAuth );
m_serverWidget->m_userEdit->setText( settings.user );
m_serverWidget->m_passEdit->setText( settings.pass );
m_locked = false;
}
void MainPage::slotHostActivated( const TQString& host )
{
// implicitly save the current settings when another host was chosen
m_config->addSettings( m_settings );
initFromSettings( m_config->settingsForHost( host ) );
}
void MainPage::slotHostChanged()
{
TQString host = m_serverWidget->m_hostCombo->currentText();
m_listBox->setEnabled( (host == "localhost") );
KMrml::ServerSettings settings = m_config->settingsForHost( host );
enableWidgetsFor( settings );
}
void MainPage::slotUseAuthChanged( bool enable )
{
m_settings.useAuth = enable;
m_serverWidget->m_userEdit->setEnabled( enable );
m_serverWidget->m_passEdit->setEnabled( enable );
if ( enable )
m_serverWidget->m_userEdit->setFocus();
if ( !m_locked )
changed();
}
void MainPage::slotUserChanged( const TQString& user )
{
if ( m_locked )
return;
m_settings.user = user;
changed();
}
void MainPage::slotPassChanged( const TQString& pass )
{
if ( m_locked )
return;
m_settings.pass = pass;
changed();
}
void MainPage::slotPortChanged( int port )
{
if ( m_locked )
return;
m_settings.configuredPort = (unsigned short int) port;
changed();
}
void MainPage::slotAutoPortChanged( bool on )
{
if ( m_locked )
return;
m_settings.autoPort = on;
m_serverWidget->m_portInput->setEnabled( !on );
changed();
}
void MainPage::slotRequesterClicked( KURLRequester *requester )
{
static bool init = true;
if ( !init )
return;
init = false;
requester->setCaption(i18n("Select Folder You Want to Index"));
}
void MainPage::slotAddClicked()
{
TQString host = m_serverWidget->m_hostCombo->currentText();
m_settings.host = host;
m_config->addSettings( m_settings );
m_serverWidget->m_hostCombo->insertItem( host );
m_serverWidget->m_hostCombo->setCurrentItem( host );
enableWidgetsFor( m_settings );
}
void MainPage::slotRemoveClicked()
{
TQString host = m_serverWidget->m_hostCombo->currentText();
if ( host.isEmpty() ) // should never happen
return;
m_config->removeSettings( host );
m_serverWidget->m_hostCombo->removeItem( m_serverWidget->m_hostCombo->currentItem() );
m_serverWidget->m_hostCombo->setCurrentItem( 0 );
host = m_serverWidget->m_hostCombo->currentText();
initFromSettings( m_config->settingsForHost( host ) );
}
void MainPage::enableWidgetsFor( const KMrml::ServerSettings& settings )
{
TQString host = settings.host;
bool enableWidgets = (m_config->hosts().findIndex( host ) > -1);
m_serverWidget->m_addButton->setEnabled(!enableWidgets && !host.isEmpty());
m_serverWidget->m_removeButton->setEnabled( enableWidgets &&
!host.isEmpty() &&
host != "localhost" );
m_serverWidget->m_autoPort->setEnabled( host == "localhost" );
bool portEnable = enableWidgets && (settings.autoPort ||
!m_serverWidget->m_autoPort->isEnabled());
m_serverWidget->m_portLabel->setEnabled( portEnable && !m_serverWidget->m_autoPort->isChecked());
m_serverWidget->m_portInput->setEnabled( portEnable && !m_serverWidget->m_autoPort->isChecked());
m_serverWidget->m_useAuth->setEnabled( enableWidgets );
m_serverWidget->m_userLabel->setEnabled( enableWidgets );
m_serverWidget->m_passLabel->setEnabled( enableWidgets );
m_serverWidget->m_userEdit->setEnabled( enableWidgets );
m_serverWidget->m_passEdit->setEnabled( enableWidgets );
bool useAuth = m_serverWidget->m_useAuth->isChecked();
m_serverWidget->m_userEdit->setEnabled( useAuth );
m_serverWidget->m_passEdit->setEnabled( useAuth );
}
void MainPage::slotDirectoriesChanged()
{
m_performIndexing = true;
changed();
}
void MainPage::processIndexDirs( const TQStringList& removeDirs )
{
// ### how to remove indexed directories?
if ( !m_performIndexing ||
(removeDirs.isEmpty() && m_config->indexableDirectories().isEmpty()) )
return;
delete m_progressDialog;
delete m_indexCleaner;
m_indexCleaner = 0L;
delete m_indexer;
m_indexer = 0L;
m_progressDialog = new KProgressDialog( this, "indexing dialog",
i18n("Removing old Index Files"),
i18n("Processing..."),
true );
m_progressDialog->setAutoClose( false );
m_progressDialog->setMinimumWidth( 300 );
connect( m_progressDialog, TQT_SIGNAL( cancelClicked() ),
TQT_SLOT( slotCancelIndexing() ));
// argh -- don't automatically show the dialog
m_progressDialog->setMinimumDuration( INT_MAX );
if ( !removeDirs.isEmpty() )
{
m_indexCleaner = new IndexCleaner( removeDirs, m_config, TQT_TQOBJECT(this) );
connect( m_indexCleaner, TQT_SIGNAL( advance( int ) ),
m_progressDialog->progressBar(), TQT_SLOT( advance( int ) ));
connect( m_indexCleaner, TQT_SIGNAL( finished() ),
TQT_SLOT( slotMaybeIndex() ) );
m_indexCleaner->start();
}
else
{
slotMaybeIndex();
}
if ( m_progressDialog )
m_progressDialog->exec();
}
void MainPage::slotMaybeIndex()
{
delete m_indexCleaner; // Stop in the name of the law!
m_indexCleaner = 0L;
m_progressDialog->setLabel( i18n("Finished.") );
if ( m_config->indexableDirectories().isEmpty() )
return;
if ( KMessageBox::questionYesNo( this,
i18n("The settings have been saved. Now, "
"the configured directories need to "
"be indexed. This may take a while. "
"Do you want to do this now?"),
i18n("Start Indexing Now?"),
i18n("Index"), i18n("Do Not Index"),
"ask_startIndexing"
) != KMessageBox::Yes )
return;
m_progressDialog->setCaption( i18n("Indexing Folders") );
m_progressDialog->setLabel( i18n("Processing...") );
m_progressDialog->progressBar()->setProgress( 0 );
// do the indexing
m_indexer = new Indexer( m_config, TQT_TQOBJECT(this), "Indexer" );
connect( m_indexer, TQT_SIGNAL( progress( int, const TQString& )),
TQT_SLOT( slotIndexingProgress( int, const TQString& ) ));
connect( m_indexer, TQT_SIGNAL( finished( int )),
TQT_SLOT( slotIndexingFinished( int ) ));
m_indexer->startIndexing( m_config->indexableDirectories() );
}
void MainPage::slotIndexingProgress( int percent, const TQString& message )
{
m_progressDialog->progressBar()->setValue( percent );
m_progressDialog->setLabel( message );
}
void MainPage::slotIndexingFinished( int returnCode )
{
if ( returnCode != 0 )
{
TQString syserr;
if ( returnCode == 127 )
syserr = i18n("Is the \"GNU Image Finding Tool\" properly installed?");
else
{
char *err = strerror( returnCode );
if ( err )
syserr = TQString::fromLocal8Bit( err );
else
syserr = i18n("Unknown error: %1").arg( returnCode );
}
KMessageBox::detailedError( this, i18n("An error occurred during indexing. The index might be invalid."),
syserr, i18n("Indexing Aborted") );
}
else
m_performIndexing = false;
delete m_indexer;
m_indexer = 0L;
if ( m_progressDialog )
{
m_progressDialog->deleteLater();
m_progressDialog = 0L;
}
}
void MainPage::slotCancelIndexing()
{
delete m_indexCleaner;
m_indexCleaner = 0L;
delete m_indexer;
m_indexer = 0L;
if ( m_progressDialog )
{
m_progressDialog->deleteLater();
m_progressDialog = 0L;
}
}
#include "mainpage.moc"

@ -1,110 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MAINPAGE_H
#define MAINPAGE_H
#include <tqvbox.h>
#include <kmrml_config.h>
class TQCheckBox;
class KComboBox;
class KEditListBox;
class KIntNumInput;
class KLineEdit;
class KProgressDialog;
class KURLRequester;
namespace KMrml
{
class Config;
}
class ServerConfigWidget;
namespace KMrmlConfig
{
class Indexer;
class IndexCleaner;
class MainPage : public TQVBox
{
Q_OBJECT
public:
MainPage( TQWidget *parent, const char *name );
~MainPage();
void resetDefaults();
void load();
void save();
signals:
void changed( bool );
private slots:
void changed() { emit changed( true ); }
void slotRequesterClicked( KURLRequester * );
void slotHostChanged();
void slotUseAuthChanged( bool );
void slotUserChanged( const TQString& );
void slotPassChanged( const TQString& );
void slotPortChanged( int );
void slotAutoPortChanged( bool );
void slotAddClicked();
void slotRemoveClicked();
void slotHostActivated( const TQString& );
void slotDirectoriesChanged();
void slotMaybeIndex();
void slotIndexingProgress( int percent, const TQString& message );
void slotIndexingFinished( int returnCode );
void slotCancelIndexing();
private:
void enableWidgetsFor( const KMrml::ServerSettings& settings );
void initFromSettings( const KMrml::ServerSettings& settings );
void processIndexDirs( const TQStringList& removedDirs );
TQStringList difference( const TQStringList& oldIndexDirs,
const TQStringList& newIndexDirs ) const;
ServerConfigWidget *m_serverWidget;
KEditListBox *m_listBox;
KMrml::Config *m_config;
KMrmlConfig::Indexer *m_indexer;
KMrmlConfig::IndexCleaner *m_indexCleaner;
KProgressDialog *m_progressDialog;
KMrml::ServerSettings m_settings;
bool m_performIndexing;
bool m_locked;
};
}
#endif // MAINPAGE_H

@ -1,277 +0,0 @@
<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
<class>ServerConfigWidget</class>
<widget class="TQWidget">
<property name="name">
<cstring>ServerConfigWidget</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>455</width>
<height>321</height>
</rect>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="TQLayoutWidget">
<property name="name">
<cstring>Layout7</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="TQLayoutWidget" row="0" column="1">
<property name="name">
<cstring>Layout4</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="KComboBox">
<property name="name">
<cstring>m_hostCombo</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
<widget class="TQPushButton">
<property name="name">
<cstring>m_addButton</cstring>
</property>
<property name="text">
<string>&amp;Add</string>
</property>
</widget>
<widget class="TQPushButton">
<property name="name">
<cstring>m_removeButton</cstring>
</property>
<property name="text">
<string>&amp;Remove</string>
</property>
</widget>
</hbox>
</widget>
<widget class="TQLayoutWidget" row="1" column="1">
<property name="name">
<cstring>Layout6</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="KIntSpinBox">
<property name="name">
<cstring>m_portInput</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" stdset="0">
<string>TCP/IP Port Number of the Indexing Server</string>
</property>
</widget>
<widget class="TQCheckBox">
<property name="name">
<cstring>m_autoPort</cstring>
</property>
<property name="text">
<string>Au&amp;to</string>
</property>
<property name="toolTip" stdset="0">
<string>Tries to automatically determine the port. This works only for local servers.</string>
</property>
</widget>
<spacer>
<property name="name">
<cstring>Spacer3</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</spacer>
</hbox>
</widget>
<widget class="TQLabel" row="0" column="0">
<property name="name">
<cstring>m_hostLabel</cstring>
</property>
<property name="text">
<string>Ho&amp;stname:</string>
</property>
<property name="buddy" stdset="0">
<cstring>m_hostCombo</cstring>
</property>
</widget>
<widget class="TQLabel" row="1" column="0">
<property name="name">
<cstring>m_portLabel</cstring>
</property>
<property name="text">
<string>P&amp;ort:</string>
</property>
<property name="buddy" stdset="0">
<cstring>m_portInput</cstring>
</property>
</widget>
</grid>
</widget>
<widget class="TQCheckBox">
<property name="name">
<cstring>m_useAuth</cstring>
</property>
<property name="text">
<string>Per&amp;form authentication</string>
</property>
</widget>
<widget class="TQLayoutWidget">
<property name="name">
<cstring>Layout12</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<spacer>
<property name="name">
<cstring>Spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</spacer>
<widget class="TQLayoutWidget">
<property name="name">
<cstring>Layout6</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="TQLabel" row="0" column="0">
<property name="name">
<cstring>m_userLabel</cstring>
</property>
<property name="text">
<string>&amp;Username:</string>
</property>
<property name="buddy" stdset="0">
<cstring>m_userEdit</cstring>
</property>
</widget>
<widget class="KLineEdit" row="1" column="1">
<property name="name">
<cstring>m_passEdit</cstring>
</property>
</widget>
<widget class="TQLabel" row="1" column="0">
<property name="name">
<cstring>m_passLabel</cstring>
</property>
<property name="text">
<string>&amp;Password:</string>
</property>
<property name="buddy" stdset="0">
<cstring>m_passEdit</cstring>
</property>
</widget>
<widget class="KLineEdit" row="0" column="1">
<property name="name">
<cstring>m_userEdit</cstring>
</property>
</widget>
</grid>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<tabstops>
<tabstop>m_hostCombo</tabstop>
<tabstop>m_addButton</tabstop>
<tabstop>m_removeButton</tabstop>
<tabstop>m_portInput</tabstop>
<tabstop>m_useAuth</tabstop>
<tabstop>m_userEdit</tabstop>
<tabstop>m_passEdit</tabstop>
</tabstops>
<layoutdefaults spacing="6" margin="11"/>
<includes>
<include location="global" impldecl="in implementation">kcombobox.h</include>
<include location="global" impldecl="in implementation">klineedit.h</include>
<include location="global" impldecl="in implementation">knuminput.h</include>
</includes>
</UI>

@ -1,26 +0,0 @@
#################################################
#
# (C) 2010-2011 Calvin Morrison
# mutantturkey@gmail.com
#
# Improvements and feedback are welcome
#
# This file is released under GPL >= 2
#
#################################################
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR}
${TDE_INCLUDE_DIR}
${TQT_INCLUDE_DIRS}
)
#### kcmkgamma (static) #########################
tde_add_library( kmrmlstuff STATIC_PIC AUTOMOC
SOURCES
kmrml_config.cpp mrml_shared.cpp
mrml_utils.cpp watcher_stub.cpp
)

@ -1,11 +0,0 @@
noinst_LTLIBRARIES = libkmrmlstuff.la
libkmrmlstuff_la_SOURCES = kmrml_config.cpp mrml_shared.cpp mrml_utils.cpp\
watcher_stub.cpp
noinst_HEADERS = kmrml_config.h mrml_shared.h mrml_utils.h watcher_stub.h
METASOURCES = AUTO
libkmrmlstuff_la_LDFLAGS = $(all_libraries) -no-undefined
libkmrmlstuff_la_LIBADD = $(LIB_TDECORE)
INCLUDES = -I$(top_srcdir) $(all_includes)

@ -1,339 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <tqdir.h>
#include <tqfile.h>
#include <tqtextcodec.h>
#include <tdeconfig.h>
#include <kdebug.h>
#include <tdeglobal.h>
#include <kprocess.h>
#include <kstandarddirs.h>
#include "kmrml_config.h"
#include <tdeversion.h>
#if TDE_VERSION < 307
#define QUOTE( x ) x
#else
#define QUOTE( x ) TDEProcess::quote( x )
#endif
using namespace KMrml;
// #define DEFAULT_ADDCOLLECTION_CMD "gift-add-collection.pl --thumbnail-dir=%t --local-encoding %d"
#define DEFAULT_ADDCOLLECTION_CMD "gift-add-collection.pl --gift-home=%h --thumbnail-dir=%t --local-encoding=%e %d"
#define DEFAULT_REMOVECOLLECTION_CMD "gift-add-collection.pl --gift-home=%h --local-encoding=%e --remove-collection %d"
#define DEFAULT_MRMLD_CMD "gift --port %p --datadir %d"
#define DEFAULT_MRMLD_CMD_AUTOPORT "gift --datadir %d"
#define CONFIG_GROUP "MRML Settings"
#define DEFAULT_HOST "localhost"
#define DEFAULT_USER "kmrml"
#define DEFAULT_PASS "none"
#define DEFAULT_AUTH false
#define DEFAULT_AUTOPORT true
const int DEFAULT_PORT = 12789;
Config::Config()
{
m_ownConfig = new TDEConfig( "tdeio_mrmlrc", false, false );
m_config = m_ownConfig;
init();
}
Config::Config( TDEConfig *config )
: m_config( config ),
m_ownConfig( 0L )
{
init();
}
Config::~Config()
{
delete m_ownConfig;
}
void Config::init()
{
m_config->setGroup( CONFIG_GROUP );
m_defaultHost = m_config->readEntry( "Default Host" );
if ( m_defaultHost.isEmpty() )
m_defaultHost = DEFAULT_HOST;
m_hostList = m_config->readListEntry( "Host List" );
if ( m_hostList.isEmpty() )
m_hostList.append( DEFAULT_HOST );
m_serverStartedIndividually =
m_config->readBoolEntry( "ServerStartedIndividually", false );
}
bool Config::sync()
{
bool notifySlaves = m_config->isDirty();
m_config->sync();
return notifySlaves;
// This moved to kcontrol/MainPage::save() so we don't have to link against
// TDEIO and need a full TDEApplication instance to work (so that the tiny
// mrmlsearch binary can also use this class)
// tell the ioslaves about the new configuration
// if ( notifySlaves )
// TDEIO::SlaveConfig::self()->reset();
}
void Config::setDefaultHost( const TQString& host )
{
m_defaultHost = host.isEmpty() ?
TQString::fromLatin1(DEFAULT_HOST) : host;
m_config->setGroup( CONFIG_GROUP );
m_config->writeEntry( "Default Host", m_defaultHost );
}
ServerSettings Config::settingsForLocalHost() const
{
return settingsForHost( "localhost" );
}
ServerSettings Config::settingsForHost( const TQString& host ) const
{
TDEConfigGroup config( m_config, settingsGroup( host ) );
ServerSettings settings;
settings.host = host;
settings.configuredPort = config.readUnsignedNumEntry( "Port",
DEFAULT_PORT );
settings.autoPort = (host == "localhost") &&
config.readBoolEntry("Automatically determine Port",
DEFAULT_AUTOPORT );
settings.user = config.readEntry( "Username", DEFAULT_USER );
settings.pass = config.readEntry( "Password", DEFAULT_PASS );
settings.useAuth = config.readBoolEntry( "Perform Authentication",
DEFAULT_AUTH );
return settings;
}
void Config::addSettings( const ServerSettings& settings )
{
TQString host = settings.host;
if ( m_hostList.find( host ) == m_hostList.end() )
m_hostList.append( host );
m_config->setGroup( CONFIG_GROUP );
m_config->writeEntry( "Host List", m_hostList );
m_config->setGroup( settingsGroup( host ) );
m_config->writeEntry( "Host", host );
m_config->writeEntry( "Port", settings.configuredPort );
m_config->writeEntry( "Automatically determine Port", settings.autoPort );
m_config->writeEntry( "Username", settings.user );
m_config->writeEntry( "Password", settings.pass );
m_config->writeEntry( "Perform Authentication", settings.useAuth );
}
bool Config::removeSettings( const TQString& host )
{
bool success = m_config->deleteGroup( settingsGroup( host ) );
if ( success )
{
m_hostList.remove( host );
m_config->setGroup( CONFIG_GROUP );
}
return success;
}
TQStringList Config::indexableDirectories() const
{
m_config->setGroup( CONFIG_GROUP );
return m_config->readListEntry( "Indexable Directories" );
}
void Config::setIndexableDirectories( const TQStringList& dirs )
{
m_config->setGroup( CONFIG_GROUP );
m_config->writeEntry( "Indexable Directories", dirs );
}
TQString Config::addCollectionCommandLine() const
{
m_config->setGroup( CONFIG_GROUP );
TQString cmd = m_config->readEntry( "AddCollection Commandline",
DEFAULT_ADDCOLLECTION_CMD );
int index = cmd.find( "%h" );
if ( index != -1 )
cmd.replace( index, 2, QUOTE( mrmldDataDir() ) );
index = cmd.find( "%e" );
if ( index != -1 )
cmd.replace( index, 2, TQTextCodec::codecForLocale()->mimeName() );
return cmd;
}
void Config::setAddCollectionCommandLine( const TQString& cmd )
{
m_config->setGroup( CONFIG_GROUP );
m_config->writeEntry( "AddCollection Commandline", cmd );
}
TQString Config::removeCollectionCommandLine() const
{
m_config->setGroup( CONFIG_GROUP );
TQString cmd = m_config->readEntry( "RemoveCollection Commandline",
DEFAULT_REMOVECOLLECTION_CMD );
int index = cmd.find( "%h" );
if ( index != -1 )
cmd.replace( index, 2, QUOTE( mrmldDataDir() ) );
index = cmd.find( "%e" );
if ( index != -1 )
cmd.replace( index, 2, TQTextCodec::codecForLocale()->mimeName() );
return cmd;
}
void Config::setRemoveCollectionCommandLine( const TQString& cmd )
{
m_config->setGroup( CONFIG_GROUP );
m_config->writeEntry( "RemoveCollection Commandline", cmd );
}
TQString Config::mrmldCommandline() const
{
ServerSettings settings = settingsForLocalHost();
m_config->setGroup( CONFIG_GROUP );
TQString cmd = m_config->readEntry( "MrmmlDaemon Commandline",
settings.autoPort ?
DEFAULT_MRMLD_CMD_AUTOPORT :
DEFAULT_MRMLD_CMD );
// add data directory and port to the commandline
int index = cmd.find( "%p" );
if ( index != -1 )
{
TQString port = settings.autoPort ?
TQString() : TQString::number( settings.configuredPort );
cmd.replace( index, 2, port );
}
index = cmd.find( "%d" );
if ( index != -1 )
{
cmd.replace( index, 2, QUOTE( mrmldDataDir() ) );
}
tqDebug("***** commandline: %s", cmd.latin1());
return cmd;
}
TQString Config::mrmldDataDir()
{
TQString dir = TDEGlobal::dirs()->saveLocation( "data",
"kmrml/mrmld-data/" );
if ( dir.isEmpty() ) // fallback
dir = TQDir::homeDirPath() + "/";
return dir;
}
void Config::setMrmldCommandLine( const TQString& cmd )
{
m_config->setGroup( CONFIG_GROUP );
m_config->writeEntry( "MrmmlDaemon Commandline", cmd );
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
ServerSettings::ServerSettings()
: configuredPort( 0 ),
autoPort( true ),
useAuth( false )
{
}
ServerSettings::ServerSettings( const TQString& host, unsigned short int port,
bool autoPort, bool useAuth,
const TQString& user, const TQString& pass )
{
this->host = host;
this->configuredPort = port;
this->autoPort = autoPort;
this->useAuth = useAuth;
this->user = user;
this->pass = pass;
}
// static
ServerSettings ServerSettings::defaults()
{
return ServerSettings( DEFAULT_HOST, DEFAULT_PORT,
(!strcmp(DEFAULT_HOST, "localhost") && DEFAULT_PORT),
DEFAULT_AUTH, DEFAULT_USER, DEFAULT_PASS );
}
KURL ServerSettings::getUrl() const
{
KURL url;
url.setProtocol( "mrml" );
url.setHost( host );
if ( !autoPort )
url.setPort( configuredPort );
if ( useAuth && user.isEmpty() )
{
url.setUser( user );
url.setPass( pass );
}
return url;
}
unsigned short int ServerSettings::port() const
{
if ( autoPort )
{
TQString portsFile = Config::mrmldDataDir() + "gift-port.txt";
TQFile file( portsFile );
if ( file.open( IO_ReadOnly ) )
{
TQString line;
(void) file.readLine( line, 6 );
// tqDebug("**** read: %s", line.latin1());
file.close();
bool ok;
unsigned short int p = line.toUShort( &ok );
if ( ok )
return p;
}
else
kdWarning() << "Can't open \"" << portsFile << "\" to automatically determine the gift port" << endl;
}
return configuredPort;
}

@ -1,123 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KMRML_CONFIG_H
#define KMRML_CONFIG_H
class TDEConfig;
#include <tqstringlist.h>
#include <kurl.h>
namespace KMrml
{
class ServerSettings
{
public:
ServerSettings();
ServerSettings(const TQString& host, unsigned short int port,
bool autoPort, bool useAuth, const
TQString& user, const TQString& pass);
// does NOT set the port in the KURL object, if autoPort is selected
// tdeio_mrml is going to determine itself (via ServerSettings::port()).
// This deuglifies the mrml:/ url a bit (no port is shown)
KURL getUrl() const;
TQString host;
TQString user;
TQString pass;
unsigned short int configuredPort;
bool autoPort :1; // only possible with host == localhost
bool useAuth :1;
static ServerSettings defaults();
// returns configuredPort or the automatically determined port,
// depending on the value of autoPort
unsigned short int port() const;
};
class Config
{
public:
Config();
Config( TDEConfig *config ); // does not take ownership of TDEConfig
~Config();
bool sync();
ServerSettings defaultSettings() const
{
return settingsForHost( m_defaultHost );
}
ServerSettings settingsForLocalHost() const;
ServerSettings settingsForHost( const TQString& host ) const;
void setDefaultHost( const TQString& host );
/**
* Indexed by the hostname -- ensures there are no dupes
*/
void addSettings( const ServerSettings& settings );
bool removeSettings( const TQString& host );
TQStringList hosts() const { return m_hostList; }
/**
* The list of indexable directories -- only applicable to "localhost"
*/
TQStringList indexableDirectories() const;
void setIndexableDirectories( const TQStringList& dirs );
TQString addCollectionCommandLine() const;
void setAddCollectionCommandLine( const TQString& cmd );
TQString removeCollectionCommandLine() const;
void setRemoveCollectionCommandLine( const TQString& cmd );
void setMrmldCommandLine( const TQString& cmd );
TQString mrmldCommandline() const;
// e.g. Wolfgang needs this :)
bool serverStartedIndividually() const {
return m_serverStartedIndividually;
}
static TQString mrmldDataDir();
private:
void init();
TQString settingsGroup( const TQString& host ) const
{
return TQString::fromLatin1( "SettingsFor: " ).append( host );
}
bool m_serverStartedIndividually;
TQString m_defaultHost;
TQStringList m_hostList;
TDEConfig *m_config;
TDEConfig *m_ownConfig;
};
}
#endif // KMRML_CONFIG_H

@ -1,235 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "mrml_shared.h"
// mrml stuff
const TQString * MrmlShared::m_sessionId = 0L;
const TQString * MrmlShared::m_transactionId = 0L;
const TQString * MrmlShared::m_algorithm = 0L;
const TQString * MrmlShared::m_algorithmId = 0L;
const TQString * MrmlShared::m_algorithmName = 0L;
const TQString * MrmlShared::m_algorithmList = 0L;
const TQString * MrmlShared::m_algorithmType = 0L;
const TQString * MrmlShared::m_collectionId = 0L;
const TQString * MrmlShared::m_collectionList = 0L;
const TQString * MrmlShared::m_collection = 0L;
const TQString * MrmlShared::m_collectionName = 0L;
const TQString * MrmlShared::m_queryParadigm = 0L;
const TQString * MrmlShared::m_queryParadigmList = 0L;
const TQString * MrmlShared::m_configureSession = 0L;
const TQString * MrmlShared::m_propertySheet = 0L;
const TQString * MrmlShared::m_propertySheetId = 0L;
const TQString * MrmlShared::m_propertySheetType = 0L;
const TQString * MrmlShared::m_sendName = 0L;
const TQString * MrmlShared::m_sendType = 0L;
const TQString * MrmlShared::m_sendValue = 0L;
const TQString * MrmlShared::m_maxSubsetSize = 0L;
const TQString * MrmlShared::m_minSubsetSize = 0L;
const TQString * MrmlShared::m_caption = 0L;
const TQString * MrmlShared::m_from = 0L;
const TQString * MrmlShared::m_to = 0L;
const TQString * MrmlShared::m_step = 0L;
const TQString * MrmlShared::m_sendBooleanInverted = 0L;
const TQString * MrmlShared::m_element = 0L;
const TQString * MrmlShared::m_attribute = 0L;
const TQString * MrmlShared::m_attributeName = 0L;
const TQString * MrmlShared::m_attributeValue = 0L;
const TQString * MrmlShared::m_children = 0L;
const TQString * MrmlShared::m_none = 0L;
const TQString * MrmlShared::m_multiSet = 0L;
const TQString * MrmlShared::m_subset = 0L;
const TQString * MrmlShared::m_setElement = 0L;
const TQString * MrmlShared::m_boolean = 0L;
const TQString * MrmlShared::m_numeric = 0L;
const TQString * MrmlShared::m_textual = 0L;
const TQString * MrmlShared::m_panel = 0L;
const TQString * MrmlShared::m_clone = 0L;
const TQString * MrmlShared::m_reference = 0L;
const TQString * MrmlShared::m_visibility = 0L;
const TQString * MrmlShared::m_visible = 0L;
const TQString * MrmlShared::m_invisible = 0L;
const TQString * MrmlShared::m_popup = 0L;
// const TQString * MrmlShared::m_ = 0L;
// meta-data
const TQString * MrmlShared::m_mrml_data = 0L;
// tdeio_mrml tasks
const TQString * MrmlShared::m_tdeio_task = 0L;
const TQString * MrmlShared::m_tdeio_initialize = 0L;
const TQString * MrmlShared::m_tdeio_startQuery = 0L;
int MrmlShared::s_references = 0;
void MrmlShared::ref()
{
if ( s_references == 0 )
init();
s_references++;
}
bool MrmlShared::deref()
{
if ( s_references > 0 )
s_references--;
if ( s_references == 0 )
{
// ### delete all strings here...
return true;
}
return false;
}
void MrmlShared::init()
{
m_sessionId = new TQString ( "session-id" ) ;
m_transactionId = new TQString ( "transaction-id" ) ;
m_algorithm = new TQString ( "algorithm" ) ;
m_algorithmId = new TQString ( "algorithm-id" ) ;
m_algorithmName = new TQString ( "algorithm-name" ) ;
m_algorithmList = new TQString ( "algorithm-list" ) ;
m_algorithmType = new TQString ( "algorithm-type" ) ;
m_collectionId = new TQString ( "collection-id" ) ;
m_collectionList = new TQString ( "collection-list" ) ;
m_collection = new TQString ( "collection" ) ;
m_collectionName = new TQString ( "collection-name" ) ;
m_queryParadigm = new TQString ( "query-paradigm" ) ;
m_queryParadigmList = new TQString ( "query-paradigm-list" ) ;
m_configureSession = new TQString ( "configure-session" ) ;
m_propertySheet = new TQString ( "property-sheet" ) ;
m_propertySheetId = new TQString ( "property-sheet-id" ) ;
m_propertySheetType = new TQString ( "property-sheet-type" ) ;
m_sendName = new TQString ( "send-name" ) ;
m_sendType = new TQString ( "send-type" ) ;
m_sendValue = new TQString ( "send-value" ) ;
m_maxSubsetSize = new TQString ( "maxsubsetsize" ) ;
m_minSubsetSize = new TQString ( "minsubsetsize" ) ;
m_caption = new TQString ( "caption" ) ;
m_from = new TQString ( "from" ) ;
m_to = new TQString ( "to" ) ;
m_step = new TQString ( "step" ) ;
m_sendBooleanInverted = new TQString ( "send-boolean-inverted" ) ;
m_element = new TQString ( "element" ) ;
m_attribute = new TQString ( "attribute" ) ;
m_attributeName = new TQString ( "attribute-name" ) ;
m_attributeValue = new TQString ( "attribute-value" ) ;
m_children = new TQString ( "children" ) ;
m_none = new TQString ( "none" ) ;
m_multiSet = new TQString ( "multi-set" ) ;
m_subset = new TQString ( "subset" ) ;
m_setElement = new TQString ( "set-element" ) ;
m_boolean = new TQString ( "boolean" ) ;
m_numeric = new TQString ( "numeric" ) ;
m_textual = new TQString ( "textual" ) ;
m_panel = new TQString ( "panel" ) ;
m_clone = new TQString ( "clone" ) ;
m_reference = new TQString ( "reference" ) ;
m_visibility = new TQString ( "visibility" ) ;
m_visible = new TQString ( "visible" ) ;
m_invisible = new TQString ( "invisible" ) ;
m_popup = new TQString ( "popup" ) ;
// m_ = new TQString ( "" ) ;
// meta-data
m_mrml_data = new TQString ( "mrml_data" ) ;
// tdeio_mrml tasks
m_tdeio_task = new TQString ( "tdeio_task" ) ;
m_tdeio_initialize = new TQString ( "tdeio_initialize" ) ;
m_tdeio_startQuery = new TQString ( "tdeio_startQuery" ) ;
}
void MrmlShared::cleanup()
{
delete m_sessionId;
delete m_transactionId;
delete m_algorithm;
delete m_algorithmId;
delete m_algorithmName;
delete m_algorithmList;
delete m_algorithmType;
delete m_collectionId;
delete m_collectionList;
delete m_collection;
delete m_collectionName;
delete m_queryParadigm;
delete m_queryParadigmList;
delete m_configureSession;
// property sheet stuff
delete m_propertySheet;
delete m_propertySheetId;
delete m_propertySheetType;
delete m_sendName;
delete m_sendType;
delete m_sendValue;
delete m_maxSubsetSize;
delete m_minSubsetSize;
delete m_caption;
delete m_from;
delete m_to;
delete m_step;
delete m_sendBooleanInverted;
delete m_multiSet;
delete m_subset;
delete m_setElement;
delete m_boolean;
delete m_numeric;
delete m_textual;
delete m_panel;
delete m_clone;
delete m_reference;
delete m_element;
delete m_attribute;
delete m_attributeName;
delete m_attributeValue;
delete m_children;
delete m_none;
delete m_visibility;
delete m_visible;
delete m_invisible;
delete m_popup;
// delete m_;
// meta-data
delete m_mrml_data;
// tdeio_mrml tasks
delete m_tdeio_task;
delete m_tdeio_initialize;
delete m_tdeio_startQuery;
}

@ -1,166 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2001,2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef SHARED_H
#define SHARED_H
// maybe use mrml_const.h from libMRML, unfortunately not installed
// by gift 0.1.6pre2
#include <tqshared.h>
#include <tqstring.h>
class MrmlShared
{
public:
// attribute/element names for mrml
static void ref();
static bool deref();
static const TQString& sessionId() { return *m_sessionId; }
static const TQString& transactionId() { return *m_transactionId; }
static const TQString& algorithm() { return *m_algorithm; }
static const TQString& algorithmId() { return *m_algorithmId; }
static const TQString& algorithmName() { return *m_algorithmName; }
static const TQString& algorithmList() { return *m_algorithmList; }
static const TQString& algorithmType() { return *m_algorithmType; }
static const TQString& collectionId() { return *m_collectionId; }
static const TQString& collectionList() { return *m_collectionList; }
static const TQString& collection() { return *m_collection; }
static const TQString& collectionName() { return *m_collectionName; }
static const TQString& queryParadigm() { return *m_queryParadigm; }
static const TQString& queryParadigmList() { return *m_queryParadigmList; }
static const TQString& configureSession() { return *m_configureSession; }
// property sheet stuff
static const TQString& propertySheet() { return *m_propertySheet; }
static const TQString& propertySheetId() { return *m_propertySheetId; }
static const TQString& propertySheetType() { return *m_propertySheetType; }
static const TQString& sendName() { return *m_sendName; }
static const TQString& sendType() { return *m_sendType; }
static const TQString& sendValue() { return *m_sendValue; }
static const TQString& maxSubsetSize() { return *m_maxSubsetSize; }
static const TQString& minSubsetSize() { return *m_minSubsetSize; }
static const TQString& caption() { return *m_caption; }
static const TQString& from() { return *m_from; }
static const TQString& to() { return *m_to; }
static const TQString& step() { return *m_step; }
static const TQString& sendBooleanInverted() { return *m_sendBooleanInverted; }
static const TQString& multiSet() { return *m_multiSet; }
static const TQString& subset() { return *m_subset; }
static const TQString& setElement() { return *m_setElement; }
static const TQString& boolean() { return *m_boolean; }
static const TQString& numeric() { return *m_numeric; }
static const TQString& textual() { return *m_textual; }
static const TQString& panel() { return *m_panel; }
static const TQString& clone() { return *m_clone; }
static const TQString& reference() { return *m_reference; }
static const TQString& element() { return *m_element; }
static const TQString& attribute() { return *m_attribute; }
static const TQString& attributeName() { return *m_attributeName; }
static const TQString& attributeValue() { return *m_attributeValue; }
static const TQString& children() { return *m_children; }
static const TQString& none() { return *m_none; }
static const TQString& visibility() { return *m_visibility; }
static const TQString& visible() { return *m_visible; }
static const TQString& invisible() { return *m_invisible; }
static const TQString& popup() { return *m_popup; }
// static const TQString& () { return *m_; }
// meta-data
static const TQString& mrml_data() { return *m_mrml_data; }
// tdeio_mrml tasks
static const TQString& tdeio_task() { return *m_tdeio_task; }
static const TQString& tdeio_initialize() { return *m_tdeio_initialize; }
static const TQString& tdeio_startQuery() { return *m_tdeio_startQuery; }
private:
static const TQString * m_sessionId;
static const TQString * m_transactionId;
static const TQString * m_algorithm;
static const TQString * m_algorithmId;
static const TQString * m_algorithmName;
static const TQString * m_algorithmList;
static const TQString * m_algorithmType;
static const TQString * m_collectionId;
static const TQString * m_collectionList;
static const TQString * m_collection;
static const TQString * m_collectionName;
static const TQString * m_queryParadigm;
static const TQString * m_queryParadigmList;
static const TQString * m_configureSession;
// property sheet stuff
static const TQString * m_propertySheet;
static const TQString * m_propertySheetId;
static const TQString * m_propertySheetType;
static const TQString * m_sendName;
static const TQString * m_sendType;
static const TQString * m_sendValue;
static const TQString * m_maxSubsetSize;
static const TQString * m_minSubsetSize;
static const TQString * m_caption;
static const TQString * m_from;
static const TQString * m_to;
static const TQString * m_step;
static const TQString * m_sendBooleanInverted;
static const TQString * m_multiSet;
static const TQString * m_subset;
static const TQString * m_setElement;
static const TQString * m_boolean;
static const TQString * m_numeric;
static const TQString * m_textual;
static const TQString * m_panel;
static const TQString * m_clone;
static const TQString * m_reference;
static const TQString * m_element;
static const TQString * m_attribute;
static const TQString * m_attributeName;
static const TQString * m_attributeValue;
static const TQString * m_children;
static const TQString * m_none;
static const TQString * m_visibility;
static const TQString * m_visible;
static const TQString * m_invisible;
static const TQString * m_popup;
// static const TQString * m_;
// meta-data
static const TQString * m_mrml_data;
// tdeio_mrml tasks
static const TQString * m_tdeio_task;
static const TQString * m_tdeio_initialize;
static const TQString * m_tdeio_startQuery;
private:
static void cleanup();
static void init();
static int s_references;
};
#endif // SHARED_H

@ -1,89 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <dcopclient.h>
#include <tdeapplication.h>
#include <kprocess.h>
#include <kstaticdeleter.h>
#include "watcher_stub.h"
#include "mrml_utils.h"
// after 100 of no use, terminate the mrmld
#define TIMEOUT 100
// how often to restart the mrmld in case of failure
#define NUM_RESTARTS 5
using namespace KMrml;
KStaticDeleter<Util> utils_sd;
Util *Util::s_self = 0L;
Util::Util()
{
// we need our own dcopclient, when used in tdeio_mrml
if ( !DCOPClient::mainClient() )
{
DCOPClient::setMainClient( new DCOPClient() );
if ( !DCOPClient::mainClient()->attach() )
tqWarning( "tdeio_mrml: Can't attach to DCOP Server.");
}
}
Util::~Util()
{
if ( this == s_self )
s_self = 0L;
}
Util *Util::self()
{
if ( !s_self )
s_self = utils_sd.setObject( new Util() );
return s_self;
}
bool Util::requiresLocalServerFor( const KURL& url )
{
return url.host().isEmpty() || url.host() == "localhost";
}
bool Util::startLocalServer( const Config& config )
{
if ( config.serverStartedIndividually() )
return true;
DCOPClient *client = DCOPClient::mainClient();
// ### check if it's already running (add dcop method to Watcher)
Watcher_stub watcher( client, "kded", "daemonwatcher");
return ( watcher.requireDaemon( client->appId(),
"mrmld", config.mrmldCommandline(),
TIMEOUT, NUM_RESTARTS )
&& watcher.ok() );
}
void Util::unrequireLocalServer()
{
DCOPClient *client = DCOPClient::mainClient();
Watcher_stub watcher( client, "kded", "daemonwatcher");
watcher.unrequireDaemon( client->appId(), "mrmld" );
}

@ -1,50 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MRML_UTILS_H
#define MRML_UTILS_H
#include <tqobject.h>
#include <kurl.h>
#include "kmrml_config.h"
namespace KMrml
{
class Util : public TQObject
{
public:
static Util * self();
~Util();
bool requiresLocalServerFor( const KURL& url );
bool startLocalServer( const Config& config );
void unrequireLocalServer();
// bool isLocalServerRunning();
private:
static Util *s_self;
Util();
};
}
#endif // MRML_UTILS_H

@ -1,6 +0,0 @@
#ifndef VERSION_H
#define VERSION_H
#define KMRML_VERSION "0.3.2"
#endif // VERSION_H

@ -1,95 +0,0 @@
//
// Generated in ../server/ via dcopidl -- needs to be in the lib tho.
// Regenerate when necessary by uncommenting the watcher.stub in
// ../server/Makefile.am
//
#include "watcher_stub.h"
#include <dcopclient.h>
#include <kdatastream.h>
namespace KMrml {
Watcher_stub::Watcher_stub( const TQCString& app, const TQCString& obj )
: DCOPStub( app, obj )
{
}
Watcher_stub::Watcher_stub( DCOPClient* client, const TQCString& app, const TQCString& obj )
: DCOPStub( client, app, obj )
{
}
bool Watcher_stub::requireDaemon( const TQCString& arg0, const TQString& arg1, const TQString& arg2, uint arg3, int arg4 )
{
bool result;
if ( !dcopClient() ) {
setStatus( CallFailed );
return false;
}
TQByteArray data, replyData;
TQCString replyType;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
arg << arg1;
arg << arg2;
arg << arg3;
arg << arg4;
if ( dcopClient()->call( app(), obj(), "requireDaemon(TQCString,TQString,TQString,uint,int)", data, replyType, replyData ) ) {
if ( replyType == "bool" ) {
TQDataStream _reply_stream( replyData, IO_ReadOnly );
_reply_stream >> result;
setStatus( CallSucceeded );
} else {
callFailed();
}
} else {
callFailed();
}
return result;
}
void Watcher_stub::unrequireDaemon( const TQCString& arg0, const TQString& arg1 )
{
if ( !dcopClient() ) {
setStatus( CallFailed );
return;
}
TQByteArray data, replyData;
TQCString replyType;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
arg << arg1;
if ( dcopClient()->call( app(), obj(), "unrequireDaemon(TQCString,TQString)", data, replyType, replyData ) ) {
setStatus( CallSucceeded );
} else {
callFailed();
}
}
TQStringList Watcher_stub::runningDaemons()
{
TQStringList result;
if ( !dcopClient() ) {
setStatus( CallFailed );
return result;
}
TQByteArray data, replyData;
TQCString replyType;
if ( dcopClient()->call( app(), obj(), "runningDaemons()", data, replyType, replyData ) ) {
if ( replyType == TQSTRINGLIST_OBJECT_NAME_STRING ) {
TQDataStream _reply_stream( replyData, IO_ReadOnly );
_reply_stream >> result;
setStatus( CallSucceeded );
} else {
callFailed();
}
} else {
callFailed();
}
return result;
}
} // namespace

@ -1,36 +0,0 @@
//
// Generated in ../server/ via dcopidl -- needs to be in the lib tho.
// Regenerate when necessary by uncommenting the watcher.stub in
// ../server/Makefile.am
//
#ifndef __WATCHER_STUB__
#define __WATCHER_STUB__
#include <dcopstub.h>
#include <tqdict.h>
#include <tqptrlist.h>
#include <tqmap.h>
#include <tqstrlist.h>
#include <tqstringlist.h>
#include <tqtimer.h>
#include <kdedmodule.h>
#include <kprocess.h>
namespace KMrml {
class Watcher_stub : public DCOPStub
{
public:
Watcher_stub( const TQCString& app, const TQCString& id );
Watcher_stub( DCOPClient* client, const TQCString& app, const TQCString& id );
virtual bool requireDaemon( const TQCString& clientAppId, const TQString& daemonKey, const TQString& commandline, uint timeout, int numRestarts );
virtual void unrequireDaemon( const TQCString& clientAppId, const TQString& daemonKey );
virtual TQStringList runningDaemons();
protected:
Watcher_stub() : DCOPStub( never_use ) {};
};
} // namespace
#endif

@ -1,121 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kstaticdeleter.h>
#include <tdeio/scheduler.h>
#include "loader.h"
Loader *Loader::s_self = 0L;
KStaticDeleter<Loader> sd;
Loader * Loader::self()
{
if ( !s_self )
s_self = sd.setObject( new Loader() );
return s_self;
}
Loader::Loader() : TQObject()
{
}
Loader::~Loader()
{
disconnect( this, TQT_SIGNAL( finished( const KURL&, const TQByteArray& )));
DownloadIterator it = m_downloads.begin();
for ( ; it != m_downloads.end(); ++it ) {
it.key()->kill();
delete it.data();
}
s_self = 0L;
}
void Loader::requestDownload( const KURL& url )
{
DownloadIterator it = m_downloads.begin();
for ( ; it != m_downloads.end(); ++it ) {
if ( it.key()->url() == url )
return;
}
TDEIO::TransferJob *job = TDEIO::get( url, false, false );
TDEIO::Scheduler::scheduleJob(job);
connect( job , TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray& )),
TQT_SLOT( slotData( TDEIO::Job *, const TQByteArray& )));
connect( job , TQT_SIGNAL( result( TDEIO::Job * )),
TQT_SLOT( slotResult( TDEIO::Job * )));
Download *d = new Download();
m_downloads.insert( job, d );
}
void Loader::slotData( TDEIO::Job *job, const TQByteArray& data )
{
DownloadIterator it = m_downloads.find( static_cast<TDEIO::TransferJob*>(job) );
if ( it != m_downloads.end() ) {
TQBuffer& buffer = it.data()->m_buffer;
if ( !buffer.isOpen() )
buffer.open( IO_ReadWrite );
if ( !buffer.isOpen() ) {
tqDebug("********* EEK, can't open buffer for thumbnail download!");
return;
}
buffer.writeBlock( data.data(), data.size() );
}
}
void Loader::slotResult( TDEIO::Job *job )
{
TDEIO::TransferJob *tjob = static_cast<TDEIO::TransferJob*>( job );
DownloadIterator it = m_downloads.find( tjob );
if ( it != m_downloads.end() ) {
Download *d = it.data();
if ( job->error() != 0 )
emit finished( tjob->url(), TQByteArray() );
else
emit finished( tjob->url(), d->m_buffer.buffer() );
delete d;
m_downloads.remove( it );
}
}
// ### simultaneous downloads with multiple views? reference count downloads!
void Loader::removeDownload( const KURL& url )
{
DownloadIterator it = m_downloads.begin();
for ( ; it != m_downloads.end(); ++it ) {
if ( it.key()->url() == url ) {
it.key()->kill();
delete it.data();
return;
}
}
}
#include "loader.moc"

@ -1,73 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef LOADER_H
#define LOADER_H
#include <tqbuffer.h>
#include <tqcstring.h>
#include <tqmap.h>
#include <tqobject.h>
#include <tdeio/job.h>
#include <kurl.h>
class Download
{
public:
~Download() {
if ( m_buffer.isOpen() )
m_buffer.close();
}
TQBuffer m_buffer;
// add context of MrmlPart for progress?
};
class Loader : public TQObject
{
friend class gcc_sucks;
Q_OBJECT
public:
static Loader *self();
~Loader();
void requestDownload( const KURL& url );
void removeDownload( const KURL& url );
signals:
void finished( const KURL& url, const TQByteArray& );
private slots:
void slotData( TDEIO::Job *, const TQByteArray& );
void slotResult( TDEIO::Job * );
private:
Loader();
TQMap<TDEIO::TransferJob*,Download*> m_downloads;
typedef TQMapIterator<TDEIO::TransferJob*,Download*> DownloadIterator;
static Loader *s_self;
};
#endif // LOADER_H

@ -1,8 +0,0 @@
[Desktop Entry]
X-TDE-ServiceTypes=image/png,image/jpeg,image/gif,image/tiff,image/bmp,image/x-xpm,image/x-xbm,image/x-png
Actions=search;
[Desktop Action search]
Name=Search for Similar Images...
Icon=image-x-generic
Exec=mrmlsearch %U

@ -1,267 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2001,2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <tdeconfig.h>
#include <kdebug.h>
#include <tdeglobal.h>
#include <kinstance.h>
#include <tdelocale.h>
#include <mrml_utils.h>
#include "mrml.h"
extern "C" {
KDE_EXPORT int kdemain( int argc, char **argv )
{
TDELocale::setMainCatalogue("tdelibs");
TDEInstance instance( "tdeio_mrml" );
TDEGlobal::locale()->insertCatalogue( "kmrml" );
kdDebug() << "Starting MRML " << getpid() << endl;
if (argc != 4)
{
fprintf(stderr, "Usage: tdeio_mrml protocol domain-socket1 domain-socket2\n");
exit(-1);
}
Mrml slave(argv[2], argv[3]);
slave.dispatchLoop();
kdDebug() << "Done" << endl;
return 0;
}
}
const int Mrml::bufsize = 8192;
Mrml::Mrml( const TQCString& pool_socket, const TQCString& app_socket )
: TCPSlaveBase( 12789, "mrml", pool_socket, app_socket ),
m_config( TDEGlobal::config() )
{
MrmlShared::ref();
}
Mrml::~Mrml()
{
KMrml::Util::self()->unrequireLocalServer();
closeDescriptor();
MrmlShared::deref();
}
bool Mrml::checkLocalServer( const KURL& url )
{
if ( KMrml::Util::self()->requiresLocalServerFor( url ) )
{
if ( !KMrml::Util::self()->startLocalServer( m_config ) )
return false;
}
return true;
}
void Mrml::get( const KURL& url )
{
// tqDebug("******* getting: %s (user: %s)", url.url().latin1(), url.user().latin1());
if ( !checkLocalServer( url ) )
{
error( TDEIO::ERR_SLAVE_DEFINED, i18n("Unable to start the Indexing Server. "
"Aborting the query.") );
return;
}
int retriesLeft = 5;
tryConnect:
TQCString utf8;
bool sendError = (retriesLeft <= 0);
if ( connectToHost( url.host(), port(url), sendError ) )
{
// tqDebug(" connected!");
TQString task = metaData( MrmlShared::tdeio_task() );
if ( task == MrmlShared::tdeio_initialize() ) {
startSession( url );
}
else if ( task == MrmlShared::tdeio_startQuery() ) {
TQString meta = metaData( MrmlShared::mrml_data() );
if ( meta.isEmpty() ) {
closeDescriptor();
error( TDEIO::ERR_SLAVE_DEFINED, i18n("No MRML data is available.") );
return;
}
utf8 = meta.utf8();
write( utf8, utf8.length() );
emitData( readAll() );
}
// no task metadata available, we're called from KonqRun or something
// like that. Emitting the mimetype seems to suffice for now. After
// that, MrmlPart is going to start and start the get() again.
else
{
mimeType( "text/mrml" );
finished();
}
}
else
{
if ( retriesLeft-- >= 0 )
{
#ifdef HAVE_USLEEP
usleep( 500 ); // wait a while for gift to start up
#endif
goto tryConnect;
return;
}
error( TDEIO::ERR_COULD_NOT_CONNECT,
i18n("Could not connect to GIFT server.") );
return;
}
closeDescriptor();
//data( TQByteArray() ); // send an empty TQByteArray to signal end of data.
finished();
}
// make sure we're connected when you call this!
TQCString Mrml::readAll()
{
TQCString data;
char buf[bufsize];
ssize_t bytes = 0;
while ( (bytes = read( buf, bufsize-1 )) > 0 ) {
buf[bytes] = '\0';
data.append( buf );
}
// tqDebug("*** readAll()::: %i, %s", data.length(), data.data());
return data;
}
TQCString Mrml::loginString()
{
return "<mrml><get-server-properties/></mrml>";
}
TQCString Mrml::getConfigurationString()
{
return "<mrml><get-configuration/></mrml>";
}
// ### needed?
TQCString Mrml::getSessionsString( const TQString& username,
const TQString& password )
{
TQCString data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><mrml><get-sessions ";
if ( !username.isEmpty() ) { // ### pop up auth-dialog???
data.append( "user-name=\"");
data.append( username.utf8() );
data.append( "\"");
if ( !password.isEmpty() ) {
data.append( " password=\"");
data.append( password.utf8() );
data.append( "\"" );
}
}
data.append( "/></mrml>" );
return data;
}
bool Mrml::startSession( const KURL& url )
{
// might first ask for collections, and then for algorithms for the
// desired collection-id
// Wolfgang says, we shouldn't create an own session-id here, as gcc 2.95
// apparently makes problems in exception handling somehow. So we simply
// accept the server's session-id.
TQString msg = mrmlString( TQString() ).arg(
"<open-session user-name=\"%1\" session-name=\"tdeio_mrml session\" /> \
<get-algorithms /> \
<get-collections /> \
</mrml>" ).arg( user( url ));
TQCString utf8 = msg.utf8();
// tqDebug(":::Writing: %s", utf8.data());
write( utf8, utf8.length() );
emitData( readAll() );
return true;
}
TQString Mrml::mrmlString( const TQString& sessionId, const TQString& transactionId )
{
TQString msg =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> \
<!DOCTYPE mrml SYSTEM \"http://isrpc85.epfl.ch/Charmer/code/mrml.dtd\"> \
%1 \
</mrml>";
if ( sessionId.isEmpty() ) // when we don't have one yet
return msg.arg( "<mrml>%1" );
if ( transactionId.isNull() )
return msg.arg( "<mrml session-id=\"%1\">%1" ).arg( sessionId );
else
return msg.arg( "<mrml session-id=\"%1\" transaction-id=\"%1\">%1")
.arg( sessionId ).arg( transactionId );
}
void Mrml::emitData( const TQCString& msg )
{
mimeType( "text/mrml" );
data( msg );
processedSize( msg.count() );
}
void Mrml::mimetype( const KURL& url )
{
if ( url.protocol() == "mrml" ) {
mimeType( "text/mrml" );
finished();
}
else
TDEIO::TCPSlaveBase::mimetype( url );
}

@ -1,7 +0,0 @@
[Desktop Entry]
Comment=Multimedia Retrieval Markup Language Document
Icon=text-html
Type=MimeType
MimeType=text/mrml
Patterns=*.mrml;*.MRML;
X-TDE-AutoEmbed=true

@ -1,84 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MRML_H
#define MRML_H
#include <tdeio/tcpslavebase.h>
#include <kurl.h>
#include <kmrml_config.h>
#include "mrml_shared.h"
class Mrml : public TDEIO::TCPSlaveBase
{
public:
Mrml( const TQCString&, const TQCString& );
~Mrml();
virtual void get( const KURL& url );
virtual void mimetype( const KURL& url );
private:
TQCString readAll();
void emitData( const TQCString& );
bool startSession( const KURL& url );
// helpers
inline TQString sessionId() {
return metaData( MrmlShared::sessionId() );
}
// misc
short int port( const KURL& url )
{
return (url.port() != 0) ?
url.port() :
m_config.settingsForHost( url.host() ).port();
}
static TQString mrmlString( const TQString& sessionId,
const TQString& transactionId = TQString() );
static TQCString loginString();
static TQCString getConfigurationString();
static TQCString getSessionsString( const TQString& username,
const TQString& password );
TQString user( const KURL& url ) {
return url.hasUser() ?
url.user() : m_config.defaultSettings().user;
}
TQString pass( const KURL& url ) {
return url.hasPass() ?
url.pass() : m_config.defaultSettings().pass;
}
bool checkLocalServer( const KURL& url );
static const int bufsize;
TQString defaultUser;
TQString defaultPass;
KMrml::Config m_config;
};
#endif // MRML_H

@ -1,10 +0,0 @@
[Protocol]
exec=tdeio_mrml
protocol=mrml
input=none
output=filesystem
reading=true
defaultMimetype=text/mrml
determineMimetypeFromExtension=false
Icon=image-x-generic
X-DocPath=tdeioslave/mrml/index.html

@ -1,76 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "mrml_creator.h"
TQDomElement MrmlCreator::createMrml( TQDomDocument& doc,
const TQString& sessionId,
const TQString& transactionId )
{
TQDomElement mrml = doc.createElement( "mrml" );
doc.appendChild( mrml );
mrml.setAttribute( MrmlShared::sessionId(), sessionId );
if ( !transactionId.isNull() )
mrml.setAttribute( MrmlShared::transactionId(), transactionId );
return mrml;
}
TQDomElement MrmlCreator::configureSession( TQDomElement& mrml,
const KMrml::Algorithm& algo,
const TQString& sessionId )
{
TQDomDocument doc = mrml.ownerDocument();
TQDomElement config = doc.createElement( MrmlShared::configureSession() );
mrml.appendChild( config );
config.setAttribute( MrmlShared::sessionId(), sessionId );
algo.toElement( config );
return config;
}
TQDomElement MrmlCreator::addQuery( TQDomElement& mrml, int resultSize )
{
TQDomElement query = mrml.ownerDocument().createElement("query-step");
mrml.appendChild( query );
// query.setAttribute( "query-step-id", "5" ); // ###
query.setAttribute( "result-size", TQString::number( resultSize ));
return query;
}
TQDomElement MrmlCreator::addRelevanceList( TQDomElement& query )
{
TQDomElement elem =
query.ownerDocument().createElement("user-relevance-element-list");
query.appendChild( elem );
return elem;
}
/**
* Creates a <user-relevance-element> with the given attributes set.
*/
void MrmlCreator::createRelevanceElement( TQDomDocument& doc,
TQDomElement& parent,
const TQString& url,
Relevance relevance )
{
TQDomElement element = doc.createElement( "user-relevance-element" );
element.setAttribute( "image-location", url );
element.setAttribute( "user-relevance", TQString::number( relevance ) );
parent.appendChild( element );
}

@ -1,49 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2001,2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MRML_CREATOR_H
#define MRML_CREATOR_H
#include <tqdom.h>
#include <kurl.h>
#include "mrml_elements.h"
#include "mrml_shared.h"
namespace MrmlCreator
{
enum Relevance { Relevant = 1, Irrelevant = -1 };
TQDomElement createMrml( TQDomDocument& doc,
const TQString& sessionId,
const TQString& transactionId = TQString() );
TQDomElement configureSession( TQDomElement& mrml,
const KMrml::Algorithm& algo,
const TQString& sessionId );
TQDomElement addQuery( TQDomElement& mrml, int resultSize );
TQDomElement addRelevanceList( TQDomElement& query );
/**
* Creates a <user-relevance-element> with the given attributes set.
*/
void createRelevanceElement( TQDomDocument& doc, TQDomElement& parent,
const TQString& url, Relevance relevance );
}
#endif // MRML_CREATOR_H

@ -1,358 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "mrml_elements.h"
#include "mrml_shared.h"
#include <kdatastream.h>
#include <tqdom.h>
using namespace KMrml;
//
// MrmlElement is currently the baseclass for Algorithm and Collection. Both
// may have a single child-element <query-paradigm-list>, with a number of
// <query-paradigm> elements as children.
//
MrmlElement::MrmlElement( const TQDomElement& elem )
{
TQValueList<TQDomElement> list =
KMrml::directChildElements( elem, MrmlShared::queryParadigmList() );
Q_ASSERT( list.count() < 2 ); // There can be only one.
if ( list.count() )
m_paradigms.initFromDOM( list.first() );
}
void MrmlElement::setOtherAttributes( TQDomElement& elem ) const
{
TQMapConstIterator<TQString,TQString> it = m_attributes.begin();
for ( ; it != m_attributes.end(); ++it )
{
elem.setAttribute( it.key(), it.data() );
}
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
AlgorithmList AlgorithmList::algorithmsForCollection( const Collection& coll ) const
{
AlgorithmList list;
AlgorithmList::ConstIterator it = begin();
for ( ; it != end(); ++it )
{
Algorithm algo = *it;
if ( algo.paradigms().matches( coll.paradigms() ) )
{
algo.setCollectionId( coll.id() );
list.append( algo );
}
}
return list;
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
Collection::Collection( const TQDomElement& elem )
: MrmlElement( elem )
{
TQDomNamedNodeMap attrs = elem.attributes();
for ( uint i = 0; i < attrs.length(); i++ )
{
TQDomAttr attribute = attrs.item( i ).toAttr();
TQString name = attribute.name();
if ( name == MrmlShared::collectionName() )
m_name = attribute.value();
else if ( name == MrmlShared::collectionId() )
m_id = attribute.value();
else // custom attributes
m_attributes.insert( name, attribute.value() );
}
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
Algorithm::Algorithm( const TQDomElement& elem )
: MrmlElement( elem )
{
TQDomNamedNodeMap attrs = elem.attributes();
for ( uint i = 0; i < attrs.length(); i++ )
{
TQDomAttr attribute = attrs.item( i ).toAttr();
TQString name = attribute.name();
if ( name == MrmlShared::algorithmName() )
m_name = attribute.value();
else if ( name == MrmlShared::algorithmId() )
m_id = attribute.value();
else if ( name == MrmlShared::algorithmType() )
m_type = attribute.value();
// not really necessary
else if ( name == MrmlShared::collectionId() )
m_collectionId = attribute.value();
else // custom attributes
m_attributes.insert( name, attribute.value() );
}
TQDomElement propsElem = firstChildElement(elem, MrmlShared::propertySheet());
m_propertySheet.initFromDOM( propsElem );
tqDebug("############# new algorithm: name: %s, id: %s, type: %s", m_name.latin1(), m_id.latin1(), m_type.latin1());
}
Algorithm Algorithm::defaultAlgorithm()
{
Algorithm algo;
algo.m_id = "adefault";
algo.m_type = "adefault"; // ### not in the DTD
algo.m_name = "dummy";
return algo;
}
TQDomElement Algorithm::toElement( TQDomElement& parent ) const
{
TQDomDocument doc = parent.ownerDocument();
TQDomElement algorithm = doc.createElement( MrmlShared::algorithm() );
parent.appendChild( algorithm );
setOtherAttributes( algorithm );
if ( !m_name.isEmpty() )
algorithm.setAttribute( MrmlShared::algorithmName(), m_name );
if ( !m_id.isEmpty() )
algorithm.setAttribute( MrmlShared::algorithmId(), m_id );
if ( !m_type.isEmpty() )
algorithm.setAttribute( MrmlShared::algorithmType(), m_type );
if ( !m_collectionId.isEmpty() )
algorithm.setAttribute( MrmlShared::collectionId(), m_collectionId );
return algorithm;
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
QueryParadigm::QueryParadigm( const TQDomElement& elem )
{
TQDomNamedNodeMap attrs = elem.attributes();
for ( uint i = 0; i < attrs.count(); i++ )
{
TQDomAttr attr = attrs.item( i ).toAttr();
m_attributes.insert( attr.name(), attr.value() );
if ( attr.name() == "type" )
m_type = attr.value();
}
}
bool QueryParadigm::matches( const QueryParadigm& other ) const
{
return m_attributes.isEmpty() || other.m_attributes.isEmpty() ||
equalMaps( m_attributes, other.m_attributes );
}
bool QueryParadigm::equalMaps( const TQMap<TQString,TQString> m1,
const TQMap<TQString,TQString> m2 )
{
if ( m1.count() != m2.count() )
return false;
TQMapConstIterator<TQString,TQString> it = m1.begin();
for ( ; it != m1.end(); ++it )
{
TQMapConstIterator<TQString,TQString> it2 = m2.find( it.key() );
if ( it2 == m2.end() || it.data() != it2.data() )
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
void QueryParadigmList::initFromDOM( const TQDomElement& elem )
{
clear();
TQValueList<TQDomElement> list =
KMrml::directChildElements( elem, MrmlShared::queryParadigm() );
TQValueListConstIterator<TQDomElement> it = list.begin();
for ( ; it != list.end(); ++it )
{
append( QueryParadigm( *it ));
}
}
// two QueryParadigmLists match, when there is at least one pair of
// QueryParadigms that match (all attribute-value pairs are equal, or there
// are no attributes at all).
bool QueryParadigmList::matches( const QueryParadigmList& other ) const
{
ConstIterator it = begin();
for ( ; it != end(); ++it )
{
ConstIterator oit = other.begin();
for ( ; oit != other.end(); ++oit )
if ( (*it).matches( *oit ) )
return true;
}
return false;
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
TQValueList<TQDomElement> KMrml::directChildElements( const TQDomElement& parent,
const TQString& tagName )
{
TQValueList<TQDomElement> list;
TQDomNode node = parent.firstChild();
while ( !node.isNull() )
{
if ( node.isElement() && node.nodeName() == tagName )
list.append( node.toElement() );
node = node.nextSibling();
}
return list;
}
TQDomElement KMrml::firstChildElement( const TQDomElement& parent,
const TQString& tagName )
{
TQDomNode node = parent.firstChild();
while ( !node.isNull() )
{
if ( node.isElement() && node.nodeName() == tagName )
return node.toElement();
node = node.nextSibling();
}
return TQDomElement();
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
TQDataStream& KMrml::operator<<( TQDataStream& stream, const QueryParadigm& )
{
return stream;
}
TQDataStream& KMrml::operator>>( TQDataStream& stream, QueryParadigm& )
{
return stream;
}
TQDataStream& KMrml::operator<<( TQDataStream& stream, const QueryParadigmList& )
{
return stream;
}
TQDataStream& KMrml::operator>>( TQDataStream& stream, QueryParadigmList& )
{
return stream;
}
TQDataStream& KMrml::operator<<( TQDataStream& stream, const MrmlElement& )
{
return stream;
}
TQDataStream& KMrml::operator>>( TQDataStream& stream, MrmlElement& )
{
return stream;
}
TQDataStream& KMrml::operator<<( TQDataStream& stream, const Algorithm& )
{
return stream;
}
TQDataStream& KMrml::operator>>( TQDataStream& stream, Algorithm& )
{
return stream;
}
TQDataStream& KMrml::operator<<( TQDataStream& stream, const Collection& )
{
return stream;
}
TQDataStream& KMrml::operator>>( TQDataStream& stream, Collection& )
{
return stream;
}
template <class t> TQDataStream& KMrml::operator<<( TQDataStream& stream,
const MrmlElementList<t>& )
{
return stream;
}
template <class t> TQDataStream& KMrml::operator>>( TQDataStream& stream,
MrmlElementList<t>& )
{
return stream;
}
TQDataStream& KMrml::operator<<( TQDataStream& stream, const AlgorithmList& )
{
return stream;
}
TQDataStream& KMrml::operator>>( TQDataStream& stream, AlgorithmList& )
{
return stream;
}

@ -1,255 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MRML_ELEMENTS_H
#define MRML_ELEMENTS_H
#include <tqdom.h>
#include <tqmap.h>
#include <tqstringlist.h>
#include <tqvaluelist.h>
#include "mrml_shared.h"
#include "propertysheet.h"
#include <assert.h>
namespace KMrml
{
class PropertySheet;
class QueryParadigm
{
public:
QueryParadigm() {}
QueryParadigm( const TQDomElement& elem );
bool matches( const QueryParadigm& other ) const;
TQString type() const { return m_type; }
// bool operator== ( const QueryParadigm& p1, const QueryParadigm& p2 )
private:
TQString m_type;
TQMap<TQString,TQString> m_attributes;
static bool equalMaps( const TQMap<TQString,TQString>,
const TQMap<TQString,TQString> );
};
class QueryParadigmList : protected TQValueList<QueryParadigm>
{
public:
typedef TQValueListIterator<QueryParadigm> Iterator;
typedef TQValueListConstIterator<QueryParadigm> ConstIterator;
void initFromDOM( const TQDomElement& elem );
bool matches( const QueryParadigmList& other ) const;
};
class MrmlElement
{
public:
MrmlElement() {}
MrmlElement( const TQDomElement& elem );
virtual ~MrmlElement() {}
TQString id() const { return m_id; }
TQString name() const { return m_name; }
TQString attribute( const TQString& name ) const { return m_attributes[ name ]; }
QueryParadigmList paradigms() const { return m_paradigms; }
TQMapConstIterator<TQString,TQString> attributeIterator() const {
return m_attributes.begin();
}
TQMapConstIterator<TQString,TQString> end() const { return m_attributes.end(); }
bool isValid() const { return !m_name.isNull() && !m_id.isNull(); }
protected:
TQString m_id;
TQString m_name;
QueryParadigmList m_paradigms;
TQMap<TQString,TQString> m_attributes;
void setOtherAttributes( TQDomElement& elem ) const;
};
class Algorithm : public MrmlElement
{
public:
Algorithm() { m_collectionId = "adefault"; }
Algorithm( const TQDomElement& elem );
TQString type() const { return m_type; }
TQString collectionId() const
{
return m_collectionId;
}
void setCollectionId( const TQString& id )
{
m_collectionId = id;
}
TQDomElement toElement( TQDomElement& parent ) const;
const PropertySheet& propertySheet() const;
static Algorithm defaultAlgorithm();
private:
TQString m_type;
PropertySheet m_propertySheet;
TQString m_collectionId;
};
class Collection : public MrmlElement
{
public:
Collection() {}
Collection( const TQDomElement& elem );
};
template <class t> class MrmlElementList : public TQValueList<t>
{
public:
typedef TQValueListIterator<t> Iterator;
typedef TQValueListConstIterator<t> ConstIterator;
/**
* Creates an invalid element.
*/
MrmlElementList( const TQString& tagName ) :
TQValueList<t>(),
m_tagName( tagName ) {}
MrmlElementList( const TQDomElement& elem, const TQString& tagName ) :
TQValueList<t>(),
m_tagName( tagName )
{
initFromDOM( elem );
}
virtual ~MrmlElementList() {};
void initFromDOM( const TQDomElement& elem )
{
assert( !m_tagName.isEmpty() );
TQValueList<t>::clear();
TQDomNodeList list = elem.elementsByTagName( m_tagName );
for ( uint i = 0; i < list.length(); i++ )
{
TQDomElement elem = list.item( i ).toElement();
t item( elem );
if ( item.isValid() )
this->append( item );
}
}
t findByName( const TQString& name ) const
{
TQValueListConstIterator<t> it = TQValueList<t>::begin();
for ( ; it != TQValueList<t>::end(); ++it )
{
if ( (*it).name() == name )
return *it;
}
return t();
}
t findById( const TQString& id ) const
{
TQValueListConstIterator<t> it = TQValueList<t>::begin();
for ( ; it != TQValueList<t>::end(); ++it )
{
if ( (*it).id() == id )
return *it;
}
return MrmlElement();
}
TQStringList itemNames() const {
TQStringList list;
TQValueListConstIterator<t> it = TQValueList<t>::begin();
for ( ; it != TQValueList<t>::end(); ++it )
list.append( (*it).name() );
return list;
}
void setItemName( const TQString& tagName ) { m_tagName = tagName; }
TQString tagName() const { return m_tagName; }
private:
TQString m_tagName;
MrmlElementList();
};
class AlgorithmList : public MrmlElementList<Algorithm>
{
public:
AlgorithmList() :
MrmlElementList<Algorithm>( MrmlShared::algorithm() )
{}
AlgorithmList algorithmsForCollection( const Collection& coll ) const;
};
class CollectionList : public MrmlElementList<Collection>
{
public:
CollectionList() :
MrmlElementList<Collection>( MrmlShared::collection() )
{}
};
TQValueList<TQDomElement> directChildElements( const TQDomElement& parent,
const TQString& tagName);
TQDomElement firstChildElement( const TQDomElement& parent,
const TQString& tagName );
TQDataStream& operator<<( TQDataStream& stream, const QueryParadigm& );
TQDataStream& operator>>( TQDataStream& stream, QueryParadigm& );
TQDataStream& operator<<( TQDataStream& stream, const QueryParadigmList& );
TQDataStream& operator>>( TQDataStream& stream, QueryParadigmList& );
TQDataStream& operator<<( TQDataStream& stream, const MrmlElement& );
TQDataStream& operator>>( TQDataStream& stream, MrmlElement& );
TQDataStream& operator<<( TQDataStream& stream, const Algorithm& );
TQDataStream& operator>>( TQDataStream& stream, Algorithm& );
TQDataStream& operator<<( TQDataStream& stream, const Collection& );
TQDataStream& operator>>( TQDataStream& stream, Collection& );
template <class t> TQDataStream& operator<<( TQDataStream&,
const MrmlElementList<t>& );
template <class t> TQDataStream& operator>>( TQDataStream&,
MrmlElementList<t>& );
TQDataStream& operator<<( TQDataStream&, const AlgorithmList& );
TQDataStream& operator>>( TQDataStream&, AlgorithmList& );
}
#endif // MRML_ELEMENTS_H

@ -1,857 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2001,2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <tqcheckbox.h>
#include <tqcursor.h>
#include <tqdir.h>
#include <tqfile.h>
#include <tqgrid.h>
#include <tqhgroupbox.h>
#include <tqlabel.h>
#include <tqpushbutton.h>
#include <tqtooltip.h>
#include <tqvbox.h>
#include <tdeaboutdata.h>
#include <tdeapplication.h>
#include <kcombobox.h>
#include <tdeconfig.h>
#include <kdatastream.h>
#include <kdebug.h>
#include <tdeglobal.h>
#include <tdelocale.h>
#include <kiconloader.h>
#include <kinstance.h>
#include <tdeio/job.h>
#include <tdeio/jobclasses.h>
#include <tdemessagebox.h>
#include <knuminput.h>
#include <kprotocolinfo.h>
#include <tdeparts/genericfactory.h>
#include <tdetempfile.h>
#include <mrml_utils.h>
#include "algorithmdialog.h"
#include "browser.h"
#include "collectioncombo.h"
#include "mrml_creator.h"
#include "mrml_elements.h"
#include "mrml_shared.h"
#include "mrml_view.h"
#include "mrml_part.h"
#include "version.h"
using namespace KMrml;
extern "C"
{
void * init_libkmrmlpart() {
return new KMrml::PartFactory();
}
}
TDEInstance * PartFactory::s_instance = 0L;
PartFactory::PartFactory()
: KParts::Factory()
{
MrmlShared::ref();
}
PartFactory::~PartFactory()
{
MrmlShared::deref();
delete s_instance;
s_instance = 0L;
}
TDEInstance * PartFactory::instance()
{
if ( !s_instance ) {
s_instance = new TDEInstance( "kmrml" );
TDEGlobal::locale()->insertCatalogue( "kmrml" );
}
return s_instance;
}
KParts::Part * PartFactory::createPartObject( TQWidget *parentWidget,
const char *widgetName,
TQObject *parent,
const char *name,
const char *,
const TQStringList& args )
{
return new MrmlPart( parentWidget, widgetName, parent, name, args );
}
// can't use this due to MrmlShared ref-counting
// typedef KParts::GenericFactory<KMrml::MrmlPart> PartFactory;
// K_EXPORT_COMPONENT_FACTORY( mrmlpart, PartFactory )
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
uint MrmlPart::s_sessionId = 0;
MrmlPart::MrmlPart( TQWidget *parentWidget, const char * /* widgetName */,
TQObject *parent, const char *name,
const TQStringList& /* args */ )
: KParts::ReadOnlyPart( parent, name ),
m_job( 0L ),
m_status( NeedCollection )
{
m_sessionId = TQString::number( s_sessionId++ ).prepend("kmrml_");
setName( "MRML Part" );
m_browser = new Browser( this, "mrml browserextension");
setInstance( PartFactory::instance(), true ); // do load plugins :)
TDEConfig *config = PartFactory::instance()->config();
config->setGroup("MRML Settings");
TQVBox *box = new TQVBox( parentWidget, "main mrml box" );
m_view = new MrmlView( box, "MrmlView" );
connect( m_view, TQT_SIGNAL( activated( const KURL&, ButtonState )),
this, TQT_SLOT( slotActivated( const KURL&, ButtonState )));
connect( m_view, TQT_SIGNAL( onItem( const KURL& )),
this, TQT_SLOT( slotSetStatusBar( const KURL& )));
m_panel = new TQHGroupBox( box, "buttons box" );
TQGrid *comboGrid = new TQGrid( 2, m_panel, "combo grid" );
comboGrid->setSpacing( KDialog::spacingHint() );
(void) new TQLabel( i18n("Server to query:"), comboGrid );
m_hostCombo = new KComboBox( false, comboGrid, "host combo" );
initHostCombo();
connect( m_hostCombo, TQT_SIGNAL( activated( const TQString& ) ),
TQT_SLOT( slotHostComboActivated( const TQString& )));
(void) new TQLabel( i18n("Search in collection:"), comboGrid );
m_collectionCombo = new CollectionCombo( comboGrid, "collection-combo" );
// will be re-set in initCollections(), but we need to set it here to
// prevent crashes when the connection to the server fails
m_collectionCombo->setCollections( &m_collections );
m_algoButton = new TQPushButton( TQString(), m_panel );
m_algoButton->setPixmap( SmallIcon("configure") );
m_algoButton->setFixedSize( m_algoButton->sizeHint() );
connect( m_algoButton, TQT_SIGNAL( clicked() ),
TQT_SLOT( slotConfigureAlgorithm() ));
TQToolTip::add( m_algoButton, i18n("Configure algorithm") );
TQWidget *spacer = new TQWidget( m_panel );
spacer->setSizePolicy( TQSizePolicy( TQSizePolicy::MinimumExpanding,
TQSizePolicy::Minimum ) );
int resultSize = config->readNumEntry( "Result-size", 20 );
m_resultSizeInput = new KIntNumInput( resultSize, m_panel );
m_resultSizeInput->setRange( 1, 100 );
m_resultSizeInput->setLabel( i18n("Maximum result images:") );
TQVBox *tmp = new TQVBox( m_panel );
m_random = new TQCheckBox( i18n("Random search"), tmp );
m_startButton = new TQPushButton( TQString(), tmp );
connect( m_startButton, TQT_SIGNAL( clicked() ), TQT_SLOT( slotStartClicked() ));
setStatus( NeedCollection );
setWidget( box );
// setXMLFile( "mrml_part.rc" );
slotSetStatusBar( TQString() );
enableServerDependentWidgets( false );
}
MrmlPart::~MrmlPart()
{
closeURL();
}
void MrmlPart::enableServerDependentWidgets( bool enable )
{
m_collectionCombo->setEnabled( enable );
m_algoButton->setEnabled( enable && false ); // ### re-enable!!!
}
void MrmlPart::initCollections( const TQDomElement& elem )
{
m_collections.initFromDOM( elem );
m_collectionCombo->setCollections( &m_collections );
enableServerDependentWidgets( m_collectionCombo->count() > 0 );
if ( m_collectionCombo->count() == 0 )
{
KMessageBox::information( widget(),
i18n("There is no image collection available\n"
"at %1.\n"), i18n("No Image Collection"));
setStatus( NeedCollection );
}
else
m_collectionCombo->updateGeometry(); // adjust the entire grid
}
void MrmlPart::initAlgorithms( const TQDomElement& elem )
{
m_algorithms.initFromDOM( elem );
}
// this is where we start!
bool MrmlPart::openURL( const KURL& url )
{
closeURL();
if ( url.protocol() != "mrml" || !url.isValid() ) {
tqWarning("MrmlPart::openURL: cannot handle url: %s", url.prettyURL().latin1());
return false; // what to do with that?
}
m_url = url;
TQString host = url.host().isEmpty() ?
TQString::fromLatin1("localhost") : url.host();
m_hostCombo->setCurrentItem( host );
// urls we need to download before starting the query
KURL::List downloadList;
m_queryList.clear();
TQString param = url.queryItem( "relevant" );
TQStringList list = TQStringList::split( ';', param );
// we can only search by example on localhost
if ( host != "localhost" )
{
if ( !list.isEmpty() )
KMessageBox::sorry( m_view,
i18n("You can only search by example images "
"on a local indexing server."),
i18n("Only Local Servers Possible") );
}
else // localhost query
{
for( TQStringList::Iterator it = list.begin(); it != list.end(); ++it )
{
KURL u;
if ( (*it).at(0) == '/' )
u.setPath( *it );
else
u = *it;
if ( u.isValid() )
{
if ( u.isLocalFile() )
m_queryList.append( u );
else
downloadList.append( u );
}
}
// ### we need a real solution for this!
// gift refuses to start when no config file is available.
if ( !TQFile::exists( m_config.mrmldDataDir() + "/gift-config.mrml" ) )
{
if ( KMessageBox::questionYesNo(0L,
i18n("There are no indexable folders "
"specified. Do you want to configure them "
"now?"),
i18n("Configuration Missing"),
i18n("Configure"),
i18n("Do Not Configure"),
"kmrml_ask_configure_gift" )
== KMessageBox::Yes )
{
TDEApplication::tdeinitExec( "tdecmshell",
TQString::fromLatin1("kcmkmrml"));
setStatus( NeedCollection );
return false;
}
}
}
if ( !downloadList.isEmpty() )
downloadReferenceFiles( downloadList );
else
contactServer( m_url );
return true;
}
void MrmlPart::contactServer( const KURL& url )
{
m_job = transferJob( url );
m_job->addMetaData( MrmlShared::tdeio_task(), MrmlShared::tdeio_initialize() );
TQString host = url.host().isEmpty() ?
TQString::fromLatin1("localhost") : url.host();
slotSetStatusBar( i18n("Connecting to indexing server at %1...").arg( host ));
}
//
// schedules a download all urls of downloadList (all remote and wellformed)
// No other downloads are running (closeURL() has been called before)
//
void MrmlPart::downloadReferenceFiles( const KURL::List& downloadList )
{
assert( m_downloadJobs.isEmpty() );
KURL::List::ConstIterator it = downloadList.begin();
for ( ; it != downloadList.end(); it++ )
{
TQString extension;
int index = (*it).fileName().findRev( '.' );
if ( index != -1 )
extension = (*it).fileName().mid( index );
KTempFile tmpFile( TQString(), extension );
if ( tmpFile.status() != 0 )
{
kdWarning() << "Can't create temporary file, skipping: " << *it << endl;
continue;
}
m_tempFiles.append( tmpFile.name() );
KURL destURL;
destURL.setPath( tmpFile.name() );
TDEIO::FileCopyJob *job = TDEIO::file_copy( *it, destURL, -1,
true /* overwrite tmpfile */ );
connect( job, TQT_SIGNAL( result( TDEIO::Job * ) ),
TQT_SLOT( slotDownloadResult( TDEIO::Job * ) ));
m_downloadJobs.append( job );
// ### should this be only called for one job?
emit started( job );
}
if ( !m_downloadJobs.isEmpty() )
slotSetStatusBar( i18n("Downloading reference files...") );
else // probably never happens
contactServer( m_url );
}
bool MrmlPart::closeURL()
{
m_view->stopDownloads();
m_view->clear();
TQPtrListIterator<TDEIO::FileCopyJob> it( m_downloadJobs );
for ( ; it.current(); ++it )
it.current()->kill();
m_downloadJobs.clear();
TQStringList::Iterator tit = m_tempFiles.begin();
for ( ; tit != m_tempFiles.end(); ++tit )
TQFile::remove( *tit );
m_tempFiles.clear();
if ( m_job ) {
m_job->kill();
m_job = 0L;
}
setStatus( NeedCollection );
return true;
}
TDEIO::TransferJob * MrmlPart::transferJob( const KURL& url )
{
TDEIO::TransferJob *job = TDEIO::get( url, true, false ); // reload, no gui
job->setAutoErrorHandlingEnabled( true, m_view );
connect( job, TQT_SIGNAL( result( TDEIO::Job * )),
TQT_SLOT( slotResult( TDEIO::Job * )));
connect( job, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray& )),
TQT_SLOT( slotData( TDEIO::Job *, const TQByteArray& )));
// ###
// connect( job, TQT_SIGNAL( infoMessage( TDEIO::Job *, const TQString& )),
// TQT_SLOT( slotResult( TDEIO::Job *, const TQString& )));
job->setWindow( widget() );
if ( !m_sessionId.isEmpty() )
job->addMetaData( MrmlShared::sessionId(), m_sessionId );
emit started( job );
emit setWindowCaption( url.prettyURL() );
setStatus( InProgress );
return job;
}
void MrmlPart::slotResult( TDEIO::Job *job )
{
if ( job == m_job )
m_job = 0L;
slotSetStatusBar( TQString() );
if ( !job->error() )
emit completed();
else {
emit canceled( job->errorString() );
// tqDebug("*** canceled: error: %s", job->errorString().latin1());
}
bool auto_random = m_view->isEmpty() && m_queryList.isEmpty();
m_random->setChecked( auto_random );
m_random->setEnabled( !auto_random );
setStatus( job->error() ? NeedCollection : CanSearch );
if ( !job->error() && !m_queryList.isEmpty() ) {
// we have a connection and we got a list of relevant URLs to query for
// (via the URL)
createQuery( &m_queryList );
m_queryList.clear();
}
}
// ### when user cancels download, we crash :(
void MrmlPart::slotDownloadResult( TDEIO::Job *job )
{
assert( job->inherits( "TDEIO::FileCopyJob" ) );
TDEIO::FileCopyJob *copyJob = static_cast<TDEIO::FileCopyJob*>( job );
if ( !copyJob->error() )
m_queryList.append( copyJob->destURL() );
m_downloadJobs.removeRef( copyJob );
if ( m_downloadJobs.isEmpty() ) // finally, we can start the query!
{
if ( m_queryList.isEmpty() ) // rather unlikely, but could happen ;)
{
kdWarning() << "Couldn't download the reference files. Will start a random search now" << endl;
}
contactServer( m_url );
}
}
// mrml-document in the bytearray
void MrmlPart::slotData( TDEIO::Job *, const TQByteArray& data )
{
if ( data.isEmpty() )
return;
TQDomDocument doc;
doc.setContent( data );
if ( !doc.isNull() )
parseMrml( doc );
}
void MrmlPart::parseMrml( TQDomDocument& doc )
{
TQDomNode mrml = doc.documentElement(); // root element
if ( !mrml.isNull() ) {
TQDomNode child = mrml.firstChild();
for ( ; !child.isNull(); child = child.nextSibling() ) {
// tqDebug("**** HERE %s", child.nodeName().latin1());
if ( child.isElement() ) {
TQDomElement elem = child.toElement();
TQString tagName = elem.tagName();
if ( tagName == "acknowledge-session-op" )
m_sessionId = elem.attribute( MrmlShared::sessionId() );
else if ( tagName == MrmlShared::algorithmList() ) {
initAlgorithms( elem );
}
else if ( tagName == MrmlShared::collectionList() ) {
initCollections( elem );
}
else if ( tagName == "error" ) {
KMessageBox::information( widget(),
i18n("Server returned error:\n%1\n")
.arg( elem.attribute( "message" )),
i18n("Server Error") );
}
else if ( tagName == "query-result" ) {
m_view->clear();
parseQueryResult( elem );
}
} // child.isElement()
}
} // !mrml.isNull()
}
void MrmlPart::parseQueryResult( TQDomElement& queryResult )
{
TQDomNode child = queryResult.firstChild();
for ( ; !child.isNull(); child = child.nextSibling() ) {
if ( child.isElement() ) {
TQDomElement elem = child.toElement();
TQString tagName = elem.tagName();
if ( tagName == "query-result-element-list" ) {
TQValueList<TQDomElement> list =
KMrml::directChildElements( elem, "query-result-element" );
TQValueListConstIterator<TQDomElement> it = list.begin();
for ( ; it != list.end(); ++it )
{
TQDomNamedNodeMap a = (*it).attributes();
m_view->addItem( KURL( (*it).attribute("image-location" ) ),
KURL( (*it).attribute("thumbnail-location" ) ),
(*it).attribute("calculated-similarity"));
}
}
else if ( tagName == "query-result" )
parseQueryResult( elem );
}
}
}
// creates/stops the query when the Start/Stop button was pressed
void MrmlPart::slotStartClicked()
{
if ( m_status == InProgress )
{
closeURL();
m_startButton->setText( i18n("&Search" ) );
return;
}
// we need to reconnect, if the initial openURL() didn't work due to
// the gift not being available.
if ( m_status == NeedCollection )
{
openURL( m_url );
return;
}
// cut off an eventual query and reference from the url, when the user
// performs a real query (otherwise restoreState() would restore and
// re-do the query from the URL
m_url.setRef( TQString() );
m_url.setQuery( TQString() );
createQuery();
m_browser->openURLNotify();
}
//
// relevantItems is 0L when called from slotStartClicked() and set to a
// non-empty list when called initially, from the commandline.
//
void MrmlPart::createQuery( const KURL::List * relevantItems )
{
if ( relevantItems && relevantItems->isEmpty() )
return;
TQDomDocument doc( "mrml" );
TQDomElement mrml = MrmlCreator::createMrml( doc,
sessionId(),
transactionId() );
Collection coll = currentCollection();
// tqDebug("** collection: name: %s, id: %s, valid: %i", coll.name().latin1(), coll.id().latin1(), coll.isValid());
Algorithm algo = firstAlgorithmForCollection( coll );
// tqDebug("** algorithm: name: %s, id: %s, valid: %i, collection-id: %s", algo.name().latin1(), algo.id().latin1(), algo.isValid(), algo.collectionId().latin1());
if ( algo.isValid() )
{
MrmlCreator::configureSession( mrml, algo, sessionId() );
}
TQDomElement query = MrmlCreator::addQuery( mrml,
m_resultSizeInput->value() );
if ( algo.isValid() )
query.setAttribute( MrmlShared::algorithmId(), algo.id() );
// ### result-cutoff, query-type?
// start-up with/without urls on the commandline via mrmlsearch
if ( relevantItems )
{
TQDomElement elem = MrmlCreator::addRelevanceList( query );
KURL::List::ConstIterator it = relevantItems->begin();
for ( ; it != relevantItems->end(); ++it )
MrmlCreator::createRelevanceElement( doc, elem, (*it).url(),
MrmlCreator::Relevant );
}
// get relevant items from the view? Only do this when relevantItems is 0L
else if ( !m_random->isChecked() )
{
TQDomElement relevants = MrmlCreator::addRelevanceList( query );
m_view->addRelevanceToQuery( doc, relevants );
}
performQuery( doc );
}
Collection MrmlPart::currentCollection() const
{
return m_collectionCombo->current();
}
Algorithm MrmlPart::firstAlgorithmForCollection( const Collection& coll ) const
{
if ( !m_algorithms.isEmpty() )
{
AlgorithmList::ConstIterator it = m_algorithms.begin();
for ( ; it != m_algorithms.end(); ++it )
{
Algorithm algo = *it;
if ( algo.paradigms().matches( coll.paradigms() ) )
{
algo.setCollectionId( coll.id() );
return algo;
}
}
}
tqDebug("#################### -> ADEFAULT!");
Algorithm algo = Algorithm::defaultAlgorithm();
algo.setCollectionId( coll.id() );
return algo;
}
// emits the given TQDomDocument for eventual plugins, checks after that
// if there are any relevance elements. If there are none, random search is
// implied and performed.
// finally, the search is actually started
void MrmlPart::performQuery( TQDomDocument& doc )
{
TQDomElement mrml = doc.documentElement();
emit aboutToStartQuery( doc ); // let plugins play with it :)
// no items available? All "neutral"? -> random search
TQDomElement queryStep = KMrml::firstChildElement( mrml, "query-step" );
bool randomSearch = false;
if ( !queryStep.isNull() )
{
TQDomElement relevanceList =
KMrml::firstChildElement(queryStep, "user-relevance-element-list");
TQValueList<TQDomElement> relevanceElements =
KMrml::directChildElements( relevanceList,
"user-relevance-element" );
randomSearch = relevanceElements.isEmpty();
if ( randomSearch )
{
m_random->setChecked( true );
m_random->setEnabled( false );
queryStep.setAttribute("query-type", "at-random");
// remove user-relevance-element-list element for random search
relevanceList.parentNode().removeChild( relevanceList );
}
}
else
{
KMessageBox::error( m_view, i18n("Error formulating the query. The "
"\"query-step\" element is missing."),
i18n("Query Error") );
}
m_job = transferJob( url() );
slotSetStatusBar( randomSearch ? i18n("Random search...") :
i18n("Searching...") );
m_job->addMetaData( MrmlShared::tdeio_task(), MrmlShared::tdeio_startQuery() );
tqDebug("\n\nSending XML:\n%s", doc.toString().latin1());
m_job->addMetaData( MrmlShared::mrml_data(), doc.toString() );
}
void MrmlPart::slotSetStatusBar( const TQString& text )
{
if ( text.isEmpty() )
emit setStatusBarText( i18n("Ready.") );
else
emit setStatusBarText( text );
}
void MrmlPart::slotActivated( const KURL& url, ButtonState button )
{
if ( button == Qt::LeftButton )
emit m_browser->openURLRequest( url );
else if ( button == Qt::MidButton )
emit m_browser->createNewWindow( url );
else if ( button == Qt::RightButton ) {
// enableExtensionActions( url, true ); // for now
emit m_browser->popupMenu( TQCursor::pos(), url, TQString() );
// enableExtensionActions( url, false );
}
}
void MrmlPart::enableExtensionActions( const KURL& url, bool enable )
{
bool del = KProtocolInfo::supportsDeleting( url );
emit m_browser->enableAction( "copy", enable );
emit m_browser->enableAction( "trash", del );
emit m_browser->enableAction( "del", del );
emit m_browser->enableAction( "shred", url.isLocalFile() );
emit m_browser->enableAction( "properties", enable );
// emit m_browser->enableAction( "print", enable ); // ### later
}
// only implemented because it's abstract in the baseclass
bool MrmlPart::openFile()
{
return false;
}
void MrmlPart::slotConfigureAlgorithm()
{
m_algoButton->setEnabled( false );
m_algoConfig = new AlgorithmDialog( m_algorithms, m_collections,
currentCollection(),
m_view, "algorithm configuration" );
connect( m_algoConfig, TQT_SIGNAL( applyClicked() ),
TQT_SLOT( slotApplyAlgoConfig() ));
connect( m_algoConfig, TQT_SIGNAL( finished() ),
TQT_SLOT( slotAlgoConfigFinished() ));
m_algoConfig->show();
}
void MrmlPart::slotApplyAlgoConfig()
{
// ###
}
void MrmlPart::slotAlgoConfigFinished()
{
if ( m_algoConfig->result() == TQDialog::Accepted )
slotApplyAlgoConfig();
m_algoButton->setEnabled( true );
m_algoConfig->deleteLater();
m_algoConfig = 0L;
}
void MrmlPart::initHostCombo()
{
m_hostCombo->clear();
m_hostCombo->insertStringList( m_config.hosts() );
}
void MrmlPart::slotHostComboActivated( const TQString& host )
{
ServerSettings settings = m_config.settingsForHost( host );
openURL( settings.getUrl() );
}
void MrmlPart::setStatus( Status status )
{
switch ( status )
{
case NeedCollection:
m_startButton->setText( i18n("&Connect") );
break;
case CanSearch:
m_startButton->setText( i18n("&Search") );
break;
case InProgress:
m_startButton->setText( i18n("Sto&p") );
break;
};
m_status = status;
}
void MrmlPart::saveState( TQDataStream& stream )
{
stream << url();
stream << m_sessionId;
stream << m_queryList;
// stream << m_algorithms;
// stream << m_collections;
stream << m_resultSizeInput->value();
stream << *m_collectionCombo;
m_view->saveState( stream );
}
void MrmlPart::restoreState( TQDataStream& stream )
{
KURL url;
stream >> url;
stream >> m_sessionId;
stream >> m_queryList;
// stream >> m_algorithms;
// stream >> m_collections;
int resultSize;
stream >> resultSize;
m_resultSizeInput->setValue( resultSize );
stream >> *m_collectionCombo;
m_view->restoreState( stream );
// openURL( url );
m_url = url;
}
TDEAboutData * MrmlPart::createAboutData()
{
TDEAboutData *data = new TDEAboutData(
"kmrml",
I18N_NOOP("MRML Client for TDE"),
KMRML_VERSION,
I18N_NOOP("A tool to search for images by their content"),
TDEAboutData::License_GPL,
I18N_NOOP("(c) 2001-2002, Carsten Pfeiffer"),
0,
I18N_NOOP("http://devel-home.kde.org/~pfeiffer/kmrml/") );
data->addAuthor( "Carsten Pfeiffer",
I18N_NOOP("Developer, Maintainer"),
"pfeiffer@kde.org" );
data->addCredit( "Wolfgang Mller",
I18N_NOOP("Developer of the GIFT, Helping Hand") );
return data;
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
#include "mrml_part.moc"

@ -1,14 +0,0 @@
[Desktop Entry]
Type=Service
Exec=blahfoo
Name=MRML View
MimeType=text/mrml
X-TDE-ServiceTypes=KParts/ReadOnlyPart
X-TDE-Library=libkmrmlpart
#X-TDE-BrowserView-AllowAsDefault=true
#X-TDE-BrowserView-HideFromMenus=true
#X-TDE-BrowserView-Args=IconView
#X-TDE-BrowserView-ModeProperty=viewMode
#X-TDE-BrowserView-ModePropertyValue=IconView
Icon=view_icon
X-TDE-InitialPreference=10

@ -1,177 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2001,2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MRMLPART_H
#define MRMLPART_H
#include <tqcstring.h>
#include <tqstringlist.h>
#include <kurl.h>
#include <tdeparts/factory.h>
#include <tdeparts/part.h>
#include <kmrml_config.h>
#include "mrml_elements.h"
class TQCheckBox;
class TQHGroupBox;
class TQPushButton;
class TDEAboutData;
class KComboBox;
class KIntNumInput;
namespace TDEIO {
class FileCopyJob;
class TransferJob;
}
namespace KMrml
{
class AlgorithmDialog;
class Browser;
class CollectionCombo;
class MrmlView;
class MrmlPart : public KParts::ReadOnlyPart
{
Q_OBJECT
public:
enum Status { NeedCollection, CanSearch, InProgress };
MrmlPart( TQWidget *parentWidget, const char *widgetName,
TQObject *parent, const char *name, const TQStringList& args );
~MrmlPart();
TQString sessionId() const { return m_sessionId; }
TQString transactionId() const { return TQString(); } // ###
void saveState( TQDataStream& stream );
void restoreState( TQDataStream& stream );
static TDEAboutData *createAboutData();
public slots:
virtual bool openURL( const KURL& );
virtual bool closeURL();
void slotActivated( const KURL& url, ButtonState );
protected:
virtual bool openFile();
Algorithm firstAlgorithmForCollection( const Collection& coll ) const;
Collection currentCollection() const;
signals:
/**
* allow plugins to extend the query
*/
void aboutToStartQuery( TQDomDocument& );
private slots:
void slotStartClicked();
void slotSetStatusBar( const TQString& );
void slotSetStatusBar( const KURL& url ) { slotSetStatusBar( url.prettyURL() ); }
void slotHostComboActivated( const TQString& );
void slotResult( TDEIO::Job * );
void slotData( TDEIO::Job *, const TQByteArray& );
void slotDownloadResult( TDEIO::Job * );
void slotConfigureAlgorithm();
void slotApplyAlgoConfig();
void slotAlgoConfigFinished();
private:
void createQuery( const KURL::List * relevantItems = 0L );
void initCollections( const TQDomElement& );
void initAlgorithms( const TQDomElement& );
void performQuery( TQDomDocument& doc );
void parseMrml( TQDomDocument& doc );
void parseQueryResult( TQDomElement& );
void enableExtensionActions( const KURL& url, bool enable );
TDEIO::TransferJob * transferJob( const KURL& url );
void initHostCombo();
void enableServerDependentWidgets( bool enable );
void setStatus( Status status );
void contactServer( const KURL& url );
void downloadReferenceFiles( const KURL::List& downloadList );
TDEIO::TransferJob *m_job;
MrmlView *m_view;
Config m_config;
KIntNumInput * m_resultSizeInput;
CollectionCombo * m_collectionCombo;
TQPushButton *m_algoButton;
TQHGroupBox *m_panel;
TQPushButton *m_startButton;
TQCheckBox *m_random;
Browser *m_browser;
AlgorithmDialog *m_algoConfig;
KComboBox *m_hostCombo;
TQPtrList<TDEIO::FileCopyJob> m_downloadJobs;
TQStringList m_tempFiles;
TQString m_sessionId;
KURL::List m_queryList; // a list of valid LOCAL (!) urls to query for
CollectionList m_collections;
AlgorithmList m_algorithms;
Status m_status;
static uint s_sessionId;
};
class PartFactory : public KParts::Factory
{
Q_OBJECT
public:
PartFactory();
~PartFactory();
static TDEInstance * instance();
protected:
virtual KParts::Part * createPartObject( TQWidget *parentWidget = 0,
const char *widgetName = 0,
TQObject *parent = 0,
const char *name = 0,
const char *classname = "KParts::Part",
const TQStringList& args = TQStringList() );
private:
static TDEInstance * s_instance;
};
}
#endif // MRMLPART_H

@ -1,480 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2001,2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <tqdom.h>
#include <tqlabel.h>
#include <tqpainter.h>
#include <tqtimer.h>
#include <tqtooltip.h>
#include <kcursor.h>
#include <kdatastream.h>
#include <tdelocale.h>
#include <kcombobox.h>
#include <kmimetype.h>
#include <kurl.h>
#include <kurldrag.h>
#include "loader.h"
#include "mrml_creator.h"
#include "mrml_view.h"
using namespace KMrml;
MrmlView::MrmlView( TQWidget *parent, const char *name )
: TQScrollView( parent, name )
{
setStaticBackground( true );
setResizePolicy( Manual );
setHScrollBarMode( AlwaysOff );
enableClipper( true ); // ### test this
m_items.setAutoDelete( true );
connect( Loader::self(), TQT_SIGNAL( finished(const KURL&, const TQByteArray&)),
TQT_SLOT( slotDownloadFinished( const KURL&, const TQByteArray& )));
m_timer = new TQTimer( this );
connect( m_timer, TQT_SIGNAL( timeout() ), TQT_SLOT( slotLayout() ));
// we need a pixmap to be shown when no thumbnail is available for a
// query result image
TQLabel l( i18n( "No thumbnail available" ), 0L );
l.setFixedSize( 80, 80 );
l.setAlignment( WordBreak | AlignCenter );
// l.setFrameStyle( TQLabel::Box | TQLabel::Plain );
// l.setLineWidth( 1 );
l.setPaletteBackgroundColor( TQt::white );
l.setPaletteForegroundColor( TQt::black );
m_unavailablePixmap = TQPixmap::grabWidget( &l );
}
MrmlView::~MrmlView()
{
}
MrmlViewItem * MrmlView::addItem( const KURL& url, const KURL& thumbURL,
const TQString& similarity )
{
bool ok;
double value = similarity.toDouble( &ok );
if ( !ok || value < 0.05 )
return 0L;
return addItem( url, thumbURL, value );
}
MrmlViewItem * MrmlView::addItem( const KURL& url, const KURL& thumbURL,
double similarity )
{
if ( !url.isValid() ) {
tqWarning( "MrmlPart: received malformed URL from query: %s",
url.prettyURL().isNull() ? "(null)" : url.prettyURL().latin1() );
return 0L;
}
// tqDebug("** url: %s", thumbURL.url().latin1());
MrmlViewItem *item = new MrmlViewItem( url, thumbURL, similarity, this );
TQPixmap *pixmap = getPixmap( thumbURL );
if ( pixmap )
item->setPixmap( *pixmap );
m_items.append( item );
m_timer->start( 0, true );
return item;
}
void MrmlView::addRelevanceToQuery( TQDomDocument& document,
TQDomElement& parent )
{
TQPtrListIterator<MrmlViewItem> it( m_items );
for( ; it.current(); ++it ) {
it.current()->createRelevanceElement( document, parent );
}
}
void MrmlView::clear()
{
m_items.clear(); // items are deleted and removed from scrollview
setContentsPos( 0, 0 );
}
TQPixmap * MrmlView::getPixmap( const KURL& url )
{
TQString u = url.url();
TQPixmap *pix = m_pixmapCache.find( u );
if ( pix )
return pix;
if ( url.isLocalFile() ) {
TQPixmap p;
if ( !p.load( url.path() ) )
p = m_unavailablePixmap;
m_pixmapCache.insert( u, p );
return m_pixmapCache.find( u );
}
else { // remote url, download with TDEIO
Loader::self()->requestDownload( url );
}
return 0L;
}
void MrmlView::slotDownloadFinished( const KURL& url, const TQByteArray& data )
{
TQPtrListIterator<MrmlViewItem> it( m_items );
for( ; it.current(); ++it ) {
MrmlViewItem *item = it.current();
if ( item->thumbURL() == url )
{
TQPixmap p;
if ( data.isEmpty() || !p.loadFromData( data ) )
p = m_unavailablePixmap;
m_pixmapCache.insert( url.url(), p );
item->setPixmap( p );
slotLayout();
return;
}
}
}
void MrmlView::stopDownloads()
{
Loader *loader = Loader::self();
TQPtrListIterator<MrmlViewItem> it( m_items );
for( ; it.current(); ++it ) {
MrmlViewItem *item = it.current();
if ( !item->hasRemotePixmap() )
loader->removeDownload( item->url() );
}
}
void MrmlView::slotLayout()
{
int itemWidth = 0;
TQPtrListIterator<MrmlViewItem> it( m_items );
for ( ; it.current(); ++it ) {
itemWidth = TQMAX( itemWidth, it.current()->sizeHint().width() );
}
if ( itemWidth == 0 )
return;
uint itemsPerRow = visibleWidth() / itemWidth;
int margin = (visibleWidth() - (itemsPerRow * itemWidth)) / 2;
int rowHeight = 0;
uint item = 0;
uint y = 5;
// pointing to the first item of a row
TQPtrListIterator<MrmlViewItem> rowIt( m_items );
for ( it.toFirst(); it.current(); ++it ) {
if ( item >= itemsPerRow ) {
item = 0;
y += rowHeight;
rowHeight = 0;
}
if ( item == 0 )
rowIt = it;
rowHeight = TQMAX( rowHeight, it.current()->sizeHint().height() );
addChild( it.current(), margin + item * itemWidth, y );
it.current()->show();
item++;
// resize all items of the current row so they all have the same size
if ( item >= itemsPerRow || it.atLast() )
{
for ( uint i = 0; (i < itemsPerRow && rowIt.current()); i++ )
{
rowIt.current()->resize( itemWidth, rowHeight );
++rowIt;
}
}
}
resizeContents( visibleWidth(), y + rowHeight );
}
void MrmlView::resizeEvent( TQResizeEvent *e )
{
int oldW = visibleWidth();
TQScrollView::resizeEvent( e );
if ( visibleWidth() != oldW )
slotLayout();
}
void MrmlView::saveState( TQDataStream& stream )
{
stream << m_items.count();
TQPtrListIterator<MrmlViewItem> it( m_items );
for( ; it.current(); ++it ) {
stream << *it.current();
}
}
void MrmlView::restoreState( TQDataStream& stream )
{
stopDownloads();
clear();
int count;
stream >> count;
KURL url, thumbURL;
double similarity;
TQ_UINT32 relevance;
MrmlViewItem *item;
for ( int i = 0; i < count; i++ )
{
stream >> url;
stream >> thumbURL;
stream >> similarity;
stream >> relevance;
item = addItem( url, thumbURL, similarity );
if ( item )
item->setRelevance( (MrmlViewItem::Relevance) relevance );
}
}
TQDataStream& KMrml::operator<<( TQDataStream& stream,
const KMrml::MrmlViewItem& item )
{
return stream << item.url()
<< item.thumbURL()
<< item.similarity()
<< static_cast<TQ_UINT32>( item.relevance() );
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
MrmlViewItem::MrmlViewItem( const KURL& url, const KURL& thumbURL,
double similarity, MrmlView *view,
const char *name )
: TQFrame( view->viewport() , name ),
m_view( view ),
m_url( url ),
m_thumbURL( thumbURL ),
similarityFullWidth( 120 ), // ###
m_hasRemotePixmap( false )
{
if ( m_similarity != -1 )
m_similarity = TQMAX( 0.0, TQMIN( 1.0, similarity ));
setFrameStyle( Panel | Sunken );
setMouseTracking( true );
m_combo = new KComboBox( this );
TQToolTip::add( m_combo, i18n("You can refine queries by giving feedback about the current result and pressing the Search button again.") );
m_combo->insertItem( i18n("Relevant"), Relevant );
m_combo->insertItem( i18n("Neutral"), Neutral );
m_combo->insertItem( i18n("Irrelevant"), Irrelevant );
m_combo->adjustSize();
m_combo->setCurrentItem( Neutral );
/*
if ( similarity > -1 )
TQToolTip::add( this, TQString::fromLatin1("<qt>%1<br>%1</qt>")
.arg( url )
.arg(i18n("Similarity: %1").arg( TQString::number(similarity))));
else
TQToolTip::add( this, TQString::fromLatin1("<qt>%1</qt>").arg( url ) );
*/
setMinimumSize( 130, 130 ); // ###
}
MrmlViewItem::~MrmlViewItem()
{
}
void MrmlViewItem::setPixmap( const TQPixmap& pix )
{
if ( !m_url.isLocalFile() )
m_hasRemotePixmap = true;
m_pixmap = pix;
adjustSize();
update();
}
void MrmlViewItem::paintEvent( TQPaintEvent *e )
{
TQFrame::paintEvent( e );
if ( !m_pixmap.isNull() ) {
bitBlt( this, pixmapX(), pixmapY(),
&m_pixmap, 0, 0, m_pixmap.width(), m_pixmap.height(),
CopyROP );
}
if ( m_similarity >= 0 ) {
TQPainter p( this );
TQPen pen( colorGroup().highlight(), 1, TQPen::SolidLine );
p.setPen( pen );
int x = margin;
int y = m_combo->y() - similarityHeight - 2;
int w = (int) (similarityFullWidth * m_similarity);
int h = similarityHeight;
p.drawRect( x, y, similarityFullWidth, h );
p.fillRect( x, y, w, h, colorGroup().highlight() );
}
}
void MrmlViewItem::resizeEvent( TQResizeEvent *e )
{
TQFrame::resizeEvent( e );
int y = height() - m_combo->height() - margin;
m_combo->move( width()/2 - m_combo->width()/2, y );
}
TQSize MrmlViewItem::sizeHint() const
{
int w = TQMAX( TQMAX(minimumHeight(), m_combo->width()), m_pixmap.width() );
w += 2 * margin;
int h = m_pixmap.isNull() ? margin : margin + spacing + m_pixmap.height();
h += (m_similarity > -1) ? similarityHeight + spacing : 0;
h += m_combo->height() + margin;
return TQSize( w, h );
}
void MrmlViewItem::mousePressEvent( TQMouseEvent *e )
{
TQFrame::mousePressEvent( e );
pressedPos.setX( 0 );
pressedPos.setY( 0 );
if ( e->button() == Qt::LeftButton || e->button() == Qt::MidButton ) {
if ( hitsPixmap( e->pos() ) )
pressedPos = e->pos();
}
else if ( e->button() == Qt::RightButton && hitsPixmap( e->pos() ) )
emit view()->activated( m_url, e->button() );
}
void MrmlViewItem::mouseMoveEvent( TQMouseEvent *e )
{
if ( hitsPixmap( e->pos() ) ) {
if ( !ownCursor() ) { // nice hacklet :)
setCursor( KCursor::handCursor() );
emit view()->onItem( m_url );
}
}
else {
if ( ownCursor() ) {
unsetCursor();
emit view()->onItem( KURL() );
}
}
if ( (e->state() & Qt::LeftButton) && !pressedPos.isNull() ) {
TQPoint dist = e->pos() - pressedPos;
if ( dist.manhattanLength() > TDEGlobalSettings::dndEventDelay() ) {
// start drag here
KURL::List urls;
// ### support multiple files?
urls.append( m_url );
KURLDrag *drag = new KURLDrag( urls, this );
drag->setPixmap( KMimeType::pixmapForURL( m_url ) );
drag->drag();
}
}
}
void MrmlViewItem::mouseReleaseEvent( TQMouseEvent *e )
{
if ( hitsPixmap( e->pos() )) {
TQPoint dist = e->pos() - pressedPos;
if ( dist.manhattanLength() < TDEGlobalSettings::dndEventDelay() ) {
emit view()->activated( m_url, e->button() );
}
}
}
bool MrmlViewItem::hitsPixmap( const TQPoint& pos ) const
{
if ( m_pixmap.isNull() )
return false;
if ( pos.x() > pixmapX() && pos.x() < pixmapX() + m_pixmap.width() &&
pos.y() > pixmapY() && pos.y() < pixmapY() + m_pixmap.height() )
return true;
return false;
}
void MrmlViewItem::createRelevanceElement( TQDomDocument& document,
TQDomElement& parent )
{
int rel = m_combo->currentItem();
if ( rel == Neutral )
return;
MrmlCreator::createRelevanceElement( document, parent, m_url.url(),
(rel == Relevant) ? MrmlCreator::Relevant : MrmlCreator::Irrelevant );
}
MrmlViewItem::Relevance MrmlViewItem::relevance() const
{
return (Relevance) m_combo->currentItem();
}
void MrmlViewItem::setRelevance( Relevance relevance )
{
m_combo->setCurrentItem( relevance );
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
int MrmlViewItemList::compareItems( TQPtrCollection::Item item1,
TQPtrCollection::Item item2 )
{
double s1 = (static_cast<MrmlViewItem*>( item1 ))->similarity();
double s2 = (static_cast<MrmlViewItem*>( item2 ))->similarity();
if ( s1 < s2 )
return 1;
else if ( s1 > s2 )
return -1;
else
return 0;
}
#include "mrml_view.moc"

@ -1,182 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MRML_VIEW_H
#define MRML_VIEW_H
#include <tqevent.h>
#include <tqframe.h>
#include <tqptrlist.h>
#include <tqpixmap.h>
#include <tqpixmapcache.h>
#include <tqscrollview.h>
class TQDomDocument;
class TQDomElement;
class TQTimer;
class KComboBox;
namespace KMrml
{
class MrmlViewItem;
class MrmlViewItemList : public TQPtrList<MrmlViewItem>
{
protected:
// sort by similarity
virtual int compareItems( TQPtrCollection::Item, TQPtrCollection::Item );
};
class MrmlView : public TQScrollView
{
friend class MrmlViewItem;
Q_OBJECT
public:
MrmlView( TQWidget *parent = 0L, const char *name = 0L );
~MrmlView();
MrmlViewItem * addItem( const KURL& url, const KURL& thumbURL,
const TQString& similarity );
MrmlViewItem * addItem( const KURL& url, const KURL& thumbURL,
double similarity );
void addRelevanceToQuery( TQDomDocument&, TQDomElement& parent );
void clear();
bool isEmpty() const { return m_items.isEmpty(); }
void stopDownloads();
void saveState( TQDataStream& stream );
void restoreState( TQDataStream& stream );
signals:
void activated( const KURL& url, ButtonState button );
void onItem( const KURL& url );
protected:
virtual void resizeEvent( TQResizeEvent * );
private slots:
void slotLayout();
void slotDownloadFinished( const KURL&, const TQByteArray& );
private:
/**
* @returns a _temporary_ pointer to a pixmap. Copy it!
*/
TQPixmap * getPixmap( const KURL& url );
MrmlViewItemList m_items;
TQTimer *m_timer;
TQPixmapCache m_pixmapCache;
TQPixmap m_unavailablePixmap;
};
class MrmlViewItem : public TQFrame
{
Q_OBJECT
public:
enum Relevance
{
Relevant = 0,
Neutral = 1,
Irrelevant = 2
};
MrmlViewItem( const KURL& url, const KURL& thumbURL, double similarity,
MrmlView *view, const char *name=0L );
virtual ~MrmlViewItem();
void setPixmap( const TQPixmap& pixmap );
void createRelevanceElement( TQDomDocument& document, TQDomElement& parent );
double similarity() const { return m_similarity; }
void setSimilarity( double value );
virtual TQSize sizeHint() const;
const KURL& url() const { return m_url; }
const KURL& thumbURL() const { return m_thumbURL; }
bool hasRemotePixmap() const { return !m_thumbURL.isLocalFile() && m_hasRemotePixmap; }
Relevance relevance() const;
void setRelevance( Relevance relevance );
protected:
virtual void paintEvent( TQPaintEvent * );
virtual void resizeEvent( TQResizeEvent * );
virtual void mousePressEvent( TQMouseEvent * );
virtual void mouseMoveEvent( TQMouseEvent * );
virtual void mouseReleaseEvent( TQMouseEvent * );
private:
bool hitsPixmap( const TQPoint& ) const;
MrmlView * view() const { return m_view; }
inline int pixmapX() const {
return TQMAX( margin, (width() - m_pixmap.width()) / 2);
}
inline int pixmapY() const {
return m_combo->y() - similarityHeight - m_pixmap.height() - margin;
}
KComboBox *m_combo; // for relevance
MrmlView *m_view;
KURL m_url;
KURL m_thumbURL;
TQPixmap m_pixmap;
double m_similarity;
const int similarityFullWidth;
bool m_hasRemotePixmap;
TQPoint pressedPos;
static const int spacing = 3;
static const int margin = 5;
static const int similarityHeight = 4;
};
TQDataStream& operator <<( TQDataStream& stream, const KMrml::MrmlViewItem& );
}
#endif // MRML_VIEW_H

@ -1,74 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// This little baby is called from Konqueror's popupmenu, when you hit
// "Search for similar images...". This program simply gets the URLs
// from Konqueror and creates a query of the form
// mrml://host.com/?relevant=url1;url2;url3;url4....
// By default, the mrml URL is mrml://localhost", but you can override that
// by editing ~/.trinity/share/config/tdeio_mrmlrc and adding
// [MRML Settings]
// Default URL=mrml://url.to.your.giftserver.com
//
// mrmlsearch will then invoke "kfmclient openURL query" to start open
// a new Konqueror window and perform the query.
#include <unistd.h>
#include <tqfile.h>
#include <tqstring.h>
#include <tdeconfig.h>
#include <tdeglobal.h>
#include <kinstance.h>
#include <kurl.h>
#include <kmrml_config.h>
extern "C" KDE_EXPORT int kdemain( int argc, char **argv )
{
TQString query;
for ( int i = 1; i < argc; i++ ) {
if ( i > 1 )
query += ';';
TQString path = TQFile::decodeName( argv[i] );
if ( path.at( 0 ) == '/' ) {
KURL u;
u.setPath( path );
path = u.url();
}
query.append( path );
}
TDEInstance instance( "tdeio_mrml" );
KMrml::Config config( instance.config() );
KMrml::ServerSettings settings = config.defaultSettings();
KURL url;
url.setProtocol( "mrml" );
url.setHost( settings.host );
query = KURL::encode_string_no_slash( query );
query.prepend( "?relevant=" ); // this is not encoded!
url.setQuery( query );
tqDebug("***** Query: %s ** URL: %s", query.latin1(), url.url().latin1());
return execlp( "kfmclient",
"kfmclient", "openURL", TQFile::encodeName(url.url()).data(),
"text/mrml", (void *)0 );
}

@ -1,206 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "propertysheet.h"
#include "mrml_elements.h"
#include "mrml_shared.h"
#include <knuminput.h>
#include <tqwidget.h>
using namespace KMrml;
template class TQValueList<TQDomElement>;
PropertySheet::PropertySheet()
{
init();
}
PropertySheet::PropertySheet( const TQDomElement& elem )
{
init();
initFromDOM( elem );
}
PropertySheet::PropertySheet( const PropertySheet& ps )
{
*this = ps;
}
PropertySheet& PropertySheet::operator= ( const PropertySheet& ps )
{
if ( &ps == this )
return *this;
m_visibility = ps.m_visibility;
m_type = ps.m_type;
m_caption = ps.m_caption;
m_id = ps.m_id;
m_sendType = ps.m_sendType;
m_sendName = ps.m_sendName;
m_sendValue = ps.m_sendValue;
m_minRange = ps.m_minRange;
m_maxRange = ps.m_maxRange;
m_stepSize = ps.m_stepSize;
m_minSubsetSize = ps.m_minSubsetSize;
m_maxSubsetSize = ps.m_maxSubsetSize;
// deep copy of m_subSheets
TQPtrListIterator<PropertySheet> it( ps.m_subSheets );
for ( ; it.current(); ++it )
m_subSheets.append( new PropertySheet( *it.current() ) );
return *this;
}
void PropertySheet::init()
{
m_subSheets.setAutoDelete( true );
m_visibility = Visible;
}
void PropertySheet::initFromDOM( const TQDomElement& elem )
{
m_subSheets.clear();
m_visibility = getVisibility( elem.attribute( MrmlShared::visibility() ));
m_type = getType( elem.attribute( MrmlShared::propertySheetType() ) );
m_caption = elem.attribute( MrmlShared::caption() );
m_id = elem.attribute( MrmlShared::propertySheetId() );
m_sendType = getSendType( elem.attribute( MrmlShared::sendType() ));
m_sendName = elem.attribute( MrmlShared::sendName() );
m_sendValue = elem.attribute( MrmlShared::sendValue() );
m_minRange = toInt( elem.attribute( MrmlShared::from() ));
m_maxRange = toInt( elem.attribute( MrmlShared::to() ));
m_stepSize = toInt( elem.attribute( MrmlShared::step() ));
m_minSubsetSize = toInt( elem.attribute( MrmlShared::minSubsetSize() ));
m_maxSubsetSize = toInt( elem.attribute( MrmlShared::maxSubsetSize() ));
TQValueList<TQDomElement> children =
KMrml::directChildElements( elem, MrmlShared::propertySheet() );
TQValueListConstIterator<TQDomElement> it = children.begin();
for ( ; it != children.end(); ++it )
m_subSheets.append( new PropertySheet( *it ) );
}
TQWidget * PropertySheet::createWidget( TQWidget */*parent*/, const char */*name*/ )
{
TQWidget *w = 0L;
switch ( m_type )
{
case Numeric:
{
// KIntNumInput *input = new KIntNumInput();
break;
}
case Subset:
{
if ( m_minSubsetSize == 1 && m_maxSubsetSize == 1 )
{
}
break;
}
default:
tqDebug("** can't create widget for type: %i", m_type);
}
return w;
}
//
// static methods
//
PropertySheet::Visibility PropertySheet::getVisibility( const TQString& value )
{
Visibility vis;
if ( value == MrmlShared::invisible() )
vis = Invisible;
else if ( value == MrmlShared::popup() )
vis = Popup;
else
vis = Visible; // default value
return vis;
}
PropertySheet::Type PropertySheet::getType( const TQString& value )
{
Type type = (Type) 0;
if ( value == MrmlShared::multiSet() )
type = MultiSet;
else if ( value == MrmlShared::subset() )
type = Subset;
else if ( value == MrmlShared::setElement() )
type = SetElement;
else if ( value == MrmlShared::boolean() )
type = Boolean;
else if ( value == MrmlShared::numeric() )
type = Numeric;
else if ( value == MrmlShared::textual() )
type = Textual;
else if ( value == MrmlShared::panel() )
type = Panel;
else if ( value == MrmlShared::clone() )
type = Clone;
else if ( value == MrmlShared::reference() )
type = Reference;
return type;
}
PropertySheet::SendType PropertySheet::getSendType( const TQString& value )
{
SendType type = (SendType) 0;
if ( value == MrmlShared::element() )
type = Element;
else if ( value == MrmlShared::attribute() )
type = Attribute;
else if ( value == MrmlShared::attributeName() )
type = AttributeName;
else if ( value == MrmlShared::attributeValue() )
type = AttributeValue;
else if ( value == MrmlShared::children() )
type = Children;
else if ( value == MrmlShared::none() )
type = None;
return type;
}
int PropertySheet::toInt( const TQString& value, int defaultValue )
{
bool ok = false;
int res = value.toInt( &ok );
return ok ? res : defaultValue;
}

@ -1,113 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef PROPERTYSHEET_H
#define PROPERTYSHEET_H
#include <tqdom.h>
#include <tqstring.h>
#include <tqptrlist.h>
class TQWidget;
namespace KMrml
{
class PropertySheet
{
public:
enum Type
{
MultiSet = 1, // ??
Subset, // radio-button/combobox or listbox
SetElement, // CheckBox -> disables/enables children?
Boolean, // CheckBox
Numeric, // Slider/Spinbox
Textual, // lineedit
Panel, // groupbox?
Clone,
Reference
};
enum Visibility
{
Visible,
Invisible,
Popup
};
enum SendType
{
Element = 1,
Attribute,
AttributeName,
AttributeValue,
Children,
None
};
PropertySheet();
PropertySheet( const TQDomElement& elem );
PropertySheet( const PropertySheet& ps );
~PropertySheet() {};
PropertySheet& operator=( const PropertySheet& ps );
bool isValid() const {
// required mrml attributes
return !m_id.isNull() && m_type != 0 && m_sendType != 0;
}
void initFromDOM( const TQDomElement& elem );
void toElement( TQDomElement& parent );
TQWidget * createWidget( TQWidget *parent, const char *name = 0 );
private:
static Visibility getVisibility( const TQString& value );
static Type getType( const TQString& value );
static SendType getSendType( const TQString& value );
static int toInt( const TQString& value, int defaultValue = 0 );
void init();
// update operator=() when adding data members!
TQPtrList<PropertySheet> m_subSheets;
Visibility m_visibility;
Type m_type;
TQString m_caption;
TQString m_id;
SendType m_sendType;
TQString m_sendName;
TQString m_sendValue;
int m_minRange;
int m_maxRange;
int m_stepSize;
// Type = Subset && m_minSubsetSize == m_maxSubsetSize == 1 -> Combobox
// or radio buttons.
// > max > 1 -> Listbox with multiselection
int m_minSubsetSize;
int m_maxSubsetSize;
};
}
#endif // PROPERTYSHEET_H

@ -1,121 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
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 General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "propertywidgets.h"
IntegerWidget::IntegerWidget( const PropertySheet& sheet,
TQWidget *parent, const char *name )
: TQHBox( parent, name )
{
}
IntegerWidget::~IntegerWidget()
{
}
int IntegerWidget::value() const
{
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
ComboWidget::ComboWidget( const PropertySheet& sheet,
TQWidget *parent, const char *name )
: TQHBox( parent, name )
{
}
ComboWidget::~ComboWidget()
{
}
TQString ComboWidget::value() const
{
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
CheckBoxWidget::CheckBoxWidget( const PropertySheet& sheet,
TQWidget *parent, const char *name )
: TQHBox( parent, name )
{
}
CheckBoxWidget::~CheckBoxWidget()
{
}
bool CheckBoxWidget::value() const
{
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
LineEditWidget::LineEditWidget( const PropertySheet& sheet,
TQWidget *parent, const char *name )
: TQHBox( parent, name )
{
}
LineEditWidget::~LineEditWidget()
{
}
TQString LineEditWidget::value() const
{
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
ListBoxWidget::ListBoxWidget( const PropertySheet& sheet,
TQWidget *parent, const char *name )
: TQHBox( parent, name )
{
}
ListBoxWidget::~ListBoxWidget()
{
}
TQStringList ListBoxWidget::value() const
{
}
#include "propertywidgets.moc"

@ -1,113 +0,0 @@
/* This file is part of the KDE project
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,