Added additional NewFeed Type SecurityItem

* added AddNewItemIfUnique() to NewsFeed



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4429 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2011-07-11 15:53:41 +00:00
parent 96b4651b7c
commit 70d8fd14d3
8 changed files with 1178 additions and 87 deletions

View File

@ -346,6 +346,7 @@ HEADERS += rshare.h \
gui/feeds/SubFileItem.h \
gui/feeds/SubDestItem.h \
gui/feeds/AttachFileItem.h \
gui/feeds/SecurityItem.h \
gui/connect/ConnectFriendWizard.h \
gui/groups/CreateGroup.h \
gui/dht/DhtWindow.h
@ -427,6 +428,7 @@ FORMS += gui/StartDialog.ui \
gui/feeds/SubFileItem.ui \
gui/feeds/SubDestItem.ui \
gui/feeds/AttachFileItem.ui \
gui/feeds/SecurityItem.ui \
gui/im_history/ImHistoryBrowser.ui \
gui/groups/CreateGroup.ui \
gui/common/GroupTreeWidget.ui \
@ -585,6 +587,7 @@ SOURCES += main.cpp \
gui/feeds/SubFileItem.cpp \
gui/feeds/SubDestItem.cpp \
gui/feeds/AttachFileItem.cpp \
gui/feeds/SecurityItem.cpp \
gui/connect/ConnectFriendWizard.cpp \
gui/groups/CreateGroup.cpp \
gui/dht/DhtWindow.cpp

View File

