added avatars to identities.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7875 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-01-25 22:09:12 +00:00
parent b321953789
commit 481ee246b5
10 changed files with 418 additions and 240 deletions

View File

@ -33,6 +33,8 @@
#include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h"
#include "retroshare/rsids.h"
#include "serialiser/rstlvimage.h"
#include "retroshare/rsgxscommon.h"
/* The Main Interface Class - for information about your Peers */
class RsIdentity;
@ -105,10 +107,13 @@ class RsGxsIdGroup
// Recognition Strings. MAX# defined above.
std::list<std::string> mRecognTags;
// Not Serialised - for GUI's benefit.
// Avatar
RsGxsImage mImage ;
// Not Serialised - for GUI's benefit.
bool mPgpKnown;
RsPgpId mPgpId;
GxsReputation mReputation;
GxsReputation mReputation;
};
@ -168,7 +173,10 @@ class RsIdentityDetails
std::list<RsRecognTag> mRecognTags;
// reputation details.
GxsReputation mReputation;
GxsReputation mReputation;
// avatar
RsGxsImage mAvatar ;
};
@ -185,7 +193,8 @@ class RsIdentityParameters
public:
RsIdentityParameters(): isPgpLinked(false) { return; }
bool isPgpLinked;
std::string nickname;
std::string nickname;
RsGxsImage mImage ;
};

View File

