mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
- Added basic infrastructure to plugin system in libretroshare and retroshare-gui.
- ported LinksCloud to a new plugin, and removed it from main sources Next moves: - add gui for managing plugins - handle windows compilation git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4275 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3925a7114a
commit
a2c91a7924
28 changed files with 4676 additions and 243 deletions
124
plugins/LinksCloud/AddLinksDialog.cpp
Normal file
124
plugins/LinksCloud/AddLinksDialog.cpp
Normal file
|
@ -0,0 +1,124 @@
|
|||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2008 Robert Fernie
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
#include <gui/common/vmessagebox.h>
|
||||
|
||||
#include "AddLinksDialog.h"
|
||||
#include <gui/RetroShareLink.h>
|
||||
#include "rsrank.h"
|
||||
|
||||
/* Images for context menu icons */
|
||||
#define IMAGE_EXPORTFRIEND ":/images/exportpeers_16x16.png"
|
||||
#define IMAGE_GREAT ":/images/filerating5.png"
|
||||
#define IMAGE_GOOD ":/images/filerating4.png"
|
||||
#define IMAGE_OK ":/images/filerating3.png"
|
||||
#define IMAGE_SUX ":/images/filerating2.png"
|
||||
#define IMAGE_BADLINK ":/images/filerating1.png"
|
||||
|
||||
/** Constructor */
|
||||
AddLinksDialog::AddLinksDialog(QString url, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
/* add button */
|
||||
connect(ui.addLinkButton, SIGNAL(clicked()), this, SLOT(addLinkComment()));
|
||||
connect(ui.closepushButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||
|
||||
connect( ui.anonBox, SIGNAL( stateChanged ( int ) ), this, SLOT( load ( void ) ) );
|
||||
|
||||
ui.linkLineEdit->setText(url);
|
||||
|
||||
RetroShareLink link(url);
|
||||
|
||||
if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
|
||||
ui.titleLineEdit->setText(link.name());
|
||||
else
|
||||
ui.titleLineEdit->setText("New File");
|
||||
|
||||
load();
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
int AddLinksDialog::IndexToScore(int index)
|
||||
{
|
||||
if ((index == -1) || (index > 4))
|
||||
return 0;
|
||||
int score = 2 - index;
|
||||
return score;
|
||||
}
|
||||
|
||||
void AddLinksDialog::addLinkComment()
|
||||
{
|
||||
/* get the title / link / comment */
|
||||
QString title = ui.titleLineEdit->text();
|
||||
QString link = ui.linkLineEdit->text();
|
||||
QString comment = ui.linkTextEdit->toPlainText();
|
||||
int32_t score = AddLinksDialog::IndexToScore(ui.scoreBox->currentIndex());
|
||||
|
||||
if ((link == "") || (title == ""))
|
||||
{
|
||||
QMessageBox::warning(NULL, tr("Add Link Failure"), tr("Missing Link and/or Title"), QMessageBox::Ok);
|
||||
/* can't do anything */
|
||||
return;
|
||||
}
|
||||
|
||||
/* add it either way */
|
||||
if (ui.anonBox->isChecked())
|
||||
{
|
||||
rsRanks->anonRankMsg("", link.toStdWString(), title.toStdWString());
|
||||
}
|
||||
else
|
||||
{
|
||||
rsRanks->newRankMsg(link.toStdWString(),
|
||||
title.toStdWString(),
|
||||
comment.toStdWString(), score);
|
||||
}
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void AddLinksDialog::load()
|
||||
{
|
||||
if (ui.anonBox->isChecked())
|
||||
{
|
||||
|
||||
/* disable comment + score */
|
||||
ui.scoreBox->setEnabled(false);
|
||||
ui.linkTextEdit->setEnabled(false);
|
||||
|
||||
/* done! */
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable comment + score */
|
||||
ui.scoreBox->setEnabled(true);
|
||||
ui.linkTextEdit->setEnabled(true);
|
||||
}
|
||||
}
|
48
plugins/LinksCloud/AddLinksDialog.h
Normal file
48
plugins/LinksCloud/AddLinksDialog.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2008 Robert Fernie
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef _ADDLINKS_DIALOG_H
|
||||
#define _ADDLINKS_DIALOG_H
|
||||
|
||||
#include "ui_AddLinksDialog.h"
|
||||
|
||||
class AddLinksDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
AddLinksDialog(QString url, QWidget *parent = 0);
|
||||
/** Default Destructor */
|
||||
|
||||
static int IndexToScore(int index);
|
||||
|
||||
public slots:
|
||||
void addLinkComment();
|
||||
|
||||
void load();
|
||||
|
||||
private:
|
||||
/** Qt Designer generated object */
|
||||
Ui::AddLinksDialog ui;
|
||||
};
|
||||
|
||||
#endif
|
288
plugins/LinksCloud/AddLinksDialog.ui
Normal file
288
plugins/LinksCloud/AddLinksDialog.ui
Normal file
|
@ -0,0 +1,288 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AddLinksDialog</class>
|
||||
<widget class="QDialog" name="AddLinksDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>614</width>
|
||||
<height>415</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Add Link</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="4">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>52</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QFrame#frame{background-image: url(:/images/connect/connectFriendBanner.png);}
|
||||
</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="linksiconlabel">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="images.qrc">:/images/irkick.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:18pt; font-weight:600; color:#ffffff;">Add Link to Cloud</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="closepushButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="addLinkButton">
|
||||
<property name="text">
|
||||
<string>Add Link</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>375</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Add a new Link</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Title:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Url:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="titleLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="linkLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QFrame" name="frame_3">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QFrame#frame_3{
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
|
||||
stop:0 #FEFEFE, stop:1 #E8E8E8);
|
||||
|
||||
border: 1px solid #CCCCCC;}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="anonBox">
|
||||
<property name="text">
|
||||
<string>Add Anonymous Link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="scoreBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>+2 Great!</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/filerating5.png</normaloff>:/images/filerating5.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>+1 Good</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/filerating4.png</normaloff>:/images/filerating4.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 Okay</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/filerating3.png</normaloff>:/images/filerating3.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>-1 Sux</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/filerating2.png</normaloff>:/images/filerating2.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>-2 Bad Link</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/filerating1.png</normaloff>:/images/filerating1.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>299</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QTextEdit" name="linkTextEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
11
plugins/LinksCloud/LinksCloud.pro
Normal file
11
plugins/LinksCloud/LinksCloud.pro
Normal file
|
@ -0,0 +1,11 @@
|
|||
!include("../Common/retroshare_plugin.pri"): error("Could not include file ../Common/retroshare_plugin.pri")
|
||||
|
||||
CONFIG *= qt uic debug resources
|
||||
|
||||
SOURCES = p3ranking.cc LinksDialog.cpp rsrankitems.cc AddLinksDialog.cpp LinksCloudPlugin.cpp
|
||||
HEADERS = rsrank.h p3ranking.h LinksDialog.h rsrankitems.h AddLinksDialog.h LinksCloudPlugin.h
|
||||
FORMS = LinksDialog.ui AddLinksDialog.ui
|
||||
|
||||
TARGET = LinksCloud
|
||||
|
||||
RESOURCES = images.qrc
|
1060
plugins/LinksCloud/LinksDialog.cpp
Normal file
1060
plugins/LinksCloud/LinksDialog.cpp
Normal file
File diff suppressed because it is too large
Load diff
92
plugins/LinksCloud/LinksDialog.h
Normal file
92
plugins/LinksCloud/LinksDialog.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/****************************************************************
|
||||
* RetroShare GUI is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2008 Robert Fernie
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef _LINKS_DIALOG_H
|
||||
#define _LINKS_DIALOG_H
|
||||
|
||||
#include <gui/mainpage.h>
|
||||
#include "ui_LinksDialog.h"
|
||||
|
||||
|
||||
class LinksDialog : public MainPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
LinksDialog(QWidget *parent = 0);
|
||||
/** Default Destructor */
|
||||
|
||||
void insertExample();
|
||||
|
||||
private slots:
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void linkTreeWidgetCostumPopupMenu( QPoint point );
|
||||
|
||||
void voteup_anon();
|
||||
void voteup_score(int score);
|
||||
void voteup_p2();
|
||||
void voteup_p1();
|
||||
void voteup_p0();
|
||||
void voteup_m1();
|
||||
void voteup_m2();
|
||||
void downloadSelected();
|
||||
|
||||
void changedSortRank( int index );
|
||||
void changedSortPeriod( int index );
|
||||
void changedSortFrom( int index );
|
||||
void changedSortTop( int index );
|
||||
|
||||
void updateLinks();
|
||||
void addLinkComment( void );
|
||||
void toggleWindows( void );
|
||||
|
||||
void openLink ( QTreeWidgetItem * item, int column );
|
||||
void changedItem(QTreeWidgetItem *curr, QTreeWidgetItem *prev);
|
||||
void checkAnon();
|
||||
|
||||
void checkUpdate();
|
||||
|
||||
void anchorClicked (const QUrl &);
|
||||
|
||||
void addNewLink();
|
||||
|
||||
private:
|
||||
|
||||
void updateComments(std::string rid, std::string pid);
|
||||
|
||||
int mStart; /* start of rank list */
|
||||
std::string mLinkId;
|
||||
|
||||
/* Worker Functions */
|
||||
/* (1) Update Display */
|
||||
|
||||
/* (2) Utility Fns */
|
||||
QTreeWidgetItem *getCurrentLine();
|
||||
|
||||
QTreeWidget *exampletreeWidget;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::LinksDialog ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
587
plugins/LinksCloud/LinksDialog.ui
Normal file
587
plugins/LinksCloud/LinksDialog.ui
Normal file
|
@ -0,0 +1,587 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LinksDialog</class>
|
||||
<widget class="QWidget" name="LinksDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>738</width>
|
||||
<height>583</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QSplitter" name="msgSplitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0" colspan="13">
|
||||
<widget class="QTreeWidget" name="linkTreeWidget">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Title / Comment</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Score</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Peer / Link</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="expandButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/edit_remove24.png</normaloff>:/images/edit_remove24.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sort by</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QComboBox" name="rankComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Combo</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Time</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/kalarm.png</normaloff>:/images/kalarm.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ranking</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/records.png</normaloff>:/images/records.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>In last</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="6">
|
||||
<widget class="QComboBox" name="periodComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Month</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/view_calendar_month.png</normaloff>:/images/view_calendar_month.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Week</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/view_calendar_week.png</normaloff>:/images/view_calendar_week.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Day</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/view_calendar_day.png</normaloff>:/images/view_calendar_day.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="7">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="8">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>From</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="9">
|
||||
<widget class="QComboBox" name="fromComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>All Peers</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/user/friends24.png</normaloff>:/images/user/friends24.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Own Links</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/user/identity16.png</normaloff>:/images/user/identity16.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="10">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="11">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="12">
|
||||
<widget class="QComboBox" name="topComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top 100</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/records.png</normaloff>:/images/records.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>101-200</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>201-300</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>301-400</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>401-500</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom 100</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="12">
|
||||
<widget class="QTextBrowser" name="linklabel">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTextBrowser{border: 2px solid #CCCCCC;
|
||||
border-radius: 10px;
|
||||
background: white;}</string>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Link:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget_1">
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>311</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="anonBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Anonymous Link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="text">
|
||||
<string>Add Link/Comment</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Title:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="titleLineEdit">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit{border: 2px solid #CCCCCC;
|
||||
border-radius: 10px;
|
||||
background: white;}</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Score:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="scoreBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>+2 Great!</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/filerating5.png</normaloff>:/images/filerating5.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>+1 Good</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/filerating4.png</normaloff>:/images/filerating4.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 Okay</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/filerating3.png</normaloff>:/images/filerating3.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>-1 Sux</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/filerating2.png</normaloff>:/images/filerating2.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>-2 Bad Link</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/filerating1.png</normaloff>:/images/filerating1.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Url:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="linkLineEdit">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit{border: 2px solid #CCCCCC;
|
||||
border-radius: 10px;
|
||||
background: white;}</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="linkTextEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTextEdit{border: 2px solid #CCCCCC;
|
||||
border-radius: 10px;
|
||||
background: white;}</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QFrame#frame{
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
|
||||
stop:0 #FEFEFE, stop:1 #E8E8E8);
|
||||
|
||||
border: 1px solid #CCCCCC;}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_1">
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="linksiconlabel">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="images.qrc">:/images/irkick.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><span style=" font-weight:600;">Links Cloud</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>596</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton:hover {
|
||||
border: 1px solid #CCCCCC;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add new link</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
5
plugins/LinksCloud/images.qrc
Normal file
5
plugins/LinksCloud/images.qrc
Normal file
|
@ -0,0 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>images/irkick.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
BIN
plugins/LinksCloud/images/irkick.png
Normal file
BIN
plugins/LinksCloud/images/irkick.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
1354
plugins/LinksCloud/p3ranking.cc
Normal file
1354
plugins/LinksCloud/p3ranking.cc
Normal file
File diff suppressed because it is too large
Load diff
165
plugins/LinksCloud/p3ranking.h
Normal file
165
plugins/LinksCloud/p3ranking.h
Normal file
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* libretroshare/src/services: p3ranking.h
|
||||
*
|
||||
* 3P/PQI network interface for RetroShare.
|
||||
*
|
||||
* Copyright 2007-2008 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef P3_GENERIC_RANKING_HEADER
|
||||
#define P3_GENERIC_RANKING_HEADER
|
||||
|
||||
class pqistore ;
|
||||
|
||||
#include "retroshare/rsplugin.h"
|
||||
#include "plugins/pluginclasses.h"
|
||||
|
||||
#include "rsrank.h"
|
||||
|
||||
/*
|
||||
* A Generic Ranking system.
|
||||
* Each User provides one cache...
|
||||
*
|
||||
* can be overloaded for specific types
|
||||
* (links, shares, photos etc)
|
||||
*
|
||||
* This is not generic yet!!!
|
||||
*/
|
||||
|
||||
class RsRankMsg;
|
||||
class RsRankLinkMsg;
|
||||
|
||||
const uint16_t RS_SERVICE_TYPE_RANK = 0x0002 ;
|
||||
const uint32_t CONFIG_TYPE_RANK_LINK = 0x0011 ;
|
||||
|
||||
class RankGroup
|
||||
{
|
||||
public:
|
||||
|
||||
std::string rid; /* Random Id */
|
||||
std::wstring link;
|
||||
std::wstring title;
|
||||
float rank;
|
||||
bool ownTag;
|
||||
std::map<std::string, RsRankLinkMsg *> comments;
|
||||
};
|
||||
|
||||
class p3Ranking: public RsCacheService, public RsRanks
|
||||
{
|
||||
public:
|
||||
|
||||
p3Ranking() ;
|
||||
|
||||
|
||||
/******************************* CACHE SOURCE / STORE Interface *********************/
|
||||
|
||||
/* overloaded functions from Cache Source */
|
||||
virtual bool loadLocalCache(const CacheData &data);
|
||||
|
||||
/* overloaded functions from Cache Store */
|
||||
virtual int loadCache(const CacheData &data);
|
||||
|
||||
/******************************* CACHE SOURCE / STORE Interface *********************/
|
||||
|
||||
public:
|
||||
|
||||
/************* Extern Interface *******/
|
||||
|
||||
/* changed */
|
||||
virtual bool updated();
|
||||
|
||||
/* Set Sort Methods */
|
||||
virtual bool setSortPeriod(uint32_t period);
|
||||
virtual bool setSortMethod(uint32_t type);
|
||||
virtual bool clearPeerFilter();
|
||||
virtual bool setPeerFilter(std::list<std::string> peers);
|
||||
|
||||
/* get Ids */
|
||||
virtual uint32_t getRankingsCount();
|
||||
virtual float getMaxRank();
|
||||
virtual bool getRankings(uint32_t first, uint32_t count, std::list<std::string> &rids);
|
||||
virtual bool getRankDetails(std::string rid, RsRankDetails &details);
|
||||
|
||||
/* Add New Comment / Msg */
|
||||
virtual std::string newRankMsg(std::wstring link, std::wstring title, std::wstring comment, int32_t score);
|
||||
virtual bool updateComment(std::string rid, std::wstring comment, int32_t score);
|
||||
virtual std::string anonRankMsg(std::string rid, std::wstring link, std::wstring title);
|
||||
|
||||
|
||||
virtual void tick();
|
||||
|
||||
void loadRankFile(std::string filename, std::string src);
|
||||
void addRankMsg(RsRankLinkMsg *msg);
|
||||
void publishMsgs(bool own);
|
||||
|
||||
float locked_calcRank(RankGroup &grp); /* returns 0->100 */
|
||||
void locked_reSortGroup(RankGroup &grp);
|
||||
|
||||
void sortAllMsgs();
|
||||
pqistore *createStore(std::string file, std::string src, bool reading);
|
||||
|
||||
|
||||
/****************** p3Config STUFF *******************/
|
||||
protected:
|
||||
bool addAnonToList(RsRankLinkMsg *msg);
|
||||
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
||||
virtual bool loadList(std::list<RsItem *>& load);
|
||||
virtual void saveDone();
|
||||
|
||||
private:
|
||||
|
||||
void createDummyData();
|
||||
|
||||
uint32_t storePeriod;
|
||||
p3ConnectMgr *mConnMgr;
|
||||
|
||||
RsMutex mRankMtx;
|
||||
|
||||
/***** below here is locked *****/
|
||||
|
||||
bool mRepublish;
|
||||
bool mRepublishFriends;
|
||||
time_t mRepublishFriendTS;
|
||||
|
||||
uint32_t mStorePeriod;
|
||||
|
||||
std::string mOwnId;
|
||||
bool mUpdated;
|
||||
bool mRepost;
|
||||
|
||||
std::map<std::string, RankGroup> mData;
|
||||
std::multimap<float, std::string> mRankings;
|
||||
|
||||
/* Filter/Sort params */
|
||||
std::list<std::string> mPeerFilter;
|
||||
uint32_t mViewPeriod;
|
||||
uint32_t mSortType;
|
||||
|
||||
/* Anonymous Link List */
|
||||
std::list<RsRankLinkMsg *> mAnon;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
96
plugins/LinksCloud/rsrank.h
Normal file
96
plugins/LinksCloud/rsrank.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
#ifndef RETROSHARE_RANKING_GUI_INTERFACE_H
|
||||
#define RETROSHARE_RANKING_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsrank.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2007-2008 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
/* The Main Interface Class - for information about your Peers */
|
||||
class RsRanks;
|
||||
extern RsRanks *rsRanks;
|
||||
|
||||
class RsRankComment
|
||||
{
|
||||
public:
|
||||
|
||||
std::string id;
|
||||
std::wstring comment;
|
||||
int32_t score;
|
||||
time_t timestamp;
|
||||
};
|
||||
|
||||
class RsRankDetails
|
||||
{
|
||||
public:
|
||||
|
||||
std::string rid;
|
||||
std::wstring link;
|
||||
std::wstring title;
|
||||
float rank;
|
||||
bool ownTag;
|
||||
|
||||
std::list<RsRankComment> comments;
|
||||
};
|
||||
|
||||
const uint32_t RS_RANK_SCORE = 0x0001;
|
||||
const uint32_t RS_RANK_TIME = 0x0002;
|
||||
const uint32_t RS_RANK_ALG = 0x0003;
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsRankDetails &detail);
|
||||
|
||||
class RsRanks
|
||||
{
|
||||
public:
|
||||
|
||||
RsRanks() { return; }
|
||||
virtual ~RsRanks() { return; }
|
||||
|
||||
/* needs update? */
|
||||
virtual bool updated() = 0;
|
||||
|
||||
/* Set Sort Methods */
|
||||
virtual bool setSortPeriod(uint32_t period) = 0;
|
||||
virtual bool setSortMethod(uint32_t type) = 0;
|
||||
virtual bool clearPeerFilter() = 0;
|
||||
virtual bool setPeerFilter(std::list<std::string> peers) = 0;
|
||||
|
||||
/* get Ids */
|
||||
virtual uint32_t getRankingsCount() = 0;
|
||||
virtual float getMaxRank() = 0;
|
||||
virtual bool getRankings(uint32_t first, uint32_t count, std::list<std::string> &rids) = 0;
|
||||
virtual bool getRankDetails(std::string rid, RsRankDetails &details) = 0;
|
||||
|
||||
/* Add New Comment / Msg */
|
||||
virtual std::string newRankMsg(std::wstring link, std::wstring title, std::wstring comment, int32_t score) = 0;
|
||||
virtual bool updateComment(std::string rid, std::wstring comment, int32_t score) = 0;
|
||||
|
||||
virtual std::string anonRankMsg(std::string rid, std::wstring link, std::wstring title) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
253
plugins/LinksCloud/rsrankitems.cc
Normal file
253
plugins/LinksCloud/rsrankitems.cc
Normal file
|
@ -0,0 +1,253 @@
|
|||
|
||||
/*
|
||||
* libretroshare/src/serialiser: rsbaseitems.cc
|
||||
*
|
||||
* RetroShare Serialiser.
|
||||
*
|
||||
* Copyright 2007-2008 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "rsrankitems.h"
|
||||
|
||||
#define RSSERIAL_DEBUG 1
|
||||
#include <iostream>
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
void RsRankMsg::clear()
|
||||
{
|
||||
rid.clear();
|
||||
timestamp = 0;
|
||||
title.clear();
|
||||
comment.clear();
|
||||
}
|
||||
|
||||
std::ostream &RsRankMsg::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsRankMsg", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
printIndent(out, int_Indent);
|
||||
out << "rid: " << rid << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "timestamp: " << timestamp << std::endl;
|
||||
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
|
||||
std::string cnv_title(title.begin(), title.end());
|
||||
out << "msg: " << cnv_title << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
std::string cnv_comment(comment.begin(), comment.end());
|
||||
out << "comment: " << cnv_comment << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "score: " << score << std::endl;
|
||||
|
||||
printRsItemEnd(out, "RsRankMsg", indent);
|
||||
return out;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
void RsRankLinkMsg::clear()
|
||||
{
|
||||
rid.clear();
|
||||
pid.clear();
|
||||
timestamp = 0;
|
||||
title.clear();
|
||||
comment.clear();
|
||||
score = 0;
|
||||
linktype = 0;
|
||||
link.clear();
|
||||
}
|
||||
|
||||
std::ostream &RsRankLinkMsg::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsRankLinkMsg", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
printIndent(out, int_Indent);
|
||||
out << "rid: " << rid << std::endl;
|
||||
printIndent(out, int_Indent);
|
||||
out << "pid: " << pid << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "timestamp: " << timestamp << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
|
||||
std::string cnv_title(title.begin(), title.end());
|
||||
out << "msg: " << cnv_title << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
std::string cnv_comment(comment.begin(), comment.end());
|
||||
out << "comment: " << cnv_comment << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "score: " << score << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "linktype: " << linktype << std::endl;
|
||||
printIndent(out, int_Indent);
|
||||
std::string cnv_link(link.begin(), link.end());
|
||||
out << "link: " << cnv_link << std::endl;
|
||||
|
||||
printRsItemEnd(out, "RsRankLinkMsg", indent);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
uint32_t RsRankSerialiser::sizeLink(RsRankLinkMsg *item)
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += GetTlvStringSize(item->rid);
|
||||
s += GetTlvStringSize(item->pid);
|
||||
s += 4; /* timestamp */
|
||||
s += GetTlvWideStringSize(item->title);
|
||||
s += GetTlvWideStringSize(item->comment);
|
||||
s += 4; /* score */
|
||||
s += 4; /* linktype */
|
||||
s += GetTlvWideStringSize(item->link);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/* serialise the data to the buffer */
|
||||
bool RsRankSerialiser::serialiseLink(RsRankLinkMsg *item, void *data, uint32_t *pktsize)
|
||||
{
|
||||
uint32_t tlvsize = sizeLink(item);
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (*pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
*pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->rid);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, item->pid);
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->timestamp);
|
||||
|
||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_TITLE, item->title);
|
||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_COMMENT, item->comment);
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, *((uint32_t *) &(item->score)));
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->linktype);
|
||||
|
||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_LINK, item->link);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsRankLinkSerialiser::serialiseLink() Size Error! " << std::endl;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsRankLinkMsg *RsRankSerialiser::deserialiseLink(void *data, uint32_t *pktsize)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_TYPE_RANK != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_RANK_LINK3 != getRsItemSubType(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*pktsize < rssize) /* check size */
|
||||
return NULL; /* not enough data */
|
||||
|
||||
/* set the packet length */
|
||||
*pktsize = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
/* ready to load */
|
||||
RsRankLinkMsg *item = new RsRankLinkMsg();
|
||||
item->clear();
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* get mandatory parts first */
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->rid);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, item->pid);
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->timestamp));
|
||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_TITLE, item->title);
|
||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_COMMENT, item->comment);
|
||||
ok &= getRawUInt32(data, rssize, &offset, (uint32_t *) &(item->score));
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->linktype));
|
||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_LINK, item->link);
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
uint32_t RsRankSerialiser::size(RsItem *item)
|
||||
{
|
||||
return sizeLink((RsRankLinkMsg *) item);
|
||||
}
|
||||
|
||||
bool RsRankSerialiser::serialise(RsItem *item, void *data, uint32_t *pktsize)
|
||||
{
|
||||
return serialiseLink((RsRankLinkMsg *) item, data, pktsize);
|
||||
}
|
||||
|
||||
RsItem *RsRankSerialiser::deserialise(void *data, uint32_t *pktsize)
|
||||
{
|
||||
return deserialiseLink(data, pktsize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
110
plugins/LinksCloud/rsrankitems.h
Normal file
110
plugins/LinksCloud/rsrankitems.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
#ifndef RS_RANK_ITEMS_H
|
||||
#define RS_RANK_ITEMS_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/serialiser: rsrankitems.h
|
||||
*
|
||||
* RetroShare Serialiser.
|
||||
*
|
||||
* Copyright 2007-2008 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rstlvtypes.h"
|
||||
|
||||
#include "p3ranking.h"
|
||||
|
||||
const uint8_t RS_PKT_SUBTYPE_RANK_LINK3 = 0x04;
|
||||
const uint8_t RS_PKT_SUBTYPE_RANK_PHOTO = 0x05;
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
class RsRankMsg: public RsItem
|
||||
{
|
||||
public:
|
||||
RsRankMsg(uint8_t subtype) :RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_RANK, subtype) { return; }
|
||||
|
||||
virtual ~RsRankMsg() { return; }
|
||||
virtual void clear();
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
std::string rid; /* Random Id */
|
||||
std::string pid; /* Peer Id (cannot use RsItem::PeerId - as FoF transport!) */
|
||||
uint32_t timestamp;
|
||||
std::wstring title;
|
||||
std::wstring comment;
|
||||
int32_t score;
|
||||
};
|
||||
|
||||
|
||||
/* Flags */
|
||||
const uint32_t RS_LINK_TYPE_WEB = 0x0001;
|
||||
const uint32_t RS_LINK_TYPE_OFF = 0x0002;
|
||||
|
||||
class RsRankLinkMsg: public RsRankMsg
|
||||
{
|
||||
public:
|
||||
RsRankLinkMsg()
|
||||
:RsRankMsg(RS_PKT_SUBTYPE_RANK_LINK3) { return; }
|
||||
virtual ~RsRankLinkMsg() { return; }
|
||||
virtual void clear();
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
/**** SAME as RsRankMsg ****
|
||||
std::string rid;
|
||||
uint32_t timestamp;
|
||||
std::wstring title;
|
||||
std::wstring comment;
|
||||
int32_t score;
|
||||
***************************/
|
||||
|
||||
/* Link specific Fields */
|
||||
uint32_t linktype; /* to be used later! */
|
||||
std::wstring link;
|
||||
};
|
||||
|
||||
class RsRankSerialiser: public RsSerialType
|
||||
{
|
||||
public:
|
||||
RsRankSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_RANK)
|
||||
{ return; }
|
||||
virtual ~RsRankSerialiser()
|
||||
{ return; }
|
||||
|
||||
virtual uint32_t size(RsItem *);
|
||||
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
virtual RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
private:
|
||||
|
||||
/* For RS_PKT_SUBTYPE_RANK_LINK */
|
||||
virtual uint32_t sizeLink(RsRankLinkMsg *);
|
||||
virtual bool serialiseLink (RsRankLinkMsg *item, void *data, uint32_t *size);
|
||||
virtual RsRankLinkMsg *deserialiseLink(void *data, uint32_t *size);
|
||||
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#endif /* RS_RANK_ITEMS_H */
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue