mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-16 18:07:11 -05:00
24a3fb58d4
- the user is asked at start wether to load or deny unregistered plugins, but can make it mind later in config->plugins - added API and SVN numbers into required external plugin symbols - user-defined plugin rules are dropped when a plugin changes (hash changes) or when the main executable changes. - added new status flags (Plugin denied, missing API/SVN numbers) - modified saveList()/loadList() to allow saving a list of rejected plugins as well. - added methods in notifyBase and inherited classes to ask for plugin confirmation. - adapted VOIP plugin to follow these new rules (API+SVN numbers). Other plugins should be adapted as well by addign the missing symbols (RETROSHARE_PLUGIN_api and RETROSHARE_PLUGIN_revision). git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5529 b45a01b8-16f6-495d-af2f-9b41ad6348cc
234 lines
4.8 KiB
C++
234 lines
4.8 KiB
C++
/*
|
|
* "$Id: notifytxt.cc,v 1.1 2007-02-19 20:08:30 rmf24 Exp $"
|
|
*
|
|
* RetroShare C++ Interface.
|
|
*
|
|
* Copyright 2004-2006 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 <stdio.h>
|
|
#include "notifytxt.h"
|
|
#include <retroshare/rspeers.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#include <iostream>
|
|
#include <sstream>
|
|
|
|
#ifdef WINDOWS_SYS
|
|
#include <conio.h>
|
|
#include <stdio.h>
|
|
|
|
#define PASS_MAX 512
|
|
|
|
char *getpass (const char *prompt)
|
|
{
|
|
static char getpassbuf [PASS_MAX + 1];
|
|
size_t i = 0;
|
|
int c;
|
|
|
|
if (prompt) {
|
|
fputs (prompt, stderr);
|
|
fflush (stderr);
|
|
}
|
|
|
|
for (;;) {
|
|
c = _getch ();
|
|
if (c == '\r') {
|
|
getpassbuf [i] = '\0';
|
|
break;
|
|
}
|
|
else if (i < PASS_MAX) {
|
|
getpassbuf[i++] = c;
|
|
}
|
|
|
|
if (i >= PASS_MAX) {
|
|
getpassbuf [i] = '\0';
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (prompt) {
|
|
fputs ("\r\n", stderr);
|
|
fflush (stderr);
|
|
}
|
|
|
|
return getpassbuf;
|
|
}
|
|
#endif
|
|
|
|
void NotifyTxt::notifyErrorMsg(int list, int type, std::string msg)
|
|
{
|
|
return;
|
|
}
|
|
|
|
void NotifyTxt::notifyChat()
|
|
{
|
|
return;
|
|
}
|
|
|
|
bool NotifyTxt::askForPluginConfirmation(const std::string& plugin_file_name, const std::string& plugin_file_hash)
|
|
{
|
|
std::cerr << "The following plugin is not registered as accepted or denied. You probably upgraded the main executable or the plugin itself." << std::endl;
|
|
std::cerr << " Hash: " << plugin_file_hash << std::endl;
|
|
std::cerr << " File: " << plugin_file_name << std::endl;
|
|
|
|
char a = 0 ;
|
|
while(a != 'y' && a != 'n')
|
|
{
|
|
std::cerr << "Enable this plugin ? (y/n) :" ;
|
|
std::cerr.flush() ;
|
|
|
|
a = fgetc(stdin) ;
|
|
}
|
|
return a == 'y' ;
|
|
}
|
|
|
|
bool NotifyTxt::askForPassword(const std::string& key_details, bool prev_is_bad, std::string& password)
|
|
{
|
|
char *passwd = getpass(("Please enter GPG password for key "+key_details+": ").c_str()) ;
|
|
password = passwd;
|
|
|
|
return !password.empty();
|
|
}
|
|
|
|
|
|
void NotifyTxt::notifyListChange(int list, int type)
|
|
{
|
|
std::cerr << "NotifyTxt::notifyListChange()" << std::endl;
|
|
switch(list)
|
|
{
|
|
// case NOTIFY_LIST_NEIGHBOURS:
|
|
// displayNeighbours();
|
|
// break;
|
|
case NOTIFY_LIST_FRIENDS:
|
|
displayFriends();
|
|
break;
|
|
case NOTIFY_LIST_DIRLIST_FRIENDS:
|
|
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 NotifyTxt::displayNeighbours()
|
|
{
|
|
std::list<std::string> neighs;
|
|
std::list<std::string>::iterator it;
|
|
|
|
rsPeers->getGPGAllList(neighs);
|
|
|
|
std::ostringstream out;
|
|
for(it = neighs.begin(); it != neighs.end(); it++)
|
|
{
|
|
RsPeerDetails detail;
|
|
rsPeers->getPeerDetails(*it, detail);
|
|
|
|
out << "Neighbour: ";
|
|
out << detail;
|
|
out << std::endl;
|
|
}
|
|
std::cerr << out.str();
|
|
}
|
|
|
|
void NotifyTxt::displayFriends()
|
|
{
|
|
std::list<std::string> ids;
|
|
std::list<std::string>::iterator it;
|
|
|
|
rsPeers->getFriendList(ids);
|
|
|
|
std::ostringstream out;
|
|
for(it = ids.begin(); it != ids.end(); it++)
|
|
{
|
|
RsPeerDetails detail;
|
|
rsPeers->getPeerDetails(*it, detail);
|
|
|
|
out << "Neighbour: ";
|
|
out << detail;
|
|
out << std::endl;
|
|
}
|
|
std::cerr << out.str();
|
|
}
|
|
|
|
void NotifyTxt::displayDirectories()
|
|
{
|
|
iface->lockData(); /* Lock Interface */
|
|
|
|
std::ostringstream out;
|
|
std::cerr << out.str();
|
|
|
|
iface->unlockData(); /* UnLock Interface */
|
|
}
|
|
|
|
|
|
void NotifyTxt::displaySearch()
|
|
{
|
|
iface->lockData(); /* Lock Interface */
|
|
|
|
std::ostringstream out;
|
|
std::cerr << out.str();
|
|
|
|
iface->unlockData(); /* UnLock Interface */
|
|
}
|
|
|
|
|
|
void NotifyTxt::displayMessages()
|
|
{
|
|
iface->lockData(); /* Lock Interface */
|
|
iface->unlockData(); /* UnLock Interface */
|
|
}
|
|
|
|
void NotifyTxt::displayChannels()
|
|
{
|
|
iface->lockData(); /* Lock Interface */
|
|
|
|
std::ostringstream out;
|
|
std::cerr << out.str();
|
|
|
|
iface->unlockData(); /* UnLock Interface */
|
|
}
|
|
|
|
|
|
void NotifyTxt::displayTransfers()
|
|
{
|
|
iface->lockData(); /* Lock Interface */
|
|
|
|
std::ostringstream out;
|
|
std::cerr << out.str();
|
|
|
|
iface->unlockData(); /* UnLock Interface */
|
|
}
|
|
|