@ -41,6 +41,8 @@
#include "feeds/PeerItem.h"
#include "feeds/ChatMsgItem.h"
#include "feeds/SecurityItem.h"
#include "settings/rsharesettings.h"
#include "chat/PopupChatDialog.h"
@ -53,6 +55,7 @@ const uint32_t NEWSFEED_BLOGNEWLIST = 0x0006;
const uint32_t NEWSFEED_BLOGMSGLIST = 0x0007;
const uint32_t NEWSFEED_MESSAGELIST = 0x0008;
const uint32_t NEWSFEED_CHATMSGLIST = 0x0009;
const uint32_t NEWSFEED_SECLIST = 0x000a;
/*****
* #define NEWS_DEBUG 1
@ -83,6 +86,9 @@ void NewsFeed::updateFeed()
uint flags = Settings->getNewsFeedFlags();
/* HACK until SECURITY is in feeds */
flags |= RS_FEED_TYPE_SECURITY;
/* check for new messages */
RsFeedItem fi;
if (rsNotify->GetFeedItem(fi))
@ -101,22 +107,26 @@ void NewsFeed::updateFeed()
if (flags & RS_FEED_TYPE_PEER)
addFeedItemPeerNew(fi);
break;
case RS_FEED_ITEM_PEER_HELLO:
if (flags & RS_FEED_TYPE_PEER)
addFeedItemPeerHello(fi);
break;
case RS_FEED_ITEM_PEER_AUTH_DENIED:
if (flags & RS_FEED_TYPE_PEER)
addFeedItemPeerAuthDenied(fi);
case RS_FEED_ITEM_SEC_CONNECT_ATTEMPT:
if (flags & RS_FEED_TYPE_SECURITY)
addFeedItemSecurityConnectAttempt(fi);
break;
case RS_FEED_ITEM_PEER_UNKNOWN_IN:
if (flags & RS_FEED_TYPE_PEER)
addFeedItemPeerUnknownIn(fi);
case RS_FEED_ITEM_SEC_AUTH_DENIED:
if (flags & RS_FEED_TYPE_SECURITY)
addFeedItemSecurityAuthDenied(fi);
break;
case RS_FEED_ITEM_PEER_UNKNOWN_OUT:
if (flags & RS_FEED_TYPE_PEER)
addFeedItemPeerUnknownOut(fi);
case RS_FEED_ITEM_SEC_UNKNOWN_IN:
if (flags & RS_FEED_TYPE_SECURITY)
addFeedItemSecurityUnknownIn(fi);
break;
case RS_FEED_ITEM_SEC_UNKNOWN_OUT:
if (flags & RS_FEED_TYPE_SECURITY)
addFeedItemSecurityUnknownOut(fi);
break;
case RS_FEED_ITEM_CHAN_NEW:
@ -187,6 +197,30 @@ void NewsFeed::addFeedItem(QWidget *item)
}
}
void NewsFeed::addFeedItemIfUnique(QWidget *item, int itemType, std::string sslId, bool replace)
{
QObjectList::iterator it;
for (it = widgetList.begin(); it != widgetList.end(); it++)
{
SecurityItem *secitem = dynamic_cast<SecurityItem*>(*it);
if ((secitem) && (secitem->isSame(sslId, itemType)))
{
if (!replace)
{
delete item;
return;
}
else
{
secitem->close();
break;
}
}
}
addFeedItem(item);
}
void NewsFeed::addFeedItemPeerConnect(RsFeedItem &fi)
{
/* make new widget */
@ -257,58 +291,72 @@ void NewsFeed::addFeedItemPeerNew(RsFeedItem &fi)
void NewsFeed::addFeedItemPeerAuthDenied(RsFeedItem &fi)
void NewsFeed::addFeedItemSecurityConnectAttempt(RsFeedItem &fi)
{
/* make new widget */
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, fi.mId1, PEER_TYPE_AUTH_DENIED, false);
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, SEC_TYPE_CONNECT_ATTEMPT, false);
/* store */
/* add to layout */
addFeedItem(pi);
addFeedItemIfUnique(pi, SEC_TYPE_CONNECT_ATTEMPT, fi.mId2, false);
#ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemPeerAuthDenied()";
std::cerr << "NewsFeed::addFeedItemSecurityConnectAttempt()";
std::cerr << std::endl;
#endif
}
void NewsFeed::addFeedItemPeerUnknownIn(RsFeedItem &fi)
void NewsFeed::addFeedItemSecurityAuthDenied(RsFeedItem &fi)
{
/* make new widget */
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, fi.mId1, PEER_TYPE_UNKNOWN_IN, false);
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, SEC_TYPE_AUTH_DENIED, false);
/* store */
/* add to layout */
addFeedItem(pi);
addFeedItemIfUnique(pi, SEC_TYPE_AUTH_DENIED, fi.mId2, false);
#ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemPeerUnknownIn()";
std::cerr << "NewsFeed::addFeedItemSecurityAuthDenied()";
std::cerr << std::endl;
#endif
}
void NewsFeed::addFeedItemPeerUnknownOut(RsFeedItem &fi)
void NewsFeed::addFeedItemSecurityUnknownIn(RsFeedItem &fi)
{
/* make new widget */
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, fi.mId1, PEER_TYPE_UNKNOWN_OUT, false);
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, SEC_TYPE_UNKNOWN_IN, false);
/* store */
/* add to layout */
addFeedItem(pi);
addFeedItemIfUnique(pi, SEC_TYPE_UNKNOWN_IN, fi.mId2, false);
#ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemPeerUnknownOut()";
std::cerr << "NewsFeed::addFeedItemSecurityUnknownIn()";
std::cerr << std::endl;
#endif
}
void NewsFeed::addFeedItemSecurityUnknownOut(RsFeedItem &fi)
{
/* make new widget */
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, SEC_TYPE_UNKNOWN_OUT, false);
/* store */
/* add to layout */
addFeedItemIfUnique(pi, SEC_TYPE_UNKNOWN_OUT, fi.mId2, false);
#ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemSecurityUnknownOut()";
std::cerr << std::endl;
#endif
}
void NewsFeed::addFeedItemChanNew(RsFeedItem &fi)
{

View File

@ -58,14 +58,17 @@ private slots:
private:
void addFeedItem(QWidget *item);
void addFeedItemIfUnique(QWidget *item, int itemType, std::string sslId, bool replace);
void addFeedItemPeerConnect(RsFeedItem &fi);
void addFeedItemPeerDisconnect(RsFeedItem &fi);
void addFeedItemPeerNew(RsFeedItem &fi);
void addFeedItemPeerHello(RsFeedItem &fi);
void addFeedItemPeerAuthDenied(RsFeedItem &fi);
void addFeedItemPeerUnknownIn(RsFeedItem &fi);
void addFeedItemPeerUnknownOut(RsFeedItem &fi);
void addFeedItemSecurityConnectAttempt(RsFeedItem &fi);
void addFeedItemSecurityAuthDenied(RsFeedItem &fi);
void addFeedItemSecurityUnknownIn(RsFeedItem &fi);
void addFeedItemSecurityUnknownOut(RsFeedItem &fi);
void addFeedItemChanNew(RsFeedItem &fi);
void addFeedItemChanUpdate(RsFeedItem &fi);

View File

@ -102,20 +102,11 @@ void PeerItem::updateItemStatic()
case PEER_TYPE_CONNECT:
title = tr("Friend Connected");
break;
case PEER_TYPE_NEW_FOF:
title = tr("Friend of Friend");
break;
case PEER_TYPE_HELLO:
title = tr("Connect Attempt");
break;
case PEER_TYPE_AUTH_DENIED:
title = tr("Not Yet Friends");
break;
case PEER_TYPE_UNKNOWN_IN:
title = tr("Unknown (Incoming) Connect Attempt");
break;
case PEER_TYPE_UNKNOWN_OUT:
title = tr("Unknown (Outgoing) Connect Attempt");
case PEER_TYPE_NEW_FOF:
title = tr("Friend of Friend");
break;
default:
title = tr("Peer");
@ -143,53 +134,15 @@ void PeerItem::updateItemStatic()
}
else
{
/* it is very likely that we will end up here for some of the
* Unknown peer cases.... so allow them here
*/
QString title;
switch(mType)
{
case PEER_TYPE_STD:
title = tr("Friend");
break;
case PEER_TYPE_CONNECT:
title = tr("Friend Connected");
break;
case PEER_TYPE_NEW_FOF:
title = tr("Friend of Friend");
break;
case PEER_TYPE_HELLO:
title = tr("Connect Attempt");
break;
case PEER_TYPE_AUTH_DENIED:
title = tr("Not Yet Friends");
break;
case PEER_TYPE_UNKNOWN_IN:
title = tr("Unknown (Incoming) Connect Attempt");
break;
case PEER_TYPE_UNKNOWN_OUT:
title = tr("Unknown (Outgoing) Connect Attempt");
break;
default:
title = tr("Peer");
break;
}
titleLabel->setText(title);
QDateTime date = QDateTime::fromTime_t(time(NULL));
QString stime = date.toString(Qt::LocalDate);
lastLabel-> setText(stime);
nameLabel->setText(QString::fromStdString(mPeerId));
idLabel->setText(QString::fromStdString(mPeerId));
statusLabel->setText(tr("Unknown Peer"));
titleLabel->setText(tr("Unknown Peer"));
trustLabel->setText(tr("Unknown Peer"));
nameLabel->setText(tr("Unknown Peer"));
idLabel->setText(tr("Unknown Peer"));
locLabel->setText(tr("Unknown Peer"));
ipLabel->setText(tr("Unknown Peer"));
connLabel->setText(tr("Unknown Peer"));
lastLabel->setText(tr("Unknown Peer"));
chatButton->setEnabled(false);

View File

@ -27,12 +27,8 @@
const uint32_t PEER_TYPE_STD = 0x0001;
const uint32_t PEER_TYPE_CONNECT = 0x0002;
const uint32_t PEER_TYPE_NEW_FOF = 0x0003; /* new Friend of Friend */
const uint32_t PEER_TYPE_HELLO = 0x0004; /* failed Connect Attempt */
const uint32_t PEER_TYPE_AUTH_DENIED = 0x0005; /* failed outgoing attempt */
const uint32_t PEER_TYPE_UNKNOWN_IN = 0x0006; /* failed incoming with unknown peer */
const uint32_t PEER_TYPE_UNKNOWN_OUT = 0x0007; /* failed outgoing with unknown peer */
const uint32_t PEER_TYPE_HELLO = 0x0003; /* failed Connect Attempt */
const uint32_t PEER_TYPE_NEW_FOF = 0x0004; /* new Friend of Friend */
class FeedHolder;

View File

@ -0,0 +1,418 @@
/****************************************************************
* 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 General Public License
* as published by the Free Software Foundation; either version 2
* 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 <QDateTime>
#include <QTimer>
#include "SecurityItem.h"
#include "FeedHolder.h"
#include "../RsAutoUpdatePage.h"
#include "gui/msgs/MessageComposer.h"
#include "gui/common/StatusDefs.h"
#include "gui/notifyqt.h"
#include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h>
#include <sstream>
/*****
* #define DEBUG_ITEM 1
****/
/** Constructor */
SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, std::string gpgId, std::string sslId, uint32_t type, bool isHome)
:QWidget(NULL), mParent(parent), mFeedId(feedId),
mSslId(sslId), mGpgId(gpgId), mType(type), mIsHome(isHome)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
messageframe->setVisible(false);
sendmsgButton->setEnabled(false);
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
/* specific ones */
connect( chatButton, SIGNAL( clicked( void ) ), this, SLOT( openChat ( void ) ) );
connect( actionNew_Message, SIGNAL( triggered( ) ), this, SLOT( sendMsg ( void ) ) );
connect( quickmsgButton, SIGNAL( clicked( ) ), this, SLOT( togglequickmessage() ) );
connect( cancelButton, SIGNAL( clicked( ) ), this, SLOT( togglequickmessage() ) );
connect( sendmsgButton, SIGNAL( clicked( ) ), this, SLOT( sendMessage() ) );
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&)));
QMenu *msgmenu = new QMenu();
msgmenu->addAction(actionNew_Message);
quickmsgButton->setMenu(msgmenu);
small();
updateItemStatic();
updateItem();
updateAvatar(QString::fromStdString(mGpgId));
}
bool SecurityItem::isSame(const std::string &sslId, uint32_t type)
{
if ((mSslId == sslId) && (mType == type))
{
return true;
}
return false;
}
void SecurityItem::updateItemStatic()
{
if (!rsPeers)
return;
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "SecurityItem::updateItemStatic()";
std::cerr << std::endl;
#endif
QString title;
switch(mType)
{
case SEC_TYPE_CONNECT_ATTEMPT:
title = tr("Connect Attempt");
break;
case SEC_TYPE_AUTH_DENIED:
title = tr("Not Yet Friends");
break;
case SEC_TYPE_UNKNOWN_IN:
title = tr("Unknown (Incoming) Connect Attempt");
break;
case SEC_TYPE_UNKNOWN_OUT:
title = tr("Unknown (Outgoing) Connect Attempt");
break;
default:
title = tr("Unknown Security Issue");
break;
}
titleLabel->setText(title);
RsPeerDetails details;
if (rsPeers->getPeerDetails(mGpgId, details))
{
/* set textcolor for peername */
QString nameStr("<span style=\"font-size:14pt; font-weight:500;"
"color:#990033;\">%1</span>");
/* set Blog name */
QString peername = QString::fromStdString(details.name);
peernameLabel->setText(nameStr.arg(peername));
QDateTime date = QDateTime::fromTime_t(details.lastConnect);
QString stime = date.toString(Qt::LocalDate);
lastLabel-> setText(stime);
/* expanded Info */
nameLabel->setText(QString::fromUtf8(details.name.c_str()));
idLabel->setText(QString::fromStdString(details.id));
locLabel->setText(QString::fromUtf8(details.location.c_str()));
}
else
{
/* it is very likely that we will end up here for some of the
* Unknown peer cases.... so allow them here
*/
QDateTime date = QDateTime::fromTime_t(time(NULL));
QString stime = date.toString(Qt::LocalDate);
lastLabel-> setText(stime);
nameLabel->setText(QString::fromStdString(mGpgId));
idLabel->setText(QString::fromStdString(mSslId));
statusLabel->setText(tr("Unknown Peer"));
trustLabel->setText(tr("Unknown Peer"));
locLabel->setText(tr("Unknown Peer"));
ipLabel->setText(tr("Unknown Peer"));
connLabel->setText(tr("Unknown Peer"));
chatButton->setEnabled(false);
}
if (mIsHome)
{
/* disable buttons */
clearButton->setEnabled(false);
//gotoButton->setEnabled(false);
/* disable buttons */
clearButton->hide();
}
}
void SecurityItem::updateItem()
{
if (!rsPeers)
return;
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "SecurityItem::updateItem()";
std::cerr << std::endl;
#endif
if(!RsAutoUpdatePage::eventsLocked()) {
RsPeerDetails details;
if (!rsPeers->getPeerDetails(mGpgId, details))
{
return;
}
/* top Level info */
QString status = StatusDefs::peerStateString(details.state);
#if 0
/* Append additional status info from status service */
StatusInfo statusInfo;
if ((rsStatus) && (rsStatus->getStatus(*it, statusInfo)))
{
status.append(QString::fromStdString("/" + RsStatusString(statusInfo.status)));
}
#endif
statusLabel->setText(status);
trustLabel->setText(QString::fromStdString(
RsPeerTrustString(details.trustLvl)));
{
std::ostringstream out;
out << details.localAddr << ":";
out << details.localPort << "/";
out << details.extAddr << ":";
out << details.extPort;
ipLabel->setText(QString::fromStdString(out.str()));
}
connLabel->setText(StatusDefs::connectStateString(details));
/* do buttons */
chatButton->setEnabled(details.state & RS_PEER_STATE_CONNECTED);
if (details.state & RS_PEER_STATE_FRIEND)
{
//addButton->setEnabled(false);
//removeButton->setEnabled(true);
quickmsgButton->setEnabled(true);
}
else
{
//addButton->setEnabled(true);
//removeButton->setEnabled(false);
quickmsgButton->setEnabled(false);
}
}
/* slow Tick */
int msec_rate = 10129;
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
return;
}
void SecurityItem::small()
{
expandFrame->hide();
}
void SecurityItem::toggle()
{
if (expandFrame->isHidden())
{
expandFrame->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide"));
}
else
{
expandFrame->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
}
}
void SecurityItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "SecurityItem::removeItem()";
std::cerr << std::endl;
#endif
hide();
if (mParent)
{
mParent->deleteFeedItem(this, mFeedId);
}
}
void SecurityItem::gotoHome()
{
#ifdef DEBUG_ITEM
std::cerr << "SecurityItem::gotoHome()";
std::cerr << std::endl;
#endif
}
/*********** SPECIFIC FUNCTIOSN ***********************/
void SecurityItem::addFriend()
{
#ifdef DEBUG_ITEM
std::cerr << "SecurityItem::addFriend()";
std::cerr << std::endl;
#endif
}
void SecurityItem::removeFriend()
{
#ifdef DEBUG_ITEM
std::cerr << "SecurityItem::removeFriend()";
std::cerr << std::endl;
#endif
}
void SecurityItem::sendMsg()
{
#ifdef DEBUG_ITEM
std::cerr << "SecurityItem::sendMsg()";
std::cerr << std::endl;
#endif
if (mParent)
{
//mParent->openMsg(FEEDHOLDER_MSG_MESSAGE, mPeerId, "");
MessageComposer *nMsgDialog = MessageComposer::newMsg();
if (nMsgDialog == NULL) {
return;
}
nMsgDialog->addRecipient(MessageComposer::TO, mGpgId, false);
nMsgDialog->show();
nMsgDialog->activateWindow();
/* window will destroy itself! */
}
}
void SecurityItem::openChat()
{
#ifdef DEBUG_ITEM
std::cerr << "SecurityItem::openChat()";
std::cerr << std::endl;
#endif
if (mParent)
{
mParent->openChat(mGpgId);
}
}
void SecurityItem::updateAvatar(const QString &peer_id)
{
if (peer_id.toStdString() != mGpgId) {
/* it 's not me */
return;
}
unsigned char *data = NULL;
int size = 0 ;
rsMsgs->getAvatarData(mGpgId,data,size);
if(size != 0)
{
// set the image
QPixmap pix ;
pix.loadFromData(data,size,"PNG") ;
avatar_label->setPixmap(pix);
delete[] data ;
}
else
{
avatar_label->setPixmap(QPixmap(":/images/user/personal64.png"));
}
}
void SecurityItem::togglequickmessage()
{
if (messageframe->isHidden())
{
messageframe->setVisible(true);
}
else
{
messageframe->setVisible(false);
}
}
void SecurityItem::sendMessage()
{
/* construct a message */
MessageInfo mi;
mi.title = tr("Quick Message").toStdWString();
mi.msg = quickmsgText->toHtml().toStdWString();
mi.msgto.push_back(mGpgId);
rsMsgs->MessageSend(mi);
quickmsgText->clear();
messageframe->setVisible(false);
}
void SecurityItem::on_quickmsgText_textChanged()
{
if (quickmsgText->toPlainText().isEmpty())
{
sendmsgButton->setEnabled(false);
}
else
{
sendmsgButton->setEnabled(true);
}
}

