Added identity validation to GXS

Added id selection dialog to photo addition (a bit crude)
Better memory fix for memory exhaustion due to requests 


git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs_sync-validate-fix@6089 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2013-01-24 21:00:18 +00:00
parent 8d89d0bc95
commit 3f10cdead8
13 changed files with 232 additions and 166 deletions

View file

@ -162,6 +162,7 @@ bool GxsSecurity::validateNxsMsg(RsNxsMsg& msg, RsTlvKeySignature& sign, RsTlvSe
msgMeta.mOrigMsgId = origMsgId;
msgMeta.mMsgId = msgId;
msgMeta.signSet = signSet;
if (signOk == 1)
{

View file

@ -101,20 +101,20 @@ void RsGenExchange::tick()
publishMsgs();
processGrpMetaChanges();
processGrpMetaChanges();
processMsgMetaChanges();
processMsgMetaChanges();
processRecvdData();
processRecvdData();
if(!mNotifications.empty())
{
notifyChanges(mNotifications);
mNotifications.clear();
}
if(!mNotifications.empty())
{
notifyChanges(mNotifications);
mNotifications.clear();
}
// implemented service tick function
service_tick();
// implemented service tick function
service_tick();
}
bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token,
@ -177,7 +177,7 @@ void RsGenExchange::generateGroupKeys(RsTlvSecurityKeySet& keySet, bool genPubli
adminKey.keyId = adminKey.keyId + "_public";
adminKey.startTS = time(NULL);
adminKey.endTS = 0; /* no end */
adminKey.endTS = adminKey.startTS + 60 * 60 * 24 * 365 * 5; /* approx 5 years */
privAdminKey.startTS = adminKey.startTS;
privAdminKey.endTS = 0; /* no end */
@ -434,7 +434,7 @@ bool RsGenExchange::createMsgSignatures(RsTlvKeySignatureSet& signSet, RsTlvBina
// poll immediately but, don't spend more than a second polling
while( (mGixs->getPrivateKey(msgMeta.mAuthorId, authorKey) == -1) &&
((now + 1) >> time(NULL))
((now + 5) > time(NULL))
)
{
#ifndef WINDOWS_SYS
@ -632,7 +632,6 @@ bool RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, RsTlvSec
{
valid = false;
}
}
@ -664,7 +663,7 @@ bool RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, RsTlvSec
#endif
}
RsTlvKeySignature sign = metaData.signSet.keySignSet[GXS_SERV::FLAG_AUTHEN_PUBLISH];
RsTlvKeySignature sign = metaData.signSet.keySignSet[GXS_SERV::FLAG_AUTHEN_IDENTITY];
valid &= GxsSecurity::validateNxsMsg(*msg, sign, authorKey);
}else
{

View file

@ -52,7 +52,7 @@ void RsGxsIfaceImpl::groupsChanged(std::list<RsGxsGroupId> &grpIds)
}
}
bool RsGxsIfaceImpl::updated()
bool RsGxsIfaceImpl::updated(bool willCallGrpChanged, bool willCallMsgChanged)
{
bool changed = false;
{
@ -61,10 +61,18 @@ bool RsGxsIfaceImpl::updated()
changed = (!mGroupChange.empty() || !mMsgChange.empty());
}
// std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
// msgsChanged(msgs);
// std::list<RsGxsGroupId> grpIds;
// groupsChanged(grpIds);
if(!willCallGrpChanged)
{
std::list<RsGxsGroupId> grpIds;
groupsChanged(grpIds);
}
if(!willCallMsgChanged)
{
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
msgsChanged(msgs);
}
return changed;
}

View file

@ -59,9 +59,15 @@ public:
/*!
* Checks to see if a change has been received for
* for a message or group
* @param willCallGrpChanged if this is set to true, group changed function will return list
* groups that have changed, if false, the group changed list is cleared
* @param willCallMsgChanged if this is set to true, msgChanged function will return map
* messages that have changed, if false, the message changed map is cleared
* @return true if a change has occured for msg or group
* @see groupsChanged
* @see msgsChanged
*/
virtual bool updated();
virtual bool updated(bool willCallGrpChanged = false, bool willCallMsgChanged = false);
/*!
* The groups changed. \n
@ -69,7 +75,8 @@ public:
* the group actually set for ui notification.
* If receivedChanges is not passed RsGxsNotify changes
* this function does nothing
* @param grpIds
* @param grpIds returns list of grpIds that have changed
* @see updated
*/
virtual void groupsChanged(std::list<RsGxsGroupId>& grpIds);
@ -79,7 +86,8 @@ public:
* the msg actually set for ui notification.
* If receivedChanges is not passed RsGxsNotify changes
* this function does nothing
* @param msgs
* @param msgs returns map of message ids that have changed
* @see updated
*/
virtual void msgsChanged(std::map<RsGxsGroupId,
std::vector<RsGxsMessageId> >& msgs);

