mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
commit
b2e37fe47e
@ -1273,6 +1273,58 @@ bool RsGenExchange::getMsgRelatedMeta(const uint32_t &token, GxsMsgRelatedMetaMa
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getSerializedGroupData(const uint32_t &token, RsGxsGroupId& id,unsigned char *& data,uint32_t& size)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
std::list<RsNxsGrp*> nxsGrps;
|
||||
|
||||
if(!mDataAccess->getGroupData(token, nxsGrps))
|
||||
return false ;
|
||||
|
||||
if(nxsGrps.size() != 1)
|
||||
{
|
||||
std::cerr << "(EE) getSerializedGroupData() got multiple groups in single request. This is unexpected." << std::endl;
|
||||
|
||||
for(std::list<RsNxsGrp*>::const_iterator it(nxsGrps.begin());it!=nxsGrps.end();++it)
|
||||
delete *it ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
RsNxsGrp *nxs_grp = *(nxsGrps.begin());
|
||||
|
||||
size = nxs_grp->serial_size() ;
|
||||
id = nxs_grp->metaData->mGroupId ;
|
||||
|
||||
if(size > 1024*1024 || NULL==(data = (unsigned char *)rs_malloc(size)))
|
||||
{
|
||||
std::cerr << "(EE) getSerializedGroupData() cannot allocate mem chunk of size " << size << ". Too big, or no room." << std::endl;
|
||||
delete nxs_grp ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return nxs_grp->serialise(data,size) ;
|
||||
}
|
||||
|
||||
bool RsGenExchange::deserializeGroupData(unsigned char *data,uint32_t size)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
|
||||
RsItem *item = RsNxsSerialiser(mServType).deserialise(data, &size);
|
||||
|
||||
RsNxsGrp *nxs_grp = dynamic_cast<RsNxsGrp*>(item) ;
|
||||
|
||||
if(item == NULL)
|
||||
{
|
||||
std::cerr << "(EE) RsGenExchange::deserializeGroupData(): cannot deserialise this data. Something's wrong." << std::endl;
|
||||
delete item ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
mReceivedGrps.push_back( GxsPendingItem<RsNxsGrp*, RsGxsGroupId>(nxs_grp, nxs_grp->grpId,time(NULL)) );
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem *>& grpItem)
|
||||
{
|
||||
|
@ -288,6 +288,20 @@ protected:
|
||||
*/
|
||||
bool getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem*>& grpItem);
|
||||
|
||||
/*!
|
||||
* \brief getSerializedGroupData
|
||||
* Retrieves the complete group data serialized into a chunk of memory. This can be useful to
|
||||
* transfer a full group from one machine to another.
|
||||
*
|
||||
* \param token token previously obtained from cache request
|
||||
* \param data memory chunk allocated (using malloc)
|
||||
* \param size size of the memory chunk.
|
||||
* \return
|
||||
*/
|
||||
|
||||
bool getSerializedGroupData(const uint32_t &token, RsGxsGroupId &id, unsigned char *& data, uint32_t& size);
|
||||
bool deserializeGroupData(unsigned char *data, uint32_t size);
|
||||
|
||||
template<class GrpType>
|
||||
bool getGroupDataT(const uint32_t &token, std::vector<GrpType*>& grpItem)
|
||||
{
|
||||
|
@ -75,6 +75,12 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
|
||||
gir->mGroupIds = groupIds;
|
||||
req = gir;
|
||||
}
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA)
|
||||
{
|
||||
GroupSerializedDataReq* gir = new GroupSerializedDataReq();
|
||||
gir->mGroupIds = groupIds;
|
||||
req = gir;
|
||||
}
|
||||
|
||||
if(req == NULL)
|
||||
{
|
||||
@ -103,34 +109,25 @@ bool RsGxsDataAccess::requestGroupInfo(uint32_t &token, uint32_t ansType, const
|
||||
uint32_t reqType = opts.mReqType;
|
||||
|
||||
if(reqType & GXS_REQUEST_TYPE_GROUP_META)
|
||||
{
|
||||
GroupMetaReq* gmr = new GroupMetaReq();
|
||||
req = gmr;
|
||||
}
|
||||
req = new GroupMetaReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_DATA)
|
||||
{
|
||||
GroupDataReq* gdr = new GroupDataReq();
|
||||
req = gdr;
|
||||
}
|
||||
req = new GroupDataReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_IDS)
|
||||
{
|
||||
GroupIdReq* gir = new GroupIdReq();
|
||||
req = gir;
|
||||
}
|
||||
|
||||
if(req == NULL)
|
||||
req = new GroupIdReq();
|
||||
else if(reqType & GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA)
|
||||
req = new GroupSerializedDataReq();
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() request type not recognised, type "
|
||||
<< reqType << std::endl;
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
generateToken(token);
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::requestGroupInfo() gets Token: " << token << std::endl;
|
||||
#endif
|
||||
|
||||
setReq(req, token, ansType, opts);
|
||||
storeRequest(req);
|
||||
|
||||
@ -430,7 +427,16 @@ bool RsGxsDataAccess::getGroupData(const uint32_t& token, std::list<RsNxsGrp*>&
|
||||
else if(req->status == GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
GroupDataReq* gmreq = dynamic_cast<GroupDataReq*>(req);
|
||||
if(gmreq)
|
||||
GroupSerializedDataReq* gsreq = dynamic_cast<GroupSerializedDataReq*>(req);
|
||||
|
||||
if(gsreq)
|
||||
{
|
||||
grpData.swap(gsreq->mGroupData);
|
||||
gsreq->mGroupData.clear();
|
||||
|
||||
locked_updateRequestStatus(token, GXS_REQUEST_V2_STATUS_DONE);
|
||||
}
|
||||
else if(gmreq)
|
||||
{
|
||||
grpData.swap(gmreq->mGroupData);
|
||||
gmreq->mGroupData.clear();
|
||||
@ -804,6 +810,7 @@ void RsGxsDataAccess::processRequests()
|
||||
MsgIdReq* mir;
|
||||
MsgRelatedInfoReq* mri;
|
||||
GroupStatisticRequest* gsr;
|
||||
GroupSerializedDataReq* grr;
|
||||
ServiceStatisticRequest* ssr;
|
||||
|
||||
#ifdef DATA_DEBUG
|
||||
@ -851,6 +858,11 @@ void RsGxsDataAccess::processRequests()
|
||||
{
|
||||
ok = getServiceStatistic(ssr);
|
||||
}
|
||||
else if((grr = dynamic_cast<GroupSerializedDataReq*>(req)) != NULL)
|
||||
{
|
||||
ok = getGroupSerializedData(grr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::processRequests() Failed to process request, token: "
|
||||
@ -929,7 +941,30 @@ bool RsGxsDataAccess::getServiceStatistic(const uint32_t &token, GxsServiceStati
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::getGroupSerializedData(GroupSerializedDataReq* req)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grpData;
|
||||
std::list<RsGxsGroupId> grpIdsOut;
|
||||
|
||||
getGroupList(req->mGroupIds, req->Options, grpIdsOut);
|
||||
|
||||
if(grpIdsOut.empty())
|
||||
return true;
|
||||
|
||||
|
||||
for(std::list<RsGxsGroupId>::iterator lit = grpIdsOut.begin();lit != grpIdsOut.end();++lit)
|
||||
grpData[*lit] = NULL;
|
||||
|
||||
bool ok = mDataStore->retrieveNxsGrps(grpData, true, true);
|
||||
req->mGroupData.clear();
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*>::iterator mit = grpData.begin();
|
||||
|
||||
for(; mit != grpData.end(); ++mit)
|
||||
req->mGroupData.push_back(mit->second) ;
|
||||
|
||||
return ok;
|
||||
}
|
||||
bool RsGxsDataAccess::getGroupData(GroupDataReq* req)
|
||||
{
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> grpData;
|
||||
|
@ -418,6 +418,13 @@ private:
|
||||
*/
|
||||
bool getGroupStatistic(GroupStatisticRequest* req);
|
||||
|
||||
/*!
|
||||
*
|
||||
* Attempts to retrieve group data in serialized format
|
||||
* @param req Request object to satisfy
|
||||
*/
|
||||
bool getGroupSerializedData(GroupSerializedDataReq* req);
|
||||
|
||||
/*!
|
||||
*
|
||||
* Attempts to service statistic
|
||||
|
@ -61,6 +61,12 @@ public:
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsGxsGroupId> mGroupIdResult;
|
||||
};
|
||||
class GroupSerializedDataReq : public GxsRequest
|
||||
{
|
||||
public:
|
||||
std::list<RsGxsGroupId> mGroupIds;
|
||||
std::list<RsNxsGrp*> mGroupData;
|
||||
};
|
||||
|
||||
class GroupDataReq : public GxsRequest
|
||||
{
|
||||
|
@ -305,6 +305,9 @@ public:
|
||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
||||
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
||||
|
||||
virtual bool serialiseIdentityToMemory(const RsGxsId& id,std::string& radix_string)=0;
|
||||
virtual bool deserialiseIdentityFromMemory(const std::string& radix_string)=0;
|
||||
|
||||
/*!
|
||||
* \brief overallReputationLevel
|
||||
* Returns the overall reputation level of the supplied identity. See rsreputations.h
|
||||
@ -319,6 +322,7 @@ public:
|
||||
*/
|
||||
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0;
|
||||
virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups)=0;
|
||||
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions) = 0;
|
||||
|
||||
};
|
||||
|
@ -47,6 +47,7 @@
|
||||
|
||||
#define GXS_REQUEST_TYPE_GROUP_STATS 0x01600000
|
||||
#define GXS_REQUEST_TYPE_SERVICE_STATS 0x03200000
|
||||
#define GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA 0x04000000
|
||||
|
||||
|
||||
// TODO CLEANUP: RS_TOKREQOPT_MSG_* should be an inner enum of RsTokReqOptions
|
||||
|
@ -70,6 +70,8 @@ static const time_t MAX_KEEP_KEYS_SIGNED_KNOWN = 30 * 86400 ; // signed ident
|
||||
|
||||
static const uint32_t MAX_DELAY_BEFORE_CLEANING= 1800 ; // clean old keys every 30 mins
|
||||
|
||||
static const uint32_t MAX_SERIALISED_IDENTITY_AGE = 600 ; // after 10 mins, a serialised identity record must be renewed.
|
||||
|
||||
RsIdentity *rsIdentity = NULL;
|
||||
|
||||
/******
|
||||
@ -97,13 +99,12 @@ RsIdentity *rsIdentity = NULL;
|
||||
#define BG_REPUTATION 3
|
||||
|
||||
|
||||
#define GXSIDREQ_CACHELOAD 0x0001
|
||||
#define GXSIDREQ_CACHEOWNIDS 0x0002
|
||||
|
||||
#define GXSIDREQ_PGPHASH 0x0010
|
||||
#define GXSIDREQ_RECOGN 0x0020
|
||||
|
||||
#define GXSIDREQ_OPINION 0x0030
|
||||
#define GXSIDREQ_CACHELOAD 0x0001
|
||||
#define GXSIDREQ_CACHEOWNIDS 0x0002
|
||||
#define GXSIDREQ_PGPHASH 0x0010
|
||||
#define GXSIDREQ_RECOGN 0x0020
|
||||
#define GXSIDREQ_OPINION 0x0030
|
||||
#define GXSIDREQ_SERIALIZE_TO_MEMORY 0x0040
|
||||
|
||||
#define GXSIDREQ_CACHETEST 0x1000
|
||||
|
||||
@ -697,6 +698,84 @@ bool p3IdService::getOwnIds(std::list<RsGxsId> &ownIds)
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3IdService::serialiseIdentityToMemory(const RsGxsId& id,std::string& radix_string)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// look into cache. If available, return the data. If not, request it.
|
||||
|
||||
std::map<RsGxsId,SerialisedIdentityStruct>::const_iterator it = mSerialisedIdentities.find(id);
|
||||
|
||||
if(it != mSerialisedIdentities.end())
|
||||
{
|
||||
Radix64::encode(it->second.mMem,it->second.mSize,radix_string) ;
|
||||
|
||||
if(it->second.mLastUsageTS + MAX_SERIALISED_IDENTITY_AGE > time(NULL))
|
||||
return true ;
|
||||
|
||||
std::cerr << "Identity " << id << " will be re-serialised, because the last record is too old." << std::endl;
|
||||
}
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
uint32_t token = 0;
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
|
||||
groupIds.push_back(RsGxsGroupId(id)) ;
|
||||
|
||||
RsGenExchange::getTokenService()->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds);
|
||||
GxsTokenQueue::queueRequest(token, GXSIDREQ_SERIALIZE_TO_MEMORY);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void p3IdService::handle_get_serialized_grp(uint32_t token)
|
||||
{
|
||||
// store the serialized data in cache.
|
||||
|
||||
unsigned char *mem = NULL;
|
||||
uint32_t size;
|
||||
RsGxsGroupId id ;
|
||||
|
||||
if(!RsGenExchange::getSerializedGroupData(token,id, mem,size))
|
||||
{
|
||||
std::cerr << "(EE) call to RsGenExchage::getSerializedGroupData() failed." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
std::cerr << "Received serialised group from RsGenExchange." << std::endl;
|
||||
|
||||
std::map<RsGxsId,SerialisedIdentityStruct>::const_iterator it = mSerialisedIdentities.find(RsGxsId(id));
|
||||
|
||||
if(it != mSerialisedIdentities.end())
|
||||
free(it->second.mMem) ;
|
||||
|
||||
SerialisedIdentityStruct s ;
|
||||
s.mMem = mem ;
|
||||
s.mSize = size ;
|
||||
s.mLastUsageTS = time(NULL) ;
|
||||
|
||||
mSerialisedIdentities[RsGxsId(id)] = s ;
|
||||
}
|
||||
|
||||
bool p3IdService::deserialiseIdentityFromMemory(const std::string& radix_string)
|
||||
{
|
||||
std::vector<uint8_t> mem = Radix64::decode(radix_string) ;
|
||||
|
||||
if(mem.empty())
|
||||
{
|
||||
std::cerr << "Cannot decode radix string \"" << radix_string << "\"" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if(!RsGenExchange::deserializeGroupData(mem.data(),mem.size()))
|
||||
{
|
||||
std::cerr << "Cannot load identity from radix string \"" << radix_string << "\"" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters ¶ms)
|
||||
{
|
||||
@ -1395,6 +1474,28 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool p3IdService::getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups)
|
||||
{
|
||||
unsigned char *mem = NULL;
|
||||
uint32_t size;
|
||||
RsGxsGroupId id ;
|
||||
|
||||
serialized_groups.clear() ;
|
||||
|
||||
if(!RsGenExchange::getSerializedGroupData(token,id, mem,size))
|
||||
{
|
||||
std::cerr << "(EE) call to RsGenExchage::getSerializedGroupData() failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string radix ;
|
||||
|
||||
Radix64::encode(mem,size,radix) ;
|
||||
|
||||
serialized_groups[RsGxsId(id)] = radix ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/********************************************************************************/
|
||||
/********************************************************************************/
|
||||
@ -4117,6 +4218,9 @@ void p3IdService::handleResponse(uint32_t token, uint32_t req_type)
|
||||
case GXSIDREQ_OPINION:
|
||||
opinion_handlerequest(token);
|
||||
break;
|
||||
case GXSIDREQ_SERIALIZE_TO_MEMORY:
|
||||
handle_get_serialized_grp(token) ;
|
||||
|
||||
default:
|
||||
/* error */
|
||||
std::cerr << "p3IdService::handleResponse() Unknown Request Type: " << req_type;
|
||||
|
@ -212,6 +212,13 @@ private:
|
||||
void init(const RsGxsIdGroupItem *item, const RsTlvPublicRSAKey& in_pub_key, const RsTlvPrivateRSAKey& in_priv_key,const std::list<RsRecognTag> &tagList);
|
||||
};
|
||||
|
||||
struct SerialisedIdentityStruct
|
||||
{
|
||||
unsigned char *mMem ;
|
||||
uint32_t mSize ;
|
||||
time_t mLastUsageTS;
|
||||
};
|
||||
|
||||
// Not sure exactly what should be inherited here?
|
||||
// Chris - please correct as necessary.
|
||||
|
||||
@ -238,6 +245,8 @@ public:
|
||||
|
||||
// These are exposed via RsIdentity.
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups);
|
||||
virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups);
|
||||
|
||||
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions);
|
||||
|
||||
// These are local - and not exposed via RsIdentity.
|
||||
@ -302,6 +311,8 @@ public:
|
||||
virtual bool requestKey(const RsGxsId &id, const std::list<RsPeerId> &peers, const RsIdentityUsage &use_info);
|
||||
virtual bool requestPrivateKey(const RsGxsId &id);
|
||||
|
||||
virtual bool serialiseIdentityToMemory(const RsGxsId& id,std::string& radix_string);
|
||||
virtual bool deserialiseIdentityFromMemory(const std::string& radix_string);
|
||||
|
||||
/**************** RsGixsReputation Implementation ****************/
|
||||
|
||||
@ -394,6 +405,12 @@ private:
|
||||
bool mBgSchedule_Active;
|
||||
uint32_t mBgSchedule_Mode;
|
||||
|
||||
/***********************************8
|
||||
* Fonction to receive and handle group serialisation to memory
|
||||
*/
|
||||
|
||||
virtual void handle_get_serialized_grp(uint32_t token);
|
||||
|
||||
/************************************************************************
|
||||
* pgphash processing.
|
||||
*
|
||||
@ -524,6 +541,8 @@ private:
|
||||
std::map<RsGxsId, std::list<RsPeerId> > mIdsNotPresent;
|
||||
std::map<RsGxsId,keyTSInfo> mKeysTS ;
|
||||
|
||||
std::map<RsGxsId,SerialisedIdentityStruct> mSerialisedIdentities ;
|
||||
|
||||
// keep a list of regular contacts. This is useful to sort IDs, and allow some services to priviledged ids only.
|
||||
std::set<RsGxsId> mContacts;
|
||||
RsNetworkExchangeService* mNes;
|
||||
|
@ -55,10 +55,11 @@
|
||||
*****/
|
||||
|
||||
// Data Requests.
|
||||
#define IDDIALOG_IDLIST 1
|
||||
#define IDDIALOG_IDDETAILS 2
|
||||
#define IDDIALOG_REPLIST 3
|
||||
#define IDDIALOG_REFRESH 4
|
||||
#define IDDIALOG_IDLIST 1
|
||||
#define IDDIALOG_IDDETAILS 2
|
||||
#define IDDIALOG_REPLIST 3
|
||||
#define IDDIALOG_REFRESH 4
|
||||
#define IDDIALOG_SERIALIZED_GROUP 5
|
||||
|
||||
#define CIRCLEGROUP_CIRCLE_COL_GROUPNAME 0
|
||||
#define CIRCLEGROUP_CIRCLE_COL_GROUPID 1
|
||||
@ -814,7 +815,7 @@ void IdDialog::loadCircleGroupData(const uint32_t& token)
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << "Loading circle info" << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
std::vector<RsGxsCircleGroup> circle_grp_v ;
|
||||
rsGxsCircles->getGroupData(token, circle_grp_v);
|
||||
|
||||
@ -1385,6 +1386,8 @@ void IdDialog::updateSelection()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void IdDialog::requestIdList()
|
||||
{
|
||||
//Disable by default, will be enable by insertIdDetails()
|
||||
@ -2174,6 +2177,45 @@ void IdDialog::insertRepList(uint32_t token)
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, true);
|
||||
}
|
||||
|
||||
void IdDialog::handleSerializedGroupData(uint32_t token)
|
||||
{
|
||||
std::map<RsGxsId,std::string> serialized_group_map ;
|
||||
|
||||
rsIdentity->getGroupSerializedData(token, serialized_group_map);
|
||||
|
||||
if(serialized_group_map.size() < 1)
|
||||
{
|
||||
std::cerr << "(EE) Cannot get radix data " << std::endl;
|
||||
return;
|
||||
}
|
||||
if(serialized_group_map.size() > 1)
|
||||
{
|
||||
std::cerr << "(EE) Too many results for serialized data" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
RsGxsId gxs_id = serialized_group_map.begin()->first ;
|
||||
std::string radix = serialized_group_map.begin()->second ;
|
||||
|
||||
RsIdentityDetails details ;
|
||||
|
||||
if(!rsIdentity->getIdDetails(gxs_id,details))
|
||||
{
|
||||
std::cerr << "(EE) Cannot get id details for key " << gxs_id << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
QList<RetroShareLink> urls ;
|
||||
|
||||
RetroShareLink link ;
|
||||
link.createIdentity(gxs_id,QString::fromUtf8(details.mNickname.c_str()),QString::fromStdString(radix)) ;
|
||||
urls.push_back(link);
|
||||
|
||||
RSLinkClipboard::copyLinks(urls) ;
|
||||
|
||||
QMessageBox::information(NULL,tr("information"),tr("This identity link was copied to your clipboard. Paste it in a mail, or a message to transmit the identity to someone.")) ;
|
||||
}
|
||||
|
||||
void IdDialog::loadRequest(const TokenQueue * queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
@ -2197,6 +2239,10 @@ void IdDialog::loadRequest(const TokenQueue * queue, const TokenRequest &req)
|
||||
insertRepList(req.mToken);
|
||||
break;
|
||||
|
||||
case IDDIALOG_SERIALIZED_GROUP:
|
||||
handleSerializedGroupData(req.mToken);
|
||||
break;
|
||||
|
||||
case IDDIALOG_REFRESH:
|
||||
// replaced by RsGxsUpdateBroadcastPage
|
||||
// updateDisplay(true);
|
||||
@ -2240,165 +2286,211 @@ void IdDialog::loadRequest(const TokenQueue * queue, const TokenRequest &req)
|
||||
|
||||
void IdDialog::IdListCustomPopupMenu( QPoint )
|
||||
{
|
||||
QMenu *contextMenu = new QMenu(this);
|
||||
QMenu *contextMenu = new QMenu(this);
|
||||
|
||||
|
||||
std::list<RsGxsId> own_identities ;
|
||||
rsIdentity->getOwnIds(own_identities) ;
|
||||
std::list<RsGxsId> own_identities ;
|
||||
rsIdentity->getOwnIds(own_identities) ;
|
||||
|
||||
// make some stats about what's selected. If the same value is used for all selected items, it can be switched.
|
||||
// make some stats about what's selected. If the same value is used for all selected items, it can be switched.
|
||||
|
||||
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
|
||||
QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
|
||||
|
||||
bool root_node_present = false ;
|
||||
bool one_item_owned_by_you = false ;
|
||||
uint32_t n_positive_reputations = 0 ;
|
||||
uint32_t n_negative_reputations = 0 ;
|
||||
uint32_t n_neutral_reputations = 0 ;
|
||||
uint32_t n_is_a_contact = 0 ;
|
||||
uint32_t n_is_not_a_contact = 0 ;
|
||||
uint32_t n_selected_items =0 ;
|
||||
bool root_node_present = false ;
|
||||
bool one_item_owned_by_you = false ;
|
||||
uint32_t n_positive_reputations = 0 ;
|
||||
uint32_t n_negative_reputations = 0 ;
|
||||
uint32_t n_neutral_reputations = 0 ;
|
||||
uint32_t n_is_a_contact = 0 ;
|
||||
uint32_t n_is_not_a_contact = 0 ;
|
||||
uint32_t n_selected_items =0 ;
|
||||
|
||||
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||
{
|
||||
if(*it == allItem || *it == contactsItem || *it == ownItem)
|
||||
{
|
||||
root_node_present = true ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
uint32_t item_flags = (*it)->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
|
||||
|
||||
if(item_flags & RSID_FILTER_OWNED_BY_YOU)
|
||||
one_item_owned_by_you = true ;
|
||||
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << " item flags = " << item_flags << std::endl;
|
||||
#endif
|
||||
RsGxsId keyId((*it)->text(RSID_COL_KEYID).toStdString());
|
||||
|
||||
RsIdentityDetails det ;
|
||||
rsIdentity->getIdDetails(keyId,det) ;
|
||||
|
||||
switch(det.mReputation.mOwnOpinion)
|
||||
{
|
||||
case RsReputations::OPINION_NEGATIVE: ++n_negative_reputations ;
|
||||
break ;
|
||||
|
||||
case RsReputations::OPINION_POSITIVE: ++n_positive_reputations ;
|
||||
break ;
|
||||
|
||||
case RsReputations::OPINION_NEUTRAL: ++n_neutral_reputations ;
|
||||
break ;
|
||||
}
|
||||
|
||||
++n_selected_items ;
|
||||
|
||||
if(rsIdentity->isARegularContact(keyId))
|
||||
++n_is_a_contact ;
|
||||
else
|
||||
++n_is_not_a_contact ;
|
||||
}
|
||||
|
||||
if(!root_node_present) // don't show menu if some of the root nodes are present
|
||||
for(QList<QTreeWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
|
||||
{
|
||||
if(*it == allItem || *it == contactsItem || *it == ownItem)
|
||||
{
|
||||
|
||||
if(!one_item_owned_by_you)
|
||||
{
|
||||
QWidget *widget = new QWidget(contextMenu);
|
||||
widget->setStyleSheet( ".QWidget{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #FEFEFE, stop:1 #E8E8E8); border: 1px solid #CCCCCC;}");
|
||||
|
||||
// create menu header
|
||||
QHBoxLayout *hbox = new QHBoxLayout(widget);
|
||||
hbox->setMargin(0);
|
||||
hbox->setSpacing(6);
|
||||
|
||||
QLabel *iconLabel = new QLabel(widget);
|
||||
QPixmap pix = QPixmap(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5);
|
||||
iconLabel->setPixmap(pix);
|
||||
iconLabel->setMaximumSize(iconLabel->frameSize().height() + pix.height(), pix.width());
|
||||
hbox->addWidget(iconLabel);
|
||||
|
||||
QLabel *textLabel = new QLabel("<strong>" + ui->titleBarLabel->text() + "</strong>", widget);
|
||||
hbox->addWidget(textLabel);
|
||||
|
||||
QSpacerItem *spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
hbox->addItem(spacerItem);
|
||||
|
||||
widget->setLayout(hbox);
|
||||
|
||||
QWidgetAction *widgetAction = new QWidgetAction(this);
|
||||
widgetAction->setDefaultWidget(widget);
|
||||
contextMenu->addAction(widgetAction);
|
||||
|
||||
if(n_selected_items == 1) // if only one item is selected, allow to chat with this item
|
||||
{
|
||||
if(own_identities.size() <= 1)
|
||||
{
|
||||
QAction *action = contextMenu->addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity()));
|
||||
|
||||
if(own_identities.empty())
|
||||
action->setEnabled(false) ;
|
||||
else
|
||||
action->setData(QString::fromStdString((own_identities.front()).toStdString())) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMenu *mnu = contextMenu->addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ;
|
||||
|
||||
for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it)
|
||||
{
|
||||
RsIdentityDetails idd ;
|
||||
rsIdentity->getIdDetails(*it,idd) ;
|
||||
|
||||
QPixmap pixmap ;
|
||||
|
||||
if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG"))
|
||||
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;
|
||||
|
||||
QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity()));
|
||||
action->setData(QString::fromStdString((*it).toStdString())) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// always allow to send messages
|
||||
contextMenu->addAction(QIcon(":/images/mail_new.png"), tr("Send message"), this, SLOT(sendMsg()));
|
||||
|
||||
contextMenu->addSeparator();
|
||||
|
||||
if(n_is_a_contact == 0)
|
||||
contextMenu->addAction(QIcon(), tr("Add to Contacts"), this, SLOT(addtoContacts()));
|
||||
|
||||
if(n_is_not_a_contact == 0)
|
||||
contextMenu->addAction(QIcon(":/images/cancel.png"), tr("Remove from Contacts"), this, SLOT(removefromContacts()));
|
||||
|
||||
contextMenu->addSeparator();
|
||||
|
||||
if(n_positive_reputations == 0) // only unban when all items are banned
|
||||
contextMenu->addAction(QIcon(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson()));
|
||||
|
||||
if(n_neutral_reputations == 0) // only unban when all items are banned
|
||||
contextMenu->addAction(QIcon(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson()));
|
||||
|
||||
if(n_negative_reputations == 0)
|
||||
contextMenu->addAction(QIcon(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson()));
|
||||
}
|
||||
|
||||
if(one_item_owned_by_you && n_selected_items==1)
|
||||
{
|
||||
contextMenu->addSeparator();
|
||||
|
||||
contextMenu->addAction(ui->editIdentity);
|
||||
contextMenu->addAction(ui->removeIdentity);
|
||||
}
|
||||
|
||||
root_node_present = true ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
contextMenu = ui->idTreeWidget->createStandardContextMenu(contextMenu);
|
||||
uint32_t item_flags = (*it)->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
|
||||
|
||||
contextMenu->exec(QCursor::pos());
|
||||
delete contextMenu;
|
||||
if(item_flags & RSID_FILTER_OWNED_BY_YOU)
|
||||
one_item_owned_by_you = true ;
|
||||
|
||||
#ifdef ID_DEBUG
|
||||
std::cerr << " item flags = " << item_flags << std::endl;
|
||||
#endif
|
||||
RsGxsId keyId((*it)->text(RSID_COL_KEYID).toStdString());
|
||||
|
||||
RsIdentityDetails det ;
|
||||
rsIdentity->getIdDetails(keyId,det) ;
|
||||
|
||||
switch(det.mReputation.mOwnOpinion)
|
||||
{
|
||||
case RsReputations::OPINION_NEGATIVE: ++n_negative_reputations ;
|
||||
break ;
|
||||
|
||||
case RsReputations::OPINION_POSITIVE: ++n_positive_reputations ;
|
||||
break ;
|
||||
|
||||
case RsReputations::OPINION_NEUTRAL: ++n_neutral_reputations ;
|
||||
break ;
|
||||
}
|
||||
|
||||
++n_selected_items ;
|
||||
|
||||
if(rsIdentity->isARegularContact(keyId))
|
||||
++n_is_a_contact ;
|
||||
else
|
||||
++n_is_not_a_contact ;
|
||||
}
|
||||
|
||||
if(!root_node_present) // don't show menu if some of the root nodes are present
|
||||
{
|
||||
|
||||
if(!one_item_owned_by_you)
|
||||
{
|
||||
QWidget *widget = new QWidget(contextMenu);
|
||||
widget->setStyleSheet( ".QWidget{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #FEFEFE, stop:1 #E8E8E8); border: 1px solid #CCCCCC;}");
|
||||
|
||||
// create menu header
|
||||
QHBoxLayout *hbox = new QHBoxLayout(widget);
|
||||
hbox->setMargin(0);
|
||||
hbox->setSpacing(6);
|
||||
|
||||
QLabel *iconLabel = new QLabel(widget);
|
||||
QPixmap pix = QPixmap(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5);
|
||||
iconLabel->setPixmap(pix);
|
||||
iconLabel->setMaximumSize(iconLabel->frameSize().height() + pix.height(), pix.width());
|
||||
hbox->addWidget(iconLabel);
|
||||
|
||||
QLabel *textLabel = new QLabel("<strong>" + ui->titleBarLabel->text() + "</strong>", widget);
|
||||
hbox->addWidget(textLabel);
|
||||
|
||||
QSpacerItem *spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
hbox->addItem(spacerItem);
|
||||
|
||||
widget->setLayout(hbox);
|
||||
|
||||
QWidgetAction *widgetAction = new QWidgetAction(this);
|
||||
widgetAction->setDefaultWidget(widget);
|
||||
contextMenu->addAction(widgetAction);
|
||||
|
||||
if(n_selected_items == 1) // if only one item is selected, allow to chat with this item
|
||||
{
|
||||
if(own_identities.size() <= 1)
|
||||
{
|
||||
QAction *action = contextMenu->addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity()));
|
||||
|
||||
if(own_identities.empty())
|
||||
action->setEnabled(false) ;
|
||||
else
|
||||
action->setData(QString::fromStdString((own_identities.front()).toStdString())) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMenu *mnu = contextMenu->addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ;
|
||||
|
||||
for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it)
|
||||
{
|
||||
RsIdentityDetails idd ;
|
||||
rsIdentity->getIdDetails(*it,idd) ;
|
||||
|
||||
QPixmap pixmap ;
|
||||
|
||||
if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG"))
|
||||
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;
|
||||
|
||||
QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity()));
|
||||
action->setData(QString::fromStdString((*it).toStdString())) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(n_selected_items==1)
|
||||
QAction *action = contextMenu->addAction(QIcon(":/images/chat_24.png"),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ;
|
||||
|
||||
// always allow to send messages
|
||||
contextMenu->addAction(QIcon(":/images/mail_new.png"), tr("Send message"), this, SLOT(sendMsg()));
|
||||
|
||||
contextMenu->addSeparator();
|
||||
|
||||
if(n_is_a_contact == 0)
|
||||
contextMenu->addAction(QIcon(), tr("Add to Contacts"), this, SLOT(addtoContacts()));
|
||||
|
||||
if(n_is_not_a_contact == 0)
|
||||
contextMenu->addAction(QIcon(":/images/cancel.png"), tr("Remove from Contacts"), this, SLOT(removefromContacts()));
|
||||
|
||||
contextMenu->addSeparator();
|
||||
|
||||
if(n_positive_reputations == 0) // only unban when all items are banned
|
||||
contextMenu->addAction(QIcon(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson()));
|
||||
|
||||
if(n_neutral_reputations == 0) // only unban when all items are banned
|
||||
contextMenu->addAction(QIcon(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson()));
|
||||
|
||||
if(n_negative_reputations == 0)
|
||||
contextMenu->addAction(QIcon(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson()));
|
||||
}
|
||||
|
||||
if(one_item_owned_by_you && n_selected_items==1)
|
||||
{
|
||||
contextMenu->addSeparator();
|
||||
|
||||
contextMenu->addAction(QIcon(":/images/chat_24.png"),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ;
|
||||
contextMenu->addAction(ui->editIdentity);
|
||||
contextMenu->addAction(ui->removeIdentity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
contextMenu = ui->idTreeWidget->createStandardContextMenu(contextMenu);
|
||||
|
||||
contextMenu->exec(QCursor::pos());
|
||||
delete contextMenu;
|
||||
}
|
||||
|
||||
void IdDialog::copyRetroshareLink()
|
||||
{
|
||||
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
||||
|
||||
if (!item)
|
||||
{
|
||||
std::cerr << "IdDialog::editIdentity() Invalid item";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
RsGxsId gxs_id(item->text(RSID_COL_KEYID).toStdString());
|
||||
|
||||
if(gxs_id.isNull())
|
||||
{
|
||||
std::cerr << "Null GXS id. Something went wrong." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
RsIdentityDetails details ;
|
||||
|
||||
if(! rsIdentity->getIdDetails(gxs_id,details))
|
||||
return ;
|
||||
|
||||
if (!mIdQueue)
|
||||
return;
|
||||
|
||||
mStateHelper->setLoading(IDDIALOG_SERIALIZED_GROUP, true);
|
||||
|
||||
mIdQueue->cancelActiveRequestTokens(IDDIALOG_SERIALIZED_GROUP);
|
||||
|
||||
std::list<RsGxsGroupId> ids ;
|
||||
ids.push_back(RsGxsGroupId(gxs_id)) ;
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_SERIALIZED_DATA;
|
||||
|
||||
uint32_t token;
|
||||
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids, IDDIALOG_SERIALIZED_GROUP);
|
||||
}
|
||||
|
||||
void IdDialog::chatIdentity()
|
||||
|
@ -93,6 +93,7 @@ private slots:
|
||||
void editIdentity();
|
||||
void chatIdentity();
|
||||
void sendMsg();
|
||||
void copyRetroshareLink();
|
||||
void on_closeInfoFrameButton_clicked();
|
||||
|
||||
void updateSelection();
|
||||
@ -132,6 +133,7 @@ private:
|
||||
|
||||
void requestRepList();
|
||||
void insertRepList(uint32_t token);
|
||||
void handleSerializedGroupData(uint32_t token);
|
||||
|
||||
void requestIdEdit(std::string &id);
|
||||
void showIdEdit(uint32_t token);
|
||||
|
@ -67,7 +67,8 @@
|
||||
#define HOST_SEARCH "search"
|
||||
#define HOST_CERTIFICATE "certificate"
|
||||
#define HOST_PUBLIC_MSG "public_msg"
|
||||
#define HOST_REGEXP "file|extra|person|forum|channel|posted|search|message|certificate|private_chat|public_msg"
|
||||
#define HOST_IDENTITY "identity"
|
||||
#define HOST_REGEXP "file|extra|person|forum|channel|posted|search|message|certificate|private_chat|public_msg|identity"
|
||||
|
||||
#define FILE_NAME "name"
|
||||
#define FILE_SIZE "size"
|
||||
@ -89,6 +90,9 @@
|
||||
#define POSTED_ID "id"
|
||||
#define POSTED_MSGID "msgid"
|
||||
|
||||
#define IDENTITY_NAME "name"
|
||||
#define IDENTITY_ID "gxsid"
|
||||
#define IDENTITY_GROUP "groupdata"
|
||||
|
||||
#define MESSAGE_ID "id"
|
||||
#define MESSAGE_SUBJECT "subject"
|
||||
@ -303,6 +307,21 @@ void RetroShareLink::fromUrl(const QUrl& url)
|
||||
return;
|
||||
}
|
||||
|
||||
if(url.host() == HOST_IDENTITY) {
|
||||
_type = TYPE_IDENTITY ;
|
||||
QString name = urlQuery.queryItemValue(IDENTITY_NAME) ;
|
||||
QString radix= urlQuery.queryItemValue(IDENTITY_GROUP) ;
|
||||
QString gxsid= urlQuery.queryItemValue(IDENTITY_ID) ;
|
||||
|
||||
RsGxsId id(gxsid.toStdString()) ;
|
||||
|
||||
if(!id.isNull())
|
||||
createIdentity(id,name,radix) ;
|
||||
else
|
||||
std::cerr << "(EE) identity link is not valid." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
if (url.host() == HOST_MESSAGE) {
|
||||
_type = TYPE_MESSAGE;
|
||||
std::string id = urlQuery.queryItemValue(MESSAGE_ID).toStdString();
|
||||
@ -333,6 +352,21 @@ RetroShareLink::RetroShareLink()
|
||||
clear();
|
||||
}
|
||||
|
||||
bool RetroShareLink::createIdentity(const RsGxsId& id, const QString& name, const QString& radix_data)
|
||||
{
|
||||
clear();
|
||||
|
||||
_name = name;
|
||||
_hash = QString::fromStdString(id.toStdString());
|
||||
_radix_group_data = radix_data ;
|
||||
|
||||
_type = TYPE_IDENTITY;
|
||||
|
||||
check();
|
||||
|
||||
return valid();
|
||||
}
|
||||
|
||||
bool RetroShareLink::createExtraFile(const QString& name, uint64_t size, const QString& hash,const QString& ssl_id)
|
||||
{
|
||||
clear();
|
||||
@ -534,6 +568,7 @@ void RetroShareLink::clear()
|
||||
_GPGid = "" ;
|
||||
_time_stamp = 0 ;
|
||||
_encrypted_chat_info = "" ;
|
||||
_radix_group_data = "" ;
|
||||
}
|
||||
|
||||
void RetroShareLink::check()
|
||||
@ -565,6 +600,17 @@ void RetroShareLink::check()
|
||||
if(!checkPGPId(_GPGid)) _valid = false ;
|
||||
break ;
|
||||
|
||||
case TYPE_IDENTITY:
|
||||
if(_name.isNull())
|
||||
_valid = false ;
|
||||
|
||||
if(_radix_group_data.isNull())
|
||||
_valid = false ;
|
||||
|
||||
if(_hash.isNull())
|
||||
_valid = false ;
|
||||
break ;
|
||||
|
||||
case TYPE_PERSON:
|
||||
if(_size != 0)
|
||||
_valid = false;
|
||||
@ -651,6 +697,9 @@ QString RetroShareLink::title() const
|
||||
return QObject::tr("%1 (%2, Extra - Source included)").arg(hash()).arg(misc::friendlyUnit(size()));
|
||||
case TYPE_FILE:
|
||||
return QString("%1 (%2)").arg(hash()).arg(misc::friendlyUnit(size()));
|
||||
case TYPE_IDENTITY:
|
||||
return _name ;
|
||||
|
||||
case TYPE_PERSON:
|
||||
return PeerDefs::rsidFromId(RsPgpId(hash().toStdString()));
|
||||
case TYPE_FORUM:
|
||||
@ -711,6 +760,14 @@ QString RetroShareLink::toString() const
|
||||
|
||||
break;
|
||||
|
||||
case TYPE_IDENTITY:
|
||||
url.setScheme(RSLINK_SCHEME) ;
|
||||
url.setHost(HOST_IDENTITY) ;
|
||||
urlQuery.addQueryItem(IDENTITY_ID,_hash) ;
|
||||
urlQuery.addQueryItem(IDENTITY_NAME,encodeItem(_name)) ;
|
||||
urlQuery.addQueryItem(IDENTITY_GROUP,_radix_group_data) ;
|
||||
break ;
|
||||
|
||||
case TYPE_EXTRAFILE:
|
||||
url.setScheme(RSLINK_SCHEME);
|
||||
url.setHost(HOST_EXTRAFILE);
|
||||
@ -798,9 +855,11 @@ QString RetroShareLink::toString() const
|
||||
|
||||
QString RetroShareLink::niceName() const
|
||||
{
|
||||
if (type() == TYPE_PERSON) {
|
||||
if (type() == TYPE_PERSON)
|
||||
return PeerDefs::rsid(name().toUtf8().constData(), RsPgpId(hash().toStdString()));
|
||||
}
|
||||
|
||||
if(type() == TYPE_IDENTITY)
|
||||
return QObject::tr("Identity link (name=%1, ID=%2)").arg(_name).arg(_hash) ;
|
||||
|
||||
if(type() == TYPE_PUBLIC_MSG) {
|
||||
RsPeerDetails detail;
|
||||
@ -1011,6 +1070,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
case TYPE_POSTED:
|
||||
case TYPE_SEARCH:
|
||||
case TYPE_MESSAGE:
|
||||
case TYPE_IDENTITY:
|
||||
case TYPE_CERTIFICATE:
|
||||
case TYPE_PUBLIC_MSG:
|
||||
case TYPE_PRIVATE_CHAT:
|
||||
@ -1156,6 +1216,15 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
}
|
||||
break ;
|
||||
|
||||
case TYPE_IDENTITY:
|
||||
{
|
||||
if(rsIdentity->deserialiseIdentityFromMemory(link.radixGroupData().toStdString()))
|
||||
QMessageBox::information(NULL,QObject::tr("Identity added to People"),QObject::tr("The identity was added to people. You can now chat with it, send messages to it, etc.")) ;
|
||||
else
|
||||
QMessageBox::warning(NULL,QObject::tr("Identity cannot be added to People"),QObject::tr("The identity was not added to people. Some error occured. The link is probably corrupted.")) ;
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_FILE:
|
||||
case TYPE_EXTRAFILE:
|
||||
{
|
||||
|
@ -68,7 +68,8 @@ class RetroShareLink
|
||||
TYPE_EXTRAFILE = 0x08,
|
||||
TYPE_PRIVATE_CHAT = 0x09,
|
||||
TYPE_PUBLIC_MSG = 0x0a,
|
||||
TYPE_POSTED = 0x0b
|
||||
TYPE_POSTED = 0x0b,
|
||||
TYPE_IDENTITY = 0x0c
|
||||
};
|
||||
|
||||
public:
|
||||
@ -85,6 +86,7 @@ class RetroShareLink
|
||||
bool createSearch(const QString& keywords);
|
||||
bool createMessage(const RsPeerId &peerId, const QString& subject);
|
||||
bool createMessage(const RsGxsId &peerId, const QString& subject);
|
||||
bool createIdentity(const RsGxsId& gxs_id,const QString& name,const QString& radix_data) ;
|
||||
bool createCertificate(const RsPeerId &ssl_id) ;
|
||||
bool createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ;
|
||||
bool createUnknwonSslCertificate(const RsPeerId &sslId, const RsPgpId &gpgId = RsPgpId()) ;
|
||||
@ -101,12 +103,13 @@ class RetroShareLink
|
||||
const QString& SSLId() const { return _SSLid ; }
|
||||
const QString& GPGId() const { return _GPGid ; }
|
||||
const QString& localIPAndPort() const { return _loc_ip_port ; }
|
||||
const QString& externalIPAndPort() const { return _ext_ip_port ; }
|
||||
const QString& dyndns() const { return _dyndns_name ; }
|
||||
const QString& location() const { return _location ; }
|
||||
const QString& radix() const { return _radix ; }
|
||||
time_t timeStamp() const { return _time_stamp ; }
|
||||
QString title() const;
|
||||
const QString& externalIPAndPort() const { return _ext_ip_port ; }
|
||||
const QString& dyndns() const { return _dyndns_name ; }
|
||||
const QString& location() const { return _location ; }
|
||||
const QString& radix() const { return _radix ; }
|
||||
time_t timeStamp() const { return _time_stamp ; }
|
||||
QString title() const;
|
||||
QString radixGroupData() const { return _radix_group_data ;}
|
||||
|
||||
unsigned int subType() const { return _subType; }
|
||||
void setSubType(unsigned int subType) { _subType = subType; }
|
||||
@ -158,12 +161,13 @@ class RetroShareLink
|
||||
QString _GPGBase64String ; // GPG Cert
|
||||
QString _GPGBase64CheckSum ; // GPG Cert
|
||||
QString _location ; // location
|
||||
QString _ext_ip_port ;
|
||||
QString _loc_ip_port ;
|
||||
QString _dyndns_name ;
|
||||
QString _ext_ip_port ;
|
||||
QString _loc_ip_port ;
|
||||
QString _dyndns_name ;
|
||||
QString _radix ;
|
||||
QString _encrypted_chat_info ; // encrypted data string for the recipient of a chat invite
|
||||
time_t _time_stamp ; // time stamp at which the link will expire.
|
||||
QString _encrypted_chat_info ; // encrypted data string for the recipient of a chat invite
|
||||
time_t _time_stamp ; // time stamp at which the link will expire.
|
||||
QString _radix_group_data;
|
||||
|
||||
unsigned int _subType; // for general use as sub type for _type (RSLINK_SUBTYPE_...)
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user