View File

@ -0,0 +1,83 @@
/****************************************************************
* 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 General Public License
* as published by the Free Software Foundation; either version 2
* 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 _SECURITY_ITEM_DIALOG_H
#define _SECURITY_ITEM_DIALOG_H
#include "ui_SecurityItem.h"
#include <stdint.h>
const uint32_t SEC_TYPE_CONNECT_ATTEMPT = 0x0001; /* failed Connect Attempt */
const uint32_t SEC_TYPE_AUTH_DENIED = 0x0002; /* failed outgoing attempt */
const uint32_t SEC_TYPE_UNKNOWN_IN = 0x0003; /* failed incoming with unknown peer */
const uint32_t SEC_TYPE_UNKNOWN_OUT = 0x0004; /* failed outgoing with unknown peer */
class FeedHolder;
class SecurityItem : public QWidget, private Ui::SecurityItem
{
Q_OBJECT
public:
/** Default Constructor */
SecurityItem(FeedHolder *parent, uint32_t feedId, std::string gpgId, std::string sslId, uint32_t type, bool isHome);
/** Default Destructor */
void updateItemStatic();
void small();
bool isSame(const std::string &sslId, uint32_t type);
private slots:
/* default stuff */
void gotoHome();
void removeItem();
void toggle();
void addFriend();
void removeFriend();
void sendMsg();
void openChat();
void updateItem();
void updateAvatar(const QString &peer_id);
void togglequickmessage();
void sendMessage();
void on_quickmsgText_textChanged();
private:
FeedHolder *mParent;
uint32_t mFeedId;
std::string mSslId;
std::string mGpgId;
uint32_t mType;
bool mIsHome;
};
#endif

