- Integrated the turtle search and download to the gui. Now the search handles both friend and turtle searching.

- added a console in config->server->F2F routing to be able to visualize turtle routing statistics

WARNING: this is not complete yet. The fllowing still needs to be done:
- detect duplicates in search results between turtle and friends search
- RegExpr search does ot work with turtle (still to code).
- search does not search own files. Is this really needed after all ?



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1540 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-08-16 20:10:53 +00:00
parent 44efa071f4
commit a293a39d1b
17 changed files with 384 additions and 160 deletions

View File

@ -57,7 +57,6 @@ const uint32_t MAX_UPNP_INIT = 10; /* seconds UPnP timeout */
/****
* #define CONN_DEBUG 1
***/
#define CONN_DEBUG 1
/****
* #define P3CONNMGR_NO_TCP_CONNECTIONS 1
***/
@ -667,14 +666,7 @@ void p3ConnectMgr::netUdpCheck()
/* get the addr from the configuration */
struct sockaddr_in iaddr = ownState.localaddr;
if(use_extr_addr_finder && mExtAddrFinder->hasValidIP(&tmpip))
{
extValid = true;
extAddr = tmpip ;
extAddr.sin_port = iaddr.sin_port ;
extAddrStable = true;
}
else if (mUpnpAddrValid)
if (mUpnpAddrValid)
{
extValid = true;
extAddr = mUpnpExtAddr;
@ -686,6 +678,13 @@ void p3ConnectMgr::netUdpCheck()
extAddr = mStunExtAddr;
extAddrStable = mStunAddrStable;
}
else if(use_extr_addr_finder && mExtAddrFinder->hasValidIP(&tmpip))
{
extValid = true;
extAddr = tmpip ;
extAddr.sin_port = iaddr.sin_port ;
extAddrStable = true;
}
if (extValid)
{
@ -1020,6 +1019,7 @@ bool p3ConnectMgr::stunCheck()
netReset();
}
#ifdef CONN_DEBUG
int i = 0;
for(i = 0; tou_getstunpeer(i, (struct sockaddr *) &raddr, &rlen,
(struct sockaddr *) &eaddr, &elen,
@ -1038,6 +1038,7 @@ bool p3ConnectMgr::stunCheck()
}
std::cerr << std::endl;
}
#endif
/* pass on udp status to dht */
if (tou_needstunpeers())

View File

@ -29,6 +29,7 @@
#include <inttypes.h>
#include <string>
#include <list>
#include <vector>
class RsTurtle;
extern RsTurtle *rsTurtle ;
@ -56,11 +57,11 @@ struct TurtleFileInfo
class RsTurtle
{
public:
enum FileSharingStrategy { SHARE_ENTIRE_NETWORK, SHARE_FRIENDS_ONLY } ;
RsTurtle() { _sharing_strategy = SHARE_ENTIRE_NETWORK ;}
virtual ~RsTurtle() {}
enum FileSharingStrategy { SHARE_ENTIRE_NETWORK, SHARE_FRIENDS_ONLY } ;
// Lauches a search request through the pipes, and immediately returns
// the request id, which will be further used by the gui to store results
// as they come back.
@ -85,6 +86,10 @@ class RsTurtle
void setFileSharingStrategy(FileSharingStrategy f) { _sharing_strategy = f ; }
// Get info from the turtle router. I use std strings to hide the internal structs.
virtual void getInfo(std::vector<std::vector<std::string> >&,std::vector<std::vector<std::string> >&,
std::vector<std::vector<std::string> >&,std::vector<std::vector<std::string> >&) const = 0;
protected:
FileSharingStrategy _sharing_strategy ;
};

View File