View file

@ -88,8 +88,7 @@ void RsGxsNetService::syncWithPeers()
sendItem(grp);
}
#ifdef GXS_ENABLE_SYNC_MSGS
//#ifdef GXS_ENABLE_SYNC_MSGS
std::map<RsGxsGroupId, RsGxsGrpMetaData* > grpMeta;
mDataStore->retrieveGxsGrpMetaData(grpMeta);
@ -127,7 +126,7 @@ void RsGxsNetService::syncWithPeers()
sendItem(msg);
}
}
#endif
//#endif
}
bool RsGxsNetService::loadList(std::list<RsItem*>& load)

View file

@ -2280,7 +2280,6 @@ int RsServer::StartupRetroShare()
mPluginsManager->registerClientServices(pqih) ;
mPluginsManager->registerCacheServices() ;
#ifdef RS_ENABLE_GXS
// The idea is that if priorGxsDir is non
@ -2348,9 +2347,9 @@ int RsServer::StartupRetroShare()
RsGenExchange::RESTRICTED_GRP_BITS);
// Re-enable later, photo not using gixs yet
// flag = GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN;
// RsGenExchange::setAuthenPolicyFlag(flag, photoAuthenPolicy,
// RsGenExchange::RESTRICTED_GRP_BITS);
flag = GXS_SERV::MSG_AUTHEN_ROOT_AUTHOR_SIGN; // should be GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN for comments
RsGenExchange::setAuthenPolicyFlag(flag, photoAuthenPolicy,
RsGenExchange::RESTRICTED_GRP_BITS);
flag = GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN;
RsGenExchange::setAuthenPolicyFlag(flag, photoAuthenPolicy,

View file

@ -1106,9 +1106,9 @@ uint32_t RsNxsSerialiser::sizeNxsExtended(RsNxsExtended *item){
return 0;
}
int RsNxsGrp::refcount = 0;
/** print and clear functions **/
int RsNxsMsg::refcount = 0;
void RsNxsMsg::clear()
{

View file

@ -73,6 +73,7 @@ public:
setPriorityLevel(QOS_PRIORITY_RS_VOIP_PING);
return;
}
virtual ~RsNxsItem(){ return; }
virtual void clear() = 0;
virtual std::ostream &print(std::ostream &out, uint16_t indent = 0) = 0;
@ -188,14 +189,18 @@ class RsNxsGrp : public RsNxsItem
public:
RsNxsGrp(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_GRP), grp(servtype), meta(servtype),
metaData(NULL) { clear(); return; }
virtual ~RsNxsGrp() { if(metaData) delete metaData; }
metaData(NULL) { clear();
//std::cout << "\nGrp refcount++ : " << ++refcount << std::endl;
return; }
virtual ~RsNxsGrp() { if(metaData) delete metaData;
//std::cout << "\nGrp refcount-- : " << --refcount << std::endl;
}
virtual void clear();
virtual std::ostream &print(std::ostream &out, uint16_t indent);
std::string grpId; /// group Id, needed to complete version Id (ncvi)
static int refcount;
RsTlvBinaryData grp; /// actual group data
/*!
@ -263,15 +268,25 @@ class RsNxsMsg : public RsNxsItem
public:
RsNxsMsg(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_MSG), meta(servtype), msg(servtype),
metaData(NULL) { clear(); return; }
~RsNxsMsg() { if(metaData) delete metaData; }
metaData(NULL) {
// std::cout << "\nrefcount++ : " << ++refcount << std::endl;
clear(); return;
}
virtual ~RsNxsMsg()
{
//std::cout << "\nrefcount-- : " << --refcount << std::endl;
if(metaData){
//std::cout << "\ndeleted\n";
delete metaData;
}
}
virtual void clear();
virtual std::ostream &print(std::ostream &out, uint16_t indent);
std::string grpId; /// group id, forms part of version id
std::string msgId; /// msg id
static int refcount;
/*!
* This should contains all the data
* which is not specific to the Gxs service data

View file

@ -691,21 +691,24 @@ bool p3IdService::cache_store(const RsGxsIdGroupItem *item)
for (kit = keySet.keys.begin(); kit != keySet.keys.end(); kit++)
{
if (kit->second.keyFlags | RSTLV_KEY_DISTRIB_ADMIN)
if (kit->second.keyFlags & RSTLV_KEY_DISTRIB_ADMIN)
{
std::cerr << "p3IdService::cache_store() Found Admin Key";
std::cerr << std::endl;
/* save full key - if we have it */
if (kit->second.keyFlags | RSTLV_KEY_TYPE_FULL)
if (kit->second.keyFlags & RSTLV_KEY_TYPE_FULL)
{
fullkey = kit->second;
full_key_ok = true;
}
/* cache public key always */
pubkey = kit->second;
pub_key_ok = true;
if (kit->second.keyFlags & RSTLV_KEY_TYPE_PUBLIC_ONLY)
{
/* cache public key always */
pubkey = kit->second;
pub_key_ok = true;
}
}
}