View File

@ -0,0 +1,587 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SecurityItem</class>
<widget class="QWidget" name="SecurityItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>476</width>
<height>382</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame{border: 2px solid red;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #FDBF7D, stop: 1 #643C35);
border-radius: 10px}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame_2">
<property name="styleSheet">
<string notr="true">QFrame#frame_2{border: transparent}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="avatar_label">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel#avatar_label{border: 2px solid green;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #BDDF7D, stop: 1 #49881F);
}</string>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="peernameLabel">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string notr="true">Peer Name</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Connected</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>190</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lastLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>388</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="quickmsgButton">
<property name="text">
<string>Write a quick Message</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/message-mail.png</normaloff>:/images/message-mail.png</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="chatButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Chat</string>
</property>
<property name="text">
<string>Start Chat</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/chat.png</normaloff>:/images/chat.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<zorder></zorder>
<zorder>avatar_label</zorder>
<zorder></zorder>
<zorder></zorder>
<zorder></zorder>
</widget>
</item>
<item row="1" column="0">
<widget class="QFrame" name="messageframe">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>130</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="verticalSpacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="sendmsgButton">
<property name="text">
<string>Send</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>469</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QTextEdit" name="quickmsgText"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="expandFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>200</width>
<height>78</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Peer ID:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Trust: </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Location</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>IP Address</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Connection Method</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="typeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="nameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="idLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="trustLabel">
<property name="text">
<string notr="true">Good</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="locLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ipLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="connLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusLabel">
<property name="text">
<string notr="true">Connected</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
<action name="actionNew_Message">
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_send.png</normaloff>:/images/mail_send.png</iconset>
</property>
<property name="text">
<string>Write Message</string>
</property>
</action>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>