2012-04-25 15:19:16 -04:00
|
|
|
/*
|
|
|
|
* RetroShare
|
|
|
|
* Copyright (C) 2012 RetroShare Team
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "FriendRequestToaster.h"
|
|
|
|
#include "gui/FriendsDialog.h"
|
2012-08-28 19:39:11 -04:00
|
|
|
#include "gui/connect/ConnectFriendWizard.h"
|
2012-04-25 15:19:16 -04:00
|
|
|
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString &sslName, const RsPeerId &peerId)
|
2013-09-01 18:18:39 -04:00
|
|
|
: QWidget(NULL), mGpgId(gpgId), mSslId(peerId), mSslName(sslName)
|
2012-04-25 15:19:16 -04:00
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
bool knownPeer = false;
|
|
|
|
RsPeerDetails details;
|
|
|
|
if (rsPeers->getGPGDetails(mGpgId, details)) {
|
|
|
|
knownPeer = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (knownPeer) {
|
2012-09-03 06:58:11 -04:00
|
|
|
connect(ui.toasterButton, SIGNAL(clicked()), SLOT(friendrequestButtonSlot()));
|
2012-04-25 15:19:16 -04:00
|
|
|
} else {
|
2012-09-03 06:58:11 -04:00
|
|
|
ui.toasterButton->setEnabled(false);
|
2012-04-25 15:19:16 -04:00
|
|
|
}
|
|
|
|
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
|
2012-05-04 10:42:06 -04:00
|
|
|
|
|
|
|
QString peerName = QString::fromUtf8(details.name.c_str());
|
2012-04-25 15:19:16 -04:00
|
|
|
|
|
|
|
/* set informations */
|
|
|
|
ui.avatarWidget->setFrameType(AvatarWidget::NORMAL_FRAME);
|
|
|
|
if (knownPeer) {
|
2012-09-03 06:58:11 -04:00
|
|
|
ui.textLabel->setText( peerName + " " + tr("wants to be friend with you on RetroShare"));
|
2012-04-25 15:19:16 -04:00
|
|
|
ui.avatarWidget->setDefaultAvatar(":/images/avatar_request.png");
|
|
|
|
} else {
|
2012-09-03 06:58:11 -04:00
|
|
|
ui.textLabel->setText( sslName + " " + tr("Unknown (Incoming) Connect Attempt"));
|
2012-04-25 15:19:16 -04:00
|
|
|
ui.avatarWidget->setDefaultAvatar(":/images/avatar_request_unknown.png");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FriendRequestToaster::friendrequestButtonSlot()
|
|
|
|
{
|
2012-08-28 19:39:11 -04:00
|
|
|
ConnectFriendWizard *connectFriendWizard = new ConnectFriendWizard;
|
2012-08-29 18:40:16 -04:00
|
|
|
connectFriendWizard->setAttribute(Qt::WA_DeleteOnClose, true);
|
2013-09-01 18:18:39 -04:00
|
|
|
connectFriendWizard->setGpgId(mGpgId, mSslId, true);
|
2012-08-28 19:39:11 -04:00
|
|
|
connectFriendWizard->show();
|
|
|
|
|
2012-04-25 15:19:16 -04:00
|
|
|
hide();
|
|
|
|
}
|