@ -1406,6 +1406,87 @@ bool p3turtle::performLocalHashSearch(const TurtleFileHash& hash,FileInfo& info)
return rsFiles->FileDetails(hash, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY, info);
}
static std::string printNumber(uint num,bool hex=false)
{
if(hex)
{
char tmp[100] ;
sprintf(tmp,"0x%08x",num) ;
return std::string(tmp) ;
}
else
{
std::ostringstream out ;
out << num ;
return out.str() ;
}
}
void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,
std::vector<std::vector<std::string> >& tunnels_info,
std::vector<std::vector<std::string> >& search_reqs_info,
std::vector<std::vector<std::string> >& tunnel_reqs_info) const
{
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
time_t now = time(NULL) ;
hashes_info.clear() ;
for(std::map<TurtleFileHash,TurtleFileHashInfo>::const_iterator it(_incoming_file_hashes.begin());it!=_incoming_file_hashes.end();++it)
{
hashes_info.push_back(std::vector<std::string>()) ;
std::vector<std::string>& hashes(hashes_info.back()) ;
hashes.push_back(it->first) ;
hashes.push_back(it->second.name) ;
hashes.push_back(printNumber(it->second.tunnels.size())) ;
hashes.push_back(printNumber(now - it->second.time_stamp)+" secs ago") ;
}
#ifdef A_VOIR
for(std::map<TurtleFileHash,FileInfo>::const_iterator it(_outgoing_file_hashes.begin());it!=_outgoing_file_hashes.end();++it)
std::cerr << " hash=0x" << it->first << ", name=" << it->second.fname << ", size=" << it->second.size << std::endl ;
#endif
tunnels_info.clear();
for(std::map<TurtleTunnelId,TurtleTunnel>::const_iterator it(_local_tunnels.begin());it!=_local_tunnels.end();++it)
{
tunnels_info.push_back(std::vector<std::string>()) ;
std::vector<std::string>& tunnel(tunnels_info.back()) ;
tunnel.push_back(printNumber(it->first,true)) ;
tunnel.push_back(rsPeers->getPeerName(it->second.local_src)) ;
tunnel.push_back(rsPeers->getPeerName(it->second.local_dst)) ;
tunnel.push_back(it->second.hash) ;
tunnel.push_back(printNumber(now-it->second.time_stamp)) ;
}
search_reqs_info.clear();
for(std::map<TurtleSearchRequestId,TurtleRequestInfo>::const_iterator it(_search_requests_origins.begin());it!=_search_requests_origins.end();++it)
{
search_reqs_info.push_back(std::vector<std::string>()) ;
std::vector<std::string>& search_req(search_reqs_info.back()) ;
search_req.push_back(printNumber(it->first,true)) ;
search_req.push_back(rsPeers->getPeerName(it->second.origin)) ;
search_req.push_back(printNumber(now - it->second.time_stamp)) ;
}
tunnel_reqs_info.clear();
for(std::map<TurtleSearchRequestId,TurtleRequestInfo>::const_iterator it(_tunnel_requests_origins.begin());it!=_tunnel_requests_origins.end();++it)
{
tunnel_reqs_info.push_back(std::vector<std::string>()) ;
std::vector<std::string>& tunnel_req(tunnel_reqs_info.back()) ;
tunnel_req.push_back(printNumber(it->first,true)) ;
tunnel_req.push_back(rsPeers->getPeerName(it->second.origin)) ;
tunnel_req.push_back(printNumber(now - it->second.time_stamp)) ;
}
}
#ifdef P3TURTLE_DEBUG
void p3turtle::dumpState()
{

View File

@ -227,6 +227,12 @@ class p3turtle: public p3Service, public pqiMonitor, public RsTurtle, public ftS
//
virtual void stopMonitoringFileTunnels(const std::string& file_hash) ;
// get info about tunnels
virtual void getInfo(std::vector<std::vector<std::string> >&,
std::vector<std::vector<std::string> >&,
std::vector<std::vector<std::string> >&,
std::vector<std::vector<std::string> >&) const ;
/************* from pqiMonitor *******************/
// Informs the turtle router that some peers are (dis)connected. This should initiate digging new tunnels,
// and closing other tunnels.

View File

@ -130,6 +130,7 @@ HEADERS += rshare.h \
gui/ExampleDialog.h \
gui/GamesDialog.h \
gui/PhotoDialog.h \
gui/TurtleRouterDialog.h \
gui/PhotoShow.h \
gui/LinksDialog.h \
gui/LibraryDialog.h \
@ -265,6 +266,7 @@ FORMS += gui/BlogDialog.ui \
gui/MainWindow.ui \
gui/ApplicationWindow.ui \
gui/ExampleDialog.ui \
gui/TurtleRouterDialog.ui \
gui/GamesDialog.ui \
gui/PhotoDialog.ui \
gui/PhotoShow.ui \
@ -344,6 +346,7 @@ SOURCES += main.cpp \
gui/TransfersDialog.cpp \
gui/graphframe.cpp \
gui/mainpagestack.cpp \
gui/TurtleRouterDialog.cpp \
gui/MainWindow.cpp \
gui/ApplicationWindow.cpp \
gui/ExampleDialog.cpp \

View File

@ -43,9 +43,7 @@
#include "MessengerWindow.h"
#include "HelpDialog.h"
#ifdef TURTLE_HOPPING
#include "gui/TurtleSearchDialog.h"
#endif
#include "gui/TurtleRouterDialog.h"
#include "statusbar/peerstatus.h"
#include "statusbar/dhtstatus.h"
@ -164,10 +162,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
ui.stackPages->add(peersDialog = new PeersDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_PEERS), tr("Friends"), grp));
#ifdef TURTLE_HOPPING
ui.stackPages->add(turtleDialog = new TurtleSearchDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_TURTLE), tr("Turtle"), grp));
#endif
// ui.stackPages->add(turtleDialog = new TurtleRouterDialog(ui.stackPages), createPageAction(QIcon(IMAGE_TURTLE), tr("Turtle"), grp));
ui.stackPages->add(searchDialog = new SearchDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_SEARCH), tr("Search"), grp));

View File

@ -38,10 +38,6 @@
#include "ApplicationWindow.h"
#include "PluginsPage.h"
#ifdef TURTLE_HOPPING
#include "TurtleSearchDialog.h"
#endif
#include "Preferences/PreferencesWindow.h"
#include "Preferences/rsharesettings.h"
@ -93,9 +89,6 @@ public:
NetworkDialog *networkDialog;
PeersDialog *peersDialog;
SearchDialog *searchDialog;
#ifdef TURTLE_HOPPING
TurtleSearchDialog *turtleDialog;
#endif
TransfersDialog *transfersDialog;
ChatDialog *chatDialog;
MessagesDialog *messagesDialog;

View File

