2018-12-25 21:10:15 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* gui/toaster/FriendRequestToaster.cpp *
|
|
|
|
* *
|
|
|
|
* Copyright (c) 2010 Retroshare Team <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2012-04-25 19:19:16 +00:00
|
|
|
|
|
|
|
#include "FriendRequestToaster.h"
|
|
|
|
#include "gui/FriendsDialog.h"
|
2012-08-28 23:39:11 +00:00
|
|
|
#include "gui/connect/ConnectFriendWizard.h"
|
2012-04-25 19:19:16 +00:00
|
|
|
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
|
2014-03-17 20:56:06 +00:00
|
|
|
FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString &sslName, const RsPeerId &peerId)
|
2013-09-01 22:18:39 +00:00
|
|
|
: QWidget(NULL), mGpgId(gpgId), mSslId(peerId), mSslName(sslName)
|
2012-04-25 19:19:16 +00: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 10:58:11 +00:00
|
|
|
connect(ui.toasterButton, SIGNAL(clicked()), SLOT(friendrequestButtonSlot()));
|
2012-04-25 19:19:16 +00:00
|
|
|
} else {
|
2012-09-03 10:58:11 +00:00
|
|
|
ui.toasterButton->setEnabled(false);
|
2012-04-25 19:19:16 +00:00
|
|
|
}
|
|
|
|
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
|
2012-05-04 14:42:06 +00:00
|
|
|
|
|
|
|
QString peerName = QString::fromUtf8(details.name.c_str());
|
2012-04-25 19:19:16 +00:00
|
|
|
|
|
|
|
/* set informations */
|
|
|
|
ui.avatarWidget->setFrameType(AvatarWidget::NORMAL_FRAME);
|
|
|
|
if (knownPeer) {
|
2012-09-03 10:58:11 +00:00
|
|
|
ui.textLabel->setText( peerName + " " + tr("wants to be friend with you on RetroShare"));
|
2012-04-25 19:19:16 +00:00
|
|
|
ui.avatarWidget->setDefaultAvatar(":/images/avatar_request.png");
|
|
|
|
} else {
|
2012-09-03 10:58:11 +00:00
|
|
|
ui.textLabel->setText( sslName + " " + tr("Unknown (Incoming) Connect Attempt"));
|
2012-04-25 19:19:16 +00:00
|
|
|
ui.avatarWidget->setDefaultAvatar(":/images/avatar_request_unknown.png");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FriendRequestToaster::friendrequestButtonSlot()
|
|
|
|
{
|
2012-08-28 23:39:11 +00:00
|
|
|
ConnectFriendWizard *connectFriendWizard = new ConnectFriendWizard;
|
2012-08-29 22:40:16 +00:00
|
|
|
connectFriendWizard->setAttribute(Qt::WA_DeleteOnClose, true);
|
2013-09-01 22:18:39 +00:00
|
|
|
connectFriendWizard->setGpgId(mGpgId, mSslId, true);
|
2012-08-28 23:39:11 +00:00
|
|
|
connectFriendWizard->show();
|
|
|
|
|
2012-04-25 19:19:16 +00:00
|
|
|
hide();
|
|
|
|
}
|