View file

@ -68,18 +68,18 @@ void p3Posted::service_tick()
generatePosts();
generateVotesAndComments();
time_t now = time(NULL);
if((now > (time_t) (VOTE_UPDATE_PERIOD + mLastUpdate)) &&
(mUpdatePhase == UPDATE_PHASE_GRP_REQUEST))
{
mPostUpdate = true;
mLastUpdate = time(NULL);
}
updateVotes();
processRankings();
// time_t now = time(NULL);
//
// if((now > (time_t) (VOTE_UPDATE_PERIOD + mLastUpdate)) &&
// (mUpdatePhase == UPDATE_PHASE_GRP_REQUEST))
// {
// mPostUpdate = true;
// mLastUpdate = time(NULL);
// }
//
// updateVotes();
//
// processRankings();
}
void p3Posted::generateVotesAndComments()
@ -505,7 +505,6 @@ bool p3Posted::requestPostRankings(uint32_t &token, const RankType &rType, const
gp->pubToken = token;
gp->rankingResult.rType = gp->rType;
gp->rankingResult.grpId = gp->grpId;
gp->grpId = gp->grpId;
mPendingPostRanks.push_back(gp);
@ -768,6 +767,7 @@ bool p3Posted::completePostedPostCalc(GxsPostedPostRanking *gpp)
break;
default:
std::cerr << "Unknown ranking tpye: " << gpp->rType << std::endl;
break;
}
return true;
}else

View file

@ -24,6 +24,8 @@ PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const RsPhotoPhoto &photo, QW
ui->lineEdit_PhotoGrapher->setVisible(false);
setUp();
ui->idChooser->setVisible(false);
}
PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget *parent) :
@ -43,6 +45,8 @@ PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget
connect(ui->lineEdit_Title, SIGNAL(editingFinished()), this, SLOT(setTitle()));
connect(ui->lineEdit_PhotoGrapher, SIGNAL(editingFinished()), this, SLOT(setPhotoGrapher()));
ui->idChooser->loadIds(0, "");
}
void PhotoItem::setSelected(bool selected)
@ -101,6 +105,15 @@ void PhotoItem::setPhotoGrapher()
const RsPhotoPhoto& PhotoItem::getPhotoDetails()
{
if(ui->idChooser->isVisible())
{
RsGxsId id;
ui->idChooser->getChosenId(id);
mPhotoDetails.mMeta.mAuthorId = id;
}
return mPhotoDetails;
}

View file

@ -1,110 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoItem</class>
<widget class="QWidget" name="PhotoItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>253</width>
<height>233</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="photoFrame">
<property name="styleSheet">
<string notr="true">QFrame#photoFrame{border: 2px solid #CCCCCC;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #EEEEEE, stop: 1 #CCCCCC);
border-radius: 10px}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_Thumbnail">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="AlbumTitle">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;Photo Title :&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;Photographer :&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="editLayOut">
<item>
<widget class="QLineEdit" name="lineEdit_Title">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_PhotoGrapher"/>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoItem</class>
<widget class="QWidget" name="PhotoItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>253</width>
<height>233</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="photoFrame">
<property name="styleSheet">
<string notr="true">QFrame#photoFrame{border: 2px solid #CCCCCC;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #EEEEEE, stop: 1 #CCCCCC);
border-radius: 10px}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_Thumbnail">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="AlbumTitle">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;Photo Title :&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;Photographer :&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="identity">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;Author :&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="editLayOut">
<item>
<widget class="QLineEdit" name="lineEdit_Title">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_PhotoGrapher"/>
</item>
<item>
<widget class="GxsIdChooser" name="idChooser"/>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GxsIdChooser</class>
<extends>QComboBox</extends>
<header>gui/gxs/GxsIdChooser.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -223,7 +223,7 @@ void PostedListDialog::updateDisplay()
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
if (rsPosted->updated())
if (rsPosted->updated(true, true))
{
/* update Forums List */