2007-11-14 22:18:48 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, crypton
|
|
|
|
*
|
|
|
|
* 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 <QFile>
|
|
|
|
#include <QFileInfo>
|
2008-01-25 03:49:40 -05:00
|
|
|
#include "common/vmessagebox.h"
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
#include "rsiface/rsiface.h"
|
2008-01-25 03:49:40 -05:00
|
|
|
#include "rsiface/rspeers.h"
|
|
|
|
|
|
|
|
#include "rshare.h"
|
|
|
|
#include "MessengerWindow.h"
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
#include "chat/PopupChatDialog.h"
|
|
|
|
#include "msgs/ChanMsgDialog.h"
|
|
|
|
#include "ChatDialog.h"
|
|
|
|
#include "connect/ConfCertDialog.h"
|
|
|
|
#include "util/PixmapMerging.h"
|
|
|
|
#include "LogoBar.h"
|
|
|
|
#include "util/Widget.h"
|
2007-11-16 20:35:52 -05:00
|
|
|
#include "gui/connect/InviteDialog.h"
|
|
|
|
#include "gui/connect/AddFriendDialog.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QCursor>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
|
|
|
|
|
|
|
/* Images for context menu icons */
|
|
|
|
#define IMAGE_REMOVEFRIEND ":/images/removefriend16.png"
|
|
|
|
#define IMAGE_EXPIORTFRIEND ":/images/exportpeers_16x16.png"
|
|
|
|
#define IMAGE_CHAT ":/images/chat.png"
|
|
|
|
#define IMAGE_SENDMESSAGE ":/images/message-mail.png"
|
|
|
|
/* Images for Status icons */
|
|
|
|
#define IMAGE_ONLINE ":/images/donline.png"
|
|
|
|
#define IMAGE_OFFLINE ":/images/dhidden.png"
|
|
|
|
/* Images for Status icons */
|
|
|
|
#define IMAGE_ON ":/images/contract_hover.png"
|
|
|
|
#define IMAGE_OFF ":/images/expand_hover.png"
|
2008-07-09 05:53:47 -04:00
|
|
|
|
|
|
|
/******
|
|
|
|
* #define MSG_DEBUG 1
|
|
|
|
*****/
|
|
|
|
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** Constructor */
|
|
|
|
MessengerWindow::MessengerWindow(QWidget * parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
2008-04-07 07:11:16 -04:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
2007-11-18 18:35:53 -05:00
|
|
|
|
2008-04-07 07:11:16 -04:00
|
|
|
RshareSettings config;
|
|
|
|
config.loadWidgetInformation(this);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-04-07 07:11:16 -04:00
|
|
|
connect( ui.messengertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messengertreeWidgetCostumPopupMenu( QPoint ) ) );
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2007-11-16 20:35:52 -05:00
|
|
|
connect( ui.avatarButton, SIGNAL(clicked()), SLOT(changeAvatarClicked()));
|
|
|
|
connect( ui.addIMAccountButton, SIGNAL(clicked( bool ) ), this , SLOT( addFriend2() ) );
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-04-07 07:11:16 -04:00
|
|
|
/* to hide the header */
|
|
|
|
ui.messengertreeWidget->header()->hide();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* Set header resize modes and initial section sizes */
|
|
|
|
ui.messengertreeWidget->setColumnCount(1);
|
|
|
|
|
|
|
|
QHeaderView * _header = ui.messengertreeWidget->header () ;
|
|
|
|
_header->setResizeMode (0, QHeaderView::Interactive);
|
|
|
|
//_header->setResizeMode (1, QHeaderView::Interactive);
|
|
|
|
//_header->setResizeMode (2, QHeaderView::Interactive);
|
|
|
|
//_header->setResizeMode (3, QHeaderView::Interactive);
|
|
|
|
|
|
|
|
_header->resizeSection ( 0, 200 );
|
|
|
|
|
2008-04-07 07:11:16 -04:00
|
|
|
//LogoBar
|
|
|
|
_rsLogoBarmessenger = NULL;
|
|
|
|
_rsLogoBarmessenger = new LogoBar(ui.logoframe);
|
|
|
|
Widget::createLayout(ui.logoframe)->addWidget(_rsLogoBarmessenger);
|
|
|
|
|
|
|
|
|
|
|
|
ui.statuscomboBox->setMinimumWidth(20);
|
|
|
|
ui.messagecomboBox->setMinimumWidth(20);
|
|
|
|
ui.searchlineEdit->setMinimumWidth(20);
|
2008-04-24 08:58:27 -04:00
|
|
|
|
|
|
|
/* The background palette breaks MessengerWindow in Linux...
|
|
|
|
* so it is disabled until a solution is found.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if 0
|
2008-04-07 07:11:16 -04:00
|
|
|
QPixmap Backpixmap((QString)":/images/backgroundimage.png");
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-04-24 08:58:27 -04:00
|
|
|
//QBrush BackBrush(Backpixmap);
|
2008-04-07 07:11:16 -04:00
|
|
|
QPalette BackPalette(BackBrush, BackBrush, BackBrush, BackBrush, BackBrush, BackBrush, BackBrush, BackBrush, BackBrush);
|
|
|
|
this->setPalette(BackPalette); //Set Background
|
2008-04-24 08:58:27 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-04-24 08:58:27 -04:00
|
|
|
/* Hide platform specific features */
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
#endif
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
void MessengerWindow::messengertreeWidgetCostumPopupMenu( QPoint point )
|
|
|
|
{
|
|
|
|
|
|
|
|
QMenu contextMnu( this );
|
|
|
|
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
|
|
|
|
|
|
|
chatAct = new QAction(QIcon(IMAGE_CHAT), tr( "Chat" ), this );
|
|
|
|
connect( chatAct , SIGNAL( triggered() ), this, SLOT( chatfriend2() ) );
|
|
|
|
|
|
|
|
sendMessageAct = new QAction(QIcon(IMAGE_SENDMESSAGE), tr( "Send Message" ), this );
|
|
|
|
connect( sendMessageAct , SIGNAL( triggered() ), this, SLOT( sendMessage() ) );
|
|
|
|
|
|
|
|
connectfriendAct = new QAction( tr( "Connect To Friend" ), this );
|
|
|
|
connect( connectfriendAct , SIGNAL( triggered() ), this, SLOT( connectfriend2() ) );
|
|
|
|
|
|
|
|
/************ Do we want these options here???
|
|
|
|
*
|
|
|
|
*
|
|
|
|
configurefriendAct = new QAction( tr( "Configure Friend" ), this );
|
|
|
|
connect( configurefriendAct , SIGNAL( triggered() ), this, SLOT( configurefriend2() ) );
|
|
|
|
|
|
|
|
exportfriendAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Export Friend" ), this );
|
|
|
|
connect( exportfriendAct , SIGNAL( triggered() ), this, SLOT( exportfriend2() ) );
|
2007-11-16 20:35:52 -05:00
|
|
|
*
|
|
|
|
*
|
2007-11-14 22:18:48 -05:00
|
|
|
*********/
|
2007-11-16 20:35:52 -05:00
|
|
|
|
|
|
|
removefriend2Act = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Remove Friend" ), this );
|
|
|
|
connect( removefriend2Act , SIGNAL( triggered() ), this, SLOT( removefriend2() ) );
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
contextMnu.clear();
|
|
|
|
contextMnu.addAction( chatAct);
|
|
|
|
contextMnu.addAction( sendMessageAct);
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction( connectfriendAct);
|
2007-11-16 20:35:52 -05:00
|
|
|
contextMnu.addAction( removefriend2Act);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/**** Do we want these options here???
|
|
|
|
*
|
|
|
|
*
|
|
|
|
contextMnu.addAction( configurefriendAct);
|
2007-11-16 20:35:52 -05:00
|
|
|
contextMnu.addAction( exportfriendAct);
|
2007-11-14 22:18:48 -05:00
|
|
|
*
|
|
|
|
*
|
|
|
|
****/
|
|
|
|
|
|
|
|
contextMnu.exec( mevent->globalPos() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* get the list of peers from the RsIface. */
|
|
|
|
void MessengerWindow::insertPeers()
|
|
|
|
{
|
2008-01-25 03:49:40 -05:00
|
|
|
if (!rsPeers)
|
|
|
|
{
|
|
|
|
/* not ready yet! */
|
|
|
|
return;
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
std::list<std::string> peers;
|
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
|
|
|
|
rsPeers->getFriendList(peers);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* get a link to the table */
|
|
|
|
QTreeWidget *peerWidget = ui.messengertreeWidget;
|
|
|
|
|
|
|
|
/* have two lists: online / offline */
|
|
|
|
QList<QTreeWidgetItem *> online_items;
|
|
|
|
QList<QTreeWidgetItem *> offline_items;
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
for(it = peers.begin(); it != peers.end(); it++)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2008-01-25 03:49:40 -05:00
|
|
|
|
|
|
|
RsPeerDetails details;
|
|
|
|
if (!rsPeers->getPeerDetails(*it, details))
|
|
|
|
{
|
|
|
|
continue; /* BAD */
|
|
|
|
}
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* make a widget per friend */
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
|
|
|
|
|
|
|
/* add all the labels */
|
|
|
|
/* (0) Person */
|
2008-01-25 03:49:40 -05:00
|
|
|
item -> setText(0, QString::fromStdString(details.name));
|
2007-11-14 22:18:48 -05:00
|
|
|
/* (1) Org */
|
2008-01-25 03:49:40 -05:00
|
|
|
//item -> setText(1, QString::fromStdString(details.org));
|
2007-11-14 22:18:48 -05:00
|
|
|
/* (2) Location */
|
2008-01-25 03:49:40 -05:00
|
|
|
//item -> setText(2, QString::fromStdString(details.location));
|
|
|
|
/* (3) Email */
|
|
|
|
//item -> setText(3, QString::fromStdString(details.email));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
/* Hidden ones: RsCertId */
|
|
|
|
item -> setText(4, QString::fromStdString(details.id));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* add to the list */
|
2008-01-25 03:49:40 -05:00
|
|
|
if (details.state & RS_PEER_STATE_CONNECTED)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
online_items.append(item);
|
|
|
|
item -> setIcon(0,(QIcon(IMAGE_ONLINE)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
offline_items.append(item);
|
|
|
|
item -> setIcon(0,(QIcon(IMAGE_OFFLINE)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
/* remove old items */
|
|
|
|
peerWidget->clear();
|
|
|
|
peerWidget->setColumnCount(1);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
if (online_items.size() > 0)
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
|
|
|
|
|
|
|
/* add all the labels */
|
|
|
|
/* (0) Person */
|
|
|
|
item -> setText(0, "Online");
|
|
|
|
item -> addChildren(online_items);
|
|
|
|
item -> setIcon(0,(QIcon(IMAGE_ON)));
|
|
|
|
peerWidget->addTopLevelItem(item);
|
|
|
|
peerWidget->expandItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (offline_items.size() > 0)
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
|
|
|
|
|
|
|
/* add all the labels */
|
|
|
|
/* (0) Person */
|
|
|
|
item -> setText(0, "Offline");
|
|
|
|
item -> addChildren(offline_items);
|
|
|
|
|
|
|
|
peerWidget->addTopLevelItem(item);
|
|
|
|
peerWidget->expandItem(item);
|
|
|
|
item -> setIcon(0,(QIcon(IMAGE_OFF)));
|
|
|
|
}
|
|
|
|
|
|
|
|
peerWidget->update(); /* update display */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Utility Fns */
|
|
|
|
std::string getMessengerPeerRsCertId(QTreeWidgetItem *i)
|
|
|
|
{
|
|
|
|
std::string id = (i -> text(4)).toStdString();
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Open a QFileDialog to browse for export a file. */
|
|
|
|
void MessengerWindow::exportfriend2()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MessengerWindow::allowfriend2()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MessengerWindow::connectfriend2()
|
|
|
|
{
|
|
|
|
bool isOnline;
|
|
|
|
QTreeWidgetItem *i = getCurrentPeer(isOnline);
|
|
|
|
if (!i)
|
|
|
|
return;
|
|
|
|
|
2008-06-16 16:28:16 -04:00
|
|
|
std::string id = (i -> text(4)).toStdString();
|
|
|
|
if (rsPeers->isOnline(id))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef MSG_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "MessengerWindow::connectfriend2() Already online" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef MSG_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "MessengerWindow::connectfriend2() Trying" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-01-25 03:49:40 -05:00
|
|
|
rsPeers->connectAttempt(getMessengerPeerRsCertId(i));
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessengerWindow::setaddressfriend2()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessengerWindow::trustfriend2()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* GUI stuff -> don't do anything directly with Control */
|
|
|
|
void MessengerWindow::configurefriend2()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Overloads the default show */
|
|
|
|
void MessengerWindow::show()
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!this->isVisible()) {
|
|
|
|
QWidget::show();
|
|
|
|
} else {
|
|
|
|
QWidget::activateWindow();
|
|
|
|
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
|
|
|
|
QWidget::raise();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessengerWindow::closeEvent (QCloseEvent * event)
|
|
|
|
{
|
2007-11-18 18:35:53 -05:00
|
|
|
RshareSettings config;
|
|
|
|
config.saveWidgetInformation(this);
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
hide();
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MessengerWindow::setChatDialog(ChatDialog *cd)
|
|
|
|
{
|
|
|
|
chatDialog = cd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MessengerWindow::chatfriend2()
|
|
|
|
{
|
|
|
|
bool isOnline;
|
|
|
|
QTreeWidgetItem *i = getCurrentPeer(isOnline);
|
|
|
|
if (!i)
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::string name = (i -> text(0)).toStdString();
|
|
|
|
std::string id = (i -> text(4)).toStdString();
|
|
|
|
|
2008-06-16 16:28:16 -04:00
|
|
|
if (!(rsPeers->isOnline(id)))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* info dialog */
|
|
|
|
QMessageBox::StandardButton sb = QMessageBox::question ( NULL,
|
|
|
|
"Friend Not Online",
|
|
|
|
"Your Friend is offline \nDo You want to send them a Message instead",
|
|
|
|
(QMessageBox::Yes | QMessageBox::No ));
|
|
|
|
if (sb == QMessageBox::Yes)
|
|
|
|
{
|
|
|
|
rsicontrol -> ClearInMsg();
|
|
|
|
rsicontrol -> SetInMsg(id, true);
|
|
|
|
|
|
|
|
/* create a message */
|
|
|
|
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
|
|
|
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
nMsgDialog->show();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* must reference ChatDialog */
|
|
|
|
if (chatDialog)
|
|
|
|
{
|
|
|
|
chatDialog->getPrivateChat(id, name, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessengerWindow::sendMessage()
|
|
|
|
{
|
|
|
|
bool isOnline;
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef MSG_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "SharedFilesDialog::msgfriend()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
QTreeWidgetItem *i = getCurrentPeer(isOnline);
|
|
|
|
|
|
|
|
if (!i)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//std::string status = (i -> text(0)).toStdString();
|
|
|
|
std::string name = (i -> text(0)).toStdString();
|
|
|
|
std::string id = (i -> text(4)).toStdString();
|
|
|
|
|
|
|
|
rsicontrol -> ClearInMsg();
|
|
|
|
rsicontrol -> SetInMsg(id, true);
|
|
|
|
|
|
|
|
/* create a message */
|
|
|
|
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
|
|
|
|
|
|
|
nMsgDialog->newMsg();
|
|
|
|
nMsgDialog->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QTreeWidgetItem *MessengerWindow::getCurrentPeer(bool &isOnline)
|
|
|
|
{
|
|
|
|
/* get the current, and extract the Id */
|
|
|
|
|
|
|
|
/* get a link to the table */
|
|
|
|
QTreeWidget *peerWidget = ui.messengertreeWidget;
|
|
|
|
QTreeWidgetItem *item = peerWidget -> currentItem();
|
|
|
|
if (!item)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef MSG_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "Invalid Current Item" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if parent is online or offline */
|
|
|
|
QTreeWidgetItem *parent = item->parent();
|
|
|
|
if ((!parent) ||
|
|
|
|
(parent == peerWidget->invisibleRootItem()))
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef MSG_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "Selected Parent Invalid Item" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-04-07 07:11:16 -04:00
|
|
|
isOnline = (parent->text(0) == "<span><strong>Online</strong></span>");
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2007-11-16 20:35:52 -05:00
|
|
|
void MessengerWindow::removefriend2()
|
|
|
|
{
|
|
|
|
bool isOnline;
|
|
|
|
QTreeWidgetItem *c = getCurrentPeer(isOnline);
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef MSG_DEBUG
|
2007-11-16 20:35:52 -05:00
|
|
|
std::cerr << "MessengerWindow::removefriend2()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-16 20:35:52 -05:00
|
|
|
if (!c)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef MSG_DEBUG
|
2007-11-16 20:35:52 -05:00
|
|
|
std::cerr << "MessengerWindow::removefriend2() Noone Selected -- sorry" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-16 20:35:52 -05:00
|
|
|
return;
|
|
|
|
}
|
2008-01-25 03:49:40 -05:00
|
|
|
rsPeers->removeFriend(getMessengerPeerRsCertId(c));
|
2007-11-16 20:35:52 -05:00
|
|
|
}
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
void MessengerWindow::changeAvatarClicked()
|
|
|
|
{
|
|
|
|
|
|
|
|
updateAvatar();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-16 20:35:52 -05:00
|
|
|
/** Add a Friend ShortCut */
|
|
|
|
void MessengerWindow::addFriend2()
|
|
|
|
{
|
|
|
|
/* call load Certificate */
|
|
|
|
#if 0
|
|
|
|
std::string id;
|
|
|
|
if (connectionsDialog)
|
|
|
|
{
|
|
|
|
id = connectionsDialog->loadneighbour();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* call make Friend */
|
|
|
|
if (id != "")
|
|
|
|
{
|
|
|
|
connectionsDialog->showpeerdetails(id);
|
|
|
|
}
|
|
|
|
virtual int NeighLoadPEMString(std::string pem, std::string &id) = 0;
|
|
|
|
#else
|
|
|
|
|
|
|
|
static AddFriendDialog *addDialog2 =
|
|
|
|
new AddFriendDialog(networkDialog2, this);
|
|
|
|
|
|
|
|
std::string invite = "";
|
|
|
|
addDialog2->setInfo(invite);
|
|
|
|
addDialog2->show();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
void MessengerWindow::updateAvatar()
|
|
|
|
{
|
|
|
|
std::string backgroundPixmapFilename = ":/images/retrosharelogo1.png";
|
|
|
|
std::string foregroundPixmapData = ":/images/nopic.png";
|
|
|
|
//std::string foregroundPixmapData = _cUserProfile->getUserProfile().getIcon().getData();
|
|
|
|
|
|
|
|
ui.avatarButton->setIcon(PixmapMerging::merge(foregroundPixmapData, backgroundPixmapFilename));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LogoBar & MessengerWindow::getLogoBar() const {
|
|
|
|
return *_rsLogoBarmessenger;
|
|
|
|
}
|
|
|
|
|