ID cleaning in gxschannels

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7158 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-03-01 22:15:49 +00:00
parent cbb2636c90
commit badb48f20e
4 changed files with 39 additions and 34 deletions

View file

@ -40,7 +40,7 @@
#define CREATEMSG_CHANNELINFO 0x002
/** Constructor */
CreateGxsChannelMsg::CreateGxsChannelMsg(std::string cId)
CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId)
: QDialog (NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mChannelId(cId) ,mCheckAttachment(true), mAutoMediaThumbNail(false)
{
/* Invoke the Qt Designer generated object setup routine */
@ -122,9 +122,11 @@ void CreateGxsChannelMsg::pasteLink()
std::cerr << "Pasting " << (*it).toString().toStdString() << std::endl;
FileInfo info ;
if(rsFiles->alreadyHaveFile( (*it).hash().toStdString(),info ) )
addAttachment((*it).hash().toStdString(), (*it).name().toUtf8().constData(), (*it).size(), true, RsPeerId()) ;
FileInfo info ;
RsFileHash hash( (*it).hash().toStdString()) ;
if(rsFiles->alreadyHaveFile( hash,info ) )
addAttachment(hash, (*it).name().toUtf8().constData(), (*it).size(), true, RsPeerId()) ;
else
not_have.push_back( *it ) ;
}
@ -283,7 +285,7 @@ void CreateGxsChannelMsg::parseRsFileListAttachments(const std::string &attachLi
quint64 qsize = 0;
std::string fname;
std::string hash;
RsFileHash hash;
uint64_t size = 0;
RsPeerId source;
@ -297,7 +299,7 @@ void CreateGxsChannelMsg::parseRsFileListAttachments(const std::string &attachLi
fname = it2->toStdString();
break;
case 1:
hash = it2->toStdString();
hash = RsFileHash(it2->toStdString());
break;
case 2:
qsize = it2->toULongLong(&ok, 10);
@ -316,21 +318,21 @@ void CreateGxsChannelMsg::parseRsFileListAttachments(const std::string &attachLi
std::cerr << "\tsize: " << size << std::endl;
std::cerr << "\tsource: " << source << std::endl;
/* basic error checking */
if ((ok) && (hash.size() == 40))
/* basic error checking */
if (ok && !hash.isNull())
{
std::cerr << "Item Ok" << std::endl;
addAttachment(hash, fname, size, source.isNull(), source);
}
else
{
std::cerr << "Error Decode: Hash size: " << hash.size() << std::endl;
std::cerr << "Error Decode: Hash is not a hash: " << hash << std::endl;
}
}
}
void CreateGxsChannelMsg::addAttachment(const std::string &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId)
void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId)
{
/* add a SubFileItem to the attachment section */
std::cerr << "CreateGxsChannelMsg::addAttachment()";
@ -403,9 +405,12 @@ void CreateGxsChannelMsg::addAttachment(const std::string &path)
FileInfo fInfo;
std::string filename;
uint64_t size = 0;
std::string hash = "";
RsFileHash hash ;
rsGxsChannels->ExtraFileHash(path, filename);
#error: hash is used uninitialized below ?!?
// only path and filename are valid.
// destroyed when fileFrame (this subfileitem) is destroyed
//SubFileItem *file = new SubFileItem(hash, filename, path, size, flags, mChannelId);
@ -537,7 +542,7 @@ void CreateGxsChannelMsg::newChannelMsg()
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
std::list<std::string> groupIds;
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(mChannelId);
std::cerr << "CreateGxsChannelMsg::newChannelMsg() Req Group Summary(" << mChannelId << ")";

View file

@ -38,13 +38,13 @@ class CreateGxsChannelMsg : public QDialog, public TokenResponse, private Ui::Cr
public:
/** Default Constructor */
CreateGxsChannelMsg(std::string cId);
CreateGxsChannelMsg(const RsGxsGroupId& cId);
/** Default Destructor */
~CreateGxsChannelMsg();
void addAttachment(const std::string &path);
void addAttachment(const std::string &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId);
void addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId);
void newChannelMsg();
@ -77,7 +77,7 @@ private:
void sendMessage(const std::string &subject, const std::string &msg, const std::list<RsGxsFile> &files);
bool setThumbNail(const std::string& path, int frame);
std::string mChannelId;
RsGxsGroupId mChannelId;
RsGroupMetaData mChannelMeta;
bool mChannelMetaLoaded;

View file

@ -143,7 +143,7 @@ void GxsChannelDialog::updateDisplay(bool complete)
/* Update channel list */
insertChannels();
}
if (!mChannelId.empty() && std::find(grpIds.begin(), grpIds.end(), mChannelId) != grpIds.end()) {
if (!mChannelId.isNull() && std::find(grpIds.begin(), grpIds.end(), mChannelId) != grpIds.end()) {
requestGroupData(mChannelId);
}
@ -192,12 +192,12 @@ void GxsChannelDialog::processSettings(bool load)
void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ )
{
if (mChannelId.empty())
if (mChannelId.isNull())
{
return;
}
uint32_t subscribeFlags = ui.treeWidget->subscribeFlags(QString::fromStdString(mChannelId));
uint32_t subscribeFlags = ui.treeWidget->subscribeFlags(QString::fromStdString(mChannelId.toStdString()));
QMenu contextMnu(this);
@ -272,7 +272,7 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ )
contextMnu.addSeparator();
QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink()));
action->setEnabled(!mChannelId.empty());
action->setEnabled(!mChannelId.isNull());
contextMnu.exec(QCursor::pos());
@ -340,7 +340,7 @@ void GxsChannelDialog::channelListCustomPopupMenu( QPoint /*point*/ )
contextMnu.addSeparator();
QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink()));
action->setEnabled(!mChannelId.empty());
action->setEnabled(!mChannelId.isNull());
contextMnu.exec(QCursor::pos());
@ -389,7 +389,7 @@ void GxsChannelDialog::shareKey()
void GxsChannelDialog::copyChannelLink()
{
#if 0
if (mChannelId.empty()) {
if (mChannelId.isNull()) {
return;
}
@ -407,7 +407,7 @@ void GxsChannelDialog::copyChannelLink()
void GxsChannelDialog::createMsg()
{
if (mChannelId.empty()) {
if (mChannelId.isNull()) {
return;
}
@ -440,7 +440,7 @@ void GxsChannelDialog::selectChannel(const QString &id)
static void channelInfoToGroupItemInfo(const RsGroupMetaData &channelInfo, GroupItemInfo &groupItemInfo)
{
groupItemInfo.id = QString::fromStdString(channelInfo.mGroupId);
groupItemInfo.id = QString::fromStdString(channelInfo.mGroupId.toStdString());
groupItemInfo.name = QString::fromUtf8(channelInfo.mGroupName.c_str());
groupItemInfo.popularity = channelInfo.mPop;
groupItemInfo.lastpost = QDateTime::fromTime_t(channelInfo.mLastPost);
@ -774,7 +774,7 @@ void GxsChannelDialog::unsubscribeChannel()
std::cerr << std::endl;
#endif
if (mChannelId.empty())
if (mChannelId.isNull())
return;
uint32_t token = 0;
@ -789,7 +789,7 @@ void GxsChannelDialog::subscribeChannel()
std::cerr << std::endl;
#endif
if (mChannelId.empty())
if (mChannelId.isNull())
return;
uint32_t token = 0;
@ -800,7 +800,7 @@ void GxsChannelDialog::subscribeChannel()
void GxsChannelDialog::showChannelDetails()
{
#if 0
if (mChannelId.empty()) {
if (mChannelId.isNull()) {
return;
}
@ -818,7 +818,7 @@ void GxsChannelDialog::showChannelDetails()
void GxsChannelDialog::setAllAsReadClicked()
{
#if 0
if (mChannelId.empty()) {
if (mChannelId.isNull()) {
return;
}
@ -846,7 +846,7 @@ void GxsChannelDialog::setAllAsReadClicked()
void GxsChannelDialog::toggleAutoDownload()
{
if (mChannelId.empty())
if (mChannelId.isNull())
return;
bool autoDl = rsGxsChannels->getChannelAutoDownload(mChannelId);
@ -864,11 +864,11 @@ void GxsChannelDialog::toggleAutoDownload()
bool GxsChannelDialog::navigate(const std::string& channelId, const std::string& msgId)
{
#if 0
if (channelId.empty()) {
if (channelId.isNull()) {
return false;
}
if (treeWidget->activateId(QString::fromStdString(channelId), msgId.empty()) == NULL) {
if (treeWidget->activateId(QString::fromStdString(channelId), msgId.isNull()) == NULL) {
return false;
}
@ -877,7 +877,7 @@ bool GxsChannelDialog::navigate(const std::string& channelId, const std::string&
return false;
}
if (msgId.empty()) {
if (msgId.isNull()) {
return true;
}
@ -976,7 +976,7 @@ void GxsChannelDialog::requestGroupData(const RsGxsGroupId &grpId)
mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_GROUP_DATA);
if (grpId.empty()) {
if (grpId.isNull()) {
mStateHelper->setActive(TOKEN_TYPE_GROUP_DATA, false);
mStateHelper->setLoading(TOKEN_TYPE_GROUP_DATA, false);
mStateHelper->clear(TOKEN_TYPE_GROUP_DATA);
@ -1043,7 +1043,7 @@ void GxsChannelDialog::requestPosts(const RsGxsGroupId &grpId)
mChannelQueue->cancelActiveRequestTokens(TOKEN_TYPE_POSTS);
if (grpId.empty()) {
if (grpId.isNull()) {
mStateHelper->setActive(TOKEN_TYPE_POSTS, false);
mStateHelper->setLoading(TOKEN_TYPE_POSTS, false);
mStateHelper->clear(TOKEN_TYPE_POSTS);

View file

@ -118,7 +118,7 @@ private:
void acknowledgeGroupUpdate(const uint32_t &token);
void acknowledgeMessageUpdate(const uint32_t &token);
std::string mChannelId; /* current Channel */
RsGxsGroupId mChannelId; /* current Channel */
TokenQueue *mChannelQueue;
/* Layout Pointers */