@ -22,6 +22,7 @@
#include <rshare.h>
#include "ServerDialog.h"
#include <gui/TurtleRouterDialog.h>
#include <iostream>
#include <sstream>
@ -44,6 +45,10 @@ ServerDialog::ServerDialog(QWidget *parent)
connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) );
connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );
connect( ui._showTurtleDialogPB,SIGNAL(clicked()),this,SLOT( showTurtleRouterDialog() )) ;
ui._enableTurtleCB->setChecked(true) ;
ui._enableTurtleCB->setEnabled(false) ;
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
@ -68,6 +73,11 @@ ServerDialog::ServerDialog(QWidget *parent)
#endif
}
void ServerDialog::showTurtleRouterDialog()
{
TurtleRouterDialog::showUp() ;
}
void ServerDialog::toggleIpDetermination(bool b)
{
rsPeers->allowServerIPDetermination(b) ;

View File

@ -50,6 +50,7 @@ private slots:
void saveAddresses();
void toggleUPnP();
void toggleIpDetermination(bool) ;
void showTurtleRouterDialog();
private:
/** A RshareSettings object used for saving/loading settings */

View File

@ -716,6 +716,67 @@ behind a firewall or a VPN.</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>F2F routing</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="_enableTurtleCB">
<property name="text">
<string>enable anonymous F2F routing</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="_showTurtleDialogPB">
<property name="text">
<string>Show router statistics</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;RetroShare&lt;/span&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; is capable of transfering data and search requests between peers that are not necessarily friends. This traffic however only transits through a connected list of friends and is anonymous.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;If want to you use &lt;/span&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;RetroShare&lt;/span&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; to anonymously share and download files, leaving this checked drastically increases your download scope, and participate into the overall network bandwidth. &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;You can separately setup share flags for each shared directory:&lt;/span&gt;&lt;/p&gt;
&lt;ul style=&quot;-qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; font-size:8pt;&quot; style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Browsable by friends&lt;/span&gt;: files are browsable from your direct friends.&lt;/li&gt;
&lt;li style=&quot; font-size:8pt;&quot; style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Anonymously shared&lt;/span&gt;: files can be downloaded by anybody through anonymous tunnels.&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="2" column="0">

View File

@ -26,6 +26,7 @@
#include "rsiface/rsexpr.h"
#include "rsiface/rsfiles.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsturtle.h"
#include "util/misc.h"
#include <iostream>
@ -248,6 +249,10 @@ void SearchDialog::download()
(item->text(SR_REALSIZE_COL)).toInt(),
"", 0, srcIds);
rsTurtle->monitorFileTunnels( item->text(SR_NAME_COL).toStdString(),
item->text(SR_HASH_COL).toStdString(),
item->text(SR_REALSIZE_COL).toInt()) ;
std::cout << "isuing file request from search dialog: -" << (item->text(SR_NAME_COL)).toStdString() << "-" << (item->text(SR_HASH_COL)).toStdString() << "-" << (item->text(SR_REALSIZE_COL)).toInt() << "-ids=" ;
for(std::list<std::string>::const_iterator it(srcIds.begin());it!=srcIds.end();++it)
std::cout << *it << "-" << std::endl ;
@ -408,9 +413,10 @@ void SearchDialog::advancedSearch(Expression* expression)
/* call to core */
std::list<FileDetail> results;
rsFiles -> SearchBoolExp(expression, results);
qulonglong searchId = rand() ; // for now, because we need to call the turtle search to get a proper id.
/* abstraction to allow reusee of tree rendering code */
resultsToTree((advSearchDialog->getSearchAsString()).toStdString(), results);
resultsToTree((advSearchDialog->getSearchAsString()).toStdString(),searchId, results);
}
@ -422,6 +428,8 @@ void SearchDialog::searchKeywords()
std::cerr << "SearchDialog::searchKeywords() : " << txt << std::endl;
TurtleRequestId req_id = rsTurtle->turtleSearch(txt) ;
/* extract keywords from lineEdit */
QStringList qWords = qTxt.split(" ", QString::SkipEmptyParts);
std::list<std::string> words;
@ -441,7 +449,8 @@ void SearchDialog::searchKeywords()
std::list<FileDetail> initialResults;
std::list<FileDetail> * finalResults = 0;
rsFiles -> SearchKeywords(words, initialResults,DIR_FLAGS_LOCAL | DIR_FLAGS_REMOTE);
//rsFiles -> SearchKeywords(words, initialResults,DIR_FLAGS_LOCAL | DIR_FLAGS_REMOTE | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE);
rsFiles -> SearchKeywords(words, initialResults,DIR_FLAGS_REMOTE | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE);
/* which extensions do we use? */
QString qExt, qName;
int extIndex;
@ -451,7 +460,9 @@ void SearchDialog::searchKeywords()
if (ui.FileTypeComboBox->currentIndex() == FILETYPE_IDX_ANY)
{
finalResults = &initialResults;
} else {
}
else
{
finalResults = new std::list<FileDetail>;
// amend the text description of the search
txt += " (" + ui.FileTypeComboBox->currentText().toStdString() + ")";
@ -487,36 +498,83 @@ void SearchDialog::searchKeywords()
}
}
/* abstraction to allow reusee of tree rendering code */
resultsToTree(txt, *finalResults);
/* abstraction to allow reusee of tree rendering code */
resultsToTree(txt,req_id, *finalResults);
ui.lineEdit->clear();
}
void SearchDialog::resultsToTree(std::string txt, std::list<FileDetail> results)
void SearchDialog::updateFiles(qulonglong search_id,FileDetail file)
{
/* translate search results */
int searchId = nextSearchId++;
std::ostringstream out;
out << searchId;
/* which extensions do we use? */
std::string txt = ui.lineEdit->text().toStdString();
std::list<FileDetail>::iterator it;
for(it = results.begin(); it != results.end(); it++)
if (ui.FileTypeComboBox->currentIndex() == FILETYPE_IDX_ANY)
insertFile(txt,search_id,file);
else
{
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(SR_NAME_COL, QString::fromStdString(it->name));
item->setText(SR_HASH_COL, QString::fromStdString(it->hash));
item->setText(SR_SEARCH_ID_COL, QString::fromStdString(out.str()));
// amend the text description of the search
txt += " (" + ui.FileTypeComboBox->currentText().toStdString() + ")";
// collect the extensions to use
QString extStr = SearchDialog::FileTypeExtensionMap->value(ui.FileTypeComboBox->currentIndex());
QStringList extList = extStr.split(" ");
QString ext = QFileInfo(QString::fromStdString(it->name)).suffix();
if (ext == "jpg" || ext == "jpeg" || ext == "png" || ext == "gif"
|| ext == "bmp" || ext == "ico" || ext == "svg")
// get this file's extension
QString qName = QString::fromStdString(file.name);
int extIndex = qName.lastIndexOf(".");
if (extIndex >= 0)
{
QString qExt = qName.mid(extIndex+1);
if (qExt != "" )
for (int i = 0; i < extList.size(); ++i)
if (qExt.toUpper() == extList.at(i).toUpper())
insertFile(txt,search_id,file);
}
}
}
void SearchDialog::insertFile(const std::string& txt,qulonglong searchId, const FileDetail& file)
{
// algo:
//
// 1 - look in result window whether the file already exist.
// 1.1 - If yes, just increment the source number.
// 2.2 - Otherwize, add an entry.
// 2 - look in the summary whether there exist the same request id.
// 1.1 - If yes, just increment the result number.
// 2.2 - Otherwize, add an entry.
//
// 1 - look in result window whether the file already exists.
//
int items = ui.searchResultWidget->topLevelItemCount();
bool found = false ;
for(int i = 0; i < items; i++)
if(ui.searchResultWidget->topLevelItem(i)->text(SR_HASH_COL) == QString::fromStdString(file.hash)
&& ui.searchResultWidget->topLevelItem(i)->text(SR_SEARCH_ID_COL).toInt(NULL,16) == searchId)
{
int s = ui.searchResultWidget->topLevelItem(i)->text(SR_ID_COL).toInt() ;
ui.searchResultWidget->topLevelItem(i)->setText(SR_ID_COL,QString::number(s+1));
found = true ;
}
if(!found)
{
/* translate search results */
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(SR_NAME_COL, QString::fromStdString(file.name));
item->setText(SR_HASH_COL, QString::fromStdString(file.hash));
QString ext = QFileInfo(QString::fromStdString(file.name)).suffix();
if (ext == "jpg" || ext == "jpeg" || ext == "png" || ext == "gif" || ext == "bmp" || ext == "ico" || ext == "svg")
{
item->setIcon(SR_ICON_COL, QIcon(":/images/FileTypePicture.png"));
item->setText(SR_TYPE_COL, QString::fromUtf8("Picture"));
}
else if (ext == "avi" || ext == "mpg" || ext == "mpeg" || ext == "wmv"
|| ext == "mkv" || ext == "mp4" || ext == "flv" || ext == "mov"
|| ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp")
else if (ext == "avi" || ext == "mpg" || ext == "mpeg" || ext == "wmv" || ext == "mkv" || ext == "mp4" || ext == "flv" || ext == "mov" || ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp")
{
item->setIcon(SR_ICON_COL, QIcon(":/images/FileTypeVideo.png"));
item->setText(SR_TYPE_COL, QString::fromUtf8("Video"));
@ -526,15 +584,12 @@ void SearchDialog::resultsToTree(std::string txt, std::list<FileDetail> results)
item->setIcon(SR_ICON_COL, QIcon(":/images/FileTypeAudio.png"));
item->setText(SR_TYPE_COL, QString::fromUtf8("Audio"));
}
else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz"
|| ext == "rar" || ext == "rpm" || ext == "deb")
else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz" || ext == "rar" || ext == "rpm" || ext == "deb")
{
item->setIcon(SR_ICON_COL, QIcon(":/images/FileTypeArchive.png"));
item->setText(SR_TYPE_COL, QString::fromUtf8("Archive"));
}
else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com"
|| ext == "bin" || ext == "exe" || ext == "js" || ext == "pif"
|| ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws")
else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com" || ext == "bin" || ext == "exe" || ext == "js" || ext == "pif" || ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws")
{
item->setIcon(SR_ICON_COL, QIcon(":/images/FileTypeProgram.png"));
item->setText(SR_TYPE_COL, QString::fromUtf8("Program"));
@ -550,7 +605,7 @@ void SearchDialog::resultsToTree(std::string txt, std::list<FileDetail> results)
item->setText(SR_TYPE_COL, QString::fromUtf8("Document"));
}
else if (ext == "doc" || ext == "rtf" || ext == "sxw" || ext == "xls"
|| ext == "sxc" || ext == "odt" || ext == "ods")
|| ext == "sxc" || ext == "odt" || ext == "ods")
{
item->setIcon(SR_ICON_COL, QIcon(":/images/FileTypeDocument.png"));
item->setText(SR_TYPE_COL, QString::fromUtf8("Document"));
@ -565,57 +620,61 @@ void SearchDialog::resultsToTree(std::string txt, std::list<FileDetail> results)
item->setIcon(SR_ICON_COL, QIcon(":/images/FileTypeAny.png"));
}
/*
* to facilitate downlaods we need to save the file size too
*/
//QVariant * variant = new QVariant((qulonglong)it->size);
//item->setText(SR_SIZE_COL, QString(variant->toString()));
item->setText(SR_SIZE_COL, misc::friendlyUnit(it->size));
item->setText(SR_REALSIZE_COL, QString::number(it->size));
item->setText(SR_SIZE_COL, misc::friendlyUnit(file.size));
item->setText(SR_REALSIZE_COL, QString::number(file.size));
item->setTextAlignment( SR_SIZE_COL, Qt::AlignRight );
// I kept the color code green=online, grey=offline
// Qt::blue is very dark and hardly compatible with the black text on it.
//
if (it->id == "Local")
{
item->setText(SR_ID_COL, QString::fromStdString(it->id));
item->setText(SR_UID_COL, QString::fromStdString(rsPeers->getOwnId()));
item->setBackground(3, QBrush(Qt::red)); /* colour green? */
}
else
{
item->setText(SR_ID_COL, QString::fromStdString( rsPeers->getPeerName(it->id)));
item->setText(SR_UID_COL, QString::fromStdString( it->id));
if(rsPeers->isOnline(it->id))
item->setBackground(3, QBrush(Qt::green));
else
item->setBackground(3, QBrush(Qt::lightGray));
}
item->setText(SR_ID_COL, QString::number(1));
item->setText(SR_SEARCH_ID_COL, QString::number(searchId,16));
ui.searchResultWidget->addTopLevelItem(item);
}
/* add to the summary as well */
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(SS_TEXT_COL, QString::fromStdString(txt));
std::ostringstream out2;
out2 << results.size();
int items2 = ui.searchSummaryWidget->topLevelItemCount();
bool found2 = false ;
item->setText(SS_COUNT_COL, QString::fromStdString(out2.str()));
item->setText(SS_SEARCH_ID_COL, QString::fromStdString(out.str()));
for(int i = 0; i < items2; i++)
if(ui.searchSummaryWidget->topLevelItem(i)->text(SS_SEARCH_ID_COL).toInt(NULL,16) == searchId)
{
if(!found) // only increment result when it's a new item.
{
int s = ui.searchSummaryWidget->topLevelItem(i)->text(SS_COUNT_COL).toInt() ;
ui.searchSummaryWidget->topLevelItem(i)->setText(SS_COUNT_COL,QString::number(s+1));
}
found2 = true ;
}
ui.searchSummaryWidget->addTopLevelItem(item);
ui.searchSummaryWidget->setCurrentItem(item);
if(!found2)
{
QTreeWidgetItem *item2 = new QTreeWidgetItem();
item2->setText(SS_TEXT_COL, QString::fromStdString(txt));
item2->setText(SS_COUNT_COL, QString::number(1));
item2->setText(SS_SEARCH_ID_COL, QString::number(searchId,16));
ui.searchSummaryWidget->addTopLevelItem(item2);
ui.searchSummaryWidget->setCurrentItem(item2);
}
/* select this search result */
selectSearchResults();
}
void SearchDialog::resultsToTree(std::string txt,qulonglong searchId, const std::list<FileDetail>& results)
{
/* translate search results */
std::ostringstream out;
out << searchId;
std::list<FileDetail>::const_iterator it;
for(it = results.begin(); it != results.end(); it++)
insertFile(txt,searchId,*it) ;
}
//void QTreeWidget::currentItemChanged ( QTreeWidgetItem * current, QTreeWidgetItem * previous ) [signal]

