2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
#include "rsiface/notifyqt.h"
|
2008-03-05 11:32:18 -05:00
|
|
|
#include "rsiface/rsnotify.h"
|
|
|
|
#include "rsiface/rspeers.h"
|
2008-03-17 10:03:47 -04:00
|
|
|
#include "rsiface/rsphoto.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
#include "gui/NetworkDialog.h"
|
|
|
|
#include "gui/PeersDialog.h"
|
|
|
|
#include "gui/SharedFilesDialog.h"
|
|
|
|
#include "gui/TransfersDialog.h"
|
|
|
|
#include "gui/ChatDialog.h"
|
|
|
|
#include "gui/MessagesDialog.h"
|
|
|
|
#include "gui/ChannelsDialog.h"
|
|
|
|
#include "gui/MessengerWindow.h"
|
|
|
|
|
2008-08-08 15:47:50 -04:00
|
|
|
#include "gui/toaster/OnlineToaster.h"
|
2008-03-05 11:32:18 -05:00
|
|
|
#include "gui/toaster/MessageToaster.h"
|
|
|
|
#include "gui/toaster/ChatToaster.h"
|
|
|
|
#include "gui/toaster/CallToaster.h"
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
/*****
|
|
|
|
* #define NOTIFY_DEBUG
|
|
|
|
****/
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
void NotifyQt::notifyErrorMsg(int list, int type, std::string msg)
|
|
|
|
{
|
|
|
|
(void) list;
|
|
|
|
(void) type;
|
|
|
|
(void) msg;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyQt::notifyChat()
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyQt::notifyListChange(int list, int type)
|
|
|
|
{
|
|
|
|
(void) type;
|
2008-07-09 05:53:47 -04:00
|
|
|
|
|
|
|
#ifdef NOTIFY_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "NotifyQt::notifyListChange()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
switch(list)
|
|
|
|
{
|
|
|
|
case NOTIFY_LIST_NEIGHBOURS:
|
|
|
|
//displayNeighbours();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_FRIENDS:
|
|
|
|
//displayFriends();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_DIRLIST:
|
|
|
|
displayDirectories();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_SEARCHLIST:
|
|
|
|
//displaySearch();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_MESSAGELIST:
|
|
|
|
//displayMessages();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_CHANNELLIST:
|
|
|
|
//displayChannels();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_TRANSFERLIST:
|
|
|
|
//displayTransfers();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NotifyQt::notifyListPreChange(int list, int type)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "NotifyQt::notifyListPreChange()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
switch(list)
|
|
|
|
{
|
|
|
|
case NOTIFY_LIST_NEIGHBOURS:
|
|
|
|
//preDisplayNeighbours();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_FRIENDS:
|
|
|
|
//preDisplayFriends();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_DIRLIST:
|
|
|
|
preDisplayDirectories();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_SEARCHLIST:
|
|
|
|
//preDisplaySearch();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_MESSAGELIST:
|
|
|
|
//preDisplayMessages();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_CHANNELLIST:
|
|
|
|
//preDisplayChannels();
|
|
|
|
break;
|
|
|
|
case NOTIFY_LIST_TRANSFERLIST:
|
|
|
|
//preDisplayTransfers();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* New Timer Based Update scheme ...
|
|
|
|
* means correct thread seperation
|
|
|
|
*
|
|
|
|
* uses Flags, to detect changes
|
|
|
|
*/
|
|
|
|
|
|
|
|
void NotifyQt::UpdateGUI()
|
|
|
|
{
|
|
|
|
iface->lockData(); /* Lock Interface */
|
|
|
|
|
|
|
|
/* make local -> so we can release iface */
|
|
|
|
bool uNeigh = iface->hasChanged(RsIface::Neighbour);
|
|
|
|
bool uFri = iface->hasChanged(RsIface::Friend);
|
|
|
|
bool uTrans = iface->hasChanged(RsIface::Transfer);
|
2008-04-05 08:14:49 -04:00
|
|
|
//bool uChat = iface->hasChanged(RsIface::Chat);
|
2007-11-14 22:18:48 -05:00
|
|
|
bool uMsg = iface->hasChanged(RsIface::Message);
|
|
|
|
bool uChan = iface->hasChanged(RsIface::Channel);
|
|
|
|
bool uRecom = iface->hasChanged(RsIface::Recommend);
|
|
|
|
bool uConf = iface->hasChanged(RsIface::Config);
|
|
|
|
|
|
|
|
iface->unlockData(); /* UnLock Interface */
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
/* hack to force updates until we've fixed that part */
|
|
|
|
static time_t lastTs = 0;
|
|
|
|
|
|
|
|
if (time(NULL) > lastTs + 5)
|
|
|
|
{
|
|
|
|
lastTs = time(NULL);
|
|
|
|
|
|
|
|
uNeigh = true;
|
|
|
|
uFri = true;
|
|
|
|
uTrans = true;
|
2008-04-05 08:14:49 -04:00
|
|
|
//uChat = true;
|
2008-01-25 03:49:40 -05:00
|
|
|
uMsg = true;
|
|
|
|
uChan = true;
|
|
|
|
uRecom = true;
|
|
|
|
uConf = true;
|
|
|
|
}
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
if (uNeigh)
|
|
|
|
displayNeighbours();
|
|
|
|
|
|
|
|
if (uFri)
|
|
|
|
displayFriends();
|
|
|
|
|
|
|
|
if (uTrans)
|
|
|
|
displayTransfers();
|
|
|
|
|
2008-04-05 08:14:49 -04:00
|
|
|
//if (uChat)
|
|
|
|
// displayChat();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
if (uMsg)
|
|
|
|
displayMessages();
|
|
|
|
|
|
|
|
if (uChan)
|
|
|
|
displayChannels();
|
|
|
|
|
|
|
|
/* TODO
|
|
|
|
if (uRecom)
|
|
|
|
displayRecommends();
|
|
|
|
|
|
|
|
if (uConf)
|
|
|
|
displayConfig();
|
|
|
|
*/
|
|
|
|
|
2008-03-05 11:32:18 -05:00
|
|
|
/* Finally Check for PopupMessages / System Error Messages */
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-03-05 11:32:18 -05:00
|
|
|
if (rsNotify)
|
|
|
|
{
|
|
|
|
uint32_t sysid;
|
|
|
|
uint32_t type;
|
|
|
|
std::string title, id, msg;
|
|
|
|
|
|
|
|
if (rsNotify->NotifyPopupMessage(type, id, msg))
|
|
|
|
{
|
|
|
|
/* id the name */
|
|
|
|
std::string name = rsPeers->getPeerName(id);
|
|
|
|
std::string realmsg = msg + name;
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case RS_POPUP_MSG:
|
|
|
|
{
|
|
|
|
MessageToaster * msgToaster = new MessageToaster();
|
|
|
|
msgToaster->setMessage(QString::fromStdString(realmsg));
|
|
|
|
msgToaster->show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case RS_POPUP_CHAT:
|
|
|
|
{
|
|
|
|
ChatToaster * chatToaster = new ChatToaster();
|
|
|
|
chatToaster->setMessage(QString::fromStdString(realmsg));
|
|
|
|
chatToaster->show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case RS_POPUP_CALL:
|
|
|
|
{
|
|
|
|
CallToaster * callToaster = new CallToaster();
|
|
|
|
callToaster->setMessage(QString::fromStdString(realmsg));
|
|
|
|
callToaster->show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
case RS_POPUP_CONNECT:
|
|
|
|
{
|
2008-08-08 15:47:50 -04:00
|
|
|
OnlineToaster * onlineToaster = new OnlineToaster();
|
|
|
|
onlineToaster->setMessage(QString::fromStdString(realmsg));
|
|
|
|
onlineToaster->show();
|
2008-03-05 11:32:18 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rsNotify->NotifySysMessage(sysid, type, title, msg))
|
|
|
|
{
|
|
|
|
/* make a warning message */
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case RS_SYS_ERROR:
|
|
|
|
QMessageBox::critical(0,
|
|
|
|
QString::fromStdString(title),
|
|
|
|
QString::fromStdString(msg));
|
|
|
|
break;
|
|
|
|
case RS_SYS_WARNING:
|
|
|
|
QMessageBox::warning(0,
|
|
|
|
QString::fromStdString(title),
|
|
|
|
QString::fromStdString(msg));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case RS_SYS_INFO:
|
|
|
|
QMessageBox::information(0,
|
|
|
|
QString::fromStdString(title),
|
|
|
|
QString::fromStdString(msg));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
void NotifyQt::displayNeighbours()
|
|
|
|
{
|
|
|
|
/* Do the GUI */
|
|
|
|
if (cDialog)
|
|
|
|
cDialog->insertConnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyQt::displayFriends()
|
|
|
|
{
|
|
|
|
if (pDialog)
|
|
|
|
pDialog->insertPeers();
|
|
|
|
if (mWindow)
|
|
|
|
mWindow->insertPeers();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void NotifyQt::preDisplayDirectories()
|
|
|
|
{
|
|
|
|
//iface->lockData(); /* Lock Interface */
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::ostringstream out;
|
|
|
|
out << "NotifyQt::preDisplayDirectories()" << std::endl;
|
|
|
|
|
|
|
|
std::cerr << out.str();
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
//iface->unlockData(); /* UnLock Interface */
|
|
|
|
|
|
|
|
if (dDialog)
|
|
|
|
{
|
|
|
|
dDialog->preModDirectories(false); /* Remote */
|
|
|
|
dDialog->preModDirectories(true); /* Local */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NotifyQt::displayDirectories()
|
|
|
|
{
|
|
|
|
//iface->lockData(); /* Lock Interface */
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::ostringstream out;
|
|
|
|
out << "NotifyQt::displayDirectories()" << std::endl;
|
|
|
|
|
|
|
|
std::cerr << out.str();
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
//iface->unlockData(); /* UnLock Interface */
|
|
|
|
|
|
|
|
|
|
|
|
if (dDialog)
|
|
|
|
{
|
|
|
|
dDialog->ModDirectories(false); /* Remote */
|
|
|
|
dDialog->ModDirectories(true); /* Local */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NotifyQt::displaySearch()
|
|
|
|
{
|
|
|
|
iface->lockData(); /* Lock Interface */
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::ostringstream out;
|
|
|
|
std::cerr << out.str();
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
iface->unlockData(); /* UnLock Interface */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NotifyQt::displayMessages()
|
|
|
|
{
|
|
|
|
if (mDialog)
|
|
|
|
mDialog -> insertMessages();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotifyQt::displayChat()
|
|
|
|
{
|
|
|
|
iface->lockData(); /* Lock Interface */
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::ostringstream out;
|
|
|
|
std::cerr << out.str();
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
iface->unlockData(); /* UnLock Interface */
|
|
|
|
|
|
|
|
if (hDialog)
|
|
|
|
hDialog -> insertChat();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NotifyQt::displayChannels()
|
|
|
|
{
|
|
|
|
iface->lockData(); /* Lock Interface */
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NOTIFY_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::ostringstream out;
|
|
|
|
std::cerr << out.str();
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|