mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-11-30 04:16:40 -05:00
This intimidating patch renames libretroshare/src/rsiface/ to
libretroshare/src/retroshare/ All the relevant headers have been modified to reflect that change. This allows installation of libretroshare on a system, headers will be put in $WHEREVER/retroshare/ and we keep the ability to compile against them, be it on the system or in the SVN tree. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3342 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e69300ccdc
commit
4bb4fc11e2
179 changed files with 289 additions and 285 deletions
25
libretroshare/src/retroshare/Makefile
Normal file
25
libretroshare/src/retroshare/Makefile
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
RS_TOP_DIR = ..
|
||||
##### Define any flags that are needed for this section #######
|
||||
###############################################################
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
OBJ = notifytxt.o retroshare.o
|
||||
|
||||
#TESTOBJ =
|
||||
|
||||
TESTS = retroshare-nogui
|
||||
|
||||
all: tests
|
||||
|
||||
retroshare-nogui: $(OBJ)
|
||||
$(CC) $(CFLAGS) -o retroshare-nogui $(OBJ) $(LIBS)
|
||||
|
||||
|
||||
###############################################################
|
||||
include $(RS_TOP_DIR)/scripts/rules.mk
|
||||
###############################################################
|
||||
|
||||
154
libretroshare/src/retroshare/rsblogs.h
Normal file
154
libretroshare/src/retroshare/rsblogs.h
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
#ifndef RS_BLOG_GUI_INTERFACE_H
|
||||
#define RS_BLOG_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsblogs.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 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 <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "rstypes.h"
|
||||
#include "rsdistrib.h" /* For FLAGS */
|
||||
|
||||
class BlogInfo
|
||||
{
|
||||
public:
|
||||
BlogInfo() {}
|
||||
std::string blogId;
|
||||
std::wstring blogName;
|
||||
std::wstring blogDesc;
|
||||
|
||||
uint32_t blogFlags;
|
||||
uint32_t pop;
|
||||
|
||||
unsigned char* pngChanImage;
|
||||
uint32_t pngImageLen;
|
||||
|
||||
time_t lastPost;
|
||||
};
|
||||
|
||||
class BlogMsgInfo
|
||||
{
|
||||
public:
|
||||
BlogMsgInfo() {}
|
||||
std::string blogId;
|
||||
std::string msgId;
|
||||
/// this has a value if replying to another msg
|
||||
std::string msgIdReply;
|
||||
|
||||
unsigned int msgflags;
|
||||
|
||||
std::wstring subject;
|
||||
std::wstring msg;
|
||||
time_t ts;
|
||||
|
||||
std::list<FileInfo> files;
|
||||
uint32_t count;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
|
||||
class BlogMsgSummary
|
||||
{
|
||||
public:
|
||||
BlogMsgSummary() {}
|
||||
std::string blogId;
|
||||
std::string msgId;
|
||||
|
||||
uint32_t msgflags;
|
||||
|
||||
std::wstring subject;
|
||||
std::wstring msg;
|
||||
std::string msgIdReply;
|
||||
uint32_t count; /* file count */
|
||||
time_t ts;
|
||||
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const BlogInfo &info);
|
||||
std::ostream &operator<<(std::ostream &out, const BlogMsgSummary &info);
|
||||
std::ostream &operator<<(std::ostream &out, const BlogMsgInfo &info);
|
||||
|
||||
class RsBlogs;
|
||||
extern RsBlogs *rsBlogs;
|
||||
|
||||
class RsBlogs
|
||||
{
|
||||
public:
|
||||
|
||||
RsBlogs() { return; }
|
||||
virtual ~RsBlogs() { return; }
|
||||
|
||||
/****************************************/
|
||||
|
||||
/*!
|
||||
* Checks if the group a blod id belongs to has changed
|
||||
*/
|
||||
virtual bool blogsChanged(std::list<std::string> &blogIds) = 0;
|
||||
|
||||
|
||||
virtual std::string createBlog(std::wstring blogName, std::wstring blogDesc, uint32_t blogFlags,
|
||||
unsigned char* pngImageData, uint32_t imageSize) = 0;
|
||||
|
||||
virtual bool getBlogInfo(std::string cId, BlogInfo &ci) = 0;
|
||||
virtual bool getBlogList(std::list<BlogInfo> &chanList) = 0;
|
||||
virtual bool getBlogMsgList(std::string cId, std::list<BlogMsgSummary> &msgs) = 0;
|
||||
|
||||
/*!
|
||||
* Retrieves a specific blog Msg based on group Id and message Id
|
||||
*/
|
||||
virtual bool getBlogMessage(std::string cId, std::string mId, BlogMsgInfo &msg) = 0;
|
||||
|
||||
/*!
|
||||
* Can send blog message to user
|
||||
* @param info the message
|
||||
*/
|
||||
virtual bool BlogMessageSend(BlogMsgInfo &info) = 0;
|
||||
|
||||
/*!
|
||||
* Allows user to subscribe to a blog via group ID
|
||||
* @param cId group id
|
||||
* @param subscribe determine subscription based on value
|
||||
*/
|
||||
virtual bool blogSubscribe(std::string cId, bool subscribe) = 0;
|
||||
|
||||
/*!
|
||||
* Commenting on other user's blogs, ensure field info has a valid info.msgIdReply has valid msg id, this
|
||||
* points to which message the blog reply is replying to
|
||||
*/
|
||||
virtual bool BlogMessageReply(BlogMsgInfo &info) = 0;
|
||||
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
virtual bool isReply(BlogMsgInfo &info) = 0;
|
||||
/****************************************/
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
220
libretroshare/src/retroshare/rschannels.h
Normal file
220
libretroshare/src/retroshare/rschannels.h
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
#ifndef RS_CHANNEL_GUI_INTERFACE_H
|
||||
#define RS_CHANNEL_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rschannels.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 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 <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "rstypes.h"
|
||||
#include "rsdistrib.h" /* For FLAGS */
|
||||
|
||||
//! Stores information for a give channel id
|
||||
/*!
|
||||
* Stores all information for a given channel id
|
||||
*/
|
||||
class ChannelInfo
|
||||
{
|
||||
public:
|
||||
ChannelInfo() : pngChanImage(NULL), pngImageLen(0) {}
|
||||
std::string channelId;
|
||||
std::wstring channelName;
|
||||
std::wstring channelDesc;
|
||||
|
||||
uint32_t channelFlags;
|
||||
uint32_t pop; /// popularity
|
||||
|
||||
unsigned char* pngChanImage;
|
||||
uint32_t pngImageLen;
|
||||
|
||||
time_t lastPost;
|
||||
};
|
||||
|
||||
//! for storing a channel msgs thumbnail picture
|
||||
class ChannelMsgThumbnail
|
||||
{
|
||||
public:
|
||||
ChannelMsgThumbnail() : image_thumbnail(NULL), im_thumbnail_size(0) {}
|
||||
|
||||
unsigned char* image_thumbnail;
|
||||
int im_thumbnail_size;
|
||||
};
|
||||
|
||||
//! Stores information on a message within a channel
|
||||
class ChannelMsgInfo
|
||||
{
|
||||
public:
|
||||
ChannelMsgInfo () : count(0), size(0) {}
|
||||
std::string channelId;
|
||||
std::string msgId;
|
||||
|
||||
unsigned int msgflags;
|
||||
|
||||
std::wstring subject;
|
||||
std::wstring msg;
|
||||
time_t ts; /// time stamp
|
||||
|
||||
std::list<FileInfo> files;
|
||||
uint32_t count; /// file count
|
||||
uint64_t size; /// size of all files
|
||||
|
||||
ChannelMsgThumbnail thumbnail;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//! gives a more brief account of a channel message than channelMsgInfo
|
||||
class ChannelMsgSummary
|
||||
{
|
||||
public:
|
||||
ChannelMsgSummary() : count(0) {}
|
||||
std::string channelId;
|
||||
std::string msgId;
|
||||
|
||||
uint32_t msgflags;
|
||||
|
||||
std::wstring subject;
|
||||
std::wstring msg;
|
||||
uint32_t count; /// file count
|
||||
time_t ts; /// time stamp
|
||||
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const ChannelInfo &info);
|
||||
std::ostream &operator<<(std::ostream &out, const ChannelMsgSummary &info);
|
||||
std::ostream &operator<<(std::ostream &out, const ChannelMsgInfo &info);
|
||||
|
||||
class RsChannels;
|
||||
extern RsChannels *rsChannels;
|
||||
|
||||
/*!
|
||||
* retroshare interface to the channels distributed group service
|
||||
* Channels user to create feeds similar to RSS feed where you can share files
|
||||
* with other users, when you subscribe to a channel you immediately begin downloading
|
||||
* the file shared on that channel. Channel feeds are shared anonymously
|
||||
*/
|
||||
class RsChannels
|
||||
{
|
||||
public:
|
||||
|
||||
RsChannels() { return; }
|
||||
virtual ~RsChannels() { return; }
|
||||
|
||||
/****************************************/
|
||||
|
||||
/*!
|
||||
* returns a list of channel id that have changed (i.e. received new message, chan descr update)
|
||||
* @param chanIds this is populated with channel ids that have changed
|
||||
*/
|
||||
virtual bool channelsChanged(std::list<std::string> &chanIds) = 0;
|
||||
|
||||
/*!
|
||||
* @param chanName name of the channel
|
||||
* @param chanDesc a short description for the created channel
|
||||
* @param chanFlags admin details on created channel group see rsdistrib.h for flags types
|
||||
* @param pngImageData point at image data in PNG format
|
||||
* @param imageSize size of the image data
|
||||
*/
|
||||
virtual std::string createChannel(std::wstring chanName, std::wstring chanDesc, uint32_t chanFlags,
|
||||
unsigned char* pngImageData, uint32_t imageSize) = 0;
|
||||
|
||||
/*!
|
||||
* retrieve channel information
|
||||
* @param cId channel id
|
||||
* @param ci channel info is store here
|
||||
*/
|
||||
virtual bool getChannelInfo(std::string cId, ChannelInfo &ci) = 0;
|
||||
|
||||
/*!
|
||||
* @param chanList populated channelinfo for all channels
|
||||
*/
|
||||
virtual bool getChannelList(std::list<ChannelInfo> &chanList) = 0;
|
||||
|
||||
/*!
|
||||
* get a message summary list for a given channel id
|
||||
* @param cId channel id user wants messages for
|
||||
* @param msgs summary of messages for the given cId
|
||||
*/
|
||||
virtual bool getChannelMsgList(std::string cId, std::list<ChannelMsgSummary> &msgs) = 0;
|
||||
|
||||
/*!
|
||||
* retrieve more comprehensive message info given channel id and message id
|
||||
*/
|
||||
virtual bool getChannelMessage(std::string cId, std::string mId, ChannelMsgInfo &msg) = 0;
|
||||
|
||||
/*!
|
||||
* send message contain in message info to the id indicated within it (make sure you set the channel id of the message info)
|
||||
* @param info message to be sent
|
||||
*/
|
||||
virtual bool ChannelMessageSend(ChannelMsgInfo &info) = 0;
|
||||
|
||||
/*!
|
||||
* @param cId the channel id
|
||||
* @param subscribe set to true if you want to subscribe and to false to unsubscribe
|
||||
*/
|
||||
virtual bool channelSubscribe(std::string cId, bool subscribe) = 0;
|
||||
|
||||
/*!
|
||||
* This hashes a file which is not already shared by client or his peers,
|
||||
* The file is copied into the channels directory if its not too large (> 100mb)
|
||||
* @param path This is full path to file
|
||||
* @param channel Id
|
||||
*/
|
||||
virtual bool channelExtraFileHash(std::string path, std::string chId, FileInfo& fInfo) = 0;
|
||||
|
||||
/*!
|
||||
* This removes hashed extra files, and also removes channels directory copy if it exists
|
||||
* @param chId channel id
|
||||
*/
|
||||
virtual bool channelExtraFileRemove(std::string hash, std::string chId) = 0;
|
||||
|
||||
/*!
|
||||
* Restores channel private keys for channel in the event keys stored in configuration files are lost
|
||||
* @param chId channel id to restore keys for
|
||||
*/
|
||||
virtual bool channelRestoreKeys(std::string chId) = 0;
|
||||
|
||||
/*!
|
||||
* shares keys with peers
|
||||
*@param chId the channel for which private publish keys will be shared
|
||||
*@param peers peers in this list will be sent keys
|
||||
*
|
||||
*/
|
||||
virtual bool channelShareKeys(std::string chId, std::list<std::string>& peers) = 0;
|
||||
/****************************************/
|
||||
|
||||
/*!
|
||||
* allows peers to change information for the channel:
|
||||
* can only change channel image, descriptions and name
|
||||
*
|
||||
*/
|
||||
virtual bool channelEditInfo(std::string chId, ChannelInfo &ci) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
50
libretroshare/src/retroshare/rsdisc.h
Normal file
50
libretroshare/src/retroshare/rsdisc.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#ifndef RETROSHARE_DISC_GUI_INTERFACE_H
|
||||
#define RETROSHARE_DISC_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsdisc.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2008-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>
|
||||
#include <map>
|
||||
|
||||
/* The Main Interface Class - for information about your Peers */
|
||||
class RsDisc;
|
||||
extern RsDisc *rsDisc;
|
||||
|
||||
class RsDisc
|
||||
{
|
||||
public:
|
||||
|
||||
RsDisc() { return; }
|
||||
virtual ~RsDisc() { return; }
|
||||
|
||||
virtual bool getDiscFriends(std::string id, std::list<std::string> &friends) = 0;
|
||||
virtual bool getDiscVersions(std::map<std::string, std::string> &versions) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
49
libretroshare/src/retroshare/rsdistrib.h
Normal file
49
libretroshare/src/retroshare/rsdistrib.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#ifndef RS_DISTRIB_GUI_INTERFACE_H
|
||||
#define RS_DISTRIB_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsdistrib.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".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define RS_DISTRIB_PRIVACY_MASK 0x000f /* who can publish & view */
|
||||
#define RS_DISTRIB_AUTHEN_MASK 0x00f0 /* how to publish */
|
||||
#define RS_DISTRIB_LISTEN_MASK 0x0f00 /* distribution flags */
|
||||
#define RS_DISTRIB_UPDATE_MASK 0xf000 /* if sending a group info update */
|
||||
|
||||
#define RS_DISTRIB_PUBLIC 0x0001 /* anyone can publish */
|
||||
#define RS_DISTRIB_PRIVATE 0x0002 /* anyone with key can publish */
|
||||
#define RS_DISTRIB_ENCRYPTED 0x0004 /* need publish key to view */
|
||||
|
||||
#define RS_DISTRIB_AUTHEN_REQ 0x0010 /* you must sign messages */
|
||||
#define RS_DISTRIB_AUTHEN_ANON 0x0020 /* you can send anonymous messages */
|
||||
|
||||
#define RS_DISTRIB_ADMIN 0x0100
|
||||
#define RS_DISTRIB_PUBLISH 0x0200
|
||||
#define RS_DISTRIB_SUBSCRIBED 0x0400
|
||||
|
||||
#define RS_DISTRIB_UPDATE 0x1000
|
||||
|
||||
|
||||
#endif
|
||||
332
libretroshare/src/retroshare/rsexpr.h
Executable file
332
libretroshare/src/retroshare/rsexpr.h
Executable file
|
|
@ -0,0 +1,332 @@
|
|||
#ifndef RS_EXPRESSIONS_H
|
||||
#define RS_EXPRESSIONS_H
|
||||
|
||||
/*
|
||||
* rs-core/src/rsiface: rsexpr.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2007-2008 by Kashif Kaleem.
|
||||
*
|
||||
* 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 <string>
|
||||
#include <list>
|
||||
#include <stdint.h>
|
||||
|
||||
/******************************************************************************************
|
||||
Enumerations defining the Operators usable in the Boolean search expressions
|
||||
******************************************************************************************/
|
||||
|
||||
|
||||
enum LogicalOperator{
|
||||
AndOp=0, /* exp AND exp */
|
||||
OrOp=1, /* exp OR exp */
|
||||
XorOp=2 /* exp XOR exp */
|
||||
};
|
||||
|
||||
|
||||
/*Operators for String Queries*/
|
||||
enum StringOperator{
|
||||
ContainsAnyStrings = 0, /* e.g. name contains any of 'conference' 'meeting' 'presentation' */
|
||||
ContainsAllStrings = 1, /* same as above except that it contains ALL of the strings */
|
||||
EqualsString = 2 /* exactly equal*/
|
||||
};
|
||||
|
||||
/*Relational operators ( >, <, >=, <=, == and InRange )*/
|
||||
enum RelOperator{
|
||||
Equals = 0,
|
||||
GreaterEquals = 1,
|
||||
Greater = 2,
|
||||
SmallerEquals = 3,
|
||||
Smaller = 4,
|
||||
InRange = 5 /* lower limit <= value <= upper limit*/
|
||||
};
|
||||
|
||||
/********************************************************************************************
|
||||
* Helper class for further serialisation
|
||||
********************************************************************************************/
|
||||
|
||||
class StringExpression ;
|
||||
class Expression ;
|
||||
|
||||
class LinearizedExpression
|
||||
{
|
||||
public:
|
||||
std::vector<uint8_t> _tokens ;
|
||||
std::vector<uint32_t> _ints ;
|
||||
std::vector<std::string> _strings ;
|
||||
|
||||
typedef enum { EXPR_DATE= 0,
|
||||
EXPR_POP = 1,
|
||||
EXPR_SIZE= 2,
|
||||
EXPR_HASH= 3,
|
||||
EXPR_NAME= 4,
|
||||
EXPR_PATH= 5,
|
||||
EXPR_EXT = 6,
|
||||
EXPR_COMP= 7 } token ;
|
||||
|
||||
static Expression *toExpr(const LinearizedExpression& e) ;
|
||||
|
||||
private:
|
||||
static Expression *toExpr(const LinearizedExpression& e,int&,int&,int&) ;
|
||||
static void readStringExpr(const LinearizedExpression& e,int& n_ints,int& n_strings,std::list<std::string>& strings,bool& b,StringOperator& op) ;
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************************
|
||||
Boolean Search Expression
|
||||
classes:
|
||||
|
||||
Expression: The base class of all expression typest
|
||||
CompoundExpression: The expression which uses a logical operator to combine
|
||||
the results of two expressions
|
||||
StringExpression: An expression which uses some sort of string comparison.
|
||||
RelExpression: A Relational Expression where > < >= <= == make sense.
|
||||
e.g. size date etc
|
||||
|
||||
******************************************************************************************/
|
||||
|
||||
class FileEntry;
|
||||
|
||||
class Expression
|
||||
{
|
||||
public:
|
||||
virtual bool eval (FileEntry *file) = 0;
|
||||
virtual ~Expression() {};
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const = 0 ;
|
||||
};
|
||||
|
||||
|
||||
class CompoundExpression : public Expression
|
||||
{
|
||||
public:
|
||||
CompoundExpression( enum LogicalOperator op, Expression * exp1, Expression *exp2)
|
||||
: Lexp(exp1), Rexp(exp2), Op(op){ }
|
||||
|
||||
bool eval (FileEntry *file) {
|
||||
if (Lexp == NULL or Rexp == NULL) {
|
||||
return false;
|
||||
}
|
||||
switch (Op){
|
||||
case AndOp:
|
||||
return Lexp->eval(file) && Rexp->eval(file);
|
||||
case OrOp:
|
||||
return Lexp->eval(file) || Rexp->eval(file);
|
||||
case XorOp:
|
||||
return Lexp->eval(file) ^ Rexp->eval(file);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
virtual ~CompoundExpression(){
|
||||
delete Lexp;
|
||||
delete Rexp;
|
||||
}
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const ;
|
||||
private:
|
||||
Expression *Lexp;
|
||||
Expression *Rexp;
|
||||
enum LogicalOperator Op;
|
||||
|
||||
};
|
||||
|
||||
class StringExpression: public Expression
|
||||
{
|
||||
public:
|
||||
StringExpression(enum StringOperator op, std::list<std::string> &t, bool ic): Op(op),terms(t), IgnoreCase(ic){}
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const ;
|
||||
protected:
|
||||
bool evalStr(std::string &str);
|
||||
|
||||
enum StringOperator Op;
|
||||
std::list<std::string> terms;
|
||||
bool IgnoreCase;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class RelExpression: public Expression
|
||||
{
|
||||
public:
|
||||
RelExpression(enum RelOperator op, T lv, T hv): Op(op), LowerValue(lv), HigherValue(hv) {}
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const ;
|
||||
protected:
|
||||
bool evalRel(T val);
|
||||
|
||||
enum RelOperator Op;
|
||||
T LowerValue;
|
||||
T HigherValue;
|
||||
};
|
||||
|
||||
template<> void RelExpression<int>::linearize(LinearizedExpression& e) const ;
|
||||
|
||||
template <class T>
|
||||
bool RelExpression<T>::evalRel(T val) {
|
||||
switch (Op) {
|
||||
case Equals:
|
||||
return LowerValue == val;
|
||||
case GreaterEquals:
|
||||
return LowerValue >= val;
|
||||
case Greater:
|
||||
return LowerValue > val;
|
||||
case SmallerEquals:
|
||||
return LowerValue <= val;
|
||||
case Smaller:
|
||||
return LowerValue < val;
|
||||
case InRange:
|
||||
return (LowerValue <= val) && (val <= HigherValue);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************
|
||||
Binary Predicate for Case Insensitive search
|
||||
|
||||
******************************************************************************************/
|
||||
/*Binary predicate for case insensitive character comparison.*/
|
||||
/*TODOS:
|
||||
*Factor locales in the comparison
|
||||
*/
|
||||
struct CompareCharIC :
|
||||
public std::binary_function< char , char , bool> {
|
||||
|
||||
bool operator () ( char ch1 , char ch2 ) const {
|
||||
return tolower( static_cast < unsigned char > (ch1) )
|
||||
== tolower( static_cast < unsigned char > (ch2) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/******************************************************************************************
|
||||
Some implementations of StringExpressions.
|
||||
|
||||
******************************************************************************************/
|
||||
|
||||
class NameExpression: public StringExpression
|
||||
{
|
||||
public:
|
||||
NameExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
|
||||
StringExpression(op,t,ic) {}
|
||||
bool eval(FileEntry *file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_NAME) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
class PathExpression: public StringExpression {
|
||||
public:
|
||||
PathExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
|
||||
StringExpression(op,t,ic) {}
|
||||
bool eval(FileEntry *file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_PATH) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
class ExtExpression: public StringExpression {
|
||||
public:
|
||||
ExtExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
|
||||
StringExpression(op,t,ic) {}
|
||||
bool eval(FileEntry *file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_EXT) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
class HashExpression: public StringExpression {
|
||||
public:
|
||||
HashExpression(enum StringOperator op, std::list<std::string> &t):
|
||||
StringExpression(op,t, true) {}
|
||||
bool eval(FileEntry *file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_HASH) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************************
|
||||
Some implementations of Relational Expressions.
|
||||
|
||||
******************************************************************************************/
|
||||
|
||||
class DateExpression: public RelExpression<int>
|
||||
{
|
||||
public:
|
||||
DateExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
DateExpression(enum RelOperator op, int lv, int hv):
|
||||
RelExpression<int>(op,lv,hv) {}
|
||||
bool eval(FileEntry *file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_DATE) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
class SizeExpression: public RelExpression<int>
|
||||
{
|
||||
public:
|
||||
SizeExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
SizeExpression(enum RelOperator op, int lv, int hv):
|
||||
RelExpression<int>(op,lv,hv) {}
|
||||
bool eval(FileEntry *file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_SIZE) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
class PopExpression: public RelExpression<int>
|
||||
{
|
||||
public:
|
||||
PopExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
PopExpression(enum RelOperator op, int lv, int hv): RelExpression<int>(op,lv,hv) {}
|
||||
PopExpression(const LinearizedExpression& e) ;
|
||||
bool eval(FileEntry *file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_POP) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* RS_EXPRESSIONS_H */
|
||||
|
||||
199
libretroshare/src/retroshare/rsfiles.h
Normal file
199
libretroshare/src/retroshare/rsfiles.h
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
#ifndef RS_FILES_GUI_INTERFACE_H
|
||||
#define RS_FILES_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsfiles.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 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 <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "rstypes.h"
|
||||
|
||||
class RsFiles;
|
||||
extern RsFiles *rsFiles;
|
||||
|
||||
class Expression;
|
||||
|
||||
/* These are used mainly by ftController at the moment */
|
||||
const uint32_t RS_FILE_CTRL_PAUSE = 0x00000100;
|
||||
const uint32_t RS_FILE_CTRL_START = 0x00000200;
|
||||
const uint32_t RS_FILE_CTRL_FORCE_CHECK = 0x00000400;
|
||||
|
||||
const uint32_t RS_FILE_RATE_TRICKLE = 0x00000001;
|
||||
const uint32_t RS_FILE_RATE_SLOW = 0x00000002;
|
||||
const uint32_t RS_FILE_RATE_STANDARD = 0x00000003;
|
||||
const uint32_t RS_FILE_RATE_FAST = 0x00000004;
|
||||
const uint32_t RS_FILE_RATE_STREAM_AUDIO = 0x00000005;
|
||||
const uint32_t RS_FILE_RATE_STREAM_VIDEO = 0x00000006;
|
||||
|
||||
const uint32_t RS_FILE_PEER_ONLINE = 0x00001000;
|
||||
const uint32_t RS_FILE_PEER_OFFLINE = 0x00002000;
|
||||
|
||||
/************************************
|
||||
* Used To indicate where to search.
|
||||
*
|
||||
* The Order of these is very important,
|
||||
* it specifies the search order too.
|
||||
*
|
||||
*/
|
||||
|
||||
const uint32_t RS_FILE_HINTS_MASK = 0x00ffffff;
|
||||
|
||||
const uint32_t RS_FILE_HINTS_CACHE = 0x00000001;
|
||||
const uint32_t RS_FILE_HINTS_EXTRA = 0x00000002;
|
||||
const uint32_t RS_FILE_HINTS_LOCAL = 0x00000004;
|
||||
const uint32_t RS_FILE_HINTS_REMOTE = 0x00000008;
|
||||
const uint32_t RS_FILE_HINTS_DOWNLOAD = 0x00000010;
|
||||
const uint32_t RS_FILE_HINTS_UPLOAD = 0x00000020;
|
||||
|
||||
const uint32_t RS_FILE_HINTS_NETWORK_WIDE = 0x00000080; // anonymously shared over network
|
||||
const uint32_t RS_FILE_HINTS_BROWSABLE = 0x00000100; // browsable by friends
|
||||
const uint32_t RS_FILE_HINTS_ASSUME_AVAILABILITY = 0x00000200; // Assume full source availability. Used for cache files.
|
||||
|
||||
const uint32_t RS_FILE_HINTS_SPEC_ONLY = 0x01000000;
|
||||
const uint32_t RS_FILE_HINTS_NO_SEARCH = 0x02000000;
|
||||
|
||||
/* Callback Codes */
|
||||
//const uint32_t RS_FILE_HINTS_CACHE = 0x00000001; // ALREADY EXISTS
|
||||
const uint32_t RS_FILE_HINTS_MEDIA = 0x00001000;
|
||||
|
||||
const uint32_t RS_FILE_HINTS_BACKGROUND = 0x00002000; // To download slowly.
|
||||
|
||||
const uint32_t RS_FILE_EXTRA_DELETE = 0x0010;
|
||||
|
||||
const uint32_t CB_CODE_CACHE = 0x0001;
|
||||
const uint32_t CB_CODE_EXTRA = 0x0002;
|
||||
const uint32_t CB_CODE_MEDIA = 0x0004;
|
||||
|
||||
struct SharedDirInfo
|
||||
{
|
||||
std::string filename ;
|
||||
uint32_t shareflags ; // RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE
|
||||
};
|
||||
|
||||
class RsFiles
|
||||
{
|
||||
public:
|
||||
|
||||
RsFiles() { return; }
|
||||
virtual ~RsFiles() { return; }
|
||||
|
||||
/****************************************/
|
||||
/* download */
|
||||
|
||||
|
||||
/***
|
||||
* Control of Downloads.
|
||||
***/
|
||||
|
||||
/// Returns false is we already have the file. Otherwise, initiates the dl and returns true.
|
||||
virtual bool FileRequest(const std::string& fname, const std::string& hash, uint64_t size, const std::string& dest, uint32_t flags, const std::list<std::string>& srcIds) = 0;
|
||||
virtual bool FileCancel(const std::string& hash) = 0;
|
||||
virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy) = 0;
|
||||
virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) = 0;
|
||||
virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() = 0;
|
||||
virtual uint32_t freeDiskSpaceLimit() const =0;
|
||||
virtual void setFreeDiskSpaceLimit(uint32_t size_in_mb) =0;
|
||||
virtual bool FileControl(const std::string& hash, uint32_t flags) = 0;
|
||||
virtual bool FileClearCompleted() = 0;
|
||||
|
||||
/***
|
||||
* Control of Downloads Priority.
|
||||
***/
|
||||
virtual uint32_t getQueueSize() = 0 ;
|
||||
virtual void setQueueSize(uint32_t s) = 0 ;
|
||||
virtual bool changeQueuePosition(const std::string hash, QueueMove mv) = 0;
|
||||
virtual bool changeDownloadSpeed(const std::string hash, int speed) = 0;
|
||||
virtual bool getDownloadSpeed(const std::string hash, int & speed) = 0;
|
||||
virtual bool clearDownload(const std::string hash) = 0;
|
||||
// virtual void getDwlDetails(std::list<DwlDetails> & details) = 0;
|
||||
|
||||
/***
|
||||
* Download / Upload Details.
|
||||
***/
|
||||
virtual bool FileDownloads(std::list<std::string> &hashs) = 0;
|
||||
virtual bool FileUploads(std::list<std::string> &hashs) = 0;
|
||||
virtual bool FileDetails(std::string hash, uint32_t hintflags, FileInfo &info) = 0;
|
||||
|
||||
/// Gives chunk details about the downloaded file with given hash.
|
||||
virtual bool FileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info) = 0 ;
|
||||
|
||||
/// details about the upload with given hash
|
||||
virtual bool FileUploadChunksDetails(const std::string& hash,const std::string& peer_id,CompressedChunkMap& map) = 0 ;
|
||||
|
||||
/***
|
||||
* Extra List Access
|
||||
***/
|
||||
virtual bool ExtraFileAdd(std::string fname, std::string hash, uint64_t size,
|
||||
uint32_t period, uint32_t flags) = 0;
|
||||
virtual bool ExtraFileRemove(std::string hash, uint32_t flags) = 0;
|
||||
virtual bool ExtraFileHash(std::string localpath,
|
||||
uint32_t period, uint32_t flags) = 0;
|
||||
virtual bool ExtraFileStatus(std::string localpath, FileInfo &info) = 0;
|
||||
virtual bool ExtraFileMove(std::string fname, std::string hash, uint64_t size,
|
||||
std::string destpath) = 0;
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* Directory Listing / Search Interface
|
||||
*/
|
||||
virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details) = 0;
|
||||
virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) = 0;
|
||||
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags) = 0;
|
||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t flags) = 0;
|
||||
|
||||
/***
|
||||
* Utility Functions.
|
||||
***/
|
||||
virtual bool ConvertSharedFilePath(std::string path, std::string &fullpath) = 0;
|
||||
virtual void ForceDirectoryCheck() = 0;
|
||||
virtual bool InDirectoryCheck() = 0;
|
||||
|
||||
/***
|
||||
* Directory Control
|
||||
***/
|
||||
virtual void setDownloadDirectory(std::string path) = 0;
|
||||
virtual void setPartialsDirectory(std::string path) = 0;
|
||||
virtual std::string getDownloadDirectory() = 0;
|
||||
virtual std::string getPartialsDirectory() = 0;
|
||||
|
||||
virtual bool getSharedDirectories(std::list<SharedDirInfo> &dirs) = 0;
|
||||
virtual bool addSharedDirectory(SharedDirInfo dir) = 0;
|
||||
virtual bool updateShareFlags(const SharedDirInfo& dir) = 0; // updates the flags. The directory should already exist !
|
||||
virtual bool removeSharedDirectory(std::string dir) = 0;
|
||||
|
||||
virtual void setShareDownloadDirectory(bool value) = 0;
|
||||
virtual bool getShareDownloadDirectory() = 0;
|
||||
virtual bool shareDownloadDirectory() = 0;
|
||||
virtual bool unshareDownloadDirectory() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
145
libretroshare/src/retroshare/rsforums.h
Normal file
145
libretroshare/src/retroshare/rsforums.h
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
#ifndef RS_FORUM_GUI_INTERFACE_H
|
||||
#define RS_FORUM_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsforums.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 <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "rstypes.h"
|
||||
#include "rsdistrib.h" /* For FLAGS */
|
||||
|
||||
#define RS_FORUMMSG_NEW 0x0010
|
||||
|
||||
|
||||
class ForumInfo
|
||||
{
|
||||
public:
|
||||
ForumInfo()
|
||||
{
|
||||
forumFlags = 0 ;
|
||||
subscribeFlags = 0 ;
|
||||
pop = 0 ;
|
||||
lastPost = 0 ;
|
||||
}
|
||||
std::string forumId;
|
||||
std::wstring forumName;
|
||||
std::wstring forumDesc;
|
||||
|
||||
uint32_t forumFlags;
|
||||
uint32_t subscribeFlags;
|
||||
|
||||
uint32_t pop;
|
||||
|
||||
time_t lastPost;
|
||||
};
|
||||
|
||||
class ForumMsgInfo
|
||||
{
|
||||
public:
|
||||
ForumMsgInfo()
|
||||
{
|
||||
msgflags = 0 ;
|
||||
ts = childTS = status = 0 ;
|
||||
}
|
||||
std::string forumId;
|
||||
std::string threadId;
|
||||
std::string parentId;
|
||||
std::string msgId;
|
||||
|
||||
std::string srcId; /* if Authenticated -> signed here */
|
||||
|
||||
unsigned int msgflags;
|
||||
|
||||
std::wstring title;
|
||||
std::wstring msg;
|
||||
time_t ts;
|
||||
time_t childTS;
|
||||
uint32_t status;
|
||||
};
|
||||
|
||||
|
||||
class ThreadInfoSummary
|
||||
{
|
||||
public:
|
||||
ThreadInfoSummary()
|
||||
{
|
||||
msgflags = 0 ;
|
||||
count = 0 ;
|
||||
ts = childTS = 0 ;
|
||||
}
|
||||
std::string forumId;
|
||||
std::string threadId;
|
||||
std::string parentId;
|
||||
std::string msgId;
|
||||
|
||||
uint32_t msgflags;
|
||||
|
||||
std::wstring title;
|
||||
std::wstring msg;
|
||||
int count; /* file count */
|
||||
time_t ts;
|
||||
time_t childTS;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const ForumInfo &info);
|
||||
std::ostream &operator<<(std::ostream &out, const ThreadInfoSummary &info);
|
||||
std::ostream &operator<<(std::ostream &out, const ForumMsgInfo &info);
|
||||
|
||||
class RsForums;
|
||||
extern RsForums *rsForums;
|
||||
|
||||
class RsForums
|
||||
{
|
||||
public:
|
||||
|
||||
RsForums() { return; }
|
||||
virtual ~RsForums() { return; }
|
||||
|
||||
/****************************************/
|
||||
|
||||
virtual bool forumsChanged(std::list<std::string> &forumIds) = 0;
|
||||
|
||||
|
||||
virtual std::string createForum(std::wstring forumName, std::wstring forumDesc, uint32_t forumFlags) = 0;
|
||||
|
||||
virtual bool getForumInfo(std::string fId, ForumInfo &fi) = 0;
|
||||
virtual bool getForumList(std::list<ForumInfo> &forumList) = 0;
|
||||
virtual bool getForumThreadList(std::string fId, std::list<ThreadInfoSummary> &msgs) = 0;
|
||||
virtual bool getForumThreadMsgList(std::string fId, std::string pId, std::list<ThreadInfoSummary> &msgs) = 0;
|
||||
virtual bool getForumMessage(std::string fId, std::string mId, ForumMsgInfo &msg) = 0;
|
||||
virtual bool setMessageStatus(const std::string& fId,const std::string& mId,const uint32_t status) = 0;
|
||||
virtual bool ForumMessageSend(ForumMsgInfo &info) = 0;
|
||||
|
||||
virtual bool forumSubscribe(std::string fId, bool subscribe) = 0;
|
||||
/****************************************/
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
113
libretroshare/src/retroshare/rsgame.h
Normal file
113
libretroshare/src/retroshare/rsgame.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
#ifndef RS_GAME_GUI_INTERFACE_H
|
||||
#define RS_GAME_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsgame.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 "rstypes.h"
|
||||
|
||||
|
||||
class RsGameLauncher;
|
||||
|
||||
/* declare single RsIface for everyone to use! */
|
||||
|
||||
extern RsGameLauncher *rsGameLauncher;
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <inttypes.h>
|
||||
|
||||
class RsGameInfo
|
||||
{
|
||||
public:
|
||||
|
||||
std::string gameId;
|
||||
std::string serverId;
|
||||
|
||||
std::string gameType;
|
||||
std::wstring gameName;
|
||||
std::string serverName;
|
||||
std::string status;
|
||||
uint16_t numPlayers;
|
||||
|
||||
};
|
||||
|
||||
class RsGamePeer
|
||||
{
|
||||
public:
|
||||
std::string id;
|
||||
bool invite;
|
||||
bool interested;
|
||||
bool play;
|
||||
};
|
||||
|
||||
class RsGameDetail
|
||||
{
|
||||
public:
|
||||
std::string gameId;
|
||||
std::string gameType;
|
||||
std::wstring gameName;
|
||||
|
||||
bool areServer; /* are we the server? */
|
||||
std::string serverId; /* if not, who is? */
|
||||
std::string serverName;
|
||||
|
||||
std::string status;
|
||||
|
||||
uint16_t numPlayers;
|
||||
std::map<std::string, RsGamePeer> gamers;
|
||||
|
||||
};
|
||||
|
||||
class RsGameLauncher
|
||||
{
|
||||
public:
|
||||
|
||||
/* server commands */
|
||||
virtual std::string createGame(uint32_t gameType, std::wstring name) = 0;
|
||||
virtual bool deleteGame(std::string gameId) = 0;
|
||||
virtual bool inviteGame(std::string gameId) = 0;
|
||||
virtual bool playGame(std::string gameId) = 0;
|
||||
//virtual bool quitGame(std::string gameId) = 0;
|
||||
|
||||
virtual bool invitePeer(std::string gameId, std::string peerId) = 0;
|
||||
virtual bool uninvitePeer(std::string gameId, std::string peerId) = 0;
|
||||
virtual bool confirmPeer(std::string gameId, std::string peerId,
|
||||
int16_t pos = -1) = 0;
|
||||
virtual bool unconfirmPeer(std::string gameId, std::string peerId) = 0;
|
||||
|
||||
/* client commands */
|
||||
virtual bool interestedPeer(std::string gameId) = 0;
|
||||
virtual bool uninterestedPeer(std::string gameId) = 0;
|
||||
|
||||
/* get details */
|
||||
virtual bool getGameList(std::list<RsGameInfo> &gameList) = 0;
|
||||
virtual bool getGameDetail(std::string gameId, RsGameDetail &detail) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
232
libretroshare/src/retroshare/rsiface.h
Normal file
232
libretroshare/src/retroshare/rsiface.h
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
#ifndef RETROSHARE_GUI_INTERFACE_H
|
||||
#define RETROSHARE_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* "$Id: rsiface.h,v 1.9 2007-04-21 19:08:51 rmf24 Exp $"
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2004-2006 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 "rstypes.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
class NotifyBase;
|
||||
class RsIface;
|
||||
class RsControl;
|
||||
class RsInit;
|
||||
struct TurtleFileInfo ;
|
||||
|
||||
/* declare single RsIface for everyone to use! */
|
||||
|
||||
extern RsIface *rsiface;
|
||||
extern RsControl *rsicontrol;
|
||||
|
||||
/* RsInit -> Configuration Parameters for RetroShare Startup
|
||||
*/
|
||||
|
||||
RsInit *InitRsConfig();
|
||||
/* extract various options for GUI */
|
||||
const char *RsConfigDirectory(RsInit *config);
|
||||
bool RsConfigStartMinimised(RsInit *config);
|
||||
void CleanupRsConfig(RsInit *);
|
||||
|
||||
|
||||
// Called First... (handles comandline options)
|
||||
int InitRetroShare(int argc, char **argv, RsInit *config);
|
||||
|
||||
// This Functions are used for Login.
|
||||
bool ValidateCertificate(RsInit *config, std::string &userName);
|
||||
bool ValidateTrustedUser(RsInit *config, std::string fname, std::string &userName);
|
||||
bool LoadPassword(RsInit *config, std::string passwd);
|
||||
bool RsGenerateCertificate(RsInit *config, std::string name, std::string org,
|
||||
std::string loc, std::string country, std::string passwd, std::string &errString);
|
||||
|
||||
/* Auto Login Fns */
|
||||
bool RsTryAutoLogin(RsInit *config);
|
||||
bool RsStoreAutoLogin(RsInit *config);
|
||||
bool RsClearAutoLogin(std::string basedir);
|
||||
|
||||
// Handle actual Login.
|
||||
int LoadCertificates(RsInit *config, bool autoLoginNT);
|
||||
|
||||
RsIface *createRsIface (NotifyBase ¬ify);
|
||||
RsControl *createRsControl(RsIface &iface, NotifyBase ¬ify);
|
||||
|
||||
|
||||
class RsIface /* The Main Interface Class - create a single one! */
|
||||
{
|
||||
public:
|
||||
RsIface(NotifyBase &callback)
|
||||
:cb(callback) { return; }
|
||||
virtual ~RsIface() { return; }
|
||||
|
||||
/****************************************/
|
||||
|
||||
/* Stubs for Very Important Fns -> Locking Functions */
|
||||
virtual void lockData() = 0;
|
||||
virtual void unlockData() = 0;
|
||||
|
||||
const std::list<FileInfo> &getRecommendList()
|
||||
{ return mRecommendList; }
|
||||
|
||||
const RsConfig &getConfig()
|
||||
{ return mConfig; }
|
||||
/****************************************/
|
||||
|
||||
|
||||
/* Flags to indicate used or not */
|
||||
enum DataFlags
|
||||
{
|
||||
Neighbour = 0,
|
||||
Friend = 1,
|
||||
DirLocal = 2, /* Not Used - QModel instead */
|
||||
DirRemote = 3, /* Not Used - QModel instead */
|
||||
Transfer = 4,
|
||||
Message = 5,
|
||||
Channel = 6,
|
||||
Chat = 7,
|
||||
Recommend = 8,
|
||||
Config = 9,
|
||||
NumOfFlags = 10
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Operations for flags
|
||||
*/
|
||||
|
||||
bool setChanged(DataFlags set); /* set to true */
|
||||
bool getChanged(DataFlags set); /* leaves it */
|
||||
bool hasChanged(DataFlags set); /* resets it */
|
||||
|
||||
private:
|
||||
|
||||
void fillLists(); /* create some dummy data to display */
|
||||
|
||||
/* Internals */
|
||||
std::list<FileInfo> mRecommendList;
|
||||
|
||||
bool mChanged[NumOfFlags];
|
||||
|
||||
RsConfig mConfig;
|
||||
|
||||
NotifyBase &cb;
|
||||
|
||||
/* Classes which can update the Lists! */
|
||||
friend class RsControl;
|
||||
friend class RsServer;
|
||||
};
|
||||
|
||||
|
||||
class RsControl /* The Main Interface Class - for controlling the server */
|
||||
{
|
||||
public:
|
||||
|
||||
RsControl(RsIface &i, NotifyBase &callback)
|
||||
:cb(callback), rsIface(i) { return; }
|
||||
|
||||
virtual ~RsControl() { return; }
|
||||
|
||||
/* Real Startup Fn */
|
||||
virtual int StartupRetroShare() = 0;
|
||||
|
||||
/****************************************/
|
||||
|
||||
/* Flagging Persons / Channels / Files in or out of a set (CheckLists) */
|
||||
virtual int SetInChat(std::string id, bool in) = 0; /* friend : chat msgs */
|
||||
virtual int SetInMsg(std::string id, bool in) = 0; /* friend : msg receipients */
|
||||
virtual int SetInBroadcast(std::string id, bool in) = 0; /* channel : channel broadcast */
|
||||
virtual int SetInSubscribe(std::string id, bool in) = 0; /* channel : subscribed channels */
|
||||
virtual int SetInRecommend(std::string id, bool in) = 0; /* file : recommended file */
|
||||
virtual int ClearInChat() = 0;
|
||||
virtual int ClearInMsg() = 0;
|
||||
virtual int ClearInBroadcast() = 0;
|
||||
virtual int ClearInSubscribe() = 0;
|
||||
virtual int ClearInRecommend() = 0;
|
||||
|
||||
virtual bool IsInChat(std::string id) = 0; /* friend : chat msgs */
|
||||
virtual bool IsInMsg(std::string id) = 0; /* friend : msg recpts*/
|
||||
|
||||
/****************************************/
|
||||
/* Config */
|
||||
|
||||
virtual int ConfigSetDataRates( int totalDownload, int totalUpload ) = 0;
|
||||
virtual int ConfigGetDataRates( float &inKb, float &outKb) = 0;
|
||||
virtual int ConfigSetBootPrompt( bool on ) = 0;
|
||||
virtual void ConfigFinalSave( ) = 0;
|
||||
virtual void rsGlobalShutDown( ) = 0;
|
||||
|
||||
/****************************************/
|
||||
|
||||
NotifyBase &getNotify() { return cb; }
|
||||
RsIface &getIface() { return rsIface; }
|
||||
|
||||
private:
|
||||
NotifyBase &cb;
|
||||
RsIface &rsIface;
|
||||
};
|
||||
|
||||
|
||||
/********************** Overload this Class for callback *****************/
|
||||
|
||||
|
||||
class NotifyBase
|
||||
{
|
||||
public:
|
||||
NotifyBase() { return; }
|
||||
virtual ~NotifyBase() { return; }
|
||||
virtual void notifyListPreChange(int list, int type) { (void) list; (void) type; return; }
|
||||
virtual void notifyListChange(int list, int type) { (void) list; (void) type; return; }
|
||||
virtual void notifyErrorMsg(int list, int sev, std::string msg) { (void) list; (void) sev; (void) msg; return; }
|
||||
virtual void notifyChat() { return; }
|
||||
virtual void notifyChatStatus(const std::string& /* peer_id */, const std::string& /* status_string */ ,bool /* is_private */) {}
|
||||
virtual void notifyCustomState(const std::string& /* peer_id */) {}
|
||||
virtual void notifyHashingInfo(std::string fileinfo) { (void)fileinfo; return ; }
|
||||
virtual void notifyTurtleSearchResult(uint32_t /* search_id */ ,const std::list<TurtleFileInfo>& files) { (void)files; }
|
||||
virtual void notifyPeerHasNewAvatar(std::string peer_id) { (void)peer_id; }
|
||||
virtual void notifyOwnAvatarChanged() {}
|
||||
virtual void notifyOwnStatusMessageChanged() {}
|
||||
virtual void notifyDiskFull(uint32_t /* location */,uint32_t /* size limit in MB */) {}
|
||||
|
||||
virtual std::string askForPassword(const std::string& /* key_details */ ,bool /* prev_is_bad */ ) { return "" ;}
|
||||
};
|
||||
|
||||
const int NOTIFY_LIST_NEIGHBOURS = 1;
|
||||
const int NOTIFY_LIST_FRIENDS = 2;
|
||||
const int NOTIFY_LIST_SEARCHLIST = 4;
|
||||
const int NOTIFY_LIST_MESSAGELIST = 5;
|
||||
const int NOTIFY_LIST_CHANNELLIST = 6;
|
||||
const int NOTIFY_LIST_TRANSFERLIST = 7;
|
||||
const int NOTIFY_LIST_CONFIG = 8;
|
||||
const int NOTIFY_LIST_DIRLIST_LOCAL = 9;
|
||||
const int NOTIFY_LIST_DIRLIST_FRIENDS = 10;
|
||||
|
||||
const int NOTIFY_TYPE_SAME = 0x01;
|
||||
const int NOTIFY_TYPE_MOD = 0x02; /* general purpose, check all */
|
||||
const int NOTIFY_TYPE_ADD = 0x04; /* flagged additions */
|
||||
const int NOTIFY_TYPE_DEL = 0x08; /* flagged deletions */
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
160
libretroshare/src/retroshare/rsinit.h
Normal file
160
libretroshare/src/retroshare/rsinit.h
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
#ifndef RETROSHARE_INIT_INTERFACE_H
|
||||
#define RETROSHARE_INIT_INTERFACE_H
|
||||
|
||||
/*
|
||||
* "$Id: rsiface.h,v 1.9 2007-04-21 19:08:51 rmf24 Exp $"
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2004-2006 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".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/****
|
||||
* #define RS_USE_PGPSSL 1
|
||||
***/
|
||||
|
||||
#define RS_USE_PGPSSL 1
|
||||
|
||||
/*!
|
||||
* Initialisation Class (not publicly disclosed to RsIFace)
|
||||
*/
|
||||
class RsInit
|
||||
{
|
||||
public:
|
||||
/* reorganised RsInit system */
|
||||
|
||||
/*!
|
||||
* PreLogin
|
||||
* Call before init retroshare, initialises rsinitconfig's public attributes
|
||||
*/
|
||||
static void InitRsConfig() ;
|
||||
|
||||
/*!
|
||||
* Should be called to load up ssl cert and private key, and intialises gpg
|
||||
* this must be called before accessing rsserver (e.g. ::startupretroshare)
|
||||
* @param argc passed from executable
|
||||
* @param argv commandline arguments passed to executable
|
||||
* @param strictCheck set to true if you want rs to continue executing if invalid argument passed and vice versa
|
||||
* @return one is initialisation has been successful
|
||||
*/
|
||||
static int InitRetroShare(int argc, char **argv,
|
||||
bool strictCheck=true);
|
||||
|
||||
/*!
|
||||
* This return directory seperator for different platforms, not an issue anymore as C library can distinguish
|
||||
* @returns directory of seperator used for different platforms
|
||||
*
|
||||
*/
|
||||
static char dirSeperator();
|
||||
static bool isPortable();
|
||||
|
||||
|
||||
/*!
|
||||
* Account Details (Combined GPG+SSL Setup)
|
||||
*/
|
||||
static bool getPreferedAccountId(std::string &id);
|
||||
static bool getPGPEngineFileName(std::string &fileName);
|
||||
static bool getAccountIds(std::list<std::string> &ids);
|
||||
static bool getAccountDetails(std::string id,
|
||||
std::string &gpgId, std::string &gpgName,
|
||||
std::string &gpgEmail, std::string &sslName);
|
||||
|
||||
static bool ValidateCertificate(std::string &userName) ;
|
||||
|
||||
|
||||
/*!
|
||||
* Generating GPGme Account
|
||||
*/
|
||||
static int GetPGPLogins(std::list<std::string> &pgpIds);
|
||||
static int GetPGPLoginDetails(std::string id, std::string &name, std::string &email);
|
||||
static bool GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString);
|
||||
|
||||
/*!
|
||||
* Login GGP
|
||||
*/
|
||||
static bool SelectGPGAccount(const std::string& gpgId);
|
||||
static bool LoadGPGPassword(std::string passwd);
|
||||
|
||||
/*!
|
||||
* Create SSL Certificates
|
||||
*/
|
||||
static bool GenerateSSLCertificate(std::string name, std::string org, std::string loc, std::string country, std::string passwd, std::string &sslId, std::string &errString);
|
||||
|
||||
/*!
|
||||
* intialises directories for passwords and ssl keys
|
||||
*/
|
||||
static bool LoadPassword(std::string id, std::string passwd) ;
|
||||
|
||||
/*!
|
||||
* Final Certificate load. This can be called if:
|
||||
* a) InitRetroshare() returns true -> autoLoad/password Set.
|
||||
* b) SelectGPGAccount() && LoadPassword()
|
||||
*
|
||||
* This wrapper is used to lock the profile first before
|
||||
* finalising the login
|
||||
*/
|
||||
static int LockAndLoadCertificates(bool autoLoginNT);
|
||||
|
||||
|
||||
/*!
|
||||
* Post Login Options
|
||||
*/
|
||||
static std::string RsConfigDirectory();
|
||||
|
||||
static std::string RsProfileConfigDirectory();
|
||||
static bool setStartMinimised() ;
|
||||
|
||||
static int getSslPwdLen();
|
||||
static bool getAutoLogin();
|
||||
static void setAutoLogin(bool autoLogin);
|
||||
static bool RsClearAutoLogin() ;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/* PreLogin */
|
||||
static std::string getHomePath() ;
|
||||
static void setupBaseDir();
|
||||
|
||||
/* Account Details */
|
||||
static bool get_configinit(std::string dir, std::string &id);
|
||||
static bool create_configinit(std::string dir, std::string id);
|
||||
|
||||
static bool setupAccount(std::string accountdir);
|
||||
|
||||
/* Auto Login */
|
||||
static bool RsStoreAutoLogin() ;
|
||||
static bool RsTryAutoLogin() ;
|
||||
|
||||
/* Lock/unlock profile directory */
|
||||
static int LockConfigDirectory(const std::string& accountDir);
|
||||
static void UnlockConfigDirectory();
|
||||
|
||||
/* The true LoadCertificates() method */
|
||||
static int LoadCertificates(bool autoLoginNT) ;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
157
libretroshare/src/retroshare/rsmsgs.h
Normal file
157
libretroshare/src/retroshare/rsmsgs.h
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
#ifndef RS_MSG_GUI_INTERFACE_H
|
||||
#define RS_MSG_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsmsgs.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 <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "rstypes.h"
|
||||
|
||||
/********************** For Messages and Channels *****************/
|
||||
|
||||
#define RS_MSG_BOXMASK 0x000f /* Mask for determining Box */
|
||||
|
||||
#define RS_MSG_OUTGOING 0x0001 /* !Inbox */
|
||||
#define RS_MSG_PENDING 0x0002 /* OutBox */
|
||||
#define RS_MSG_DRAFT 0x0004 /* Draft */
|
||||
|
||||
/* ORs of above */
|
||||
#define RS_MSG_INBOX 0x00 /* Inbox */
|
||||
#define RS_MSG_SENTBOX 0x01 /* Sentbox */
|
||||
#define RS_MSG_OUTBOX 0x03 /* Outbox */
|
||||
#define RS_MSG_DRAFTBOX 0x05 /* Draftbox */
|
||||
|
||||
#define RS_MSG_NEW 0x0010 /* New */
|
||||
#define RS_MSG_TRASH 0x0020 /* Trash */
|
||||
|
||||
class MessageInfo
|
||||
{
|
||||
public:
|
||||
MessageInfo() {}
|
||||
std::string msgId;
|
||||
std::string srcId;
|
||||
|
||||
unsigned int msgflags;
|
||||
|
||||
std::list<std::string> msgto;
|
||||
std::list<std::string> msgcc;
|
||||
std::list<std::string> msgbcc;
|
||||
|
||||
std::wstring title;
|
||||
std::wstring msg;
|
||||
|
||||
std::wstring attach_title;
|
||||
std::wstring attach_comment;
|
||||
std::list<FileInfo> files;
|
||||
int size; /* total of files */
|
||||
int count; /* file count */
|
||||
|
||||
int ts;
|
||||
};
|
||||
|
||||
class MsgInfoSummary
|
||||
{
|
||||
public:
|
||||
MsgInfoSummary() {}
|
||||
|
||||
std::string msgId;
|
||||
std::string srcId;
|
||||
|
||||
uint32_t msgflags;
|
||||
|
||||
std::wstring title;
|
||||
int count; /* file count */
|
||||
time_t ts;
|
||||
|
||||
};
|
||||
|
||||
#define RS_CHAT_PUBLIC 0x0001
|
||||
#define RS_CHAT_PRIVATE 0x0002
|
||||
#define RS_CHAT_AVATAR_AVAILABLE 0x0004
|
||||
|
||||
class ChatInfo
|
||||
{
|
||||
public:
|
||||
std::string rsid;
|
||||
unsigned int chatflags;
|
||||
std::string name;
|
||||
std::wstring msg;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const MessageInfo &info);
|
||||
std::ostream &operator<<(std::ostream &out, const ChatInfo &info);
|
||||
|
||||
class RsMsgs;
|
||||
extern RsMsgs *rsMsgs;
|
||||
|
||||
class RsMsgs
|
||||
{
|
||||
public:
|
||||
|
||||
RsMsgs() { return; }
|
||||
virtual ~RsMsgs() { return; }
|
||||
|
||||
/****************************************/
|
||||
/* Message Items */
|
||||
|
||||
virtual bool getMessageSummaries(std::list<MsgInfoSummary> &msgList) = 0;
|
||||
virtual bool getMessage(std::string mId, MessageInfo &msg) = 0;
|
||||
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) = 0;
|
||||
|
||||
virtual bool MessageSend(MessageInfo &info) = 0;
|
||||
virtual bool MessageToDraft(MessageInfo &info) = 0;
|
||||
virtual bool MessageToTrash(std::string mid, bool bTrash) = 0;
|
||||
|
||||
virtual bool MessageDelete(std::string mid) = 0;
|
||||
virtual bool MessageRead(std::string mid) = 0;
|
||||
|
||||
/****************************************/
|
||||
/* Chat */
|
||||
virtual bool chatAvailable() = 0;
|
||||
virtual bool ChatSend(ChatInfo &ci) = 0;
|
||||
virtual bool getNewChat(std::list<ChatInfo> &chats) = 0;
|
||||
virtual void sendStatusString(const std::string& id,const std::string& status_string) = 0 ;
|
||||
virtual void sendGroupChatStatusString(const std::string& status_string) = 0 ;
|
||||
|
||||
virtual void setCustomStateString(const std::string& status_string) = 0 ;
|
||||
virtual std::string getCustomStateString() = 0 ;
|
||||
virtual std::string getCustomStateString(const std::string& peer_id) = 0 ;
|
||||
|
||||
// get avatar data for peer pid
|
||||
virtual void getAvatarData(std::string pid,unsigned char *& data,int& size) = 0 ;
|
||||
// set own avatar data
|
||||
virtual void setOwnAvatarData(const unsigned char *data,int size) = 0 ;
|
||||
virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
|
||||
|
||||
/****************************************/
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
129
libretroshare/src/retroshare/rsnotify.h
Normal file
129
libretroshare/src/retroshare/rsnotify.h
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
#ifndef RS_NOTIFY_GUI_INTERFACE_H
|
||||
#define RS_NOTIFY_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsnotify.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 <map>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
class RsNotify;
|
||||
extern RsNotify *rsNotify;
|
||||
|
||||
const uint32_t RS_SYS_ERROR = 0x0001;
|
||||
const uint32_t RS_SYS_WARNING = 0x0002;
|
||||
const uint32_t RS_SYS_INFO = 0x0004;
|
||||
|
||||
const uint32_t RS_POPUP_MSG = 0x0001;
|
||||
const uint32_t RS_POPUP_CHAT = 0x0002;
|
||||
const uint32_t RS_POPUP_CALL = 0x0004;
|
||||
const uint32_t RS_POPUP_CONNECT = 0x0008;
|
||||
const uint32_t RS_SYSTRAY_GROUP_MSG = 0x0010;
|
||||
|
||||
/* CHAT flags are here - so they are in the same place as
|
||||
* other Notify flags... not used by libretroshare though
|
||||
*/
|
||||
const uint32_t RS_CHAT_OPEN_NEW = 0x0001;
|
||||
const uint32_t RS_CHAT_REOPEN = 0x0002;
|
||||
const uint32_t RS_CHAT_FOCUS = 0x0004;
|
||||
|
||||
const uint32_t RS_FEED_TYPE_PEER = 0x0010;
|
||||
const uint32_t RS_FEED_TYPE_CHAN = 0x0020;
|
||||
const uint32_t RS_FEED_TYPE_FORUM = 0x0040;
|
||||
const uint32_t RS_FEED_TYPE_BLOG = 0x0080;
|
||||
const uint32_t RS_FEED_TYPE_CHAT = 0x0100;
|
||||
const uint32_t RS_FEED_TYPE_MSG = 0x0200;
|
||||
const uint32_t RS_FEED_TYPE_FILES = 0x0400;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_PEER_CONNECT = RS_FEED_TYPE_PEER | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0004;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_CHAN_NEW = RS_FEED_TYPE_CHAN | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_CHAN_UPDATE = RS_FEED_TYPE_CHAN | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_CHAN_MSG = RS_FEED_TYPE_CHAN | 0x0003;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_FORUM_NEW = RS_FEED_TYPE_FORUM | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_FORUM_UPDATE = RS_FEED_TYPE_FORUM | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_FORUM_MSG = RS_FEED_TYPE_FORUM | 0x0003;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_BLOG_NEW = RS_FEED_TYPE_BLOG | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_BLOG_UPDATE = RS_FEED_TYPE_BLOG | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_BLOG_MSG = RS_FEED_TYPE_BLOG | 0x0003;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_CHAT_NEW = RS_FEED_TYPE_CHAT | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001;
|
||||
|
||||
|
||||
class RsFeedItem
|
||||
{
|
||||
public:
|
||||
RsFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3)
|
||||
:mType(type), mId1(id1), mId2(id2), mId3(id3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RsFeedItem() :mType(0) { return; }
|
||||
|
||||
uint32_t mType;
|
||||
std::string mId1, mId2, mId3;
|
||||
};
|
||||
|
||||
|
||||
class RsNotify
|
||||
{
|
||||
public:
|
||||
|
||||
RsNotify() { return; }
|
||||
virtual ~RsNotify() { return; }
|
||||
|
||||
/* Output for retroshare-gui */
|
||||
virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type,
|
||||
std::string &title, std::string &msg) = 0;
|
||||
virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, std::string &title, std::string &msg) = 0;
|
||||
virtual bool NotifyLogMessage(uint32_t &sysid, uint32_t &type,
|
||||
std::string &title, std::string &msg) = 0;
|
||||
|
||||
/* Control over Messages */
|
||||
virtual bool GetSysMessageList(std::map<uint32_t, std::string> &list) = 0;
|
||||
virtual bool GetPopupMessageList(std::map<uint32_t, std::string> &list) = 0;
|
||||
|
||||
virtual bool SetSysMessageMode(uint32_t sysid, uint32_t mode) = 0;
|
||||
virtual bool SetPopupMessageMode(uint32_t ptype, uint32_t mode) = 0;
|
||||
|
||||
/* Feed Output */
|
||||
virtual bool GetFeedItem(RsFeedItem &item) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
195
libretroshare/src/retroshare/rspeers.h
Normal file
195
libretroshare/src/retroshare/rspeers.h
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
#ifndef RETROSHARE_PEER_GUI_INTERFACE_H
|
||||
#define RETROSHARE_PEER_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rspeer.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2004-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
|
||||
* A peer is another RS instance, means associated with an SSL certificate
|
||||
* A same GPG person can have multiple peer running with different SSL certs signed by the same GPG key
|
||||
* Thus a peer have SSL cert details, and also the parent GPG details
|
||||
*/
|
||||
class RsPeers;
|
||||
extern RsPeers *rsPeers;
|
||||
|
||||
/* Trust Levels */
|
||||
const uint32_t RS_TRUST_LVL_NONE = 2;
|
||||
const uint32_t RS_TRUST_LVL_MARGINAL = 3;
|
||||
const uint32_t RS_TRUST_LVL_FULL = 4;
|
||||
const uint32_t RS_TRUST_LVL_ULTIMATE = 5;
|
||||
|
||||
|
||||
/* Net Mode */
|
||||
const uint32_t RS_NETMODE_UDP = 0x0001;
|
||||
const uint32_t RS_NETMODE_UPNP = 0x0002;
|
||||
const uint32_t RS_NETMODE_EXT = 0x0003;
|
||||
const uint32_t RS_NETMODE_UNREACHABLE = 0x0004;
|
||||
|
||||
/* Visibility */
|
||||
const uint32_t RS_VS_DHT_ON = 0x0001;
|
||||
const uint32_t RS_VS_DISC_ON = 0x0002;
|
||||
|
||||
/* State */
|
||||
const uint32_t RS_PEER_STATE_FRIEND = 0x0001;
|
||||
const uint32_t RS_PEER_STATE_ONLINE = 0x0002;
|
||||
const uint32_t RS_PEER_STATE_CONNECTED = 0x0004;
|
||||
const uint32_t RS_PEER_STATE_UNREACHABLE= 0x0008;
|
||||
|
||||
/* A couple of helper functions for translating the numbers games */
|
||||
|
||||
std::string RsPeerTrustString(uint32_t trustLvl);
|
||||
std::string RsPeerStateString(uint32_t state);
|
||||
std::string RsPeerNetModeString(uint32_t netModel);
|
||||
std::string RsPeerLastConnectString(uint32_t lastConnect);
|
||||
|
||||
|
||||
/* Details class */
|
||||
class RsPeerDetails
|
||||
{
|
||||
public:
|
||||
|
||||
RsPeerDetails();
|
||||
|
||||
/* Auth details */
|
||||
bool isOnlyGPGdetail;
|
||||
std::string id;
|
||||
std::string gpg_id;
|
||||
std::string name;
|
||||
std::string email;
|
||||
std::string location;
|
||||
std::string org;
|
||||
|
||||
std::string issuer;
|
||||
|
||||
std::string fpr; /* pgp fingerprint */
|
||||
std::string authcode;
|
||||
std::list<std::string> gpgSigners;
|
||||
|
||||
uint32_t trustLvl;
|
||||
uint32_t validLvl;
|
||||
|
||||
bool ownsign; /* we have signed the remote peer GPG key */
|
||||
bool hasSignedMe; /* the remote peer has signed my GPG key */
|
||||
|
||||
bool accept_connection;
|
||||
|
||||
/* Network details (only valid if friend) */
|
||||
uint32_t state;
|
||||
|
||||
std::string localAddr;
|
||||
uint16_t localPort;
|
||||
std::string extAddr;
|
||||
uint16_t extPort;
|
||||
std::string dyndns;
|
||||
std::list<std::string> ipAddressList;
|
||||
|
||||
uint32_t netMode;
|
||||
uint32_t tryNetMode; /* only for ownState */
|
||||
uint32_t visState;
|
||||
|
||||
/* basic stats */
|
||||
uint32_t lastConnect; /* how long ago */
|
||||
std::string autoconnect;
|
||||
uint32_t connectPeriod;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
||||
|
||||
class RsPeers
|
||||
{
|
||||
public:
|
||||
|
||||
RsPeers() { return; }
|
||||
virtual ~RsPeers() { return; }
|
||||
|
||||
/* Updates ... */
|
||||
virtual bool FriendsChanged() = 0;
|
||||
virtual bool OthersChanged() = 0;
|
||||
|
||||
/* Peer Details (Net & Auth) */
|
||||
virtual std::string getOwnId() = 0;
|
||||
|
||||
virtual bool getOnlineList(std::list<std::string> &ssl_ids) = 0;
|
||||
virtual bool getFriendList(std::list<std::string> &ssl_ids) = 0;
|
||||
//virtual bool getOthersList(std::list<std::string> &ssl_ids) = 0;
|
||||
virtual void getPeerCount (unsigned int *pnFriendCount, unsigned int *pnnOnlineCount) = 0;
|
||||
|
||||
virtual bool isOnline(std::string ssl_id) = 0;
|
||||
virtual bool isFriend(std::string ssl_id) = 0;
|
||||
virtual bool isGPGAccepted(std::string gpg_id_is_friend) = 0; //
|
||||
virtual std::string getPeerName(std::string ssl_or_gpg_id) = 0;
|
||||
virtual std::string getGPGName(std::string gpg_id) = 0;
|
||||
virtual bool getPeerDetails(std::string ssl_or_gpg_id, RsPeerDetails &d) = 0; //get Peer detail accept SSL and PGP certs
|
||||
|
||||
/* Using PGP Ids */
|
||||
virtual std::string getGPGOwnId() = 0;
|
||||
virtual std::string getGPGId(std::string sslid_or_gpgid) = 0; //return the gpg id of the given gpg or ssl id
|
||||
virtual bool getGPGAcceptedList(std::list<std::string> &gpg_ids) = 0;
|
||||
virtual bool getGPGSignedList(std::list<std::string> &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
|
||||
virtual bool getGPGValidList(std::list<std::string> &gpg_ids) = 0;
|
||||
virtual bool getGPGAllList(std::list<std::string> &gpg_ids) = 0;
|
||||
virtual bool getGPGDetails(std::string gpg_id, RsPeerDetails &d) = 0;
|
||||
virtual bool getSSLChildListOfGPGId(std::string gpg_id, std::list<std::string> &ssl_ids) = 0;
|
||||
|
||||
/* Add/Remove Friends */
|
||||
virtual bool addFriend(std::string ssl_id, std::string gpg_id) = 0;
|
||||
virtual bool addDummyFriend(std::string gpg_id) = 0; //we want to add a empty ssl friend for this gpg id
|
||||
virtual bool isDummyFriend(std::string ssl_id) = 0;
|
||||
virtual bool removeFriend(std::string ssl_or_gpg_id) = 0;
|
||||
|
||||
/* Network Stuff */
|
||||
virtual bool connectAttempt(std::string ssl_id) = 0;
|
||||
virtual bool setLocation(std::string ssl_id, std::string location) = 0;//location is shown in the gui to differentiate ssl certs
|
||||
virtual bool setLocalAddress(std::string ssl_id, std::string addr, uint16_t port) = 0;
|
||||
virtual bool setExtAddress( std::string ssl_id, std::string addr, uint16_t port) = 0;
|
||||
virtual bool setDynDNS(std::string id, std::string addr) = 0;
|
||||
virtual bool setNetworkMode(std::string ssl_id, uint32_t netMode) = 0;
|
||||
virtual bool setVisState(std::string ssl_id, uint32_t vis) = 0;
|
||||
|
||||
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
|
||||
virtual void allowServerIPDetermination(bool) = 0;
|
||||
virtual void allowTunnelConnection(bool) = 0;
|
||||
virtual bool getAllowServerIPDetermination() = 0 ;
|
||||
virtual bool getAllowTunnelConnection() = 0 ;
|
||||
|
||||
/* Auth Stuff */
|
||||
virtual std::string GetRetroshareInvite() = 0;
|
||||
|
||||
virtual bool loadCertificateFromFile(std::string fname, std::string &ssl_id, std::string &gpg_id) = 0;
|
||||
virtual bool loadDetailsFromStringCert(std::string certGPG, RsPeerDetails &pd) = 0;
|
||||
virtual bool saveCertificateToFile(std::string id, std::string fname) = 0;
|
||||
virtual std::string saveCertificateToString(std::string id) = 0;
|
||||
|
||||
virtual bool setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptance) = 0;
|
||||
virtual bool signGPGCertificate(std::string gpg_id) = 0;
|
||||
virtual bool trustGPGCertificate(std::string gpg_id, uint32_t trustlvl) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
127
libretroshare/src/retroshare/rsphoto.h
Normal file
127
libretroshare/src/retroshare/rsphoto.h
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
#ifndef RETROSHARE_PHOTO_GUI_INTERFACE_H
|
||||
#define RETROSHARE_PHOTO_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsphoto.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2008-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 RsPhoto;
|
||||
extern RsPhoto *rsPhoto;
|
||||
|
||||
class RsPhotoDetails;
|
||||
class RsPhotoShowDetails;
|
||||
|
||||
class RsPhotoShowInfo
|
||||
{
|
||||
public:
|
||||
|
||||
std::string photoId;
|
||||
std::wstring altComment;
|
||||
uint32_t deltaT; /* in 100ths of sec? */
|
||||
};
|
||||
|
||||
class RsPhotoShowDetails
|
||||
{
|
||||
public:
|
||||
|
||||
RsPhotoShowDetails();
|
||||
|
||||
std::string id;
|
||||
std::string showid;
|
||||
|
||||
std::string name;
|
||||
std::wstring location;
|
||||
std::wstring comment;
|
||||
std::string date;
|
||||
std::list<RsPhotoShowInfo> photos;
|
||||
};
|
||||
|
||||
/* Details class */
|
||||
class RsPhotoDetails
|
||||
{
|
||||
public:
|
||||
|
||||
RsPhotoDetails();
|
||||
|
||||
std::string id;
|
||||
std::string srcid;
|
||||
|
||||
std::string hash;
|
||||
uint64_t size;
|
||||
|
||||
std::string name;
|
||||
std::wstring comment;
|
||||
|
||||
std::string location;
|
||||
std::string date;
|
||||
|
||||
uint32_t format;
|
||||
|
||||
bool isAvailable;
|
||||
std::string path;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsPhotoShowDetails &detail);
|
||||
std::ostream &operator<<(std::ostream &out, const RsPhotoDetails &detail);
|
||||
|
||||
class RsPhoto
|
||||
{
|
||||
public:
|
||||
|
||||
RsPhoto() { return; }
|
||||
virtual ~RsPhoto() { return; }
|
||||
|
||||
/* changed? */
|
||||
virtual bool updated() = 0;
|
||||
|
||||
/* access data */
|
||||
virtual bool getPhotoList(std::string id, std::list<std::string> &hashs) = 0;
|
||||
virtual bool getShowList(std::string id, std::list<std::string> &showIds) = 0;
|
||||
virtual bool getShowDetails(std::string id, std::string showId, RsPhotoShowDetails &detail) = 0;
|
||||
virtual bool getPhotoDetails(std::string id, std::string photoId, RsPhotoDetails &detail) = 0;
|
||||
|
||||
/* add / delete */
|
||||
virtual std::string createShow(std::string name) = 0;
|
||||
virtual bool deleteShow(std::string showId) = 0;
|
||||
virtual bool addPhotoToShow(std::string showId, std::string photoId, int16_t index) = 0;
|
||||
virtual bool movePhotoInShow(std::string showId, std::string photoId, int16_t index) = 0;
|
||||
virtual bool removePhotoFromShow(std::string showId, std::string photoId) = 0;
|
||||
|
||||
virtual std::string addPhoto(std::string path) = 0; /* add from file */
|
||||
virtual bool addPhoto(std::string srcId, std::string photoId) = 0; /* add from peers photos */
|
||||
virtual bool deletePhoto(std::string photoId) = 0;
|
||||
|
||||
/* modify properties (TODO) */
|
||||
virtual bool modifyShow(std::string showId, std::wstring name, std::wstring comment) = 0;
|
||||
virtual bool modifyPhoto(std::string photoId, std::wstring name, std::wstring comment) = 0;
|
||||
virtual bool modifyShowComment(std::string showId, std::string photoId, std::wstring comment) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
96
libretroshare/src/retroshare/rsrank.h
Normal file
96
libretroshare/src/retroshare/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
|
||||
107
libretroshare/src/retroshare/rsstatus.h
Normal file
107
libretroshare/src/retroshare/rsstatus.h
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#ifndef RS_STATUS_INTERFACE_H
|
||||
#define RS_STATUS_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsstatus.h
|
||||
*
|
||||
* RetroShare C++ .
|
||||
*
|
||||
* Copyright 2007-2008 by Vinny Do, Chris Evi-Parker.
|
||||
*
|
||||
* 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".
|
||||
*
|
||||
*/
|
||||
|
||||
class RsStatus;
|
||||
|
||||
extern RsStatus *rsStatus;
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <inttypes.h>
|
||||
#include <list>
|
||||
|
||||
|
||||
const uint32_t RS_STATUS_AWAY = 0x0001;
|
||||
const uint32_t RS_STATUS_BUSY = 0x0002;
|
||||
const uint32_t RS_STATUS_ONLINE = 0x0003;
|
||||
const uint32_t RS_STATUS_INACTIVE = 0x0004;
|
||||
|
||||
//! data object for peer status information
|
||||
/*!
|
||||
* data object used for peer status information
|
||||
*/
|
||||
class StatusInfo
|
||||
{
|
||||
public:
|
||||
StatusInfo()
|
||||
{
|
||||
status = 0;
|
||||
time_stamp = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string id;
|
||||
uint32_t status;
|
||||
time_t time_stamp; /// for owner time set, and for their peers time sent
|
||||
};
|
||||
|
||||
|
||||
//! Interface to retroshare for Rs status
|
||||
/*!
|
||||
* Provides an interface for retroshare's status functionality
|
||||
*/
|
||||
class RsStatus
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* This retrieves the own status info
|
||||
* @param statusInfo is populated with own status
|
||||
*/
|
||||
virtual bool getOwnStatus(StatusInfo& statusInfo) = 0;
|
||||
|
||||
/**
|
||||
* This retrieves the status info on the client's peers
|
||||
* @param statusInfo is populated with client's peer's status
|
||||
*/
|
||||
virtual bool getStatus(std::list<StatusInfo>& statusInfo) = 0;
|
||||
|
||||
/**
|
||||
* send the client's status to his/her peers
|
||||
* @param id the peer to send the status (empty, send to all)
|
||||
* @param status the status of the peers
|
||||
* @return will return false if status info does not belong to client
|
||||
*/
|
||||
virtual bool sendStatus(std::string id, uint32_t status) = 0;
|
||||
|
||||
/**
|
||||
* checks to see if any status items have been received
|
||||
*/
|
||||
virtual bool statusAvailable() = 0;
|
||||
|
||||
/**
|
||||
* translates the status field of a peer to a string
|
||||
* @status the status id that needs to be translated
|
||||
* @statusString the string translation is passed here
|
||||
*/
|
||||
virtual void getStatusString(uint32_t status, std::string& statusString) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
103
libretroshare/src/retroshare/rsturtle.h
Normal file
103
libretroshare/src/retroshare/rsturtle.h
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#ifndef RETROSHARE_TURTLE_GUI_INTERFACE_H
|
||||
#define RETROSHARE_TURTLE_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsturtle.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2009 by Cyril Soler.
|
||||
*
|
||||
* 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 "csoler@users.sourceforge.net"
|
||||
*
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
class LinearizedExpression ;
|
||||
|
||||
class RsTurtle;
|
||||
extern RsTurtle *rsTurtle ;
|
||||
|
||||
typedef uint32_t TurtleRequestId ;
|
||||
|
||||
// This is the structure used to send back results of the turtle search
|
||||
// to the notifyBase class.
|
||||
|
||||
struct TurtleFileInfo
|
||||
{
|
||||
std::string hash ;
|
||||
std::string name ;
|
||||
uint64_t size ;
|
||||
};
|
||||
|
||||
// Interface class for turtle hopping.
|
||||
//
|
||||
// This class mainly interacts with the turtle router, that is responsible
|
||||
// for routing turtle packets between peers, accepting/forwarding search
|
||||
// requests and dowloading files.
|
||||
//
|
||||
// As seen from here, the interface is really simple.
|
||||
//
|
||||
class RsTurtle
|
||||
{
|
||||
public:
|
||||
enum FileSharingStrategy { SHARE_ENTIRE_NETWORK, SHARE_FRIENDS_ONLY } ;
|
||||
|
||||
RsTurtle() { _sharing_strategy = SHARE_ENTIRE_NETWORK ;}
|
||||
virtual ~RsTurtle() {}
|
||||
|
||||
// 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.
|
||||
//
|
||||
virtual TurtleRequestId turtleSearch(const std::string& match_string) = 0 ;
|
||||
virtual TurtleRequestId turtleSearch(const LinearizedExpression& expr) = 0 ;
|
||||
|
||||
// Initiates tunnel handling for the given file hash. tunnels. Launches
|
||||
// an exception if an error occurs during the initialization process. The
|
||||
// turtle router itself does not initiate downloads, it only maintains
|
||||
// tunnels for the given hash. The download should be driven by the file
|
||||
// transfer module by calling ftServer::FileRequest().
|
||||
//
|
||||
virtual void monitorFileTunnels(const std::string& name,const std::string& file_hash,uint64_t size) = 0 ;
|
||||
|
||||
// Tells the turtle router to stop handling tunnels for the given file hash. Traditionally this should
|
||||
// be called after calling ftServer::fileCancel().
|
||||
//
|
||||
virtual void stopMonitoringFileTunnels(const std::string& file_hash) = 0 ;
|
||||
|
||||
// Sets the file sharing strategy. It concerns all local files. It would
|
||||
// be better to handle this for each file, of course.
|
||||
|
||||
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;
|
||||
|
||||
// Convenience function.
|
||||
virtual bool isTurtlePeer(const std::string& peer_id) const = 0 ;
|
||||
|
||||
protected:
|
||||
FileSharingStrategy _sharing_strategy ;
|
||||
};
|
||||
|
||||
#endif
|
||||
395
libretroshare/src/retroshare/rstypes.h
Normal file
395
libretroshare/src/retroshare/rstypes.h
Normal file
|
|
@ -0,0 +1,395 @@
|
|||
#ifndef RS_TYPES_GUI_INTERFACE_H
|
||||
#define RS_TYPES_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* "$Id: rstypes.h,v 1.7 2007-05-05 16:10:05 rmf24 Exp $"
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2004-2006 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 <list>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef std::string RsCertId;
|
||||
typedef std::string RsChanId;
|
||||
typedef std::string RsMsgId;
|
||||
typedef std::string RsAuthId;
|
||||
|
||||
const uint32_t FT_STATE_FAILED = 0x0000 ;
|
||||
const uint32_t FT_STATE_OKAY = 0x0001 ;
|
||||
const uint32_t FT_STATE_WAITING = 0x0002 ;
|
||||
const uint32_t FT_STATE_DOWNLOADING = 0x0003 ;
|
||||
const uint32_t FT_STATE_COMPLETE = 0x0004 ;
|
||||
const uint32_t FT_STATE_QUEUED = 0x0005 ;
|
||||
const uint32_t FT_STATE_PAUSED = 0x0006 ;
|
||||
const uint32_t FT_STATE_CHECKING_HASH = 0x0007 ;
|
||||
|
||||
// These constants are used by RsDiscSpace
|
||||
//
|
||||
const uint32_t RS_PARTIALS_DIRECTORY = 0x0000 ;
|
||||
const uint32_t RS_DOWNLOAD_DIRECTORY = 0x0001 ;
|
||||
const uint32_t RS_CONFIG_DIRECTORY = 0x0002 ;
|
||||
|
||||
class TransferInfo
|
||||
{
|
||||
public:
|
||||
/**** Need Some of these Fields ****/
|
||||
std::string peerId;
|
||||
std::string name; /* if has alternative name? */
|
||||
double tfRate; /* kbytes */
|
||||
int status; /* FT_STATE_... */
|
||||
uint64_t transfered ; // used when no chunkmap data is available
|
||||
};
|
||||
|
||||
enum QueueMove { QUEUE_TOP = 0x00,
|
||||
QUEUE_UP = 0x01,
|
||||
QUEUE_DOWN = 0x02,
|
||||
QUEUE_BOTTOM = 0x03
|
||||
};
|
||||
|
||||
enum DwlSpeed { SPEED_LOW = 0x00,
|
||||
SPEED_NORMAL = 0x01,
|
||||
SPEED_HIGH = 0x02
|
||||
};
|
||||
|
||||
|
||||
|
||||
class FileInfo
|
||||
{
|
||||
/* old BaseInfo Entries */
|
||||
public:
|
||||
|
||||
FileInfo() :flags(0), mId(0) { return; }
|
||||
RsCertId id; /* key for matching everything */
|
||||
int flags; /* INFO_TAG above */
|
||||
|
||||
/* allow this to be tweaked by the GUI Model */
|
||||
mutable unsigned int mId; /* (GUI) Model Id -> unique number */
|
||||
|
||||
/* Old FileInfo Entries */
|
||||
public:
|
||||
|
||||
static const int kRsFiStatusNone = 0;
|
||||
static const int kRsFiStatusStall = 1;
|
||||
static const int kRsFiStatusProgress = 2;
|
||||
static const int kRsFiStatusDone = 2;
|
||||
|
||||
/* FileInfo(); */
|
||||
|
||||
int searchId; /* 0 if none */
|
||||
std::string path;
|
||||
std::string fname;
|
||||
std::string hash;
|
||||
std::string ext;
|
||||
|
||||
uint64_t size;
|
||||
uint64_t avail; /* how much we have */
|
||||
int status;
|
||||
|
||||
bool inRecommend;
|
||||
|
||||
double rank;
|
||||
int age;
|
||||
uint32_t queue_position ;
|
||||
|
||||
/* Transfer Stuff */
|
||||
uint64_t transfered;
|
||||
double tfRate; /* in kbytes */
|
||||
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
||||
std::list<TransferInfo> peers;
|
||||
|
||||
DwlSpeed priority ;
|
||||
time_t lastTS;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
||||
|
||||
|
||||
/* matched to the uPnP states */
|
||||
#define UPNP_STATE_UNINITIALISED 0
|
||||
#define UPNP_STATE_UNAVAILABILE 1
|
||||
#define UPNP_STATE_READY 2
|
||||
#define UPNP_STATE_FAILED_TCP 3
|
||||
#define UPNP_STATE_FAILED_UDP 4
|
||||
#define UPNP_STATE_ACTIVE 5
|
||||
|
||||
class RsConfig
|
||||
{
|
||||
public:
|
||||
RsConfig()
|
||||
{
|
||||
localPort = extPort = 0 ;
|
||||
firewalled = forwardPort = false ;
|
||||
maxDownloadDataRate = maxUploadDataRate = maxIndivDataRate = 0 ;
|
||||
promptAtBoot = 0 ;
|
||||
DHTActive = uPnPActive = netLocalOk = netUpnpOk = netDhtOk = netStunOk = netExtraAddressOk = false ;
|
||||
uPnPState = DHTPeers = 0 ;
|
||||
}
|
||||
std::string ownId;
|
||||
std::string ownName;
|
||||
|
||||
std::string localAddr;
|
||||
int localPort;
|
||||
std::string extAddr;
|
||||
int extPort;
|
||||
std::string extName;
|
||||
|
||||
bool firewalled;
|
||||
bool forwardPort;
|
||||
|
||||
int maxDownloadDataRate; /* kb */
|
||||
int maxUploadDataRate; /* kb */
|
||||
int maxIndivDataRate; /* kb */
|
||||
|
||||
int promptAtBoot; /* popup the password prompt */
|
||||
|
||||
/* older data types */
|
||||
bool DHTActive;
|
||||
bool uPnPActive;
|
||||
|
||||
int uPnPState;
|
||||
int DHTPeers;
|
||||
|
||||
/* Flags for Network Status */
|
||||
bool netLocalOk; /* That we've talked to someone! */
|
||||
bool netUpnpOk; /* upnp is enabled and active */
|
||||
bool netDhtOk; /* response from dht */
|
||||
bool netStunOk; /* recvd stun / udp packets */
|
||||
bool netExtraAddressOk; /* recvd ip address with external finder*/
|
||||
};
|
||||
|
||||
/********************** For Search Interface *****************/
|
||||
|
||||
/* This is still rough, implement later! */
|
||||
|
||||
/* text based ones */
|
||||
const std::string TypeExt = "ext";
|
||||
const std::string TypeName = "name";
|
||||
const std::string TypeHash = "hash";
|
||||
const std::string TypeSize = "size";
|
||||
|
||||
const int OpContains = 0x001;
|
||||
const int OpExactMatch = 0x002;
|
||||
const int OpLessThan = 0x003;
|
||||
const int OpGreaterThan = 0x004;
|
||||
|
||||
class Condition
|
||||
{
|
||||
public:
|
||||
|
||||
std::string type;
|
||||
int op;
|
||||
double value;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
class SearchRequest
|
||||
{
|
||||
public:
|
||||
int searchId;
|
||||
RsCertId toId; /* all zeros for everyone! */
|
||||
std::list<Condition> tests;
|
||||
};
|
||||
|
||||
|
||||
/********************** For FileCache Interface *****************/
|
||||
|
||||
#define DIR_TYPE_ROOT 0x01
|
||||
#define DIR_TYPE_PERSON 0x02
|
||||
#define DIR_TYPE_DIR 0x04
|
||||
#define DIR_TYPE_FILE 0x08
|
||||
|
||||
/* flags for Directry request -
|
||||
* two types;
|
||||
* (1) Local / Remote (top byte)
|
||||
* (2) Request type: Parent / Child - allows reduction in workload.
|
||||
* (TODO)
|
||||
*/
|
||||
|
||||
#define DIR_FLAGS_LOCAL 0x1000
|
||||
#define DIR_FLAGS_REMOTE 0x2000
|
||||
|
||||
#define DIR_FLAGS_PARENT 0x0001
|
||||
#define DIR_FLAGS_DETAILS 0x0002
|
||||
#define DIR_FLAGS_CHILDREN 0x0004
|
||||
#define DIR_FLAGS_NETWORK_WIDE 0x0008
|
||||
#define DIR_FLAGS_BROWSABLE 0x0010
|
||||
|
||||
class DirStub
|
||||
{
|
||||
public:
|
||||
uint8_t type;
|
||||
std::string name;
|
||||
void *ref;
|
||||
};
|
||||
|
||||
class DirDetails
|
||||
{
|
||||
public:
|
||||
void *parent;
|
||||
int prow; /* parent row */
|
||||
|
||||
void *ref;
|
||||
uint8_t type;
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string hash;
|
||||
std::string path;
|
||||
uint64_t count;
|
||||
uint32_t age;
|
||||
uint32_t flags;
|
||||
uint32_t min_age ; // minimum age of files in this subtree
|
||||
|
||||
std::list<DirStub> children;
|
||||
};
|
||||
|
||||
class FileDetail
|
||||
{
|
||||
public:
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string hash;
|
||||
std::string path;
|
||||
uint64_t size;
|
||||
uint32_t age;
|
||||
uint32_t rank;
|
||||
};
|
||||
|
||||
class CompressedChunkMap ;
|
||||
|
||||
class FileChunksInfo
|
||||
{
|
||||
public:
|
||||
enum ChunkState { CHUNK_DONE, CHUNK_ACTIVE, CHUNK_OUTSTANDING } ;
|
||||
enum ChunkStrategy { CHUNK_STRATEGY_STREAMING, CHUNK_STRATEGY_RANDOM } ;
|
||||
|
||||
uint64_t file_size ; // real size of the file
|
||||
uint32_t chunk_size ; // size of chunks
|
||||
uint32_t flags ;
|
||||
uint32_t strategy ;
|
||||
|
||||
// dl state of chunks. Only the last chunk may have size < chunk_size
|
||||
std::vector<ChunkState> chunks ;
|
||||
|
||||
// For each source peer, gives the compressed bit map of have/don't have sate
|
||||
std::map<std::string, CompressedChunkMap> compressed_peer_availability_maps ;
|
||||
|
||||
// For each chunk (by chunk number), gives the completion of the chunk.
|
||||
//
|
||||
std::vector<std::pair<uint32_t,uint32_t> > active_chunks ;
|
||||
};
|
||||
|
||||
class CompressedChunkMap
|
||||
{
|
||||
public:
|
||||
CompressedChunkMap() {}
|
||||
|
||||
CompressedChunkMap(const std::vector<FileChunksInfo::ChunkState>& uncompressed_data)
|
||||
{
|
||||
_map.resize( getCompressedSize(uncompressed_data.size()),0 ) ;
|
||||
|
||||
for(uint32_t i=0;i<uncompressed_data.size();++i)
|
||||
if(uncompressed_data[i]==FileChunksInfo::CHUNK_DONE)
|
||||
set(i) ;
|
||||
}
|
||||
|
||||
CompressedChunkMap(uint32_t nb_chunks,uint32_t value)
|
||||
{
|
||||
_map.resize(getCompressedSize(nb_chunks),value) ;
|
||||
}
|
||||
|
||||
static uint32_t getCompressedSize(uint32_t size) { return (size>>5) + !!(size&31) ; }
|
||||
|
||||
uint32_t filledChunks(uint32_t nbchks)
|
||||
{
|
||||
uint32_t res = 0 ;
|
||||
for(uint32_t i=0;i<std::min(nbchks,(uint32_t)_map.size()*32);++i)
|
||||
res += operator[](i) ;
|
||||
return res ;
|
||||
}
|
||||
inline bool operator[](uint32_t i) const { return (_map[i >> 5] & (1 << (i & 31))) > 0 ; }
|
||||
|
||||
inline void set(uint32_t j) { _map[j >> 5] |= (1 << (j & 31)) ; }
|
||||
inline void reset(uint32_t j) { _map[j >> 5] &= ~(1 << (j & 31)) ; }
|
||||
|
||||
/// compressed map, one bit per chunk
|
||||
std::vector<uint32_t> _map ;
|
||||
};
|
||||
|
||||
class CRC32Map
|
||||
{
|
||||
public:
|
||||
// Build from a file.
|
||||
//
|
||||
CRC32Map(uint64_t file_size,uint32_t chunk_size)
|
||||
: _crcs( file_size/chunk_size + ( (file_size%chunk_size)>0)), _ccmap(file_size/chunk_size + ( (file_size%chunk_size)>0),0)
|
||||
{
|
||||
}
|
||||
CRC32Map() {}
|
||||
|
||||
// Compares two maps and returns the valid chunks in a compressed chunk map.
|
||||
//
|
||||
friend CompressedChunkMap compare(const CRC32Map& crc1,const CRC32Map& crc2) ;
|
||||
|
||||
inline void set(uint32_t i,uint32_t val) { _crcs[i] = val ; _ccmap.set(i) ; }
|
||||
|
||||
inline uint32_t operator[](int i) const { return _crcs[i] ; }
|
||||
inline uint32_t size() const { return _crcs.size() ; }
|
||||
private:
|
||||
std::vector<uint32_t> _crcs;
|
||||
CompressedChunkMap _ccmap ;
|
||||
|
||||
friend class RsTurtleFileCrcItem ;
|
||||
friend class RsFileItemSerialiser ;
|
||||
friend class RsFileCRC32Map ;
|
||||
};
|
||||
|
||||
/* class which encapsulates download details */
|
||||
class DwlDetails {
|
||||
public:
|
||||
DwlDetails() { return; }
|
||||
DwlDetails(std::string fname, std::string hash, int count, std::string dest,
|
||||
uint32_t flags, std::list<std::string> srcIds, uint32_t queue_pos)
|
||||
: fname(fname), hash(hash), count(count), dest(dest), flags(flags),
|
||||
srcIds(srcIds), queue_position(queue_pos), retries(0) { return; }
|
||||
|
||||
/* download details */
|
||||
std::string fname;
|
||||
std::string hash;
|
||||
int count;
|
||||
std::string dest;
|
||||
uint32_t flags;
|
||||
std::list<std::string> srcIds;
|
||||
|
||||
/* internally used in download queue */
|
||||
uint32_t queue_position;
|
||||
|
||||
/* how many times a failed dwl will be requeued */
|
||||
unsigned int retries;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue