2010-12-07 19:14:12 -05:00
|
|
|
/****************************************************************
|
|
|
|
* This file is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include <QInputDialog>
|
|
|
|
#include <QMessageBox>
|
2010-12-07 19:14:12 -05:00
|
|
|
#include <QTimer>
|
|
|
|
//#include <QMutexLocker>
|
|
|
|
#include <QDesktopWidget>
|
2009-12-28 17:40:45 -05:00
|
|
|
|
|
|
|
#include "notifyqt.h"
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsnotify.h>
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
#include <retroshare/rsphoto.h>
|
2010-11-21 10:22:41 -05:00
|
|
|
#include <retroshare/rsmsgs.h>
|
2009-12-28 17:40:45 -05:00
|
|
|
#ifdef TURTLE_HOPPING
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsturtle.h>
|
2009-12-28 17:40:45 -05:00
|
|
|
#endif
|
|
|
|
|
2010-12-07 19:14:12 -05:00
|
|
|
#include "RsAutoUpdatePage.h"
|
2009-12-28 17:40:45 -05:00
|
|
|
|
2010-08-31 16:00:49 -04:00
|
|
|
#ifndef MINIMAL_RSGUI
|
2011-02-22 09:51:03 -05:00
|
|
|
#include "MainWindow.h"
|
2010-12-07 19:14:12 -05:00
|
|
|
#include "toaster/OnlineToaster.h"
|
|
|
|
#include "toaster/MessageToaster.h"
|
|
|
|
#include "toaster/DownloadToaster.h"
|
2010-08-31 16:00:49 -04:00
|
|
|
#endif // MINIMAL_RSGUI
|
2009-12-28 17:40:45 -05:00
|
|
|
|
|
|
|
#include "gui/settings/rsharesettings.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
2010-01-20 17:02:43 -05:00
|
|
|
#include <time.h>
|
2009-12-28 17:40:45 -05:00
|
|
|
|
|
|
|
/*****
|
|
|
|
* #define NOTIFY_DEBUG
|
|
|
|
****/
|
|
|
|
|
2010-12-07 19:14:12 -05:00
|
|
|
class Toaster
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Toaster(QWidget *widget)
|
|
|
|
{
|
|
|
|
this->widget = widget;
|
|
|
|
|
|
|
|
/* Standard values */
|
|
|
|
timeToShow = 500;
|
|
|
|
timeToLive = 3000;
|
|
|
|
timeToHide = 500;
|
|
|
|
|
|
|
|
/* Calculated values */
|
|
|
|
elapsedTimeToShow = 0;
|
|
|
|
elapsedTimeToLive = 0;
|
|
|
|
elapsedTimeToHide = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
QWidget *widget;
|
|
|
|
|
|
|
|
/* Standard values */
|
|
|
|
int timeToShow;
|
|
|
|
int timeToLive;
|
|
|
|
int timeToHide;
|
|
|
|
|
|
|
|
/* Calculated values */
|
|
|
|
QPoint startPos;
|
|
|
|
QPoint endPos;
|
|
|
|
int elapsedTimeToShow;
|
|
|
|
int elapsedTimeToLive;
|
|
|
|
int elapsedTimeToHide;
|
|
|
|
};
|
|
|
|
|
2010-07-18 07:43:39 -04:00
|
|
|
/*static*/ NotifyQt *NotifyQt::_instance = NULL;
|
|
|
|
|
|
|
|
/*static*/ NotifyQt *NotifyQt::Create ()
|
|
|
|
{
|
|
|
|
if (_instance == NULL) {
|
|
|
|
_instance = new NotifyQt ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return _instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ NotifyQt *NotifyQt::getInstance ()
|
|
|
|
{
|
|
|
|
return _instance;
|
|
|
|
}
|
|
|
|
|
2010-12-07 19:14:12 -05:00
|
|
|
NotifyQt::NotifyQt() : cDialog(NULL)
|
|
|
|
{
|
|
|
|
runningToasterTimer = new QTimer(this);
|
|
|
|
connect(runningToasterTimer, SIGNAL(timeout()), this, SLOT(runningTick()));
|
|
|
|
runningToasterTimer->setInterval(10); // tick 100 times a second
|
|
|
|
runningToasterTimer->setSingleShot(true);
|
|
|
|
}
|
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
void NotifyQt::notifyErrorMsg(int list, int type, std::string msg)
|
|
|
|
{
|
2010-02-07 13:10:12 -05:00
|
|
|
emit errorOccurred(list,type,QString::fromStdString(msg)) ;
|
2009-12-28 17:40:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyQt::notifyOwnAvatarChanged()
|
|
|
|
{
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "Notifyqt:: notified that own avatar changed" << std::endl ;
|
2010-02-08 11:42:26 -05:00
|
|
|
#endif
|
2009-12-28 17:40:45 -05:00
|
|
|
emit ownAvatarChanged() ;
|
|
|
|
}
|
|
|
|
|
2011-08-05 16:45:09 -04:00
|
|
|
bool NotifyQt::askForPassword(const std::string& key_details, bool prev_is_bad, std::string& password)
|
2009-12-28 17:40:45 -05:00
|
|
|
{
|
2010-04-19 17:50:03 -04:00
|
|
|
RsAutoUpdatePage::lockAllEvents() ;
|
|
|
|
|
2011-02-27 16:47:49 -05:00
|
|
|
QInputDialog dialog;
|
|
|
|
dialog.setWindowTitle(tr("GPG key passphrase"));
|
|
|
|
dialog.setLabelText((prev_is_bad?tr("Wrong password !") + "\n\n" : QString()) +
|
2011-07-17 19:07:29 -04:00
|
|
|
tr("Please enter the password to unlock the following GPG key:") + "\n" + QString::fromUtf8(key_details.c_str()));
|
2011-02-27 16:47:49 -05:00
|
|
|
dialog.setTextEchoMode(QLineEdit::Password);
|
|
|
|
dialog.setWindowIcon(QIcon(":/images/rstray3.png"));
|
|
|
|
|
|
|
|
int ret = dialog.exec();
|
2010-04-19 17:50:03 -04:00
|
|
|
|
|
|
|
RsAutoUpdatePage::unlockAllEvents() ;
|
|
|
|
|
2011-08-05 16:45:09 -04:00
|
|
|
if (ret == QDialog::Accepted) {
|
2011-08-27 18:54:05 -04:00
|
|
|
password = dialog.textValue().toUtf8().constData();
|
2011-08-05 16:45:09 -04:00
|
|
|
return true;
|
2011-02-27 16:47:49 -05:00
|
|
|
}
|
|
|
|
|
2011-08-05 16:45:09 -04:00
|
|
|
return false;
|
2009-12-28 17:40:45 -05:00
|
|
|
}
|
|
|
|
|
2010-11-05 18:46:40 -04:00
|
|
|
void NotifyQt::notifyDiscInfoChanged()
|
|
|
|
{
|
2011-01-20 17:22:02 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2010-11-05 18:46:40 -04:00
|
|
|
std::cerr << "Notifyqt:: notified that discoveryInfo changed" << std::endl ;
|
2011-01-20 17:22:02 -05:00
|
|
|
#endif
|
2010-11-05 18:46:40 -04:00
|
|
|
|
|
|
|
emit discInfoChanged() ;
|
|
|
|
}
|
2010-11-24 19:20:25 -05:00
|
|
|
|
|
|
|
void NotifyQt::notifyDownloadComplete(const std::string& fileHash)
|
|
|
|
{
|
2011-01-20 17:22:02 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2010-11-24 19:20:25 -05:00
|
|
|
std::cerr << "Notifyqt::notifyDownloadComplete notified that a download is completed" << std::endl;
|
2011-01-20 17:22:02 -05:00
|
|
|
#endif
|
2010-11-24 19:20:25 -05:00
|
|
|
|
|
|
|
emit downloadComplete(QString::fromStdString(fileHash));
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyQt::notifyDownloadCompleteCount(uint32_t count)
|
|
|
|
{
|
|
|
|
std::cerr << "Notifyqt::notifyDownloadCompleteCount " << count << std::endl;
|
|
|
|
|
|
|
|
emit downloadCompleteCountChanged(count);
|
|
|
|
}
|
|
|
|
|
2010-05-21 16:49:48 -04:00
|
|
|
void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb)
|
|
|
|
{
|
|
|
|
std::cerr << "Notifyqt:: notified that disk is full" << std::endl ;
|
|
|
|
|
|
|
|
emit diskFull(loc,size_in_mb) ;
|
|
|
|
}
|
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
/* peer has changed the state */
|
|
|
|
void NotifyQt::notifyPeerStatusChanged(const std::string& peer_id, uint32_t state)
|
|
|
|
{
|
|
|
|
#ifdef NOTIFY_DEBUG
|
|
|
|
std::cerr << "Notifyqt:: notified that peer " << peer_id << " has changed the state to " << state << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
emit peerStatusChanged(QString::fromStdString(peer_id), state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* one or more peers has changed the states */
|
|
|
|
void NotifyQt::notifyPeerStatusChangedSummary()
|
|
|
|
{
|
|
|
|
#ifdef NOTIFY_DEBUG
|
|
|
|
std::cerr << "Notifyqt:: notified that one peer has changed the state" << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
emit peerStatusChangedSummary();
|
|
|
|
}
|
|
|
|
|
2010-10-06 20:17:42 -04:00
|
|
|
void NotifyQt::notifyChannelMsgReadSatusChanged(const std::string& channelId, const std::string& msgId, uint32_t status)
|
|
|
|
{
|
|
|
|
emit channelMsgReadSatusChanged(QString::fromStdString(channelId), QString::fromStdString(msgId), status);
|
|
|
|
}
|
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
void NotifyQt::notifyOwnStatusMessageChanged()
|
|
|
|
{
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "Notifyqt:: notified that own avatar changed" << std::endl ;
|
2010-02-08 11:42:26 -05:00
|
|
|
#endif
|
2009-12-28 17:40:45 -05:00
|
|
|
emit ownStatusMessageChanged() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id)
|
|
|
|
{
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "notifyQt: notification of new avatar." << std::endl ;
|
2010-02-08 11:42:26 -05:00
|
|
|
#endif
|
2009-12-28 17:40:45 -05:00
|
|
|
emit peerHasNewAvatar(QString::fromStdString(peer_id)) ;
|
|
|
|
}
|
|
|
|
|
2010-09-02 06:15:13 -04:00
|
|
|
void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& status_string)
|
2009-12-28 17:40:45 -05:00
|
|
|
{
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "notifyQt: Received custom status string notification" << std::endl ;
|
2010-02-08 11:42:26 -05:00
|
|
|
#endif
|
2010-09-02 06:15:13 -04:00
|
|
|
emit peerHasNewCustomStateString(QString::fromStdString(peer_id), QString::fromStdString(status_string)) ;
|
2009-12-28 17:40:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyQt::notifyChatStatus(const std::string& peer_id,const std::string& status_string,bool is_private)
|
|
|
|
{
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "notifyQt: Received chat status string: " << status_string << std::endl ;
|
2010-02-08 11:42:26 -05:00
|
|
|
#endif
|
2009-12-28 17:40:45 -05:00
|
|
|
emit chatStatusChanged(QString::fromStdString(peer_id),QString::fromStdString(status_string),is_private) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyQt::notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleFileInfo>& files)
|
|
|
|
{
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "in notify search result..." << std::endl ;
|
2010-02-08 11:42:26 -05:00
|
|
|
#endif
|
2009-12-28 17:40:45 -05:00
|
|
|
|
|
|
|
for(std::list<TurtleFileInfo>::const_iterator it(files.begin());it!=files.end();++it)
|
|
|
|
{
|
|
|
|
FileDetail det ;
|
|
|
|
det.rank = 0 ;
|
|
|
|
det.age = 0 ;
|
|
|
|
det.name = (*it).name ;
|
|
|
|
det.hash = (*it).hash ;
|
|
|
|
det.size = (*it).size ;
|
|
|
|
det.id = "Anonymous" ;
|
|
|
|
|
|
|
|
emit gotTurtleSearchResult(search_id,det) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-09 14:35:34 -04:00
|
|
|
void NotifyQt::notifyHashingInfo(uint32_t type, const std::string& fileinfo)
|
|
|
|
{
|
|
|
|
QString info;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case NOTIFY_HASHTYPE_EXAMINING_FILES:
|
|
|
|
info = tr("Examining shared files...");
|
|
|
|
break;
|
|
|
|
case NOTIFY_HASHTYPE_FINISH:
|
|
|
|
break;
|
|
|
|
case NOTIFY_HASHTYPE_HASH_FILE:
|
|
|
|
info = tr("Hashing file") + " " + QString::fromUtf8(fileinfo.c_str());
|
|
|
|
break;
|
|
|
|
case NOTIFY_HASHTYPE_SAVE_FILE_INDEX:
|
|
|
|
info = tr("Saving file index...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
emit hashingInfoChanged(info);
|
2009-12-28 17:40:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//void NotifyQt::notifyChat()
|
|
|
|
//{
|
|
|
|
// std::cerr << "Received chat notification" << std::endl ;
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
|
|
|
|
void NotifyQt::notifyListChange(int list, int type)
|
|
|
|
{
|
|
|
|
#ifdef NOTIFY_DEBUG
|
|
|
|
std::cerr << "NotifyQt::notifyListChange()" << std::endl;
|
|
|
|
#endif
|
|
|
|
switch(list)
|
|
|
|
{
|
|
|
|
case NOTIFY_LIST_NEIGHBOURS:
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2011-08-21 18:28:19 -04:00
|
|
|
std::cerr << "received neighbours changed" << std::endl ;
|
2009-12-28 17:40:45 -05:00
|
|
|
#endif
|
2011-08-21 18:28:19 -04:00
|
|
|
emit neighboursChanged();
|
2009-12-28 17:40:45 -05:00
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_FRIENDS:
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "received friends changed" << std::endl ;
|
|
|
|
#endif
|
|
|
|
emit friendsChanged() ;
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_DIRLIST_LOCAL:
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "received files changed" << std::endl ;
|
|
|
|
#endif
|
|
|
|
emit filesPostModChanged(true) ; /* Local */
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_DIRLIST_FRIENDS:
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "received files changed" << std::endl ;
|
|
|
|
#endif
|
|
|
|
emit filesPostModChanged(false) ; /* Local */
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_SEARCHLIST:
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_MESSAGELIST:
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "received msg changed" << std::endl ;
|
|
|
|
#endif
|
|
|
|
emit messagesChanged() ;
|
|
|
|
break;
|
2010-08-22 18:12:26 -04:00
|
|
|
case NOTIFY_LIST_MESSAGE_TAGS:
|
|
|
|
#ifdef NOTIFY_DEBUG
|
|
|
|
std::cerr << "received msg tags changed" << std::endl ;
|
|
|
|
#endif
|
|
|
|
emit messagesTagsChanged();
|
|
|
|
break;
|
2009-12-28 17:40:45 -05:00
|
|
|
case NOTIFY_LIST_CHANNELLIST:
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_TRANSFERLIST:
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "received transfer changed" << std::endl ;
|
|
|
|
#endif
|
|
|
|
emit transfersChanged() ;
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_CONFIG:
|
2010-02-08 11:42:26 -05:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2009-12-28 17:40:45 -05:00
|
|
|
std::cerr << "received config changed" << std::endl ;
|
|
|
|
#endif
|
|
|
|
emit configChanged() ;
|
|
|
|
break ;
|
2010-08-09 17:20:34 -04:00
|
|
|
case NOTIFY_LIST_FORUMLIST_LOCKED:
|
|
|
|
#ifdef NOTIFY_DEBUG
|
|
|
|
std::cerr << "received forum msg changed" << std::endl ;
|
|
|
|
#endif
|
|
|
|
emit forumsChanged(); // use connect with Qt::QueuedConnection
|
|
|
|
break;
|
2010-10-06 20:17:42 -04:00
|
|
|
case NOTIFY_LIST_CHANNELLIST_LOCKED:
|
|
|
|
#ifdef NOTIFY_DEBUG
|
|
|
|
std::cerr << "received channel msg changed" << std::endl ;
|
|
|
|
#endif
|
|
|
|
emit channelsChanged(type); // use connect with Qt::QueuedConnection
|
|
|
|
break;
|
2010-09-01 13:56:15 -04:00
|
|
|
case NOTIFY_LIST_PUBLIC_CHAT:
|
2010-08-31 13:13:52 -04:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2010-09-01 13:56:15 -04:00
|
|
|
std::cerr << "received public chat changed" << std::endl ;
|
2010-08-31 13:13:52 -04:00
|
|
|
#endif
|
2010-09-01 13:56:15 -04:00
|
|
|
emit publicChatChanged(type);
|
|
|
|
break;
|
2010-09-20 20:08:06 -04:00
|
|
|
case NOTIFY_LIST_PRIVATE_INCOMING_CHAT:
|
|
|
|
case NOTIFY_LIST_PRIVATE_OUTGOING_CHAT:
|
2010-09-01 13:56:15 -04:00
|
|
|
#ifdef NOTIFY_DEBUG
|
|
|
|
std::cerr << "received private chat changed" << std::endl ;
|
|
|
|
#endif
|
2010-09-20 20:08:06 -04:00
|
|
|
emit privateChatChanged(list, type);
|
2010-08-31 13:13:52 -04:00
|
|
|
break;
|
2010-09-22 18:37:57 -04:00
|
|
|
case NOTIFY_LIST_GROUPLIST:
|
|
|
|
#ifdef NOTIFY_DEBUG
|
|
|
|
std::cerr << "received groups changed" << std::endl ;
|
|
|
|
#endif
|
|
|
|
emit groupsChanged(type);
|
|
|
|
break;
|
2009-12-28 17:40:45 -05:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-12 10:06:29 -04:00
|
|
|
void NotifyQt::notifyListPreChange(int list, int /*type*/)
|
2009-12-28 17:40:45 -05:00
|
|
|
{
|
|
|
|
#ifdef NOTIFY_DEBUG
|
|
|
|
std::cerr << "NotifyQt::notifyListPreChange()" << std::endl;
|
|
|
|
#endif
|
|
|
|
switch(list)
|
|
|
|
{
|
|
|
|
case NOTIFY_LIST_NEIGHBOURS:
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_FRIENDS:
|
|
|
|
emit friendsChanged() ;
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_DIRLIST_FRIENDS:
|
|
|
|
emit filesPreModChanged(false) ; /* remote */
|
|
|
|
break ;
|
|
|
|
case NOTIFY_LIST_DIRLIST_LOCAL:
|
|
|
|
emit filesPreModChanged(true) ; /* local */
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_SEARCHLIST:
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_MESSAGELIST:
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_CHANNELLIST:
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_TRANSFERLIST:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* New Timer Based Update scheme ...
|
|
|
|
* means correct thread seperation
|
|
|
|
*
|
|
|
|
* uses Flags, to detect changes
|
|
|
|
*/
|
|
|
|
|
|
|
|
void NotifyQt::UpdateGUI()
|
|
|
|
{
|
2010-08-31 16:00:49 -04:00
|
|
|
#ifndef MINIMAL_RSGUI
|
2009-12-28 17:40:45 -05:00
|
|
|
/* hack to force updates until we've fixed that part */
|
|
|
|
static time_t lastTs = 0;
|
|
|
|
|
|
|
|
// std::cerr << "Got update signal t=" << lastTs << std::endl ;
|
|
|
|
|
|
|
|
lastTs = time(NULL) ;
|
|
|
|
|
|
|
|
static bool already_updated = false ; // these only update once at start because they may already have been set before
|
|
|
|
// the gui is running, then they get updated by callbacks.
|
|
|
|
if(!already_updated)
|
|
|
|
{
|
|
|
|
emit messagesChanged() ;
|
2011-08-21 18:28:19 -04:00
|
|
|
emit neighboursChanged();
|
2009-12-28 17:40:45 -05:00
|
|
|
emit configChanged();
|
|
|
|
|
|
|
|
already_updated = true ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finally Check for PopupMessages / System Error Messages */
|
|
|
|
|
|
|
|
if (rsNotify)
|
|
|
|
{
|
|
|
|
uint32_t sysid;
|
|
|
|
uint32_t type;
|
|
|
|
std::string title, id, msg;
|
2010-11-24 19:20:25 -05:00
|
|
|
|
2010-06-13 17:02:29 -04:00
|
|
|
if (rsNotify->NotifyPopupMessage(type, id, title, msg))
|
2009-12-28 17:40:45 -05:00
|
|
|
{
|
2010-05-20 17:53:27 -04:00
|
|
|
uint popupflags = Settings->getNotifyFlags();
|
2009-12-28 17:40:45 -05:00
|
|
|
|
2010-12-07 19:14:12 -05:00
|
|
|
/* You can set timeToShow, timeToLive and timeToHide or can leave the standard */
|
|
|
|
Toaster *toaster = NULL;
|
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
/* id the name */
|
2011-07-17 19:07:29 -04:00
|
|
|
QString name;
|
2010-11-25 08:33:16 -05:00
|
|
|
|
|
|
|
if (type == RS_POPUP_DOWNLOAD) {
|
2010-11-24 19:20:25 -05:00
|
|
|
/* id = file hash */
|
|
|
|
} else {
|
2011-07-17 19:07:29 -04:00
|
|
|
name = QString::fromUtf8(rsPeers->getPeerName(id).c_str());
|
2010-11-25 08:33:16 -05:00
|
|
|
}
|
2010-11-21 10:22:41 -05:00
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case RS_POPUP_MSG:
|
2010-12-07 19:14:12 -05:00
|
|
|
if (popupflags & RS_POPUP_MSG)
|
2010-12-05 17:27:50 -05:00
|
|
|
{
|
2011-07-17 19:07:29 -04:00
|
|
|
toaster = new Toaster(new MessageToaster(name, QString::fromUtf8(title.c_str()), QString::fromStdString(msg)));
|
2010-12-05 17:27:50 -05:00
|
|
|
}
|
2010-12-07 19:14:12 -05:00
|
|
|
break;
|
|
|
|
case RS_POPUP_CONNECT:
|
|
|
|
if (popupflags & RS_POPUP_CONNECT)
|
2010-12-05 17:27:50 -05:00
|
|
|
{
|
2011-09-02 06:22:44 -04:00
|
|
|
toaster = new Toaster(new OnlineToaster(id, name));
|
2010-12-05 17:27:50 -05:00
|
|
|
}
|
2009-12-28 17:40:45 -05:00
|
|
|
break;
|
2010-11-24 19:20:25 -05:00
|
|
|
case RS_POPUP_DOWNLOAD:
|
|
|
|
if (popupflags & RS_POPUP_DOWNLOAD)
|
|
|
|
{
|
2010-12-07 19:14:12 -05:00
|
|
|
toaster = new Toaster(new DownloadToaster(id, QString::fromUtf8(title.c_str())));
|
2010-11-24 19:20:25 -05:00
|
|
|
}
|
|
|
|
break;
|
2009-12-28 17:40:45 -05:00
|
|
|
}
|
2010-12-05 17:27:50 -05:00
|
|
|
|
2010-12-07 19:14:12 -05:00
|
|
|
if (toaster) {
|
|
|
|
/* init attributes */
|
|
|
|
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
|
|
|
|
|
|
|
/* add toaster to waiting list */
|
|
|
|
// QMutexLocker lock(&waitingToasterMutex);
|
|
|
|
waitingToasterList.push_back(toaster);
|
|
|
|
}
|
2009-12-28 17:40:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rsNotify->NotifySysMessage(sysid, type, title, msg))
|
|
|
|
{
|
|
|
|
/* make a warning message */
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case RS_SYS_ERROR:
|
2010-12-21 16:13:08 -05:00
|
|
|
QMessageBox::critical(MainWindow::getInstance(),
|
2009-12-28 17:40:45 -05:00
|
|
|
QString::fromStdString(title),
|
|
|
|
QString::fromStdString(msg));
|
|
|
|
break;
|
|
|
|
case RS_SYS_WARNING:
|
2010-12-21 16:13:08 -05:00
|
|
|
QMessageBox::warning(MainWindow::getInstance(),
|
2009-12-28 17:40:45 -05:00
|
|
|
QString::fromStdString(title),
|
|
|
|
QString::fromStdString(msg));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case RS_SYS_INFO:
|
2010-12-21 16:13:08 -05:00
|
|
|
QMessageBox::information(MainWindow::getInstance(),
|
2009-12-28 17:40:45 -05:00
|
|
|
QString::fromStdString(title),
|
|
|
|
QString::fromStdString(msg));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-12-07 19:14:12 -05:00
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
if (rsNotify->NotifyLogMessage(sysid, type, title, msg))
|
|
|
|
{
|
|
|
|
/* make a log message */
|
|
|
|
std::string logMesString = title + " " + msg;
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case RS_SYS_ERROR:
|
|
|
|
case RS_SYS_WARNING:
|
|
|
|
case RS_SYS_INFO: emit logInfoChanged(QString(logMesString.c_str()));
|
|
|
|
default:;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-07 19:14:12 -05:00
|
|
|
|
|
|
|
/* Now start the waiting toasters */
|
|
|
|
startWaitingToasters();
|
|
|
|
|
2010-08-31 16:00:49 -04:00
|
|
|
#endif // MINIMAL_RSGUI
|
2009-12-28 17:40:45 -05:00
|
|
|
}
|
2010-09-07 11:49:31 -04:00
|
|
|
|
|
|
|
void NotifyQt::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType)
|
|
|
|
{
|
|
|
|
emit chatStyleChanged(styleType);
|
|
|
|
}
|
2010-12-07 19:14:12 -05:00
|
|
|
|
|
|
|
void NotifyQt::startWaitingToasters()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// QMutexLocker lock(&waitingToasterMutex);
|
|
|
|
|
|
|
|
if (waitingToasterList.empty()) {
|
|
|
|
/* No toasters are waiting */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// QMutexLocker lock(&runningToasterMutex);
|
|
|
|
|
|
|
|
if (runningToasterList.size() >= 3) {
|
|
|
|
/* Don't show more than 3 toasters at once */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Toaster *toaster = NULL;
|
|
|
|
|
|
|
|
{
|
|
|
|
// QMutexLocker lock(&waitingToasterMutex);
|
|
|
|
|
|
|
|
if (waitingToasterList.size()) {
|
|
|
|
/* Take one toaster of the waiting list */
|
|
|
|
toaster = waitingToasterList.front();
|
|
|
|
waitingToasterList.pop_front();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (toaster) {
|
|
|
|
// QMutexLocker lock(&runningToasterMutex);
|
|
|
|
|
|
|
|
/* Calculate positions */
|
|
|
|
QSize size = toaster->widget->size();
|
|
|
|
|
|
|
|
QDesktopWidget *desktop = QApplication::desktop();
|
|
|
|
QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen());
|
|
|
|
|
2010-12-10 16:49:38 -05:00
|
|
|
RshareSettings::enumToasterPosition position = Settings->getToasterPosition();
|
|
|
|
QPoint margin = Settings->getToasterMargin();
|
|
|
|
|
|
|
|
switch (position) {
|
|
|
|
case RshareSettings::TOASTERPOS_TOPLEFT:
|
|
|
|
toaster->startPos = QPoint(desktopGeometry.left() + margin.x(), desktopGeometry.top() - size.height());
|
|
|
|
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + margin.y());
|
|
|
|
break;
|
|
|
|
case RshareSettings::TOASTERPOS_TOPRIGHT:
|
|
|
|
toaster->startPos = QPoint(desktopGeometry.right() - size.width() - margin.x(), desktopGeometry.top() - size.height());
|
|
|
|
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + margin.y());
|
|
|
|
break;
|
|
|
|
case RshareSettings::TOASTERPOS_BOTTOMLEFT:
|
|
|
|
toaster->startPos = QPoint(desktopGeometry.left() + margin.x(), desktopGeometry.bottom());
|
|
|
|
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - margin.y());
|
|
|
|
break;
|
|
|
|
case RshareSettings::TOASTERPOS_BOTTOMRIGHT: // default
|
|
|
|
default:
|
|
|
|
toaster->startPos = QPoint(desktopGeometry.right() - size.width() - margin.x(), desktopGeometry.bottom());
|
|
|
|
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - margin.y());
|
|
|
|
break;
|
|
|
|
}
|
2010-12-07 19:14:12 -05:00
|
|
|
|
|
|
|
/* Initialize widget */
|
|
|
|
toaster->widget->move(toaster->startPos);
|
|
|
|
|
|
|
|
/* Initialize toaster */
|
|
|
|
toaster->elapsedTimeToShow = 0;
|
|
|
|
toaster->elapsedTimeToLive = 0;
|
|
|
|
toaster->elapsedTimeToHide = 0;
|
|
|
|
|
|
|
|
/* Add toaster to the running list */
|
|
|
|
runningToasterList.push_front(toaster);
|
|
|
|
if (runningToasterTimer->isActive() == false) {
|
|
|
|
/* Start the toaster timer */
|
|
|
|
runningToasterTimer->start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyQt::runningTick()
|
|
|
|
{
|
|
|
|
// QMutexLocker lock(&runningToasterMutex);
|
|
|
|
|
2010-12-09 15:16:05 -05:00
|
|
|
QDesktopWidget *desktop = QApplication::desktop();
|
|
|
|
QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen());
|
|
|
|
|
2010-12-07 19:14:12 -05:00
|
|
|
int interval = runningToasterTimer->interval();
|
|
|
|
QPoint diff;
|
|
|
|
|
|
|
|
QList<Toaster*>::iterator it = runningToasterList.begin();
|
|
|
|
while (it != runningToasterList.end()) {
|
|
|
|
Toaster *toaster = *it;
|
|
|
|
|
2010-12-09 15:16:05 -05:00
|
|
|
bool visible = true;
|
|
|
|
if (toaster->elapsedTimeToShow) {
|
|
|
|
/* Toaster is started, check for visible */
|
|
|
|
visible = toaster->widget->isVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint newPos;
|
|
|
|
enum { NOTHING, SHOW, HIDE } operation = NOTHING;
|
2010-12-07 19:14:12 -05:00
|
|
|
|
|
|
|
if (visible && toaster->elapsedTimeToShow <= toaster->timeToShow) {
|
|
|
|
/* Toaster is showing */
|
2010-12-09 15:16:05 -05:00
|
|
|
if (toaster->elapsedTimeToShow == 0) {
|
|
|
|
/* Toaster is not visible, show it now */
|
|
|
|
operation = SHOW;
|
|
|
|
}
|
2010-12-07 19:14:12 -05:00
|
|
|
|
2010-12-09 15:16:05 -05:00
|
|
|
toaster->elapsedTimeToShow += interval;
|
2010-12-07 19:14:12 -05:00
|
|
|
|
2010-12-09 15:16:05 -05:00
|
|
|
newPos = QPoint(toaster->startPos.x() - (toaster->startPos.x() - toaster->endPos.x()) * toaster->elapsedTimeToShow / toaster->timeToShow,
|
|
|
|
toaster->startPos.y() - (toaster->startPos.y() - toaster->endPos.y()) * toaster->elapsedTimeToShow / toaster->timeToShow);
|
2010-12-07 19:14:12 -05:00
|
|
|
} else if (visible && toaster->elapsedTimeToLive <= toaster->timeToLive) {
|
|
|
|
/* Toaster is living */
|
|
|
|
toaster->elapsedTimeToLive += interval;
|
|
|
|
|
2010-12-09 15:16:05 -05:00
|
|
|
newPos = toaster->endPos;
|
2010-12-07 19:14:12 -05:00
|
|
|
} else if (visible && toaster->elapsedTimeToHide <= toaster->timeToHide) {
|
|
|
|
/* Toaster is hiding */
|
|
|
|
toaster->elapsedTimeToHide += interval;
|
|
|
|
|
2010-12-09 15:16:05 -05:00
|
|
|
if (toaster->elapsedTimeToHide == toaster->timeToHide) {
|
|
|
|
/* Toaster is back at the start position, hide it */
|
|
|
|
operation = HIDE;
|
|
|
|
}
|
2010-12-07 19:14:12 -05:00
|
|
|
|
2010-12-09 15:16:05 -05:00
|
|
|
newPos = QPoint(toaster->startPos.x() - (toaster->startPos.x() - toaster->endPos.x()) * (toaster->timeToHide - toaster->elapsedTimeToHide) / toaster->timeToHide,
|
|
|
|
toaster->startPos.y() - (toaster->startPos.y() - toaster->endPos.y()) * (toaster->timeToHide - toaster->elapsedTimeToHide) / toaster->timeToHide);
|
2010-12-07 19:14:12 -05:00
|
|
|
} else {
|
|
|
|
/* Toaster is hidden, delete it */
|
|
|
|
it = runningToasterList.erase(it);
|
|
|
|
delete(toaster->widget);
|
|
|
|
delete(toaster);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-12-09 15:16:05 -05:00
|
|
|
toaster->widget->move(newPos + diff);
|
|
|
|
diff += newPos - toaster->startPos;
|
|
|
|
|
2010-12-10 16:49:38 -05:00
|
|
|
QRect mask = QRect(0, 0, toaster->widget->width(), qAbs(toaster->startPos.y() - newPos.y()));
|
|
|
|
if (newPos.y() > toaster->startPos.y()) {
|
|
|
|
/* Toaster is moving from top */
|
|
|
|
mask.moveTop(toaster->widget->height() - (newPos.y() - toaster->startPos.y()));
|
|
|
|
}
|
|
|
|
toaster->widget->setMask(QRegion(mask));
|
2010-12-09 15:16:05 -05:00
|
|
|
|
|
|
|
switch (operation) {
|
|
|
|
case NOTHING:
|
|
|
|
break;
|
|
|
|
case SHOW:
|
|
|
|
toaster->widget->show();
|
|
|
|
break;
|
|
|
|
case HIDE:
|
|
|
|
toaster->widget->hide();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-12-07 19:14:12 -05:00
|
|
|
++it;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (runningToasterList.size()) {
|
|
|
|
/* There are more running toasters, start the timer again */
|
|
|
|
runningToasterTimer->start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
//void NotifyQt::displaySearch()
|
|
|
|
//{
|
|
|
|
// iface->lockData(); /* Lock Interface */
|
|
|
|
//
|
|
|
|
//#ifdef NOTIFY_DEBUG
|
|
|
|
// std::ostringstream out;
|
|
|
|
// std::cerr << out.str();
|
|
|
|
//#endif
|
|
|
|
//
|
|
|
|
// iface->unlockData(); /* UnLock Interface */
|
|
|
|
//}
|
|
|
|
|
|
|
|
// void NotifyQt::displayChat()
|
|
|
|
// {
|
|
|
|
// iface->lockData(); /* Lock Interface */
|
|
|
|
//
|
|
|
|
// #ifdef NOTIFY_DEBUG
|
|
|
|
// std::ostringstream out;
|
|
|
|
// std::cerr << out.str();
|
|
|
|
// #endif
|
|
|
|
//
|
|
|
|
// iface->unlockData(); /* UnLock Interface */
|
|
|
|
//
|
|
|
|
// if (hDialog)
|
|
|
|
// hDialog -> insertChat();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//void NotifyQt::displayChannels()
|
|
|
|
//{
|
|
|
|
// iface->lockData(); /* Lock Interface */
|
|
|
|
//
|
|
|
|
//#ifdef NOTIFY_DEBUG
|
|
|
|
// std::ostringstream out;
|
|
|
|
// std::cerr << out.str();
|
|
|
|
//#endif
|
|
|
|
//
|
|
|
|
// iface->unlockData(); /* UnLock Interface */
|
|
|
|
//
|
|
|
|
// if (sDialog)
|
|
|
|
// sDialog -> insertChannels();
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//void NotifyQt::displayTransfers()
|
|
|
|
//{
|
|
|
|
// /* Do the GUI */
|
|
|
|
// if (tDialog)
|
|
|
|
// tDialog->insertTransfers();
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//void NotifyQt::preDisplayNeighbours()
|
|
|
|
//{
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void NotifyQt::preDisplayFriends()
|
|
|
|
//{
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
|
|
|
|
//void NotifyQt::preDisplaySearch()
|
|
|
|
//{
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void NotifyQt::preDisplayMessages()
|
|
|
|
//{
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void NotifyQt::preDisplayChannels()
|
|
|
|
//{
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void NotifyQt::preDisplayTransfers()
|
|
|
|
//{
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//}
|