@ -131,17 +131,13 @@ RsItem* RsGxsIdSerialiser::deserialise(void* data, uint32_t* size)
void RsGxsIdGroupItem::clear()
{
group.mPgpIdHash.clear();
group.mPgpIdSign.clear();
group.mRecognTags.clear();
group.mPgpKnown = false;
group.mPgpId.clear();
mPgpIdHash.clear();
mPgpIdSign.clear();
mRecognTags.clear();
mImage.TlvClear();
}
std::ostream& RsGxsIdGroupItem::print(std::ostream& out, uint16_t indent)
{
printRsItemBase(out, "RsGxsIdGroupItem", indent);
@ -150,20 +146,20 @@ std::ostream& RsGxsIdGroupItem::print(std::ostream& out, uint16_t indent)
printIndent(out, int_Indent);
out << "MetaData: " << meta << std::endl;
printIndent(out, int_Indent);
out << "PgpIdHash: " << group.mPgpIdHash << std::endl;
out << "PgpIdHash: " << mPgpIdHash << std::endl;
printIndent(out, int_Indent);
std::string signhex;
// convert from binary to hex.
for(unsigned int i = 0; i < group.mPgpIdSign.length(); i++)
for(unsigned int i = 0; i < mPgpIdSign.length(); i++)
{
rs_sprintf_append(signhex, "%02x", (uint32_t) ((uint8_t) group.mPgpIdSign[i]));
rs_sprintf_append(signhex, "%02x", (uint32_t) ((uint8_t) mPgpIdSign[i]));
}
out << "PgpIdSign: " << signhex << std::endl;
printIndent(out, int_Indent);
out << "RecognTags:" << std::endl;
RsTlvStringSetRef set(TLV_TYPE_RECOGNSET, group.mRecognTags);
RsTlvStringSetRef set(TLV_TYPE_RECOGNSET, mRecognTags);
set.print(out, int_Indent + 2);
printRsItemEnd(out ,"RsGxsIdGroupItem", indent);
@ -173,17 +169,17 @@ std::ostream& RsGxsIdGroupItem::print(std::ostream& out, uint16_t indent)
uint32_t RsGxsIdSerialiser::sizeGxsIdGroupItem(RsGxsIdGroupItem *item)
{
uint32_t s = 8; // header
const RsGxsIdGroup& group = item->group;
uint32_t s = 8; // header
s += Sha1CheckSum::SIZE_IN_BYTES;
s += GetTlvStringSize(item->mPgpIdSign);
s += Sha1CheckSum::SIZE_IN_BYTES;
s += GetTlvStringSize(group.mPgpIdSign);
RsTlvStringSetRef set(TLV_TYPE_RECOGNSET, item->mRecognTags);
s += set.TlvSize();
RsTlvStringSetRef set(TLV_TYPE_RECOGNSET, item->group.mRecognTags);
s += set.TlvSize();
s += item->mImage.TlvSize() ;
return s;
return s;
}
bool RsGxsIdSerialiser::serialiseGxsIdGroupItem(RsGxsIdGroupItem *item, void *data, uint32_t *size)
@ -211,12 +207,14 @@ bool RsGxsIdSerialiser::serialiseGxsIdGroupItem(RsGxsIdGroupItem *item, void *da
offset += 8;
/* GxsIdGroupItem */
ok &= item->group.mPgpIdHash.serialise(data, tlvsize, offset);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_SIGN, item->group.mPgpIdSign);
ok &= item->mPgpIdHash.serialise(data, tlvsize, offset);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_SIGN, item->mPgpIdSign);
RsTlvStringSetRef set(TLV_TYPE_RECOGNSET, item->group.mRecognTags);
RsTlvStringSetRef set(TLV_TYPE_RECOGNSET, item->mRecognTags);
ok &= set.SetTlv(data, tlvsize, &offset);
ok &= item->mImage.SetTlv(data,tlvsize,&offset) ;
if(offset != tlvsize)
{
#ifdef GXSID_DEBUG
@ -234,7 +232,48 @@ bool RsGxsIdSerialiser::serialiseGxsIdGroupItem(RsGxsIdGroupItem *item, void *da
return ok;
}
bool RsGxsIdGroupItem::fromGxsIdGroup(RsGxsIdGroup &group, bool moveImage)
{
clear();
meta = group.mMeta;
mPgpIdHash = group.mPgpIdHash;
mPgpIdSign = group.mPgpIdSign;
mRecognTags = group.mRecognTags;
if (moveImage)
{
mImage.binData.bin_data = group.mImage.mData;
mImage.binData.bin_len = group.mImage.mSize;
group.mImage.shallowClear();
}
else
{
mImage.binData.setBinData(group.mImage.mData, group.mImage.mSize);
}
return true ;
}
bool RsGxsIdGroupItem::toGxsIdGroup(RsGxsIdGroup &group, bool moveImage)
{
group.mMeta = meta;
group.mPgpIdHash = mPgpIdHash;
group.mPgpIdSign = mPgpIdSign;
group.mRecognTags = mRecognTags;
if (moveImage)
{
group.mImage.take((uint8_t *) mImage.binData.bin_data, mImage.binData.bin_len);
// mImage doesn't have a ShallowClear at the moment!
mImage.binData.TlvShallowClear();
}
else
{
group.mImage.copy((uint8_t *) mImage.binData.bin_data, mImage.binData.bin_len);
}
return true ;
}
RsGxsIdGroupItem* RsGxsIdSerialiser::deserialiseGxsIdGroupItem(void *data, uint32_t *size)
{
/* get the type and size */
@ -271,14 +310,17 @@ RsGxsIdGroupItem* RsGxsIdSerialiser::deserialiseGxsIdGroupItem(void *data, uint3
/* skip the header */
offset += 8;
ok &= item->group.mPgpIdHash.deserialise(data, rssize, offset);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_SIGN, item->group.mPgpIdSign);
ok &= item->mPgpIdHash.deserialise(data, rssize, offset);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_SIGN, item->mPgpIdSign);
RsTlvStringSetRef set(TLV_TYPE_RECOGNSET, item->group.mRecognTags);
RsTlvStringSetRef set(TLV_TYPE_RECOGNSET, item->mRecognTags);
ok &= set.GetTlv(data, rssize, &offset);
if (offset != rssize)
// image is optional,so that we can continue reading old items.
if(offset < rssize)
ok &= item->mImage.GetTlv(data,rssize,&offset) ;
if (offset != rssize)
{
#ifdef GXSID_DEBUG
std::cerr << "RsGxsIdSerialiser::deserialiseGxsIdGroupItem() FAIL size mismatch" << std::endl;

View File

@ -34,7 +34,9 @@
#include "rsgxsitems.h"
#include "retroshare/rsidentity.h"
const uint8_t RS_PKT_SUBTYPE_GXSID_GROUP_ITEM = 0x02;
//const uint8_t RS_PKT_SUBTYPE_GXSID_GROUP_ITEM_deprecated = 0x02;
const uint8_t RS_PKT_SUBTYPE_GXSID_GROUP_ITEM = 0x02;
const uint8_t RS_PKT_SUBTYPE_GXSID_OPINION_ITEM = 0x03;
const uint8_t RS_PKT_SUBTYPE_GXSID_COMMENT_ITEM = 0x04;
@ -43,15 +45,26 @@ class RsGxsIdGroupItem : public RsGxsGrpItem
public:
RsGxsIdGroupItem(): RsGxsGrpItem(RS_SERVICE_GXS_TYPE_GXSID,
RS_PKT_SUBTYPE_GXSID_GROUP_ITEM) { return;}
virtual ~RsGxsIdGroupItem() { return;}
RsGxsIdGroupItem(): RsGxsGrpItem(RS_SERVICE_GXS_TYPE_GXSID,
RS_PKT_SUBTYPE_GXSID_GROUP_ITEM) { return;}
virtual ~RsGxsIdGroupItem() { return;}
void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
bool fromGxsIdGroup(RsGxsIdGroup &group, bool moveImage);
bool toGxsIdGroup(RsGxsIdGroup &group, bool moveImage);
RsGxsIdGroup group;
Sha1CheckSum mPgpIdHash;
// Need a signature as proof - otherwise anyone could add others Hashes.
// This is a string, as the length is variable.
std::string mPgpIdSign;
// Recognition Strings. MAX# defined above.
std::list<std::string> mRecognTags;
// Avatar
RsTlvImage mImage ;
};
#if 0
@ -59,7 +72,7 @@ class RsGxsIdOpinionItem : public RsGxsMsgItem
{
public:
RsGxsIdOpinionItem(): RsGxsMsgItem(RS_SERVICE_GXS_TYPE_GXSID,
RsGxsIdOpinionItem(): RsGxsMsgItem(RS_SERVICE_GXS_TYPE_GXSID,
RS_PKT_SUBTYPE_GXSID_OPINION_ITEM) {return; }
virtual ~RsGxsIdOpinionItem() { return;}
void clear();

View File

@ -324,7 +324,9 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters &params)
RsGxsIdGroup id;
id.mMeta.mGroupName = params.nickname;
id.mMeta.mGroupName = params.nickname;
id.mImage = params.mImage;
if (params.isPgpLinked)
{
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
@ -740,8 +742,8 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
item->print(std::cerr);
std::cerr << std::endl;
#endif // DEBUG_IDS
RsGxsIdGroup group = item->group;
group.mMeta = item->meta;
RsGxsIdGroup group ;
item->toGxsIdGroup(group,false) ;
// Decode information from serviceString.
SSGxsIdGroup ssdata;
@ -769,7 +771,7 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
}
groups.push_back(group);
delete(item);
delete(item);
}
else
{
@ -789,19 +791,21 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
bool p3IdService::createGroup(uint32_t& token, RsGxsIdGroup &group)
{
RsGxsIdGroupItem* item = new RsGxsIdGroupItem();
item->group = group;
item->meta = group.mMeta;
RsGenExchange::publishGroup(token, item);
return true;
RsGxsIdGroupItem* item = new RsGxsIdGroupItem();
item->meta = group.mMeta;
item->mImage.binData.setBinData(group.mImage.mData, group.mImage.mSize);
RsGenExchange::publishGroup(token, item);
return true;
}
bool p3IdService::updateGroup(uint32_t& token, RsGxsIdGroup &group)
{
RsGxsId id = RsGxsId(group.mMeta.mGroupId.toStdString());
RsGxsIdGroupItem* item = new RsGxsIdGroupItem();
item->group = group;
item->meta = group.mMeta;
RsGxsIdGroupItem* item = new RsGxsIdGroupItem();
item->fromGxsIdGroup(group,false) ;
#ifdef DEBUG_IDS
std::cerr << "p3IdService::updateGroup() Updating RsGxsId: " << id;
@ -850,9 +854,9 @@ bool p3IdService::updateGroup(uint32_t& token, RsGxsIdGroup &group)
bool p3IdService::deleteGroup(uint32_t& token, RsGxsIdGroup &group)
{
RsGxsId id = RsGxsId(group.mMeta.mGroupId.toStdString());
RsGxsIdGroupItem* item = new RsGxsIdGroupItem();
item->group = group;
item->meta = group.mMeta;
RsGxsIdGroupItem* item = new RsGxsIdGroupItem();
item->fromGxsIdGroup(group,false) ;
#ifdef DEBUG_IDS
std::cerr << "p3IdService::deleteGroup() Deleting RsGxsId: " << id;
@ -1285,7 +1289,9 @@ RsGxsIdCache::RsGxsIdCache(const RsGxsIdGroupItem *item, const RsTlvSecurityKey
mPublishTs = item->meta.mPublishTs;
// Save RecognTags.
mRecognTags = tagList;
mRecognTags = tagList;
details.mAvatar.copy((uint8_t *) item->mImage.binData.bin_data, item->mImage.binData.bin_len);
// Fill in Details.
details.mNickname = item->meta.mGroupName;
@ -1396,7 +1402,7 @@ bool p3IdService::recogn_extract_taginfo(const RsGxsIdGroupItem *item, std::list
std::list<std::string>::const_iterator rit;
int count = 0;
for(rit = item->group.mRecognTags.begin(); rit != item->group.mRecognTags.end(); ++rit)
for(rit = item->mRecognTags.begin(); rit != item->mRecognTags.end(); ++rit)
{
if (++count > RSRECOGN_MAX_TAGINFO)
{
@ -2179,7 +2185,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
if(pk.keyFlags == (RSTLV_KEY_DISTRIB_ADMIN | RSTLV_KEY_TYPE_FULL))
{
item->group.mMeta.mGroupId = RsGxsGroupId(pk.keyId);
item->meta.mGroupId = RsGxsGroupId(pk.keyId);
break;
}
}
@ -2195,36 +2201,36 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
/********************* TEMP HACK UNTIL GXS FILLS IN GROUP_ID *****************/
// SANITY CHECK.
if (item->group.mMeta.mAuthorId != item->meta.mAuthorId)
{
std::cerr << "p3IdService::service_CreateGroup() AuthorId mismatch(";
std::cerr << item->group.mMeta.mAuthorId;
std::cerr << " vs ";
std::cerr << item->meta.mAuthorId;
std::cerr << std::endl;
}
if (item->group.mMeta.mGroupId != item->meta.mGroupId)
{
std::cerr << "p3IdService::service_CreateGroup() GroupId mismatch(";
std::cerr << item->group.mMeta.mGroupId;
std::cerr << " vs ";
std::cerr << item->meta.mGroupId;
std::cerr << std::endl;
}
if (item->group.mMeta.mGroupFlags != item->meta.mGroupFlags)
{
std::cerr << "p3IdService::service_CreateGroup() GroupFlags mismatch(";
std::cerr << item->group.mMeta.mGroupFlags;
std::cerr << " vs ";
std::cerr << item->meta.mGroupFlags;
std::cerr << std::endl;
}
// if (item->mMeta.mAuthorId != item->meta.mAuthorId)
// {
// std::cerr << "p3IdService::service_CreateGroup() AuthorId mismatch(";
// std::cerr << item->mMeta.mAuthorId;
// std::cerr << " vs ";
// std::cerr << item->meta.mAuthorId;
// std::cerr << std::endl;
// }
//
// if (item->group.mMeta.mGroupId != item->meta.mGroupId)
// {
// std::cerr << "p3IdService::service_CreateGroup() GroupId mismatch(";
// std::cerr << item->mMeta.mGroupId;
// std::cerr << " vs ";
// std::cerr << item->meta.mGroupId;
// std::cerr << std::endl;
// }
//
//
// if (item->group.mMeta.mGroupFlags != item->meta.mGroupFlags)
// {
// std::cerr << "p3IdService::service_CreateGroup() GroupFlags mismatch(";
// std::cerr << item->mMeta.mGroupFlags;
// std::cerr << " vs ";
// std::cerr << item->meta.mGroupFlags;
// std::cerr << std::endl;
// }
#ifdef DEBUG_IDS
std::cerr << "p3IdService::service_CreateGroup() for : " << item->group.mMeta.mGroupId;
std::cerr << "p3IdService::service_CreateGroup() for : " << item->mMeta.mGroupId;
std::cerr << std::endl;
std::cerr << "p3IdService::service_CreateGroup() Alt GroupId : " << item->meta.mGroupId;
std::cerr << std::endl;
@ -2232,7 +2238,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
ServiceCreate_Return createStatus;
if (item->group.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
if (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
{
/* create the hash */
Sha1CheckSum hash;
@ -2265,9 +2271,9 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
std::cerr << std::endl;
#endif
RsGxsId gxsId(item->group.mMeta.mGroupId.toStdString());
RsGxsId gxsId(item->meta.mGroupId.toStdString());
calcPGPHash(gxsId, ownFinger, hash);
item->group.mPgpIdHash = hash;
item->mPgpIdHash = hash;
#ifdef DEBUG_IDS
@ -2306,13 +2312,13 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
std::string strout;
#endif
/* push binary into string -> really bad! */
item->group.mPgpIdSign = "";
item->mPgpIdSign = "";
for(unsigned int i = 0; i < sign_size; i++)
{
#ifdef DEBUG_IDS
rs_sprintf_append(strout, "%02x", (uint32_t) signarray[i]);
#endif
item->group.mPgpIdSign += signarray[i];
item->mPgpIdSign += signarray[i];
}
createStatus = SERVICE_CREATE_SUCCESS;
@ -2330,7 +2336,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
// Enforce no AuthorId.
item->meta.mAuthorId.clear() ;
item->group.mMeta.mAuthorId.clear() ;
//item->mMeta.mAuthorId.clear() ;
// copy meta data to be sure its all the same.
//item->group.mMeta = item->meta;

View File

@ -377,11 +377,15 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
item->setToolTip(RSID_COL_IDTYPE, tooltip) ;
}
QPixmap pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ;
#ifdef ID_DEBUG
std::cerr << "Setting item image : " << pixmap.width() << " x " << pixmap.height() << std::endl;
#endif
item->setIcon(RSID_COL_NICKNAME, QIcon(pixmap));
QPixmap pixmap ;
if(data.mImage.mSize == 0 || !pixmap.loadFromData(data.mImage.mData, data.mImage.mSize, "PNG"))
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ;
item->setIcon(RSID_COL_NICKNAME, QIcon(pixmap));
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
{
@ -545,11 +549,15 @@ void IdDialog::insertIdDetails(uint32_t token)
ui->headerFrame->setHeaderText(QString::fromUtf8(data.mMeta.mGroupName.c_str()));
QPixmap pix = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ;
QPixmap pixmap ;
if(data.mImage.mSize == 0 || !pixmap.loadFromData(data.mImage.mData, data.mImage.mSize, "PNG"))
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ;
#ifdef ID_DEBUG
std::cerr << "Setting header frame image : " << pix.width() << " x " << pix.height() << std::endl;
#endif
ui->headerFrame->setHeaderImage(pix);
ui->headerFrame->setHeaderImage(pixmap);
if (data.mPgpKnown)
{
@ -953,7 +961,10 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
RsIdentityDetails idd ;
rsIdentity->getIdDetails(*it,idd) ;
QPixmap pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;
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())) ;

View File

@ -21,9 +21,12 @@
*
*/
#include <QBuffer>
#include "gui/Identity/IdEditDialog.h"
#include "gui/common/UIStateHelper.h"
#include "util/TokenQueue.h"
#include "util/misc.h"
#include <retroshare/rsidentity.h>
#include <retroshare/rspeers.h>
@ -78,11 +81,22 @@ IdEditDialog::IdEditDialog(QWidget *parent)
connect(ui.toolButton_Tag3, SIGNAL(clicked(bool)), this, SLOT(rmTag3()));
connect(ui.toolButton_Tag4, SIGNAL(clicked(bool)), this, SLOT(rmTag4()));
connect(ui.toolButton_Tag5, SIGNAL(clicked(bool)), this, SLOT(rmTag5()));
connect(ui.avatarLabel, SIGNAL(clicked(bool)), this, SLOT(changeAvatar()));
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
ui.pushButton_Tag->setEnabled(false);
}
void IdEditDialog::changeAvatar()
{
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Avatar"), 128, 128);
if (img.isNull())
return;
ui.avatarLabel->setPixmap(img) ;
}
IdEditDialog::~IdEditDialog()
{
delete(mIdQueue);
@ -177,8 +191,15 @@ void IdEditDialog::loadExistingId(uint32_t token)
ui.lineEdit_KeyId->setText(tr("Error getting key!"));
return;
}
mEditGroup = datavector[0];
QPixmap pixmap;
if (datavector.size() != 1)
if(mEditGroup.mImage.mSize > 0 && pixmap.loadFromData(mEditGroup.mImage.mData, mEditGroup.mImage.mSize, "PNG"))
ui.avatarLabel->setPixmap(pixmap);
// else
// ui.avatarLabel->setPixmap(pixmap); // we need to use the default pixmap here, generated from the ID
if (datavector.size() != 1)
{
std::cerr << "IdDialog::insertIdDetails() Invalid datavector size";
std::cerr << std::endl;
@ -192,8 +213,6 @@ void IdEditDialog::loadExistingId(uint32_t token)
return;
}
mEditGroup = datavector[0];
bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
if (realid)
@ -446,7 +465,22 @@ void IdEditDialog::createId()
RsIdentityParameters params;
params.nickname = groupname;
params.isPgpLinked = (ui.radioButton_GpgId->isChecked());
params.isPgpLinked = (ui.radioButton_GpgId->isChecked());
const QPixmap *pixmap = ui.avatarLabel->pixmap();
if (!pixmap->isNull())
{
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
pixmap->save(&buffer, "PNG"); // writes image into ba in PNG format
params.mImage.copy((uint8_t *) ba.data(), ba.size());
}
else
params.mImage.clear();
uint32_t dummyToken = 0;
rsIdentity->createIdentity(dummyToken, params);

View File

@ -54,7 +54,8 @@ private slots:
void idTypeToggled(bool checked);
void submit();
void addRecognTag();
void changeAvatar() ;
void addRecognTag();
void checkNewTag();
void rmTag1();
void rmTag2();

View File

@ -6,15 +6,21 @@
<rect>
<x>0</x>
<y>0</y>
<width>468</width>
<height>480</height>
<width>515</width>
<height>591</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>64</horstretch>
<verstretch>64</verstretch>
</sizepolicy>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/identity/identities_32.png</normaloff>:/images/identity/identities_32.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
@ -22,14 +28,7 @@
<number>0</number>
</property>
<item>
<widget class="HeaderFrame" name="headerFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
<widget class="HeaderFrame" name="headerFrame" native="true"/>
</item>
<item>
<widget class="QFrame" name="frame">
@ -45,97 +44,188 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Type</string>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_GpgId">
<property name="text">
<string>PGP Associated ID</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/tags/pgp-known.png</normaloff>:/images/tags/pgp-known.png</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_Pseudo">
<property name="text">
<string>Pseudonym</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/tags/anon.png</normaloff>:/images/tags/anon.png</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>131</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="radioButton_GpgId">
<property name="text">
<string>PGP Associated ID</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/tags/pgp-known.png</normaloff>:/images/tags/pgp-known.png</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Nickname</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Nickname"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Key ID</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_KeyId">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>PGP Hash</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_GpgHash">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>PGP Id</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_GpgId">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>PGP Name</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_GpgName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="avatarLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="text">
<string extracomment="Click here to change your avatar">TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<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>
</item>
</layout>
</item>
<item row="0" column="3">
<widget class="QRadioButton" name="radioButton_Pseudo">
<property name="text">
<string>Pseudonym</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/tags/anon.png</normaloff>:/images/tags/anon.png</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>131</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Nickname</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Key ID</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>PGP Hash</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>PGP Id</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>PGP Name</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -148,37 +238,6 @@
</property>
</spacer>
</item>
<item row="1" column="1" colspan="4">
<widget class="QLineEdit" name="lineEdit_Nickname"/>
</item>
<item row="2" column="1" colspan="4">
<widget class="QLineEdit" name="lineEdit_KeyId">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1" colspan="4">
<widget class="QLineEdit" name="lineEdit_GpgHash">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1" colspan="4">
<widget class="QLineEdit" name="lineEdit_GpgId">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1" colspan="4">
<widget class="QLineEdit" name="lineEdit_GpgName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -337,9 +396,8 @@
<customwidgets>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<extends>QWidget</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>

View File

@ -469,8 +469,12 @@ QString GxsIdDetails::getComment(const RsIdentityDetails &details)
void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &icons)
{
QPixmap pix ;
pix.convertFromImage(makeDefaultIcon(details.mId));
QPixmap pix ;
if(details.mAvatar.mSize == 0 || !pix.loadFromData(details.mAvatar.mData, details.mAvatar.mSize, "PNG"))
pix.convertFromImage(makeDefaultIcon(details.mId));
QIcon idIcon(pix);
//CreateIdIcon(id, idIcon);
icons.push_back(idIcon);

View File

@ -293,7 +293,7 @@ QPixmap misc::getOpenThumbnailedPicture(QWidget *parent, const QString &caption,
if (!getOpenFileName(parent, RshareSettings::LASTDIR_IMAGES, caption, tr("Pictures (*.png *.xpm *.jpg *.tiff *.gif)"), fileName))
return QPixmap();
return QPixmap(fileName).scaledToHeight(height).copy( 0, 0, width, height);
return QPixmap(fileName).scaledToHeight(height, Qt::SmoothTransformation).copy( 0, 0, width, height);
//return QPixmap(fileName).scaledToHeight(width, height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
}