Improved the bootstrap Stun system.

* searching for STUN ID's continues until RS_STUN_FOUND_MIN are found (10).
 * abandon STUN search if Ext or Upnp mode.
 * add Bootstrap IDs to rear of mStunList. (bugfix)

Force saving of certificates after "oldFormat" loading.
Corrected printStunList() fn call.

Added a notification system: 
 (1) libretroshare System Notifications.
 	- System notification if Firewall Status is bad.
 (2) PopUp messages.
 	- Popup for a connected peer.
 	- Popup for a new message.
 * New interface (to be revised).



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@376 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-03-05 16:32:18 +00:00
parent 08860b25e6
commit 0bdc3522a6
13 changed files with 579 additions and 26 deletions

View file

@ -11,6 +11,7 @@ RSOBJ = p3peers.o \
p3rank.o \
p3photo.o \
p3msgs.o \
p3notify.o \
p3discovery.o \
p3face-file.o \
p3face-server.o \

View file

@ -58,6 +58,7 @@
/* Implemented Rs Interfaces */
#include "rsserver/p3face.h"
#include "rsserver/p3notify.h"
#include "rsserver/p3peers.h"
#include "rsserver/p3rank.h"
#include "rsserver/p3msgs.h"
@ -482,6 +483,9 @@ int RsServer::StartupRetroShare(RsInit *config)
/* setup classes / structures */
/**************************************************************************/
/* Setup Notify Early - So we can use it. */
rsNotify = new p3Notify();
mConnMgr = new p3ConnectMgr(mAuthMgr);
p3UpnpMgr *mUpnpMgr = new upnphandler();
p3DhtMgr *mDhtMgr = new OpenDHTMgr(ownId, mConnMgr, config->basedir);
@ -675,6 +679,7 @@ int RsServer::StartupRetroShare(RsInit *config)
rsDisc = new p3Discovery(ad);
rsPhoto = new p3Photo(photoService);
/* put a welcome message in! */
if (config->firsttime_run)
{

View file

@ -0,0 +1,129 @@
/*
* libretroshare/src/rsserver: p3notify.cc
*
* RetroShare C++ Interface.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "rsserver/p3notify.h"
/* external reference point */
RsNotify *rsNotify = NULL;
/* Output for retroshare-gui */
bool p3Notify::NotifySysMessage(uint32_t &sysid, uint32_t &type,
std::string &title, std::string &msg)
{
RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/
if (pendingSysMsgs.size() > 0)
{
p3NotifySysMsg smsg = pendingSysMsgs.front();
pendingSysMsgs.pop_front();
sysid = smsg.sysid;
type = smsg.type;
title = smsg.title;
msg = smsg.msg;
return true;
}
return false;
}
bool p3Notify::NotifyPopupMessage(uint32_t &ptype, std::string &name, std::string &msg)
{
RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/
if (pendingPopupMsgs.size() > 0)
{
p3NotifyPopupMsg pmsg = pendingPopupMsgs.front();
pendingPopupMsgs.pop_front();
ptype = pmsg.type;
name = pmsg.name;
msg = pmsg.msg;
return true;
}
return false;
}
/* Control over Messages */
bool p3Notify::GetSysMessageList(std::map<uint32_t, std::string> &list)
{
return false;
}
bool p3Notify::GetPopupMessageList(std::map<uint32_t, std::string> &list)
{
return false;
}
bool p3Notify::SetSysMessageMode(uint32_t sysid, uint32_t mode)
{
return false;
}
bool p3Notify::SetPopupMessageMode(uint32_t ptype, uint32_t mode)
{
return false;
}
/* Input from libretroshare */
bool p3Notify::AddPopupMessage(uint32_t ptype, std::string name, std::string msg)
{
RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/
p3NotifyPopupMsg pmsg;
pmsg.type = ptype;
pmsg.name = name;
pmsg.msg = msg;
pendingPopupMsgs.push_back(pmsg);
return true;
}
bool p3Notify::AddSysMessage(uint32_t sysid, uint32_t type,
std::string title, std::string msg)
{
RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/
p3NotifySysMsg smsg;
smsg.sysid = sysid;
smsg.type = type;
smsg.title = title;
smsg.msg = msg;
pendingSysMsgs.push_back(smsg);
return true;
}

View file

@ -0,0 +1,85 @@
#ifndef RS_P3_NOTIFY_INTERFACE_H
#define RS_P3_NOTIFY_INTERFACE_H
/*
* libretroshare/src/rsserver: p3notify.h
*
* RetroShare C++ Interface.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "rsiface/rsnotify.h"
#include "util/rsthreads.h"
class p3NotifySysMsg
{
public:
uint32_t sysid;
uint32_t type;
std::string title;
std::string msg;
};
class p3NotifyPopupMsg
{
public:
uint32_t type;
std::string name;
std::string msg;
};
class p3Notify: public RsNotify
{
public:
p3Notify() { return; }
virtual ~p3Notify() { return; }
/* Output for retroshare-gui */
virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type,
std::string &title, std::string &msg);
virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, std::string &msg);
/* Control over Messages */
virtual bool GetSysMessageList(std::map<uint32_t, std::string> &list);
virtual bool GetPopupMessageList(std::map<uint32_t, std::string> &list);
virtual bool SetSysMessageMode(uint32_t sysid, uint32_t mode);
virtual bool SetPopupMessageMode(uint32_t ptype, uint32_t mode);
/* Input from libretroshare */
virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string msg);
virtual bool AddSysMessage(uint32_t sysid, uint32_t type,
std::string title, std::string msg);
private:
RsMutex noteMtx;
std::list<p3NotifySysMsg> pendingSysMsgs;
std::list<p3NotifyPopupMsg> pendingPopupMsgs;
};
#endif