From c90d0d6abd04f10a80d4d4a83820ee91d94f8726 Mon Sep 17 00:00:00 2001 From: drbob Date: Mon, 19 Nov 2012 22:14:45 +0000 Subject: [PATCH] Added Identity stuff into the GUI. - Generic Classes: - GxsIdChooser: gets a list of current OwnIds for user to select AuthorId. - GxsIdLabel: retrieves and displays Author Information. - GxsIdTreeWidgetItem: retrieves and displays Author Information, in specified column. - Added GxsIdChooser into GxsGroupDialog & CreateGxsForumMsg. - Added GxsIdTreeWidgetItem into Forum Thread listings. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5849 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/RetroShare.pro | 7 + retroshare-gui/src/gui/GxsForumsDialog.cpp | 31 ++-- retroshare-gui/src/gui/GxsForumsDialog.h | 8 +- .../src/gui/gxs/GxsForumGroupDialog.cpp | 1 - retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp | 2 + retroshare-gui/src/gui/gxs/GxsGroupDialog.ui | 8 + retroshare-gui/src/gui/gxs/GxsIdChooser.cpp | 143 ++++++++++++++++++ retroshare-gui/src/gui/gxs/GxsIdChooser.h | 50 ++++++ retroshare-gui/src/gui/gxs/GxsIdLabel.cpp | 124 +++++++++++++++ retroshare-gui/src/gui/gxs/GxsIdLabel.h | 51 +++++++ .../src/gui/gxs/GxsIdTreeWidgetItem.cpp | 141 +++++++++++++++++ .../src/gui/gxs/GxsIdTreeWidgetItem.h | 53 +++++++ .../src/gui/gxsforums/CreateGxsForumMsg.cpp | 28 +++- .../src/gui/gxsforums/CreateGxsForumMsg.ui | 14 +- 14 files changed, 639 insertions(+), 22 deletions(-) create mode 100644 retroshare-gui/src/gui/gxs/GxsIdChooser.cpp create mode 100644 retroshare-gui/src/gui/gxs/GxsIdChooser.h create mode 100644 retroshare-gui/src/gui/gxs/GxsIdLabel.cpp create mode 100644 retroshare-gui/src/gui/gxs/GxsIdLabel.h create mode 100644 retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp create mode 100644 retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 050914d3b..e7ebd96db 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -1017,10 +1017,14 @@ gxsgui { gui/gxs/GxsCommentTreeWidget.h \ gui/gxs/WikiGroupDialog.h \ gui/gxs/GxsForumGroupDialog.h \ + gui/gxs/GxsIdChooser.h \ + gui/gxs/GxsIdLabel.h \ + gui/gxs/GxsIdTreeWidgetItem.h \ # gui/gxs/GxsMsgDialog.h \ FORMS += gui/gxs/GxsGroupDialog.ui \ + # gui/gxs/GxsMsgDialog.ui \ # gui/gxs/GxsCommentTreeWidget.ui \ @@ -1028,6 +1032,9 @@ gxsgui { gui/gxs/GxsCommentTreeWidget.cpp \ gui/gxs/WikiGroupDialog.cpp \ gui/gxs/GxsForumGroupDialog.cpp \ + gui/gxs/GxsIdChooser.cpp \ + gui/gxs/GxsIdLabel.cpp \ + gui/gxs/GxsIdTreeWidgetItem.cpp \ # gui/gxs/GxsMsgDialog.cpp \ diff --git a/retroshare-gui/src/gui/GxsForumsDialog.cpp b/retroshare-gui/src/gui/GxsForumsDialog.cpp index 8092cf79a..a0abfb71b 100644 --- a/retroshare-gui/src/gui/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/GxsForumsDialog.cpp @@ -241,10 +241,6 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent) ui.threadTreeWidget->installEventFilter(this); - - - rsGxsForums->generateDummyData(); - /* Hide platform specific features */ #ifdef Q_WS_WIN @@ -2094,8 +2090,8 @@ void GxsForumsDialog::loadGroupThreadData_InsertThreads(const uint32_t &token) } } -bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std::string authorName, - bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item) +bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, + bool useChildTS, uint32_t filterColumn, GxsIdTreeWidgetItem *item) { QString text; @@ -2120,6 +2116,8 @@ bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std item->setText(COLUMN_THREAD_TITLE, GxsForumsDialog::titleFromInfo(msgInfo.mMeta)); + item->setId(msgInfo.mMeta.mAuthorId, COLUMN_THREAD_AUTHOR); +#if 0 text = QString::fromUtf8(authorName.c_str()); if (text.isEmpty()) @@ -2130,6 +2128,7 @@ bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std { item->setText(COLUMN_THREAD_AUTHOR, text); } +#endif #ifdef TOGXS if (msgInfo.mMeta.mMsgFlags & RS_DISTRIB_AUTHEN_REQ) @@ -2173,11 +2172,13 @@ bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std void GxsForumsDialog::loadForumBaseThread(const RsGxsForumMsg &msg) { - std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); + //std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); - QTreeWidgetItem *item = new QTreeWidgetItem(); // no Parent. + //QTreeWidgetItem *item = new QTreeWidgetItem(); // no Parent. + GxsIdTreeWidgetItem *item = new GxsIdTreeWidgetItem(); // no Parent. - convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, item); + //convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, item); + convertMsgToThreadWidget(msg, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, item); /* request Children Data */ uint32_t token; @@ -2262,21 +2263,23 @@ void GxsForumsDialog::loadChildData_InsertThreads(const uint32_t &token) void GxsForumsDialog::loadForumChildMsg(const RsGxsForumMsg &msg, QTreeWidgetItem *parent) { - std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); + //std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); - QTreeWidgetItem *child = NULL; + //QTreeWidgetItem *child = NULL; + GxsIdTreeWidgetItem *child = NULL; if (mThreadLoad.FlatView) { - child = new QTreeWidgetItem(); // no Parent. + child = new GxsIdTreeWidgetItem(); // no Parent. } else { - child = new QTreeWidgetItem(parent); + child = new GxsIdTreeWidgetItem(parent); } - convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, child); + convertMsgToThreadWidget(msg, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, child); + //convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, child); /* request Children Data */ uint32_t token; diff --git a/retroshare-gui/src/gui/GxsForumsDialog.h b/retroshare-gui/src/gui/GxsForumsDialog.h index 37d803830..f80769575 100644 --- a/retroshare-gui/src/gui/GxsForumsDialog.h +++ b/retroshare-gui/src/gui/GxsForumsDialog.h @@ -34,6 +34,8 @@ #include +#include "gui/gxs/GxsIdTreeWidgetItem.h" + class ForumInfo; @@ -202,8 +204,10 @@ private: void requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId); void loadMsgData_ReplyMessage(const uint32_t &token); - bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std::string authorName, - bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item); + bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, + bool useChildTS, uint32_t filterColumn, GxsIdTreeWidgetItem *item); + //bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std::string authorName, + // bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item); TokenQueue *mForumQueue; diff --git a/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.cpp index 66381d075..7f8773671 100644 --- a/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.cpp @@ -58,7 +58,6 @@ GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent :GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent, "Create New Forum") { - } GxsForumGroupDialog::GxsForumGroupDialog(const RsGxsForumGroup &group, QWidget *parent) diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp index 97e2978b0..402fd3cde 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp @@ -84,11 +84,13 @@ GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenQueue, uint32_t enableFlags, uin /* Setup Reasonable Defaults */ + ui.idChooser->loadIds(0,""); } GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, uint32_t mode, QWidget *parent) : QDialog(parent), mMode(mode), mGrpMeta(grpMeta) { + ui.idChooser->loadIds(0,""); } void GxsGroupDialog::setMode(uint32_t mode) diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui index 777f80b11..c0a9160c0 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui @@ -186,6 +186,9 @@ border-radius: 10px; + + + @@ -554,6 +557,11 @@ p, li { white-space: pre-wrap; }
gui/common/FriendSelectionWidget.h
1 + + GxsIdChooser + QComboBox +
gui/gxs/GxsIdChooser.h
+
diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp new file mode 100644 index 000000000..0b1fadb48 --- /dev/null +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -0,0 +1,143 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include "GxsIdChooser.h" + +#include + +#include + +#include + +/** Constructor */ +GxsIdChooser::GxsIdChooser(QWidget *parent) +: QComboBox(parent), mFlags(IDCHOOSER_ANON_DEFAULT), mDefaultId("") +{ + return; +} + +void GxsIdChooser::loadIds(uint32_t chooserFlags, RsGxsId defId) +{ + mFlags = chooserFlags; + mDefaultId = defId; + loadPrivateIds(); +} + + +bool MakeIdDesc(const RsGxsId &id, QString &desc) +{ + RsIdentityDetails details; + + if (!rsIdentity->getIdDetails(id, details)) + { + return false; + } + + desc = QString::fromUtf8(details.mNickname.c_str()); + if (details.mPgpLinked) + { + desc += " (PGP) ["; + } + else + { + desc += " (Anon) ["; + } + desc += QString::fromStdString(id.substr(0,5)); + desc += "...]"; + + return true; +} + + +void GxsIdChooser::loadPrivateIds() +{ + std::list ids; + rsIdentity->getOwnIds(ids); + + + if (ids.empty()) + { + std::cerr << "GxsIdChooser::loadPrivateIds() ERROR no ids"; + std::cerr << std::endl; + return; + } + + //rsIdentity->getDefaultId(defId); + // Prefer to use an application specific default??? + int def = -1; + + if (!(mFlags & IDCHOOSER_ID_REQUIRED)) + { + /* add No Signature option */ + QString str = "No Signature"; + QString id = ""; + + addItem(str, id); + if (mFlags & IDCHOOSER_ANON_DEFAULT) + { + def = 0; + } + } + + int i = 1; + std::list::iterator it; + for(it = ids.begin(); it != ids.end(); it++, i++) + { + /* add to Chooser */ + QString str; + if (!MakeIdDesc(*it, str)) + { + std::cerr << "GxsIdChooser::loadPrivateIds() ERROR Desc for Id: " << *it; + std::cerr << std::endl; + continue; + } + QString id = QString::fromStdString(*it); + + addItem(str, id); + + if (mDefaultId == *it) + { + def = i; + } + } + + if (def >= 0) + { + setCurrentIndex(def); + //ui.comboBox->setCurrentIndex(def); + } +} + +bool GxsIdChooser::getChosenId(RsGxsId &id) +{ + if (count() < 1) + { + return false; + } + + int idx = currentIndex(); + + QVariant var = itemData(idx); + id = var.toString().toStdString(); + + return true; +} + diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.h b/retroshare-gui/src/gui/gxs/GxsIdChooser.h new file mode 100644 index 000000000..39606442a --- /dev/null +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.h @@ -0,0 +1,50 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + + +#ifndef _GXS_ID_CHOOSER_H +#define _GXS_ID_CHOOSER_H + +#include +#include + +#define IDCHOOSER_ID_REQUIRED 0x0001 +#define IDCHOOSER_ANON_DEFAULT 0x0002 + +class GxsIdChooser : public QComboBox +{ + Q_OBJECT + +public: + GxsIdChooser(QWidget *parent = NULL); + + void loadIds(uint32_t chooserFlags, RsGxsId defId); + bool getChosenId(RsGxsId &id); + +private: + void loadPrivateIds(); + + uint32_t mFlags; + RsGxsId mDefaultId; +}; + +#endif + diff --git a/retroshare-gui/src/gui/gxs/GxsIdLabel.cpp b/retroshare-gui/src/gui/gxs/GxsIdLabel.cpp new file mode 100644 index 000000000..26189b803 --- /dev/null +++ b/retroshare-gui/src/gui/gxs/GxsIdLabel.cpp @@ -0,0 +1,124 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include "GxsIdLabel.h" + +#include + +#include + +#include + +/** Constructor */ +GxsIdLabel::GxsIdLabel(QWidget *parent) +:QLabel(parent), mTimer(NULL), mCount(0) +{ + mTimer = new QTimer(this); + mTimer->setSingleShot(true); + connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId())); + + return; +} + +void GxsIdLabel::setId(const RsGxsId &id) +{ + mId = id; + if (mId == "") + { + setText("No Signature"); + } + else + { + loadId(); + } +} + +bool GxsIdLabel::getId(RsGxsId &id) +{ + id = mId; + return true; +} + +static bool MakeIdDesc(const RsGxsId &id, QString &str) +{ + RsIdentityDetails details; + + if (!rsIdentity->getIdDetails(id, details)) + { + str = "Loading... " + QString::fromStdString(id.substr(0,5)); + return false; + } + + str = QString::fromUtf8(details.mNickname.c_str()); + + bool addCode = true; + if (details.mPgpLinked) + { + str += " (PGP) ["; + if (details.mPgpKnown) + { + /* look up real name */ + std::string authorName = rsPeers->getPeerName(details.mPgpId); + str += QString::fromUtf8(authorName.c_str()); + str += "]"; + + addCode = false; + } + } + else + { + str += " (Anon) ["; + } + + if (addCode) + { + str += QString::fromStdString(id.substr(0,5)); + str += "...]"; + } + + return true; +} + +#define MAX_ATTEMPTS 3 + +void GxsIdLabel::loadId() +{ + mCount++; + + /* try and get details - if not there ... set callback */ + QString desc; + bool loaded = MakeIdDesc(mId, desc); + + setText(desc); + + if (loaded) + { + return; + } + + if (mCount < MAX_ATTEMPTS) + { + /* timer event to try again */ + mTimer->setInterval(mCount * 1000); + mTimer->start(); + } +} + diff --git a/retroshare-gui/src/gui/gxs/GxsIdLabel.h b/retroshare-gui/src/gui/gxs/GxsIdLabel.h new file mode 100644 index 000000000..e0e7c4992 --- /dev/null +++ b/retroshare-gui/src/gui/gxs/GxsIdLabel.h @@ -0,0 +1,51 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + + +#ifndef _GXS_ID_LABEL_H +#define _GXS_ID_LABEL_H + +#include +#include +#include + +class GxsIdLabel : public QLabel +{ + Q_OBJECT + +public: + GxsIdLabel(QWidget *parent = NULL); + + void setId(const RsGxsId &id); + bool getId(RsGxsId &id); + +private slots: + void loadId(); + +private: + + QTimer *mTimer; + RsGxsId mId; + int mCount; +}; + +#endif + diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp new file mode 100644 index 000000000..bee6c95cd --- /dev/null +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -0,0 +1,141 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include "GxsIdTreeWidgetItem.h" + +#include + +#include + +#include + +/** Constructor */ +GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidget *parent) +:QTreeWidgetItem(parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0) +{ + mTimer = new QTimer(this); + mTimer->setSingleShot(true); + connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId())); + + return; +} + +GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidgetItem *parent) +:QTreeWidgetItem(parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0) +{ + mTimer = new QTimer(this); + mTimer->setSingleShot(true); + connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId())); + + return; +} + +void GxsIdTreeWidgetItem::setId(const RsGxsId &id, int column) +{ + std::cerr << " GxsIdTreeWidgetItem::setId(" << id << "," << column << ")"; + std::cerr << std::endl; + + mId = id; + mColumn = column; + if (mId == "") + { + setText(mColumn, "No Signature"); + } + else + { + loadId(); + } +} + +bool GxsIdTreeWidgetItem::getId(RsGxsId &id) +{ + id = mId; + return true; +} + +static bool MakeIdDesc(const RsGxsId &id, QString &str) +{ + RsIdentityDetails details; + + if (!rsIdentity->getIdDetails(id, details)) + { + str = "Loading... " + QString::fromStdString(id.substr(0,5)); + return false; + } + + str = QString::fromUtf8(details.mNickname.c_str()); + + bool addCode = true; + if (details.mPgpLinked) + { + str += " (PGP) ["; + if (details.mPgpKnown) + { + /* look up real name */ + std::string authorName = rsPeers->getPeerName(details.mPgpId); + str += QString::fromUtf8(authorName.c_str()); + str += "]"; + + addCode = false; + } + } + else + { + str += " (Anon) ["; + } + + if (addCode) + { + str += QString::fromStdString(id.substr(0,5)); + str += "...]"; + } + + return true; +} + +#define MAX_ATTEMPTS 5 + +void GxsIdTreeWidgetItem::loadId() +{ + std::cerr << " GxsIdTreeWidgetItem::loadId() Id: " << mId << ", mCount: " << mCount; + std::cerr << std::endl; + + mCount++; + + /* try and get details - if not there ... set callback */ + QString desc; + bool loaded = MakeIdDesc(mId, desc); + + setText(mColumn, desc); + + if (loaded) + { + return; + } + + if (mCount < MAX_ATTEMPTS) + { + /* timer event to try again */ + mTimer->setInterval(mCount * 1000); + mTimer->start(); + } +} + diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h new file mode 100644 index 000000000..0db4b346e --- /dev/null +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h @@ -0,0 +1,53 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2012 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + + +#ifndef _GXS_ID_TREEWIDGETITEM_H +#define _GXS_ID_TREEWIDGETITEM_H + +#include +#include +#include + +class GxsIdTreeWidgetItem : public QObject, public QTreeWidgetItem +{ + Q_OBJECT + +public: + GxsIdTreeWidgetItem(QTreeWidget *parent = NULL); + GxsIdTreeWidgetItem(QTreeWidgetItem *parent); + + void setId(const RsGxsId &id, int column); + bool getId(RsGxsId &id); + +private slots: + void loadId(); + +private: + + QTimer *mTimer; + RsGxsId mId; + int mCount; + int mColumn; +}; + +#endif + diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index 82fe2ce4e..eb8df4a9c 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -104,6 +104,9 @@ void CreateGxsForumMsg::newMsg() mParentMsgLoaded = false; mForumMetaLoaded = false; + /* fill in the available OwnIds for signing */ + ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, ""); + /* request Data */ { RsTokReqOptions opts; @@ -259,8 +262,29 @@ void CreateGxsForumMsg::createMsg() #endif if ((msg.mMsg == "") && (msg.mMeta.mMsgName == "")) - return; /* do nothing */ - + return; /* do nothing */ + + if (ui.signBox->isChecked()) + { + RsGxsId authorId; + if (ui.idChooser->getChosenId(authorId)) + { + msg.mMeta.mAuthorId = authorId; + std::cerr << "CreateGxsForumMsg::createMsg() AuthorId: " << authorId; + std::cerr << std::endl; + } + else + { + std::cerr << "CreateGxsForumMsg::createMsg() ERROR GETTING AuthorId!"; + std::cerr << std::endl; + } + } + else + { + std::cerr << "CreateGxsForumMsg::createMsg() No Signature (for now :)"; + std::cerr << std::endl; + } + uint32_t token; rsGxsForums->createMsg(token, msg); close(); diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui index d71364f87..40d8dcb15 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui @@ -10,7 +10,7 @@ 0 0 482 - 448 + 497
@@ -180,6 +180,9 @@ border: 1px solid #CCCCCC;}
+ + + @@ -246,8 +249,8 @@ border: 1px solid #CCCCCC;} <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html> +</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"></p></body></html> @@ -319,6 +322,11 @@ p, li { white-space: pre-wrap; } + + GxsIdChooser + QComboBox +
gui/gxs/GxsIdChooser.h
+
HashBox QScrollArea