View File

@ -29,13 +29,12 @@
//#include <config/rsharesettings.h>
#include <rsiface/rsfiles.h>
#include "mainpage.h"
#include "ui_SearchDialog.h"
#include "advsearch/advancedsearchdialog.h"
#include "Preferences/rsharesettings.h"
class FileDetail;
class SearchDialog : public MainPage
{
Q_OBJECT
@ -46,6 +45,9 @@ class SearchDialog : public MainPage
/** Default Destructor */
public slots:
void updateFiles(qulonglong request_id,FileDetail file) ;
private slots:
/** Create the context popup menu and it's submenus */
@ -84,7 +86,9 @@ private slots:
private:
/** render the results to the tree widget display */
void resultsToTree(std::string, std::list<FileDetail>);
void resultsToTree(std::string,qulonglong searchId, const std::list<FileDetail>&);
void insertFile(const std::string& txt,qulonglong searchId, const FileDetail& file) ;
/** the advanced search dialog instance */
AdvancedSearchDialog * advSearchDialog;

View File

@ -22,7 +22,7 @@
#include <list>
#include "rshare.h"
#include "TurtleSearchDialog.h"
#include "SearchDialog.h"
#include "rsiface/rsiface.h"
#include "rsiface/rsexpr.h"
#include "rsiface/rsfiles.h"
@ -71,19 +71,19 @@
/* static members */
/* These indices MUST be identical to their equivalent indices in the combobox */
const int TurtleSearchDialog::FILETYPE_IDX_ANY = 0;
const int TurtleSearchDialog::FILETYPE_IDX_ARCHIVE = 1;
const int TurtleSearchDialog::FILETYPE_IDX_AUDIO = 2;
const int TurtleSearchDialog::FILETYPE_IDX_CDIMAGE = 3;
const int TurtleSearchDialog::FILETYPE_IDX_DOCUMENT = 4;
const int TurtleSearchDialog::FILETYPE_IDX_PICTURE = 5;
const int TurtleSearchDialog::FILETYPE_IDX_PROGRAM = 6;
const int TurtleSearchDialog::FILETYPE_IDX_VIDEO = 7;
QMap<int, QString> * TurtleSearchDialog::FileTypeExtensionMap = new QMap<int, QString>();
bool TurtleSearchDialog::initialised = false;
const int SearchDialog::FILETYPE_IDX_ANY = 0;
const int SearchDialog::FILETYPE_IDX_ARCHIVE = 1;
const int SearchDialog::FILETYPE_IDX_AUDIO = 2;
const int SearchDialog::FILETYPE_IDX_CDIMAGE = 3;
const int SearchDialog::FILETYPE_IDX_DOCUMENT = 4;
const int SearchDialog::FILETYPE_IDX_PICTURE = 5;
const int SearchDialog::FILETYPE_IDX_PROGRAM = 6;
const int SearchDialog::FILETYPE_IDX_VIDEO = 7;
QMap<int, QString> * SearchDialog::FileTypeExtensionMap = new QMap<int, QString>();
bool SearchDialog::initialised = false;
/** Constructor */
TurtleSearchDialog::TurtleSearchDialog(QWidget *parent)
SearchDialog::SearchDialog(QWidget *parent)
: MainPage(parent),
advSearchDialog(NULL),
contextMnu(NULL), contextMnu2(NULL),
@ -93,7 +93,7 @@ TurtleSearchDialog::TurtleSearchDialog(QWidget *parent)
ui.setupUi(this);
/* initialise the filetypes mapping */
if (!TurtleSearchDialog::initialised)
if (!SearchDialog::initialised)
{
initialiseFileTypeMappings();
}
@ -181,22 +181,22 @@ TurtleSearchDialog::TurtleSearchDialog(QWidget *parent)
#endif
}
void TurtleSearchDialog::initialiseFileTypeMappings()
void SearchDialog::initialiseFileTypeMappings()
{
/* edit these strings to change the range of extensions recognised by the search */
TurtleSearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_ANY, "");
TurtleSearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_AUDIO, "aac aif iff m3u mid midi mp3 mpa ogg ra ram wav wma");
TurtleSearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_ARCHIVE, "7z bz2 gz pkg rar sea sit sitx tar zip");
TurtleSearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_CDIMAGE, "iso nrg mdf");
TurtleSearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_DOCUMENT, "doc odt ott rtf pdf ps txt log msg wpd wps" );
TurtleSearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_PICTURE, "3dm 3dmf ai bmp drw dxf eps gif ico indd jpe jpeg jpg mng pcx pcc pct pgm "
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_ANY, "");
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_AUDIO, "aac aif iff m3u mid midi mp3 mpa ogg ra ram wav wma");
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_ARCHIVE, "7z bz2 gz pkg rar sea sit sitx tar zip");
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_CDIMAGE, "iso nrg mdf");
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_DOCUMENT, "doc odt ott rtf pdf ps txt log msg wpd wps" );
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_PICTURE, "3dm 3dmf ai bmp drw dxf eps gif ico indd jpe jpeg jpg mng pcx pcc pct pgm "
"pix png psd psp qxd qxprgb sgi svg tga tif tiff xbm xcf");
TurtleSearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_PROGRAM, "app bat cgi com bin exe js pif py pl sh vb ws ");
TurtleSearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_VIDEO, "3gp asf asx avi mov mp4 mkv flv mpeg mpg qt rm swf vob wmv");
TurtleSearchDialog::initialised = true;
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_PROGRAM, "app bat cgi com bin exe js pif py pl sh vb ws ");
SearchDialog::FileTypeExtensionMap->insert(FILETYPE_IDX_VIDEO, "3gp asf asx avi mov mp4 mkv flv mpeg mpg qt rm swf vob wmv");
SearchDialog::initialised = true;
}
void TurtleSearchDialog::searchtableWidgetCostumPopupMenu( QPoint point )
void SearchDialog::searchtableWidgetCostumPopupMenu( QPoint point )
{
// block the popup if no results available
if ((ui.searchResultWidget->selectedItems()).size() == 0) return;
@ -229,7 +229,7 @@ void TurtleSearchDialog::searchtableWidgetCostumPopupMenu( QPoint point )
}
void TurtleSearchDialog::download()
void SearchDialog::download()
{
/* should also be able to handle multi-selection */
QList<QTreeWidgetItem*> itemsForDownload = ui.searchResultWidget->selectedItems();
@ -244,7 +244,7 @@ void TurtleSearchDialog::download()
if(item->text(SR_ID_COL) != "Local")
{
std::cerr << "TurtleSearchDialog::download() Calling File Request";
std::cerr << "SearchDialog::download() Calling File Request";
#ifdef TO_DO
// This is disabled, although it still works for friends files. Indeed, one must first
// warn the turtle router to digg tunnels for the given hashes, then call rsFiles.
@ -275,14 +275,14 @@ void TurtleSearchDialog::download()
}
void TurtleSearchDialog::broadcastonchannel()
void SearchDialog::broadcastonchannel()
{
QMessageBox::warning(0, tr("Sorry"), tr("This function is not yet implemented."));
}
void TurtleSearchDialog::recommendtofriends()
void SearchDialog::recommendtofriends()
{
QMessageBox::warning(0, tr("Sorry"), tr("This function is not yet implemented."));
@ -290,7 +290,7 @@ void TurtleSearchDialog::recommendtofriends()
/** context menu searchTablewidget2 **/
void TurtleSearchDialog::searchtableWidget2CostumPopupMenu( QPoint point )
void SearchDialog::searchtableWidget2CostumPopupMenu( QPoint point )
{
// block the popup if no results available
@ -317,7 +317,7 @@ void TurtleSearchDialog::searchtableWidget2CostumPopupMenu( QPoint point )
}
/** remove selected search result **/
void TurtleSearchDialog::searchRemove()
void SearchDialog::searchRemove()
{
/* get the current search id from the summary window */
QTreeWidgetItem *ci = ui.searchSummaryWidget->currentItem();
@ -327,7 +327,7 @@ void TurtleSearchDialog::searchRemove()
/* get the searchId text */
QString searchId = ci->text(SS_SEARCH_ID_COL);
std::cerr << "TurtleSearchDialog::searchRemove(): searchId: " << searchId.toStdString();
std::cerr << "SearchDialog::searchRemove(): searchId: " << searchId.toStdString();
std::cerr << std::endl;
/* show only matching searchIds in main window */
@ -359,7 +359,7 @@ void TurtleSearchDialog::searchRemove()
}
/** remove all search results **/
void TurtleSearchDialog::searchRemoveAll()
void SearchDialog::searchRemoveAll()
{
ui.searchResultWidget->clear();
ui.searchSummaryWidget->clear();
@ -370,13 +370,13 @@ void TurtleSearchDialog::searchRemoveAll()
Advanced search implementation
*******************************************************************/
// Event handlers for hide and show events
void TurtleSearchDialog::hideEvent(QHideEvent * event)
void SearchDialog::hideEvent(QHideEvent * event)
{
showAdvSearchDialog(false);
MainPage::hideEvent(event);
}
void TurtleSearchDialog::toggleAdvancedSearchDialog(bool toggled)
void SearchDialog::toggleAdvancedSearchDialog(bool toggled)
{
// record the users preference for future reference
RshareSettings rsharesettings;
@ -386,7 +386,7 @@ void TurtleSearchDialog::toggleAdvancedSearchDialog(bool toggled)
showAdvSearchDialog(toggled);
}
void TurtleSearchDialog::showAdvSearchDialog(bool show)
void SearchDialog::showAdvSearchDialog(bool show)
{
// instantiate if about to show for the first time
if (advSearchDialog == 0 && show)
@ -404,7 +404,7 @@ void TurtleSearchDialog::showAdvSearchDialog(bool show)
}
}
void TurtleSearchDialog::advancedSearch(Expression* expression)
void SearchDialog::advancedSearch(Expression* expression)
{
// advSearchDialog->hide();
//
@ -418,7 +418,7 @@ void TurtleSearchDialog::advancedSearch(Expression* expression)
void TurtleSearchDialog::searchKeywords()
void SearchDialog::searchKeywords()
{
QString qTxt = ui.lineEdit->text();
std::string txt = qTxt.toStdString();
@ -426,7 +426,7 @@ void TurtleSearchDialog::searchKeywords()
TurtleRequestId id = rsTurtle->turtleSearch(txt) ;
}
void TurtleSearchDialog::updateFiles(qulonglong search_id,TurtleFileInfo file)
void SearchDialog::updateFiles(qulonglong search_id,TurtleFileInfo file)
{
/* which extensions do we use? */
std::string txt = ui.lineEdit->text().toStdString();
@ -438,7 +438,7 @@ void TurtleSearchDialog::updateFiles(qulonglong search_id,TurtleFileInfo file)
// amend the text description of the search
txt += " (" + ui.FileTypeComboBox->currentText().toStdString() + ")";
// collect the extensions to use
QString extStr = TurtleSearchDialog::FileTypeExtensionMap->value(ui.FileTypeComboBox->currentIndex());
QString extStr = SearchDialog::FileTypeExtensionMap->value(ui.FileTypeComboBox->currentIndex());
QStringList extList = extStr.split(" ");
// get this file's extension
@ -457,7 +457,7 @@ void TurtleSearchDialog::updateFiles(qulonglong search_id,TurtleFileInfo file)
}
}
void TurtleSearchDialog::insertFile(const std::string& txt,qulonglong searchId, const TurtleFileInfo& file)
void SearchDialog::insertFile(const std::string& txt,qulonglong searchId, const TurtleFileInfo& file)
{
// algo:
//
@ -591,7 +591,7 @@ void TurtleSearchDialog::insertFile(const std::string& txt,qulonglong searchId,
//void QTreeWidget::currentItemChanged ( QTreeWidgetItem * current, QTreeWidgetItem * previous ) [signal]
void TurtleSearchDialog::selectSearchResults()
void SearchDialog::selectSearchResults()
{
/* highlight this search in summary window */
QTreeWidgetItem *ci = ui.searchSummaryWidget->currentItem();
@ -601,7 +601,7 @@ void TurtleSearchDialog::selectSearchResults()
/* get the searchId text */
QString searchId = ci->text(SS_SEARCH_ID_COL);
std::cerr << "TurtleSearchDialog::selectSearchResults(): searchId: " << searchId.toStdString();
std::cerr << "SearchDialog::selectSearchResults(): searchId: " << searchId.toStdString();
std::cerr << std::endl;
/* show only matching searchIds in main window */

View File

@ -129,20 +129,20 @@ int main(int argc, char *argv[])
// I'm using a signal to transfer the hashing info to the mainwindow, because Qt schedules signals properly to
// avoid clashes between infos from threads.
//
QObject::connect(notify,SIGNAL(hashingInfoChanged(const QString&)),w ,SLOT(updateHashingInfo(const QString&))) ;
#ifdef TURTLE_HOPPING
qRegisterMetaType<TurtleFileInfo>("TurtleFileInfo") ;
qRegisterMetaType<FileDetail>("FileDetail") ;
std::cerr << "connecting signals and slots" << std::endl ;
QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,TurtleFileInfo)),w->turtleDialog,SLOT(updateFiles(qulonglong,TurtleFileInfo))) ;
#endif
QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->sharedfilesDialog,SLOT(preModDirectories(bool) )) ;
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog,SLOT(postModDirectories(bool) )) ;
QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ;
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->messengerWindow ,SLOT(insertPeers() )) ;
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->peersDialog ,SLOT(insertPeers() )) ;
QObject::connect(notify,SIGNAL(neighborsChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ;
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
QObject::connect(notify,SIGNAL(configChanged()) ,w->messagesDialog ,SLOT(displayConfig() )) ;
QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ;
QObject::connect(notify,SIGNAL(hashingInfoChanged(const QString&)),w ,SLOT(updateHashingInfo(const QString&))) ;
QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->sharedfilesDialog ,SLOT(preModDirectories(bool) )) ;
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog ,SLOT(postModDirectories(bool) )) ;
QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ;
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->messengerWindow ,SLOT(insertPeers() )) ;
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->peersDialog ,SLOT(insertPeers() )) ;
QObject::connect(notify,SIGNAL(neighborsChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ;
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
QObject::connect(notify,SIGNAL(configChanged()) ,w->messagesDialog ,SLOT(displayConfig() )) ;
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&)));
QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)),w->networkDialog,SLOT(setLogInfo(QString))) ;

