diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 9bd63d20a..d28c44190 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -235,12 +235,10 @@ HEADERS += dbase/cachestrapper.h \ rsiface/rsnotify.h \ rsiface/rspeers.h \ rsiface/rsphoto.h \ - rsiface/rsQblog.h \ rsiface/rsblogs.h \ rsiface/rsrank.h \ rsiface/rsstatus.h \ rsiface/rstypes.h \ - rsserver/p3blog.h \ rsserver/p3discovery.h \ rsserver/p3face.h \ rsserver/p3msgs.h \ @@ -281,7 +279,6 @@ HEADERS += dbase/cachestrapper.h \ services/p3gameservice.h \ services/p3msgservice.h \ services/p3photoservice.h \ - services/p3Qblog.h \ services/p3blogs.h \ services/p3ranking.h \ services/p3service.h \ @@ -316,7 +313,6 @@ SOURCES += \ rsserver/rsinit.cc \ rsserver/p3face-config.cc \ rsserver/p3face-server.cc \ - rsserver/p3blog.cc \ rsserver/p3discovery.cc \ rsserver/p3msgs.cc \ rsserver/p3photo.cc \ @@ -343,7 +339,6 @@ SOURCES += \ services/p3channels.cc \ services/p3forums.cc \ services/p3blogs.cc \ - services/p3Qblog.cc \ services/p3statusservice.cc \ services/p3distrib.cc \ services/p3photoservice.cc \ diff --git a/libretroshare/src/rsiface/rsQblog.h b/libretroshare/src/rsiface/rsQblog.h deleted file mode 100644 index 5cddc3f39..000000000 --- a/libretroshare/src/rsiface/rsQblog.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef RSQBLOG_H_ -#define RSQBLOG_H_ - -/* - * libretroshare/src/rsiface: rsQblog.h - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by Chris Evi-Parker, 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 - #include - #include - #include - - #include "../rsiface/rstypes.h" - - -/* delcare interafce for everyone o use */ -class RsQblog; -extern RsQblog *rsQblog; - - /*! allows gui to interface with the rsQblogs service */ - class RsQblog - { - public: - - - RsQblog() { return; } - virtual ~RsQblog() { return; } - - - /** - * send blog info, will send to a data structure for transmission - * @param msg The msg the usr wants to send - */ - virtual bool sendBlog(const std::wstring &msg) = 0; - - /** - * retrieve blog of a usr - * @param blogs contains the blog msgs of usr along with time posted for sorting - */ - virtual bool getBlogs(std::map< std::string, std::multimap > &blogs) = 0; - - /** - * Stuff DrBob Added for Profile View! - */ - - /** - * get users Latest Blog Post. - * @param id the usr whose idetails you want to get. - * @param ts Timestamp of the Blog Post. - * @param post the actual Blog Post. - */ - virtual bool getPeerLatestBlog(std::string id, uint32_t &ts, std::wstring &post) = 0; - - }; - -#endif /*RSQBLOG_H_*/ diff --git a/libretroshare/src/rsserver/p3blog.cc b/libretroshare/src/rsserver/p3blog.cc deleted file mode 100644 index ddeff33cb..000000000 --- a/libretroshare/src/rsserver/p3blog.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* - * libretroshare/src/rsserver: p3blog.cc - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by 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". - * - */ - -#include - -RsQblog* rsQblog = NULL; - -p3Blog::p3Blog(p3Qblog* qblog) : -mQblog(qblog) -{ - return; -} - -p3Blog::~p3Blog() -{ - return; -} - -bool p3Blog::getBlogs(std::map< std::string, std::multimap > &blogs) -{ - return mQblog->getBlogs(blogs); -} - -bool p3Blog::sendBlog(const std::wstring &msg) -{ - return mQblog->sendBlog(msg); -} - -bool p3Blog::getPeerLatestBlog(std::string id, uint32_t &ts, std::wstring &post) -{ - //return mQblog->getPeerLatestBlog(id, ts, post); - ts = time(NULL); - post = L"Hmmm, not much, just eating prawn crackers at the moment... but I'll post this every second if you want ;)"; - - return true; -} - diff --git a/libretroshare/src/rsserver/p3blog.h b/libretroshare/src/rsserver/p3blog.h deleted file mode 100644 index 4f8016e4a..000000000 --- a/libretroshare/src/rsserver/p3blog.h +++ /dev/null @@ -1,57 +0,0 @@ - - - -#ifndef P3BLOG_H_ -#define P3BLOG_H_ - -/* - * libretroshare/src/rsserver: p3blog.h - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by 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". - * - */ - -#include "../rsiface/rsQblog.h" -#include "../services/p3Qblog.h" - -/*! - * Interface class using composition (p3Qblog is an attribute) - * See derived class for documentation of derived functions - */ -class p3Blog : public RsQblog -{ - public: - - p3Blog(p3Qblog* qblog); - virtual ~p3Blog(); - - virtual bool sendBlog(const std::wstring &msg); - virtual bool getBlogs(std::map< std::string, std::multimap > &blogs); - virtual bool getPeerLatestBlog(std::string id, uint32_t &ts, std::wstring &post); - - private: - - /// to make rsCore blog-service calls - p3Qblog* mQblog; -}; - - -#endif /*P3BLOG_H_*/ diff --git a/libretroshare/src/rsserver/p3face-server.cc b/libretroshare/src/rsserver/p3face-server.cc index 2e96bbd94..0516e5cf7 100644 --- a/libretroshare/src/rsserver/p3face-server.cc +++ b/libretroshare/src/rsserver/p3face-server.cc @@ -213,12 +213,6 @@ void RsServer::run() /* Tick slow services */ if (mRanking) mRanking->tick(); - - - if(mQblog) - mQblog->tick(); - - #if 0 std::string opt; diff --git a/libretroshare/src/rsserver/p3face.h b/libretroshare/src/rsserver/p3face.h index 1b35368ba..8f5f7107a 100644 --- a/libretroshare/src/rsserver/p3face.h +++ b/libretroshare/src/rsserver/p3face.h @@ -42,7 +42,6 @@ #include "services/p3msgservice.h" #include "services/p3chatservice.h" #include "services/p3ranking.h" -#include "services/p3Qblog.h" #include "services/p3blogs.h" #include "services/p3statusservice.h" #include "services/p3channels.h" @@ -178,7 +177,6 @@ class RsServer: public RsControl, public RsThread p3Channels *mChannels; /* caches (that need ticking) */ p3Ranking *mRanking; - p3Qblog *mQblog; /* Config */ p3ConfigMgr *mConfigMgr; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index b3eefa4dc..c0ed6b08d 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1866,7 +1866,6 @@ RsTurtle *rsTurtle = NULL ; #include "services/p3forums.h" #include "services/p3channels.h" #include "services/p3statusservice.h" -#include "services/p3Qblog.h" #include "services/p3blogs.h" #include "turtle/p3turtle.h" #include "services/p3tunnel.h" @@ -1885,7 +1884,6 @@ RsTurtle *rsTurtle = NULL ; #include "rsserver/p3msgs.h" #include "rsserver/p3discovery.h" #include "rsserver/p3photo.h" -#include "rsserver/p3blog.h" #include "rsserver/p3status.h" #include "rsiface/rsgame.h" @@ -2092,14 +2090,6 @@ int RsServer::StartupRetroShare() CachePair cp2(photoService, photoService, CacheId(RS_SERVICE_TYPE_PHOTO, 0)); mCacheStrapper -> addCachePair(cp2); - mQblog = new p3Qblog(mConnMgr, RS_SERVICE_TYPE_QBLOG, /* ...then for Qblog */ - mCacheStrapper, mCacheTransfer, - localcachedir, remotecachedir, 3600 * 24 * 30 * 6); // 6 Months - - CachePair cp3(mQblog, mQblog, CacheId(RS_SERVICE_TYPE_QBLOG, 0)); - mCacheStrapper -> addCachePair(cp3); - - #else mQblog = NULL; #endif @@ -2258,11 +2248,9 @@ int RsServer::StartupRetroShare() #ifndef RS_RELEASE rsGameLauncher = gameLauncher; rsPhoto = new p3Photo(photoService); - rsQblog = new p3Blog(mQblog); #else rsGameLauncher = NULL; rsPhoto = NULL; - rsQblog = NULL; #endif diff --git a/libretroshare/src/services/p3Qblog.cc b/libretroshare/src/services/p3Qblog.cc deleted file mode 100644 index fd2f59ad8..000000000 --- a/libretroshare/src/services/p3Qblog.cc +++ /dev/null @@ -1,510 +0,0 @@ -/* - * libretroshare/src/services: p3Qblog.cc - * - * RetroShare C++ Interface. - * - * Copyright 2007-2008 by 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". - * - */ - -#include "serialiser/rsqblogitems.h" -#include "p3Qblog.h" -#include -#include -#include -#include "pqi/pqistore.h" -#include "pqi/pqibin.h" - -const uint32_t BLOG_MAX_FWD_OFFSET = (60 * 60 * 24 * 2); /* 2 Days */ -const uint32_t FRIEND_QBLOG_REPOST_PERIOD = 60; /* every minute for testing */ - - -#define QBLOG_DEBUG 1 - - -p3Qblog::p3Qblog(p3ConnectMgr *connMgr, - uint16_t type, CacheStrapper *cs, CacheTransfer *cft, - std::string sourcedir, std::string storedir, - uint32_t storePeriod) - :CacheSource(type, true, cs, sourcedir), - CacheStore(type, true, cs, cft, storedir), - mConnMgr(connMgr), - mStorePeriod(storePeriod), mPostsUpdated(false), mProfileUpdated(false) -{ - { - RsStackMutex stack(mBlogMtx); - mOwnId = mConnMgr->getOwnId(); // get your own usr Id - loadDummy(); // load dummy data - - #ifdef QBLOG_DEBUG - /*if(!ok) - std::cerr << "initialization failed: could not retrieve friend list"; */ - #endif - - } - - return; -} - -std::ostream &operator<<(std::ostream& out, const std::wstring wstr) -{ - std::string str(wstr.begin(), wstr.end()); - out << str; - - return out; -} - -bool p3Qblog::loadLocalCache(const CacheData &data) -{ - std::string filename = data.path + '/' + data.name; - std::string hash = data.hash; - std::string source = data.pid; - - #ifdef QBLOG_DEBUG - std::cerr << "p3Ranking::loadLocalCache()"; - std::cerr << std::endl; - std::cerr << "\tSource: " << source; - std::cerr << std::endl; - std::cerr << "\tFilename: " << filename; - std::cerr << std::endl; - std::cerr << "\tHash: " << hash; - std::cerr << std::endl; - std::cerr << "\tSize: " << data.size; - std::cerr << std::endl; - #endif - - loadBlogFile(filename, source); - - { - RsStackMutex stack(mBlogMtx); - mPostsUpdated = true; // there is nothing to tick/repost (i.e. comes from cache) - } - - if (data.size > 0) /* don't refresh zero sized caches */ - { - refreshCache(data); - } - - return true; -} - - -int p3Qblog::loadCache(const CacheData &data) -{ - std::string filename = data.path + '/' + data.name; - std::string hash = data.hash; - std::string source = data.pid; - - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::loadCache()"; - std::cerr << std::endl; - std::cerr << "\tSource: " << source; - std::cerr << std::endl; - std::cerr << "\tFilename: " << filename; - std::cerr << std::endl; - std::cerr << "\tHash: " << hash; - std::cerr << std::endl; - std::cerr << "\tSize: " << data.size; - std::cerr << std::endl; - #endif - - loadBlogFile(filename, source); - - - CacheStore::lockData(); /***** LOCK ****/ - locked_storeCacheEntry(data); - CacheStore::unlockData(); /***** UNLOCK ****/ - - return 1; -} - -bool p3Qblog::loadBlogFile(std::string filename, std::string src) -{ - /* create the serialiser to load info */ - RsSerialiser *rsSerialiser = new RsSerialiser(); - rsSerialiser->addSerialType(new RsQblogMsgSerialiser()); - - uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_READABLE; - BinInterface *bio = new BinFileInterface(filename.c_str(), bioflags); - pqistore *store = new pqistore(rsSerialiser, src, bio, 0); - - #ifdef QBLOG_DEBUG - - std::cerr << "p3Qblog::loadBlogFile()"; - std::cerr << std::endl; - std::cerr << "\tSource: " << src; - std::cerr << std::endl; - std::cerr << "\tFilename: " << filename; - std::cerr << std::endl; - - #endif - - /* will load file info to these items */ - RsItem *item; - RsQblogMsg *newBlog; - - time_t now = time(NULL); - time_t min, max; - - { /********** STACK LOCKED MTX ******/ - RsStackMutex stack(mBlogMtx); - min = now - mStorePeriod; - max = now + BLOG_MAX_FWD_OFFSET; - } /********** STACK LOCKED MTX ******/ - - while(NULL != (item = store->GetItem())) - { - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::loadBlogFile() Got Item:"; - std::cerr << std::endl; - item->print(std::cerr, 10); - std::cerr << std::endl; - #endif - - if (NULL == (newBlog = dynamic_cast(item))) - { - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::loadBlogFile() Item not Blog (deleting):"; - std::cerr << std::endl; - #endif - - delete item; - } - /* check timestamp: delete if here longer than store period or more than two days */ - else if (((time_t) newBlog->sendTime < min) || - ((time_t) newBlog->sendTime > max)) - { - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::loadBlogFile() Outside TimeRange (deleting):"; - std::cerr << std::endl; - #endif - /* if outside time range remove */ - delete newBlog; - } - else - { - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::loadBlogFile() Loading Item"; - std::cerr << std::endl; - #endif - - addBlog(newBlog); // add received blog to list - } - } - - delete store; // store finished with/return resource - return true; -} - -bool p3Qblog::addBlog(RsQblogMsg *newBlog) -{ - #ifdef QBLOG_DEBUG - std::cerr << "p3Ranking::addBlog() Item:"; - std::cerr << std::endl; - newBlog->print(std::cerr, 10); // check whats in the blog item - std::cerr << std::endl; - #endif - - { - RsStackMutex Stack(mBlogMtx); - - mUsrBlogSet[newBlog->PeerId()].insert(std::make_pair(newBlog->sendTime, newBlog->message)); - - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::addBlog()"; - std::cerr << std::endl; - std::cerr << "\tpeerId" << newBlog->PeerId(); - std::cerr << std::endl; - std::cerr << "\tmUsrBlogSet: time" << newBlog->sendTime; - std::cerr << std::endl; - std::cerr << "\tmUsrBlogSet: blog" << newBlog->message; - std::cerr << std::endl; - #endif - mPostsUpdated = false; // need to figure how this should work/ where this should be placed - } - - return true; -} - -bool p3Qblog::postBlogs(void) -{ - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::postBlogs()"; - std::cerr << std::endl; - #endif - - std::string path = CacheSource::getCacheDir(); - std::ostringstream out; - uint16_t subid = 1; - - out << "qblogs-" << time(NULL) << ".rsqb"; // create blog file name based on time posted - - /* determine filename */ - std::string tmpname = out.str(); - std::string fname = path + "/" + tmpname; - - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::postBlogs() Storing to: " << fname; - std::cerr << std::endl; - #endif - - RsSerialiser *rsSerialiser = new RsSerialiser(); - rsSerialiser->addSerialType(new RsQblogMsgSerialiser()); - - uint32_t bioflags = BIN_FLAGS_HASH_DATA | BIN_FLAGS_WRITEABLE; - BinInterface *bio = new BinFileInterface(fname.c_str(), bioflags); - pqistore *store = new pqistore(rsSerialiser, mOwnId, bio, - BIN_FLAGS_NO_DELETE); - - { - RsStackMutex stack(mBlogMtx); /********** STACK LOCKED MTX ******/ - - /* iterate through list */ - std::list::iterator it; - - for(it = mBlogs.begin(); it != mBlogs.end(); it++) - { - /* only post own blogs */ - if(mOwnId == (*it)->PeerId()) - { - /*write to serialiser*/ - RsItem *item = *it; - - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::postBlogs() Storing Item:"; - std::cerr << std::endl; - item->print(std::cerr, 10); - std::cerr << std::endl; - #endif - - store->SendItem(item); - } - else /* if blogs belong to a friend */ - { - #ifdef QBLOG_DEBUG - std::cerr << "p3Ranking::postBlogs() Skipping friend blog items:"; - std::cerr << std::endl; - #endif - - continue; - } - } - - } - - /* flag as new info */ - CacheData data; - - { /********** STACK LOCKED MTX ******/ - RsStackMutex stack(mBlogMtx); - data.pid = mOwnId; - } /********** STACK LOCKED MTX ******/ - - data.cid = CacheId(CacheSource::getCacheType(), subid); - - data.path = path; - data.name = tmpname; - - data.hash = bio->gethash(); - data.size = bio->bytecount(); - data.recvd = time(NULL); - - #ifdef QBLOG_DEBUG - std::cerr << "p3Ranking::postBlogs() refreshing Cache"; - std::cerr << std::endl; - std::cerr << "\tCache Path: " << data.path; - std::cerr << std::endl; - std::cerr << "\tCache Name: " << data.name; - std::cerr << std::endl; - std::cerr << "\tCache Hash: " << data.hash; - std::cerr << std::endl; - std::cerr << "\tCache Size: " << data.size; - std::cerr << std::endl; - #endif - - if(data.size > 0) /* don't refresh zero sized caches */ - { - refreshCache(data); - } - - delete store; - return true; -} - - - - -p3Qblog::~p3Qblog() -{ - return; -} - - - -bool p3Qblog::getBlogs(std::map< std::string, std::multimap > &blogs) -{ - { - RsStackMutex stack(mBlogMtx); - - if(mUsrBlogSet.empty()) // return error blogs are empty - { - std::cerr << "usr blog set empty!" << std::endl; - return false; - } - - blogs = mUsrBlogSet; - - - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::getBlogs() number of blogs: " << mUsrBlogSet.size(); - std::cerr << std::endl; - #endif - } - - return true; -} - -bool p3Qblog::sendBlog(const std::wstring &msg) -{ - time_t blogTimeStamp; - - { - RsStackMutex stack(mBlogMtx); - mUsrBlogSet[mOwnId].insert(std::make_pair(blogTimeStamp, msg)); - - RsQblogMsg *blog = new RsQblogMsg(); - blog->clear(); - - blog->sendTime = blogTimeStamp; - blog->message = msg; - - - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::sendBlogFile()"; - std::cerr << std::endl; - std::cerr << "\tblogItem->sendTime" << blog->sendTime; - std::cerr << std::endl; - std::cerr << "\tblogItem->message" << blog->message; - std::cerr << std::endl; - #endif - - mBlogs.push_back(blog); - } - return true; -} - -void p3Qblog::loadDummy(void) -{ - std::list peers; - std::wstring cnv_wstr; - mConnMgr->getFriendList(peers); // retrieve peers list from core - if(peers.empty()) - { - //for(int i = 0; i < 50; i++) - // std::cerr << "nothing in peer list!!!" << std::endl; - } - - - srand(60); - long int now = time(NULL); // the present time - std::multimap emptySet; // time/blog map - - //std::string statusSet[5] = { "great", "rubbish", "ecstatic", "save me", "emo depression"}; - //std::string songs[5] = { "broken spleen", "niobium", "ewe (a sheep)", "velvet stuff", "chun li kicks"}; - - /* the usr dummy usr blogs */ - std::string B1 = "I think we should eat more cheese"; - std::string B2 = "today was so cool, i got attacked by fifty ninja while buying a loaf so i used my paper bag to suffocate each of them to death at hyper speed"; - std::string B3 = "Nuthins up"; - std::string B4 = "stop bothering me"; - std::string B5 = "I'm really a boring person and having nothin interesting to say"; - std::string blogs[5] = {B1, B2, B3, B4, B5}; - - - - /* fill up maps: first usrblogset with empty blogs */ - - std::list::iterator it; - - mUsrBlogSet.insert(std::make_pair(mOwnId, emptySet)); - - for(it = peers.begin(); it!=peers.end();it++) - { - mUsrBlogSet.insert(std::make_pair(*it, emptySet)); - } - - /* now fill up blog map */ - - - - for(int i=0; i < 50 ; i++) - { - std::list::iterator it = peers.begin(); - long int timeStamp; - timeStamp = now + rand() % 2134223; - int b = rand() % 5; - cnv_wstr.assign(blogs[b].begin(), blogs[b].end()); - mUsrBlogSet[mOwnId].insert(std::make_pair(timeStamp, cnv_wstr )); // store a random blog - - for(;it!=peers.end(); it++) - { - timeStamp = now + rand() % 2134223; // a random time for each blog - int c = rand() % 5; - cnv_wstr.assign(blogs[c].begin(), blogs[c].end()); - mUsrBlogSet[*it].insert(std::make_pair(timeStamp, cnv_wstr)); // store a random blog - } - } - - return; -} - -bool p3Qblog::getPeerLatestBlog(std::string id, uint32_t &ts, std::wstring &post) -{ - #ifdef QBLOG_DEBUG - std::cerr << "p3Qblog::getPeerLatestBlog(): " << "not implemented yet" << std::endl; - #endif - return false; -} - - -bool p3Qblog::sort(void) -{ - // TODO sorts blog maps in time order - return true; -} - -void p3Qblog::tick() -{ - bool postUpdated = false; // so stack mutex is not enabled during postblog call - - { - RsStackMutex stack(mBlogMtx); - postUpdated = mPostsUpdated; - } - - if(!postUpdated) - { - if(!postBlogs()) - std::cerr << "p3Qblog::tick():" << "tick failed!"; - - /* drbob: added to stop infinite qblog output */ - RsStackMutex stack(mBlogMtx); - mPostsUpdated = true; - } -} diff --git a/libretroshare/src/services/p3Qblog.h b/libretroshare/src/services/p3Qblog.h deleted file mode 100644 index b4eae2b5e..000000000 --- a/libretroshare/src/services/p3Qblog.h +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef P3QBLOG_H_ -#define P3QBLOG_H_ - -/* - * libretroshare/src/rsiface: p3Qblog.h - * - * RetroShare Blog Service. - * - * Copyright 2007-2008 by Chris Evi-Parker, 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 -#include -#include -#include - -#include "dbase/cachestrapper.h" -#include "pqi/pqiservice.h" -#include "pqi/pqistreamer.h" -#include "pqi/p3connmgr.h" -#include "pqi/p3cfgmgr.h" - -#include "serialiser/rsserial.h" -#include "rsiface/rstypes.h" - -class RsQblogMsg; /* to populate maps of blogs */ - -/*! - * contains definitions of the interface and blog information to be manipulated - * See RsQblog class for virtual methods documentation - */ - class p3Qblog : public CacheSource, public CacheStore - { - /** - * overloads extractor to make printing wstrings easier - */ - friend std::ostream &operator<<(std::ostream &out, const std::wstring); - - public: - - p3Qblog(p3ConnectMgr *connMgr, - uint16_t type, CacheStrapper *cs, CacheTransfer *cft, - std::string sourcedir, std::string storedir, - uint32_t storePeriod); - virtual ~p3Qblog (); - - public: - - /******************************* CACHE SOURCE / STORE Interface *********************/ - - /// overloaded functions from Cache Source - virtual bool loadLocalCache(const CacheData &data); - - /// overloaded functions from Cache Store - virtual int loadCache(const CacheData &data); - - /******************************* CACHE SOURCE / STORE Interface *********************/ - - public: - - virtual bool sendBlog(const std::wstring &msg); - virtual bool getBlogs(std::map< std::string, std::multimap > &blogs); - virtual bool getPeerLatestBlog(std::string id, uint32_t &ts, std::wstring &post); - - /** - * to be run by server, update method - */ - void tick(); - - private: - -/********************* begining of private utility methods **************************/ - - /* - * to load and transform cache source to normal attribute format of a blog message - * @param filename - * @param source - */ - bool loadBlogFile(std::string filename, std::string src); - - /* - * add a blog item to maps - * @param newBlog a blog item from a peer or yourself - */ - bool addBlog(RsQblogMsg *newBlog); - - /* - * post our blog to our friends, connectivity method - */ - bool postBlogs(void); - - /* - * sort usr/blog maps in time order - */ - bool sort(void); - - -/************************* end of private methods **************************/ - - /// handles connection to peers - p3ConnectMgr *mConnMgr; - /// for locking files provate members below - RsMutex mBlogMtx; - /// the current usr - std::string mOwnId; - /// contain usrs and their blogs - std::map< std::string, std::multimap > mUsrBlogSet; - ///fills up above sets - std::list mBlogs; - ///how long to keep posts - uint32_t mStorePeriod; - /// to track blog updates - bool mPostsUpdated; - /// to track profile updates - bool mProfileUpdated; - - /* - * load dummy data - */ - void loadDummy(void); - - }; - -#endif /*P3QBLOG_H_*/