You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.5 KiB
95 lines
3.5 KiB
15 years ago
|
/*
|
||
|
This file is part of KDE.
|
||
|
|
||
|
Copyright (c) 2005 Tobias Koenig <tokoe@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; if not, write to the Free Software
|
||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
|
||
|
As a special exception, permission is given to link this program
|
||
14 years ago
|
with any edition of TQt, and distribute the resulting executable,
|
||
|
without including the source code for TQt in the source distribution.
|
||
15 years ago
|
*/
|
||
|
|
||
4 years ago
|
#include "googlesearch.h"
|
||
15 years ago
|
#include "resultelement.h"
|
||
|
#include "resultelementarray.h"
|
||
|
|
||
|
GoogleSearch::GoogleSearch()
|
||
15 years ago
|
: TQObject( 0, "" )
|
||
15 years ago
|
{
|
||
15 years ago
|
connect( &mService, TQT_SIGNAL( doGetCachedPageResponse( TQByteArray* ) ),
|
||
|
this, TQT_SLOT( cachedPageResult( TQByteArray* ) ) );
|
||
|
connect( &mService, TQT_SIGNAL( doSpellingSuggestionResponse( TQString* ) ),
|
||
|
this, TQT_SLOT( spellingSuggestionResult( TQString* ) ) );
|
||
|
connect( &mService, TQT_SIGNAL( doGoogleSearchResponse( GoogleSearchResult* ) ),
|
||
|
this, TQT_SLOT( googleSearchResult( GoogleSearchResult* ) ) );
|
||
15 years ago
|
|
||
|
mKey = "";
|
||
|
}
|
||
|
|
||
15 years ago
|
void GoogleSearch::cachedPage( const TQString &url )
|
||
15 years ago
|
{
|
||
15 years ago
|
mService.doGetCachedPage( new TQString( mKey ), new TQString( url ) );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void GoogleSearch::spellingSuggestion( const TQString &phrase )
|
||
15 years ago
|
{
|
||
15 years ago
|
mService.doSpellingSuggestion( new TQString( mKey ), new TQString( phrase ) );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void GoogleSearch::googleSearch( const TQString &query, int start, int maxResults, bool filter,
|
||
|
const TQString &restrict, bool safeSearch, const TQString &lr, const TQString &ie,
|
||
|
const TQString &oe )
|
||
15 years ago
|
{
|
||
15 years ago
|
mService.doGoogleSearch( new TQString( mKey ), new TQString( query ), new int( start ), new int( maxResults ),
|
||
|
new bool( filter ), new TQString( restrict ), new bool( safeSearch ), new TQString( lr ),
|
||
|
new TQString( ie ), new TQString( oe ) );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void GoogleSearch::cachedPageResult( TQByteArray *array )
|
||
15 years ago
|
{
|
||
13 years ago
|
tqDebug( "--------------- Cached Page Results ---------------------" );
|
||
|
tqDebug( "%s", array->data() );
|
||
|
tqDebug( "---------------------------------------------------------" );
|
||
15 years ago
|
|
||
|
delete array;
|
||
|
}
|
||
|
|
||
15 years ago
|
void GoogleSearch::spellingSuggestionResult( TQString *word )
|
||
15 years ago
|
{
|
||
13 years ago
|
tqDebug( "--------------- Spelling Suggestion ---------------------" );
|
||
|
tqDebug( "%s", word->latin1() );
|
||
|
tqDebug( "---------------------------------------------------------" );
|
||
15 years ago
|
|
||
|
delete word;
|
||
|
}
|
||
|
|
||
|
void GoogleSearch::googleSearchResult( GoogleSearchResult *result )
|
||
|
{
|
||
13 years ago
|
tqDebug( "--------------------- Search Results ---------------------" );
|
||
15 years ago
|
ResultElementArray *array = result->resultElements();
|
||
15 years ago
|
TQPtrList<ResultElement> *list = array->items();
|
||
|
TQPtrListIterator<ResultElement> it( *list );
|
||
15 years ago
|
while ( it.current() != 0 ) {
|
||
13 years ago
|
tqDebug( "%s: %s", it.current()->summary()->latin1(), it.current()->uRL()->latin1() );
|
||
15 years ago
|
++it;
|
||
|
}
|
||
13 years ago
|
tqDebug( "---------------------------------------------------------" );
|
||
15 years ago
|
|
||
|
delete result;
|
||
|
}
|
||
|
|
||
|
#include "googlesearch.moc"
|