View File

@ -45,15 +45,23 @@ void NotifyQt::notifyChatStatus(const std::string& peer_id,const std::string& st
emit chatStatusChanged(QString::fromStdString(peer_id),QString::fromStdString(status_string)) ;
}
#ifdef TURTLE_HOPPING
void NotifyQt::notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleFileInfo>& files)
{
std::cerr << "in notify search result..." << std::endl ;
for(std::list<TurtleFileInfo>::const_iterator it(files.begin());it!=files.end();++it)
emit gotTurtleSearchResult(search_id,*it) ;
{
FileDetail det ;
det.rank = 0 ;
det.age = 0 ;
det.name = (*it).name ;
det.hash = (*it).hash ;
det.id = "Anonymous" ;
emit gotTurtleSearchResult(search_id,det) ;
}
}
#endif
void NotifyQt::notifyHashingInfo(std::string fileinfo)
{
emit hashingInfoChanged(QString::fromStdString(fileinfo)) ;

View File

@ -2,6 +2,7 @@
#define RSIFACE_NOTIFY_TXT_H
#include "rsiface/rsiface.h"
#include "rsiface/rsturtle.h"
#include <QObject>
#include <string>
@ -14,12 +15,7 @@ class ChatDialog;
class MessagesDialog;
class ChannelsDialog;
class MessengerWindow;
#ifdef TURTLE_HOPPING
#include "rsiface/rsturtle.h"
class TurtleSearchDialog ;
struct TurtleFileInfo ;
#endif
//class NotifyQt: public NotifyBase, public QObject
class NotifyQt: public QObject, public NotifyBase
@ -52,9 +48,7 @@ class NotifyQt: public QObject, public NotifyBase
// virtual void notifyChat();
virtual void notifyChatStatus(const std::string& peer_id,const std::string& status_string);
virtual void notifyHashingInfo(std::string fileinfo);
#ifdef TURTLE_HOPPING
virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleFileInfo>& found_files);
#endif
signals:
// It's beneficial to send info to the GUI using signals, because signals are thread-safe
@ -70,9 +64,7 @@ class NotifyQt: public QObject, public NotifyBase
void configChanged() const ;
void logInfoChanged(const QString&) const ;
void chatStatusChanged(const QString&,const QString&) const ;
#ifdef TURTLE_HOPPING
void gotTurtleSearchResult(qulonglong search_id,TurtleFileInfo file) const ;
#endif
void gotTurtleSearchResult(qulonglong search_id,FileDetail file) const ;
public slots:

View File

@ -29,6 +29,7 @@
#include <inttypes.h>
#include <string>
#include <list>
#include <vector>
class RsTurtle;
extern RsTurtle *rsTurtle ;
@ -56,11 +57,11 @@ struct TurtleFileInfo
class RsTurtle
{
public:
enum FileSharingStrategy { SHARE_ENTIRE_NETWORK, SHARE_FRIENDS_ONLY } ;
RsTurtle() { _sharing_strategy = SHARE_ENTIRE_NETWORK ;}
virtual ~RsTurtle() {}
enum FileSharingStrategy { SHARE_ENTIRE_NETWORK, SHARE_FRIENDS_ONLY } ;
// Lauches a search request through the pipes, and immediately returns
// the request id, which will be further used by the gui to store results
// as they come back.
@ -85,6 +86,10 @@ class RsTurtle
void setFileSharingStrategy(FileSharingStrategy f) { _sharing_strategy = f ; }
// Get info from the turtle router. I use std strings to hide the internal structs.
virtual void getInfo(std::vector<std::vector<std::string> >&,std::vector<std::vector<std::string> >&,
std::vector<std::vector<std::string> >&,std::vector<std::vector<std::string> >&) const = 0;
protected:
FileSharingStrategy _sharing_strategy ;
};