diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/Doxyfile b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/Doxyfile new file mode 100644 index 000000000..9e3f2c382 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/Doxyfile @@ -0,0 +1,283 @@ +# Doxyfile 1.5.1-KDevelop + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = qt_chat +PROJECT_NUMBER = 0.1 +OUTPUT_DIRECTORY = +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = /home/normal/ +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = NO +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = /home/normal/c++/qt_chat +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py \ + *.C \ + *.CC \ + *.C++ \ + *.II \ + *.I++ \ + *.H \ + *.HH \ + *.H++ \ + *.CS \ + *.PHP \ + *.PHP3 \ + *.M \ + *.MM \ + *.PY \ + *.C \ + *.H \ + *.tlh \ + *.diff \ + *.patch \ + *.moc \ + *.xpm \ + *.dox +RECURSIVE = yes +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = yes +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = qt_chat.tag +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 1000 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/I2PMessengerPlugin.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/I2PMessengerPlugin.cpp new file mode 100644 index 000000000..4f7e0c0e0 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/I2PMessengerPlugin.cpp @@ -0,0 +1,31 @@ +//#include +//#include +//#include + +#include "I2PMessengerPlugin.h" +#include "gui/form_Main.h" + +QString +I2PMessengerPlugin::pluginDescription() const +{ + QString res; + res = "A I2P Messenger plugin" ; + + return res; +} + +QString +I2PMessengerPlugin::pluginName() const +{ + return "I2P Messenger" ; +} + +QWidget* +I2PMessengerPlugin::pluginWidget(QWidget * parent ) +{ + form_MainWindow* mainForm= new form_MainWindow(); + return mainForm; +} + + +Q_EXPORT_PLUGIN2(i2pmessenger_plugin, I2PMessengerPlugin) diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/I2PMessengerPlugin.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/I2PMessengerPlugin.h new file mode 100644 index 000000000..a989d6c3f --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/I2PMessengerPlugin.h @@ -0,0 +1,27 @@ +#ifndef _HWA_PLUGIN_H_ +#define _HWA_PLUGIN_H_ + +#include + +#include +#include + +#include + +#include + +class I2PMessengerPlugin: public QObject, public PluginInterface +{ + Q_OBJECT + Q_INTERFACES(PluginInterface) + + public slots: + + virtual QString pluginDescription() const ; + virtual QString pluginName() const ; + + virtual QWidget* pluginWidget(QWidget * parent = 0) ; + +}; + +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/about.html b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/about.html new file mode 100644 index 000000000..4edcea111 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/about.html @@ -0,0 +1,16 @@ + + + + + +
+

+ +
+Applicationversion:	[APPVERSIONSTRING]
+Protocolversion:	[PROTOCOLVERSIONSTRING]
+	
+
+
+ + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/application.ini b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/application.ini new file mode 100644 index 000000000..181cda3d7 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/application.ini @@ -0,0 +1,18 @@ +[%General] +Debug_Max_Message_count=99 +Waittime_between_rechecking_offline_users=30000 +current_Style=Plastique +current_Style_sheet=Default + +[Network] +Destination=test +SamHost=192.168.0.1 +SamPort=7656 +SessionOptionString="inbound.nickname=I2PChat inbound.quantity=1 inbound.backupQuantity=1 inbound.length=1 outbound.quantity=1 outbound.backupQuantity=1 outbound.length=1" +TunnelName=I2PChat +inbound.backupQuantity=1 +inbound.length=1 +inbound.quantity=1 +outbound.backupQuantity=1 +outbound.length=1 +outbound.quantity=1 diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_DebugMessages.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_DebugMessages.cpp new file mode 100644 index 000000000..be6b181c6 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_DebugMessages.cpp @@ -0,0 +1,76 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "form_DebugMessages.h" + +form_DebugMessages::form_DebugMessages(cCore* core,QDialog *parent){ + setupUi(this); + this->setAttribute(Qt::WA_DeleteOnClose,true); + + this->core=core; + this->DebugMessageManager=core->get_DebugMessageHandler(); + + connect(cmd_clear,SIGNAL(clicked() ),this,SLOT(clearDebugMessages())); + connect(DebugMessageManager,SIGNAL(newDebugMessage(QString) ),this,SLOT(newDebugMessage( QString))); + connect(cmd_connectionDump,SIGNAL(clicked()),this, + SLOT(connectionDump())); + + newDebugMessage(""); +} + +form_DebugMessages::~form_DebugMessages() +{ +} + +void form_DebugMessages::connectionDump() +{ + QString Message=core->get_connectionDump(); + + QMessageBox* msgBox= new QMessageBox(this); + msgBox->setIcon(QMessageBox::Information); + msgBox->setText("DebugInformations fromCore"); + msgBox->setInformativeText(Message); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); +} + + + + + +void form_DebugMessages::newDebugMessage(QString Message) +{ + textEdit->clear(); + + QStringList temp=DebugMessageManager->getAllMessages(); + for(int i=0;itextEdit->append(temp[i]); + } + + QTextCursor cursor = textEdit->textCursor(); + cursor.movePosition(QTextCursor::Start); + textEdit->setTextCursor(cursor); + +} +void form_DebugMessages::clearDebugMessages(){ + DebugMessageManager->clearAllMessages(); + textEdit->clear(); +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_DebugMessages.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_DebugMessages.h new file mode 100644 index 000000000..60184ee3f --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_DebugMessages.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef FORM_DEBUGMESSAGES_H +#define FORM_DEBUGMESSAGES_H + +#include +#include "ui_form_DebugMessages.h" +#include "src/Core.h" +#include "src/DebugMessageManager.h" + +class form_DebugMessages : public QDialog, private Ui::form_DebugMessages +{ + Q_OBJECT + public: + form_DebugMessages(cCore* core,QDialog *parent = 0); + ~form_DebugMessages(); + + private slots: + void newDebugMessage(QString Message); + void clearDebugMessages(); + void connectionDump(); + + private: + cCore* core; + cDebugMessageManager* DebugMessageManager; +}; +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_DebugMessages.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_DebugMessages.ui new file mode 100644 index 000000000..fae069100 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_DebugMessages.ui @@ -0,0 +1,77 @@ + + form_DebugMessages + + + + 0 + 0 + 400 + 300 + + + + DebugMessages + + + + 9 + + + 6 + + + + + + + + 6 + + + 0 + + + + + ConnectionDump + + + + + + + &Clear + + + + + + + C&lose + + + + + + + + + + + cmd_close + clicked() + form_DebugMessages + close() + + + 296 + 276 + + + 199 + 149 + + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.cpp new file mode 100644 index 000000000..bc521c675 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.cpp @@ -0,0 +1,77 @@ +/**************************************************************** + * I2P Messenger is distributed under the following license: + * + * Copyright (C) 2009, I2P Messenger + * + * 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 "form_HelpDialog.h" + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + + +form_HelpDialog::form_HelpDialog(QString ProgrammVersion,QString ProtocolVersion,QWidget *parent) +:QDialog(parent) +{ + + ui.setupUi(this); + this->setAttribute(Qt::WA_DeleteOnClose,true); + + QString tmp; + + + + QFile aboutFile(QString(QApplication::applicationDirPath()+"/about.html")); + if (aboutFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&aboutFile); + tmp=in.readAll(); + tmp.replace("[APPVERSIONSTRING]",ProgrammVersion); + tmp.replace("[PROTOCOLVERSIONSTRING]",ProtocolVersion); + ui.about->setText(tmp); + } + +/* + QFile authorsFile(QLatin1String(":/authors.html")); + if (authorsFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&authorsFile); + ui.authors->setText(in.readAll()); + } + QFile thanksFile(QLatin1String(":/thanks.html")); + if (thanksFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&thanksFile); + ui.thanks->setText(in.readAll()); + } + */ + //ui.authors->setText + + + ui.label_2->setMinimumWidth(20); +} + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.h new file mode 100644 index 000000000..f0d9ff549 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.h @@ -0,0 +1,43 @@ +/**************************************************************** + * I2P Messenger is distributed under the following license: + * + * Copyright (C) 2009, I2P Messenger + * + * 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. + ****************************************************************/ + +#ifndef _HELPDIALOG_H +#define _HELPDIALOG_H + +#include + +#include "ui_form_HelpDialog.h" + + +class form_HelpDialog : public QDialog +{ + Q_OBJECT + +public: + form_HelpDialog(QString ProgrammVersion,QString ProtocolVersion,QWidget *parent = 0); +private slots: + +private: + Ui::form_HelpDialog ui; +}; + +#endif + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.ui new file mode 100644 index 000000000..6b0ea94bf --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.ui @@ -0,0 +1,684 @@ + + form_HelpDialog + + + + 0 + 0 + 501 + 328 + + + + + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 0 + 0 + 0 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + 104 + 104 + 104 + + + + + + + 208 + 208 + 208 + + + + + + + 255 + 255 + 255 + + + + + + + 247 + 247 + 247 + + + + + + + 104 + 104 + 104 + + + + + + + 139 + 139 + 139 + + + + + + + 104 + 104 + 104 + + + + + + + 255 + 255 + 255 + + + + + + + 104 + 104 + 104 + + + + + + + 240 + 240 + 240 + + + + + + + 240 + 240 + 240 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 231 + 231 + 231 + + + + + + + + + Arial + 8 + 50 + false + false + false + false + + + + Qt::NoContextMenu + + + + 0 + + + 0 + + + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + 6 + + + + + + + + :/images/info16.png + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:9pt; font-weight:600;">About I2P Messenger</span></p></body></html> + + + + + + + + + + + 0 + + + + About + + + + 9 + + + 6 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> +<p align="justify" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:1; text-indent:0px;"></p></body></html> + + + true + + + + + + + + Authors + + + + 6 + + + 9 + + + + + false + + + QTextEdit::NoWrap + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> + + + false + + + Qt::TextBrowserInteraction + + + + + + + + Thanks to + + + + 6 + + + 9 + + + + + false + + + QTextEdit::NoWrap + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> + + + false + + + Qt::TextBrowserInteraction + + + + + + + + + + + authors + tabWidget + + + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.cpp new file mode 100644 index 000000000..f28da593e --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.cpp @@ -0,0 +1,546 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include + +#include "form_Main.h" + +/*Icons */ +#define ICON_QUIT ":/icons/exit.png" +#define ICON_MINIMIZE ":/icons/window_nofullscreen.png" +#define ICON_MAXIMIZE ":/icons/window_fullscreen.png" +#define ICON_QTCHAT ":/icons/userblue24.png" +#define ICON_CLOSE ":/icons/exit.png" +#define ICON_NEWUSER ":/icons/add_user.png" +#define ICON_SETTINGS ":/icons/settings.png" +#define ICON_NEWUNREADMESSAGE ":/icons/send.png" +#define ICON_USER_TRYTOCONNECT ":/icons/yellow.png" +#define ICON_USER_OFFLINE ":/icons/red.png" +#define ICON_USER_ONLINE ":/icons/green.png" +#define ICON_USER_WANTTOCHAT ":/icons/chatty.png" +#define ICON_USER_AWAY ":/icons/xa.png" +#define ICON_USER_DONT_DUSTURB ":/icons/dnd.png" +#define ICON_USER_INVISIBLE ":/icons/invisible.png" +#define ICON_DEBUGMESSAGES ":/icons/status_unknown.png" +#define ICON_MYDESTINATION ":/icons/editcopy.png" +#define ICON_ABOUT ":/icons/about.png" + +form_MainWindow::form_MainWindow(QWidget* parent) + : QMainWindow(parent){ + setupUi(this); // this sets up GUI + + //this->setAttribute(Qt::WA_DeleteOnClose,true); + + initStyle(); + + //initTryIconMenu(); + //initTryIcon(); + init(); +} +void form_MainWindow::init() +{ + using namespace SESSION_Types; + + Core= new cCore(); + fillComboBox(); + createToolBar(); + applicationIsClosing=false; + QListWidget* listWidget=this->listWidget; + + connect (Core,SIGNAL(eventUserChanged()),this, + SLOT(eventUserChanged())); + + connect(Core,SIGNAL(eventOnlineStatusChanged()),this, + SLOT(OnlineStateChanged())); + + connect(listWidget,SIGNAL(itemDoubleClicked( QListWidgetItem* )),this, + SLOT(openChatDialog ())); + + connect(listWidget, SIGNAL( customContextMenuRequested(QPoint)), this, + SLOT( connecttreeWidgetCostumPopupMenu(QPoint))); + + connect(comboBox,SIGNAL(currentIndexChanged( int)),this, + SLOT(onlineComboBoxChanged())); + + this->eventUserChanged(); +} + +form_MainWindow::~form_MainWindow(){ + + delete Core; + //delete trayIcon; + //applicationIsClosing=true; + //this->close(); +} + + +void form_MainWindow::fillComboBox() +{ + QComboBox* comboBox = this->comboBox; + comboBox->addItem(QIcon(ICON_USER_TRYTOCONNECT) ,"TryToConnect"); + comboBox->addItem(QIcon(ICON_USER_OFFLINE) ,"Offline"); +} + +void form_MainWindow::onlineComboBoxChanged() +{ + QString text=comboBox->currentText(); + + if(text.contains("Online",Qt::CaseInsensitive)==true){ + if(Core->getOnlineStatus()!=User::USERONLINE) + Core->setOnlineStatus(User::USERONLINE); + } + else if(text.contains("WantToChat",Qt::CaseInsensitive)==true){ + if(Core->getOnlineStatus()!=User::USERWANTTOCHAT) + Core->setOnlineStatus(User::USERWANTTOCHAT); + } + else if(text.contains("Away",Qt::CaseInsensitive)==true){ + if(Core->getOnlineStatus()!=User::USERAWAY) + Core->setOnlineStatus(User::USERAWAY); + } + else if(text.contains("don't disturb",Qt::CaseInsensitive)==true){ + if(Core->getOnlineStatus()!=User::USERDONT_DISTURB) + Core->setOnlineStatus(User::USERDONT_DISTURB); + } + else if(text.contains("Invisible",Qt::CaseInsensitive)==true){ + if(Core->getOnlineStatus()!=User::USERINVISIBLE) + Core->setOnlineStatus(User::USERINVISIBLE); + } + else if(text.contains("Offline",Qt::CaseInsensitive)==true){ + if(Core->checkIfAFileTransferOrReciveisActive()==false){ + if(Core->getOnlineStatus()!=User::USEROFFLINE) + Core->setOnlineStatus(User::USEROFFLINE); + } + else{ + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Information); + msgBox->setText(""); + msgBox->setInformativeText("Sorry a Filetransfer or Filerecive ist active,\nClosing aborted"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); + } + } + else if(text.contains("TryToConnect",Qt::CaseInsensitive)==true){ + if(Core->getOnlineStatus()!=User::USERTRYTOCONNECT) + Core->setOnlineStatus(User::USERTRYTOCONNECT); + } + +} + +void form_MainWindow::createToolBar() +{ + //toolBar->setIconSize(QSize(24, 24)); + QToolBar* toolBar=this->toolBar; + + + toolBar->setMovable(false); + toolBar->addAction(QIcon(ICON_NEWUSER) ,"add User" ,this,SLOT(openAdduserWindow() ) ); + toolBar->addAction(QIcon(ICON_SETTINGS) ,"Settings" ,this,SLOT(openConfigWindow() ) ); + toolBar->addAction(QIcon(ICON_DEBUGMESSAGES) ,"DebugMessages",this,SLOT(openDebugMessagesWindow() ) ); + toolBar->addAction(QIcon(ICON_MYDESTINATION) ,"ME" ,this,SLOT(namingMe())); + toolBar->addAction(QIcon(ICON_CLOSE) ,"Close" ,this,SLOT(closeApplication())); + toolBar->addAction(QIcon(ICON_ABOUT) ,"About" ,this,SLOT(openAboutDialog())); +} + + +void form_MainWindow::openConfigWindow(){ + + form_settingsgui* dialog= new form_settingsgui(); + connect(this,SIGNAL(closeAllWindows()),dialog, + SLOT(close())); + + dialog->show(); + +} +void form_MainWindow::openAdduserWindow(){ + form_newUserWindow* dialog= new form_newUserWindow(Core); + + connect(this,SIGNAL(closeAllWindows()),dialog, + SLOT(close())); + + dialog->show(); +} + +void form_MainWindow::openDebugMessagesWindow(){ + form_DebugMessages* dialog= new form_DebugMessages(this->Core); + + connect(this,SIGNAL(closeAllWindows()),dialog, + SLOT(close())); + + dialog->show(); +} + +void form_MainWindow::namingMe(){ + QClipboard *clipboard = QApplication::clipboard(); + QString Destination=Core->getMyDestination(); + if(Destination!=""){ + clipboard->setText(Destination); + QMessageBox::information(this, "", + "Your Destination is in the clipboard",QMessageBox::Close); + } + else + QMessageBox::information(this, "", + "Your Client must be Online for that",QMessageBox::Close); +} +void form_MainWindow::closeApplication(){ + + if(Core->checkIfAFileTransferOrReciveisActive()==false){ + + emit closeAllWindows(); + + delete Core; + //delete trayIcon; + applicationIsClosing=true; + this->close(); + } + else{ + + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Information); + msgBox->setText(""); + msgBox->setInformativeText("Sorry a Filetransfer or Filerecive ist active,\nClosing aborted"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); + + } + + + +} +void form_MainWindow::eventUserChanged(){ + + bool showUnreadMessageAtTray=false; + QList users=Core->get_userList(); + listWidget->clear(); + + + for(int i=0;igetHaveNewUnreadMessages()==true){ + newItem->setIcon(QIcon(ICON_NEWUNREADMESSAGE)); + showUnreadMessageAtTray=true; + + } + else + switch(users.at(i)->get_OnlineState()) + { + + case USERTRYTOCONNECT: + { + newItem->setIcon(QIcon(ICON_USER_OFFLINE)); + break; + } + case USERINVISIBLE: + case USEROFFLINE: + { + newItem->setIcon(QIcon(ICON_USER_OFFLINE)); + break; + } + case USERONLINE: + { + newItem->setIcon(QIcon(ICON_USER_ONLINE)); + break; + } + case USERWANTTOCHAT: + { + newItem->setIcon(QIcon(ICON_USER_WANTTOCHAT)); + break; + } + case USERAWAY: + { + newItem->setIcon(QIcon(ICON_USER_AWAY)); + break; + } + case USERDONT_DISTURB: + { + newItem->setIcon(QIcon(ICON_USER_DONT_DUSTURB)); + break; + } + + + } + newItem->setText(users.at(i)->get_Name()); + newItem->setTextAlignment(Qt::AlignLeft); + newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + ChildWidthI2PDestinationAsText->setText(users.at(i)->get_I2PDestination()); + ChildWidthI2PDestinationAsText->setHidden(true);//DEBUG + } + + /*if(showUnreadMessageAtTray==false) + trayIcon->setIcon(QIcon(ICON_QTCHAT)); + else + trayIcon->setIcon(QIcon(ICON_NEWUNREADMESSAGE));*/ +} + +//void form_MainWindow::UserDoubleClicked(QListWidgetItem * item) +void form_MainWindow::openChatDialog() +{ + QListWidgetItem *t=listWidget->item(listWidget->currentRow()+1); + QString Destination =t->text(); + + cUser* User; + User=Core->getUserByI2P_Destination(Destination); + if(User==NULL)return; + + if(User->getHaveAllreadyOneChatWindow()==false){ + form_ChatWidget* tmp= new form_ChatWidget(User); + + connect(this,SIGNAL(closeAllWindows()),tmp, + SLOT(close())); + + eventUserChanged(); + + tmp->show(); + } + else{ + QMessageBox::information(this, "", + "Only one Chatwindows for each User",QMessageBox::Close); + } +} +void form_MainWindow::connecttreeWidgetCostumPopupMenu(QPoint point){ + QListWidget* listWidget=this->listWidget; + + if(listWidget->count()==0)return; + + QMenu contextMnu( this ); + QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, + Qt::RightButton, Qt::NoModifier ); + + + QAction* UserChat = new QAction("Chat",this); + connect( UserChat , SIGNAL(triggered()),this, SLOT( openChatDialog())); + + + QAction* UserDelete = new QAction("Delete",this); + connect( UserDelete , SIGNAL(triggered()),this, SLOT( deleteUserClicked())); + + QAction* UserRename = new QAction("Rename",this); + connect(UserRename,SIGNAL(triggered()),this, SLOT(userRenameCLicked())); + + + + + + contextMnu.clear(); + contextMnu.addAction(UserChat); + contextMnu.addAction(UserDelete); + contextMnu.addAction(UserRename); + + + QListWidgetItem *t=listWidget->item(listWidget->currentRow()+1); + QString Destination =t->text(); + + cUser* User; + User=Core->getUserByI2P_Destination(Destination); + + if(User->get_ConnectionStatus()==ONLINE) + { + QAction* UserSendFile = new QAction("SendFile",this); + connect(UserSendFile,SIGNAL(triggered()),this, SLOT(SendFile())); + contextMnu.addAction(UserSendFile); + } + + contextMnu.exec( mevent->globalPos()); +} + +void form_MainWindow::deleteUserClicked(){ + QListWidgetItem *t=listWidget->item(listWidget->currentRow()+1); + QString Destination =t->text(); + + Core->deleteUserByI2PDestination(Destination); +} + +void form_MainWindow::userRenameCLicked(){ + QListWidgetItem *t=listWidget->item(listWidget->currentRow()); + QString OldNickname=t->text(); + + QListWidgetItem *t2= listWidget->item(listWidget->currentRow()+1); + QString Destination =t2->text(); + + form_RenameWindow* Dialog= new form_RenameWindow(Core,OldNickname,Destination); + Dialog->show(); +} + +/*void form_MainWindow::closeEvent(QCloseEvent *e) +{ + static bool firstTime = true; + if(applicationIsClosing==true) return; + + if (trayIcon->isVisible()) { + if (firstTime) + { + + firstTime = false; + } + hide(); + e->ignore(); + } + +} + +void form_MainWindow::updateMenu() +{ + toggleVisibilityAction->setText(isVisible() ? tr("Hide") : tr("Show")); +} + +void form_MainWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e) +{ + if(e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick){ + if(isHidden()){ + show(); + + //eventUserChanged(); + + if(isMinimized()){ + if(isMaximized()){ + showMaximized(); + }else{ + showNormal(); + } + } + raise(); + activateWindow(); + }else{ + hide(); + } + } +} + +void form_MainWindow::toggleVisibilitycontextmenu() +{ + if (isVisible()) + hide(); + else + show(); +}*/ + + +void form_MainWindow::OnlineStateChanged() +{ + QComboBox* comboBox = this->comboBox; + if(Core->getOnlineStatus()==User::USERONLINE) + { + comboBox->clear(); + comboBox->addItem(QIcon(ICON_USER_ONLINE) , "Online"); + comboBox->addItem(QIcon(ICON_USER_WANTTOCHAT) , "WantToChat"); + comboBox->addItem(QIcon(ICON_USER_AWAY) , "Away"); + comboBox->addItem(QIcon(ICON_USER_DONT_DUSTURB) , "don't disturb"); + comboBox->addItem(QIcon(ICON_USER_INVISIBLE) , "Invisible"); + comboBox->addItem(QIcon(ICON_USER_OFFLINE) , "Offline"); + + } + else if(Core->getOnlineStatus()==User::USEROFFLINE) + { + comboBox->clear(); + comboBox->addItem(QIcon(ICON_USER_OFFLINE) , "Offline"); + comboBox->addItem(QIcon(ICON_USER_TRYTOCONNECT) , "TryToConnect"); + + } +} + +void form_MainWindow::openAboutDialog() +{ + form_HelpDialog* dialog = new form_HelpDialog(Core->get_ClientVersion(),Core->get_ProtocolVersion()); + + connect(this,SIGNAL(closeAllWindows()),dialog, + SLOT(close())); + + dialog->show(); +} + +void form_MainWindow::initStyle() +{ + QSettings * settings=new QSettings(QApplication::applicationDirPath()+"/application.ini",QSettings::IniFormat); + settings->beginGroup("General"); + //Load Style + QString Style=(settings->value("current_Style","")).toString(); + if(Style.isEmpty()==true) + { + //find default Style for this System + QRegExp regExp("Q(.*)Style"); + Style = QApplication::style()->metaObject()->className(); + + if (Style == QLatin1String("QMacStyle")) + Style = QLatin1String("Macintosh (Aqua)"); + else if (regExp.exactMatch(Style)) + Style = regExp.cap(1); + + //styleCombo->addItems(QStyleFactory::keys()); + } + + qApp->setStyle(Style); + //Load Style end + + //Load Stylesheet + QFile file(QApplication::applicationDirPath() + "/qss/" + + settings->value("current_Style_sheet","Default").toString() + ".qss"); + + file.open(QFile::ReadOnly); + QString styleSheet = QLatin1String(file.readAll()); + qApp->setStyleSheet(styleSheet); + //load Stylesheet end + settings->endGroup(); + + delete settings; +} + +/*void form_MainWindow::initTryIconMenu() +{ + // Tray icon Menu + menu = new QMenu(this); + QObject::connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); + toggleVisibilityAction = + menu->addAction(QIcon(ICON_QTCHAT), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu())); + menu->addSeparator(); + //menu->addAction(QIcon(ICON_MINIMIZE), tr("Minimize"), this, SLOT(showMinimized())); + //menu->addAction(QIcon(ICON_MAXIMIZE), tr("Maximize"), this, SLOT(showMaximized())); + menu->addSeparator(); + menu->addAction(QIcon(ICON_CLOSE), tr("&Quit"), this, SLOT(closeApplication())); +} + +void form_MainWindow::initTryIcon() +{ + // Create the tray icon + trayIcon = new QSystemTrayIcon(this); + trayIcon->setToolTip(tr("I2PChat")); + trayIcon->setContextMenu(menu); + trayIcon->setIcon(QIcon(ICON_QTCHAT)); + + connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, + SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason))); + trayIcon->show(); +}*/ + +void form_MainWindow::SendFile() +{ + QString FilePath=QFileDialog::getOpenFileName(this,"Open File", ".", "all Files (*.*)"); + + QListWidgetItem *t=listWidget->item(listWidget->currentRow()+1); + QString Destination =t->text(); + + if(!FilePath.isEmpty()) + Core->startFileTransfer(FilePath,Destination); + +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.h new file mode 100644 index 000000000..3e2e22dde --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.h @@ -0,0 +1,102 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef FORM_MAIN_H +#define FORM_MAIN_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ui_form_Main.h" +#include "form_settingsgui.h" +#include "form_newUser.h" +#include "form_DebugMessages.h" +#include "form_chatwidget.h" +#include "form_rename.h" +#include "form_HelpDialog.h" +#include "src/Core.h" +#include "src/User.h" + + +class form_MainWindow : public QMainWindow, private Ui::form_MainWindow +{ + Q_OBJECT + + public: + form_MainWindow ( QWidget* parent=0 ); + ~form_MainWindow(); + + protected: + //void closeEvent(QCloseEvent *); + + signals: + void closeAllWindows(); + + private slots: + //Windows + void openConfigWindow(); + void openAdduserWindow(); + void openDebugMessagesWindow(); + void openAboutDialog(); + void openChatDialog (); + //Windows end + void namingMe(); + void SendFile(); + void closeApplication(); + void eventUserChanged(); + //void UserDoubleClicked ( QListWidgetItem * item ); + + + void connecttreeWidgetCostumPopupMenu ( QPoint point ); + void deleteUserClicked(); + void userRenameCLicked(); + //void updateMenu(); + void onlineComboBoxChanged(); + //void toggleVisibility(QSystemTrayIcon::ActivationReason e); + //void toggleVisibilitycontextmenu(); + void OnlineStateChanged(); + private: + void init(); + void initStyle(); + //void initTryIconMenu(); + //void initTryIcon(); + + void fillComboBox(); + void createToolBar(); + cCore* Core; + bool applicationIsClosing; + + cConnectionI2P* I2P; + form_newUserWindow* newUserWindow; + + //QSystemTrayIcon *trayIcon; + //QAction *toggleVisibilityAction, *toolAct; + //QMenu *menu; + + +}; +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.ui new file mode 100644 index 000000000..71aa4f84e --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.ui @@ -0,0 +1,68 @@ + + form_MainWindow + + + + 0 + 0 + 233 + 427 + + + + I2PChat + + + :/icons/userblue24.png + + + + + 9 + + + 6 + + + + + QComboBox::NoInsert + + + + + + + Qt::CustomContextMenu + + + QAbstractItemView::AllEditTriggers + + + + + + + + + + 21 + 30 + + + + false + + + Qt::Horizontal + + + 4 + + + + + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.cpp new file mode 100644 index 000000000..41908be5d --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.cpp @@ -0,0 +1,131 @@ +#include "form_chatwidget.h" +#include "src/User.h" + + + +form_ChatWidget::form_ChatWidget(cUser* user,QWidget* parent /* = 0 */) +: QWidget(parent) +{ + + setupUi(this); + this->setAttribute(Qt::WA_DeleteOnClose,true); + + this->user=user; + user->set_HaveAllreadyOneChatWindow(true); + + connect(user,SIGNAL(newMessageRecived()),this, + SLOT(newMessageRecived())); + + connect(this,SIGNAL(sendChatMessage(QString)),user, + SLOT(sendChatMessage(QString))); + + + + mCurrentFont = QFont("Comic Sans MS", 10); + + textColor = Qt::black; + QPixmap pxm(24,24); + pxm.fill(textColor); + txtColor->setIcon(pxm); + + connect(send, SIGNAL(clicked()), SLOT(sendMessageSignal())); + connect(txtColor, SIGNAL(clicked()), SLOT(setTextColor())); + connect(txtBold, SIGNAL(clicked(bool)),SLOT(setBold(bool))); + connect(txtFont, SIGNAL(clicked()), SLOT(setFont())); + +/* + message->setStyleSheet( + "QTextEdit {" + " selection-color: white;" + " selection-background-color: black;" + " color: red" // text color + "}" + ); +*/ + + resize(450,400); + newMessageRecived(); + +} +void form_ChatWidget::newMessageRecived(){ + QTextEdit *chat=this->chat; + chat->clear(); + + QStringList Messages=user->get_ChatMessages(); + int i=0; + while(iaddMessage(test); + i++; + } +} + + +void form_ChatWidget::addMessage(QString text){ + QTextEdit *chat=this->chat; + + chat->insertHtml(text); + + QTextCursor cursor = chat->textCursor(); + cursor.movePosition(QTextCursor::End); + chat->setTextCursor(cursor); +} + +void form_ChatWidget::setTextColor(){ + QTextEdit *message=this->message; + textColor = QColorDialog::getColor(Qt::black, this); + + //textColor = QColorDialog::getColor(message->textColor(), this); + QPixmap pxm(24,24); + pxm.fill(textColor); + txtColor->setIcon(pxm); + + message->setTextColor(textColor); + + +} + +void form_ChatWidget::setFont() +{ + QTextEdit *message=this->message; + bool ok; + mCurrentFont = QFontDialog::getFont(&ok, mCurrentFont, this); + + + message->setCurrentFont(mCurrentFont); + message->setFocus(); +} + + +void form_ChatWidget::setBold(bool t){ + + QTextEdit *message=this->message; + QFont font = message->currentFont(); + font.setBold(t); + message->setCurrentFont(font); + +} + +void form_ChatWidget::closeEvent(QCloseEvent *e){ + user->set_HaveAllreadyOneChatWindow(false); + disconnect(user,SIGNAL(newMessageRecived()),this, + SLOT(newMessageRecived())); +} + +void form_ChatWidget::sendMessageSignal(){ + QTextEdit *message=this->message; + + QFont font = message->currentFont(); + QColor color= message->textColor(); + + + emit sendChatMessage(message->toHtml()); + //message->setHtml(""); + + message->setText(" "); + message->selectAll(); + message->setTextColor(color); + message->setCurrentFont(font); + + +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.h new file mode 100644 index 000000000..26c7934bb --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.h @@ -0,0 +1,36 @@ +#ifndef FORM_CHATWIDGET_h +#define FORM_CHATWIDGET_h + + +#include "ui_form_chatwidget.h" +#include +#include + +#include + +class cUser; +class form_ChatWidget : public QWidget, public Ui::form_chatwidget +{ +Q_OBJECT +public: + form_ChatWidget(cUser* user,QWidget* parent = 0); + void closeEvent(QCloseEvent *e); +private slots: + void sendMessageSignal(); + void addMessage(QString text); + void setTextColor(); + void newMessageRecived(); + void setBold(bool t); + void setFont(); + + +signals: + void sendChatMessage(QString chatMessage); + +private: + QColor textColor; + QStringList history; + cUser* user; + QFont mCurrentFont; +}; +#endif \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.ui new file mode 100644 index 000000000..322dd6665 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.ui @@ -0,0 +1,297 @@ + + form_chatwidget + + + + 0 + 0 + 707 + 575 + + + + User Chat + + + + 9 + + + 6 + + + + + + 0 + 0 + + + + false + + + Qt::Vertical + + + + true + + + + + + 6 + + + 0 + + + + + 6 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + true + + + + 24 + 24 + + + + B + + + + + + + + + 24 + 24 + + + + true + + + false + + + + + + + true + + + + 24 + 24 + + + + U + + + + + + + + + 24 + 24 + + + + true + + + + + + + true + + + + 24 + 24 + + + + I + + + + + + + + + 24 + 24 + + + + true + + + + + + + true + + + + 24 + 24 + + + + C + + + + + + + + + 24 + 24 + + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + F + + + + + + + + + 6 + + + 0 + + + + + + + + + + 6 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + &Senden + + + + + + + + + + + + + + + + + txtItalic + clicked(bool) + message + setFontItalic(bool) + + + 644 + 258 + + + 348 + 401 + + + + + txtUnder + clicked(bool) + message + setFontUnderline(bool) + + + 614 + 258 + + + 348 + 401 + + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.cpp new file mode 100644 index 000000000..49b8deb6e --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.cpp @@ -0,0 +1,123 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "form_fileRecive.h" +#include "src/FileTransferRecive.h" + +form_fileRecive::form_fileRecive(cFileTransferRecive * FileRecive) +{ + setupUi(this); + this->setAttribute(Qt::WA_DeleteOnClose,true); + + this->FileRecive=FileRecive; + init(); + + connect(FileRecive,SIGNAL(event_FileRecivedFinishedOK()),this, + SLOT(slot_FileRecivedFinishedOK())); + + connect(FileRecive,SIGNAL(event_allreadyRecivedSizeChanged(quint64)),this, + SLOT(slot_allreadyRecivedSizeChanged(quint64))); + + connect(FileRecive,SIGNAL(event_FileReciveError()),this, + SLOT(slot_FileReciveError())); + + connect(FileRecive,SIGNAL(event_FileReciveAbort()),this, + SLOT(slot_FileReciveAbort())); + + connect(pushButton,SIGNAL(pressed()),this, + SLOT(slot_Button())); + +} + +void form_fileRecive::init() +{ + QLabel *label_4=this->label_4; + QLabel *label_6=this->label_6; + QLabel *label_7=this->label_7; + QProgressBar * progressBar= this->progressBar; + + + label_4->setText(FileRecive->get_FileName()); + + QString SSize; + SSize.setNum(FileRecive->get_FileSize(),10); + label_6->setText(SSize); + label_7->setText("Bits"); + checkBox_3->setChecked(true); + progressBar->setMinimum(0); + progressBar->setMaximum(FileRecive->get_FileSize()); + progressBar->setValue(0); +} + +void form_fileRecive::slot_Button() +{ + QPushButton* pushButton= this->pushButton; + FileRecive->abbortFileRecive(); + this->close(); +} + +void form_fileRecive::slot_allreadyRecivedSizeChanged(quint64 value) +{ + progressBar->setValue(value); +} + +void form_fileRecive::slot_FileRecivedFinishedOK() +{ + QCheckBox* checkBox_4= this->checkBox_4; + checkBox_4->setChecked(true); + + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Information); + msgBox->setText("cFileTransfer"); + msgBox->setInformativeText("FileRecive Finished"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); + + this->close(); +} + +void form_fileRecive::slot_FileReciveError() +{ + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Information); + msgBox->setText("cFileTransferRecive(StreamStatus)"); + msgBox->setInformativeText("FileRecive Error(connection Broke)\nnincomplead File deleted"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); + + this->close(); +} + +void form_fileRecive::slot_FileReciveAbort() +{ + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Information); + msgBox->setText("Filetransfer"); + msgBox->setInformativeText("the Sender abort the Filetransfer\nincomplead File deleted"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); + + this->close(); +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.h new file mode 100644 index 000000000..ef0a8e74b --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef FORM_FILERECIVE_H +#define FORM_FILERECIVE_H + +#include + +#include "ui_form_fileRecive.h" + + +class cFileTransferRecive; +class form_fileRecive : public QDialog, public Ui::form_FileRecive +{ + Q_OBJECT + public: + form_fileRecive(cFileTransferRecive* FileRecive); + + private slots: + void slot_Button(); + void slot_allreadyRecivedSizeChanged(quint64 value); + void slot_FileRecivedFinishedOK(); + void slot_FileReciveError(); + void slot_FileReciveAbort();//the othersite abort the filesend + + + private: + void init(); + cFileTransferRecive* FileRecive; +}; +#endif \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.ui new file mode 100644 index 000000000..86ec75d9f --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.ui @@ -0,0 +1,206 @@ + + form_FileRecive + + + + 0 + 0 + 530 + 300 + + + + + 530 + 300 + + + + + 530 + 300 + + + + + 530 + 300 + + + + Dialog + + + + + 10 + 10 + 251 + 131 + + + + Status + + + + + 20 + 20 + 145 + 100 + + + + + + + false + + + Reciveing + + + + + + + false + + + Finished + + + + + + + + + + 266 + 9 + 254 + 131 + + + + FileInfo + + + + + 10 + 40 + 231 + 61 + + + + + + + FileName: + + + + + + + Name + + + + + + + FileSize: + + + + + + + Size + + + + + + + SizeTyp + + + + + + + + + + 230 + 240 + 75 + 28 + + + + abort + + + + + + 10 + 140 + 511 + 91 + + + + FileSend + + + + + 20 + 20 + 54 + 18 + + + + progress + + + + + + 20 + 40 + 481 + 23 + + + + 24 + + + + + + 480 + 70 + 21 + 18 + + + + 100 + + + + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.cpp new file mode 100644 index 000000000..a0f74de43 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.cpp @@ -0,0 +1,156 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "form_fileSend.h" + + + +form_fileSend::form_fileSend(cFileTransferSend * FileTransfer) +{ + setupUi(this); + this->setAttribute(Qt::WA_DeleteOnClose,true); + + this->FileTransfer=FileTransfer; + QPushButton* pushButton= this->pushButton; + + init(); + + connect(FileTransfer,SIGNAL(event_allreadySendedSizeChanged(quint64)),this, + SLOT(slot_allreadySendedSizeChanged(quint64))); + + connect(FileTransfer,SIGNAL(event_FileTransferFinishedOK()),this, + SLOT(slot_FileTransferFinishedOK())); + + connect(FileTransfer,SIGNAL(event_FileTransferAccepted(bool)),this, + SLOT(slot_FileTransferAccepted(bool))); + + connect(FileTransfer,SIGNAL(event_FileTransferAborted()),this, + SLOT(slot_FileTransferAborted())); + + connect(FileTransfer,SIGNAL(event_FileTransferError()),this, + SLOT(slot_FileTransferError())); + + connect(pushButton,SIGNAL(pressed()),this, + SLOT(slot_Button())); +} + +void form_fileSend::init() +{ + + QLabel *label_4=this->label_4; + QLabel *label_6=this->label_6; + QLabel *label_7=this->label_7; + QProgressBar * progressBar= this->progressBar; + + + label_4->setText(FileTransfer->get_FileName()); + + QString SSize; + SSize.setNum(FileTransfer->get_FileSize(),10); + label_6->setText(SSize); + label_7->setText("Bits"); + progressBar->setMinimum(0); + progressBar->setMaximum(FileTransfer->get_FileSize()); + progressBar->setValue(0); +} + +void form_fileSend::slot_allreadySendedSizeChanged(quint64 value) +{ + progressBar->setValue(value); +} + +void form_fileSend::slot_FileTransferFinishedOK() +{ + QCheckBox* checkBox_4= this->checkBox_4; + checkBox_4->setChecked(true); + + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Information); + msgBox->setText("Filetransfer"); + msgBox->setInformativeText("Filetransfer Finished (OK)"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); + this->close(); + + this->close(); +} + +void form_fileSend::slot_FileTransferAccepted(bool t) +{ + QPushButton* pushButton= this->pushButton; + + if(t==true){ + checkBox_2->setChecked(true); + checkBox_3->setChecked(true); + } + else{ + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Information); + msgBox->setText("FileTransfer)"); + msgBox->setInformativeText("Filetransfer don't Accepted\nFileSending Abborted"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); + + this->close(); + } +} + +void form_fileSend::slot_Button() +{ + QPushButton* pushButton= this->pushButton; + FileTransfer->abbortFileSend(); + + this->close(); +} + +void form_fileSend::slot_FileTransferError() +{ + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Information); + msgBox->setText("Filetransfer"); + msgBox->setInformativeText("FileTransfer Error(connection Broke)"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); + + this->close(); +} + +void form_fileSend::slot_FileTransferAborted() +{ + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Information); + msgBox->setText("Filetransfer"); + msgBox->setInformativeText("The Reciver abort the Filerecive"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); + this->close(); +} + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.h new file mode 100644 index 000000000..ce5b74814 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + + +#ifndef FORM_FILESEND_H +#define FORM_FILESEND_H + +#include + +#include "ui_form_fileSend.h" +#include "src/FileTransferSend.h" +class form_fileSend : public QDialog, public Ui::form_FileSend +{ + Q_OBJECT + public: + form_fileSend(cFileTransferSend* FileTransfer); + + private slots: + void slot_allreadySendedSizeChanged(quint64 value); + void slot_FileTransferFinishedOK(); + void slot_FileTransferError(); + void slot_FileTransferAccepted(bool t); + void slot_FileTransferAborted(); + void slot_Button(); + + private: + void init(); + cFileTransferSend* FileTransfer; +}; +#endif \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.ui new file mode 100644 index 000000000..f5cf999cf --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.ui @@ -0,0 +1,242 @@ + + form_FileSend + + + + 0 + 0 + 530 + 300 + + + + + 530 + 300 + + + + + 530 + 300 + + + + + 530 + 300 + + + + Dialog + + + + + 10 + 10 + 251 + 131 + + + + Status + + + + + 20 + 20 + 145 + 100 + + + + + + + false + + + FileInfo sended + + + true + + + + + + + false + + + FileTransfer Accepted + + + + + + + false + + + Transfering + + + + + + + false + + + Finished + + + + + + + + + + 266 + 9 + 254 + 131 + + + + FileInfo + + + + + 10 + 40 + 231 + 61 + + + + + + + FileName: + + + + + + + Name + + + + + + + FileSize: + + + + + + + Size + + + + + + + SizeTyp + + + + + + + + + + 230 + 240 + 75 + 28 + + + + abort + + + + + + 10 + 140 + 511 + 91 + + + + FileSend + + + + + 20 + 20 + 54 + 18 + + + + progress + + + + + + 20 + 40 + 481 + 23 + + + + 24 + + + + + + 480 + 70 + 21 + 18 + + + + 100 + + + + + + 20 + 70 + 21 + 18 + + + + 0 + + + + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.cpp new file mode 100644 index 000000000..7e3c01a35 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.cpp @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "form_newUser.h" + +form_newUserWindow::form_newUserWindow(cCore* Core,QDialog *parent){ + setupUi(this); + this->setAttribute(Qt::WA_DeleteOnClose,true); + this->Core=Core; + connect(buttonBox,SIGNAL(accepted()),this,SLOT(addnewUser())); +} +void form_newUserWindow::addnewUser() +{ + QString Name=lineEdit->text(); + QString I2PDestination=textEdit->toPlainText(); + + + if(I2PDestination==Core->getMyDestination()) + { + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText("Adding User"); + msgBox.setInformativeText("This Destination is yours, adding aborted !"); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.exec(); + return; + + } + + if(Core->addNewUser(Name,I2PDestination,"","")==false) + QMessageBox::warning(this, tr("I2PChat"), + ("There allready exits one user with the same I2P,- or TorDestination"), + QMessageBox::Ok); + + this->close(); +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.h new file mode 100644 index 000000000..5e52400fd --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef FORM_NEWUSER_H +#define FORM_NEWUSER_H + +#include +#include "ui_form_newUser.h" +#include "src/Core.h" + +class form_newUserWindow : public QDialog, private Ui::form_newUserWindow +{ + Q_OBJECT + public: + form_newUserWindow(cCore* Core,QDialog *parent = 0); + + private slots: + void addnewUser(); + + private: + cCore* Core; +}; + +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.ui new file mode 100644 index 000000000..33a395ab5 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.ui @@ -0,0 +1,167 @@ + + form_newUserWindow + + + + 0 + 0 + 465 + 434 + + + + new User + + + + + + 0 + + + 6 + + + + + false + + + + + + + 6 + + + 0 + + + + + Network: + + + + + + + false + + + I2P + + + + + + + false + + + Tor + + + + + + + + + 6 + + + 0 + + + + + Nickname: + + + + + + + + + + + + Destination Tor: + + + + + + + Destination I2P: + + + + + + + + + + + + Qt::Horizontal + + + + 258 + 20 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + form_newUserWindow + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + form_newUserWindow + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_rename.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_rename.cpp new file mode 100644 index 000000000..92f498bb8 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_rename.cpp @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "form_rename.h" + +form_RenameWindow::form_RenameWindow(cCore* Core,QString OldNickname,QString Destination){ + setupUi(this); + + this->setAttribute(Qt::WA_DeleteOnClose,true); + this->Core=Core; + this->Destination=Destination; + + QLineEdit* lineEdit = this->lineEdit; + lineEdit->setText(OldNickname); + + connect(okButton,SIGNAL(clicked()),this, + SLOT(OK())); +} + +void form_RenameWindow::OK(){ + QLineEdit* lineEdit_2 = this->lineEdit_2; + Core->renameuserByI2PDestination(Destination,lineEdit_2->text()); + this->close(); +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_rename.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_rename.h new file mode 100644 index 000000000..4225f8ed5 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_rename.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef FORM_RENAME_H +#define FORM_RENAME_H + +#include +#include "ui_form_rename.h" +#include "src/Core.h" + + +class form_RenameWindow : public QDialog, private Ui::form_renameWindow +{ + Q_OBJECT + public: + form_RenameWindow(cCore* Core,QString OldNickname,QString Destination); + private slots: + void OK(); + private: + cCore* Core; + QString Destination; +}; + +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_rename.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_rename.ui new file mode 100644 index 000000000..476540054 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_rename.ui @@ -0,0 +1,122 @@ + + form_renameWindow + + + + 0 + 0 + 324 + 152 + + + + Dialog + + + + 9 + + + 6 + + + + + New Nickname + + + + 9 + + + 6 + + + + + Old Nickname + + + + + + + false + + + + + + + New Nickname + + + + + + + + + + Qt::Vertical + + + + 268 + 0 + + + + + + + + + + + Qt::Horizontal + + + + 125 + 22 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + CancelButton + clicked() + form_renameWindow + close() + + + 277 + 129 + + + 161 + 75 + + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.cpp new file mode 100644 index 000000000..69f3d9a27 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.cpp @@ -0,0 +1,197 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "form_settingsgui.h" + +form_settingsgui::form_settingsgui(QWidget *parent, Qt::WFlags flags) + : QDialog(parent, flags) +{ + setupUi(this); + this->setAttribute(Qt::WA_DeleteOnClose,true); + settings= new QSettings(QApplication::applicationDirPath()+"/application.ini",QSettings::IniFormat); + + loadqss(); + styleCombo->addItems(QStyleFactory::keys()); + loadSettings(); + + connect(ok_Button,SIGNAL(clicked() ),this,SLOT(saveSettings() ) ); + connect(cancel_Button,SIGNAL(clicked() ),this,SLOT(close() ) ); +} + +form_settingsgui::~form_settingsgui() +{ + delete (settings); +} + +void form_settingsgui::loadSettings() +{ + + + settings->beginGroup("General"); + spinBox->setValue(settings->value("Debug_Max_Message_count","20").toInt()); + spinBox_3->setValue(settings->value("Waittime_between_rechecking_offline_users","30000").toInt()/1000); + + + if(settings->value("current_Style","").toString().isEmpty()==false) + styleCombo->setCurrentIndex(styleCombo->findText(settings->value("current_Style","").toString())); + else + { + //find default Style for this System + QRegExp regExp("Q(.*)Style"); + QString defaultStyle = QApplication::style()->metaObject()->className(); + + if (defaultStyle == QLatin1String("QMacStyle")) + defaultStyle = QLatin1String("Macintosh (Aqua)"); + else if (regExp.exactMatch(defaultStyle)) + defaultStyle = regExp.cap(1); + + //styleCombo->addItems(QStyleFactory::keys()); + styleCombo->setCurrentIndex(styleCombo->findText(defaultStyle)); + + } + + styleSheetCombo->setCurrentIndex(styleSheetCombo->findText(settings->value("current_Style_sheet","Default").toString())); + settings->endGroup(); + + settings->beginGroup("Network"); + lineEdit_3->setText(settings->value("SamHost","127.0.0.1").toString()); + lineEdit_2->setText(settings->value("Destination","test").toString()); + lineEdit->setText(settings->value("TunnelName","I2PChat").toString()); + spinBox_10->setValue(settings->value("SamPort","7656").toInt()); + + spinBox_4->setMinimum(0); + spinBox_4->setValue(settings->value("inbound.length","1").toInt()); + spinBox_4->setMaximum(3); + + spinBox_5->setMinimum(0); + spinBox_5->setValue(settings->value("inbound.quantity","1").toInt()); + spinBox_5->setMaximum(3); + + spinBox_6->setMinimum(0); + spinBox_6->setValue(settings->value("inbound.backupQuantity","1").toInt()); + spinBox_6->setMaximum(3); + + spinBox_7->setMinimum(0); + spinBox_7->setValue(settings->value("outbound.backupQuantity","1").toInt()); + spinBox_7->setMaximum(3); + + spinBox_8->setMinimum(0); + spinBox_8->setValue(settings->value("outbound.length","1").toInt()); + spinBox_8->setMaximum(3); + + spinBox_9->setMinimum(0); + spinBox_9->setValue(settings->value("outbound.quantity","1").toInt()); + spinBox_9->setMaximum(3); + settings->endGroup(); + +} +void form_settingsgui::saveSettings() +{ + QString SessionOptionString; + QString temp; + + SessionOptionString="inbound.nickname="+lineEdit->text(); + + SessionOptionString+=" inbound.quantity="; + temp.setNum(spinBox_5->value()); + SessionOptionString+=temp; + + SessionOptionString+=" inbound.backupQuantity="; + temp.setNum(spinBox_6->value()); + SessionOptionString+=temp; + + SessionOptionString+=" inbound.length="; + temp.setNum(spinBox_4->value()); + SessionOptionString+=temp; + + SessionOptionString+=" outbound.quantity="; + temp.setNum(spinBox_9->value()); + SessionOptionString+=temp; + + SessionOptionString+=" outbound.backupQuantity="; + temp.setNum(spinBox_7->value()); + SessionOptionString+=temp; + + SessionOptionString+=" outbound.length="; + temp.setNum(spinBox_8->value()); + SessionOptionString+=temp; + + settings->beginGroup("Network"); + settings->setValue("SamHost",lineEdit_3->text()); + settings->setValue("Destination",lineEdit_2->text()); + settings->setValue("TunnelName",lineEdit->text()); + settings->setValue("SamPort",spinBox_10->value()); + //Inbound options + settings->setValue("inbound.quantity",spinBox_5->value()); + settings->setValue("inbound.backupQuantity",spinBox_6->value()); + settings->setValue("inbound.length",spinBox_4->value()); + //Outpound options + settings->setValue("outbound.quantity",spinBox_9->value()); + settings->setValue("outbound.backupQuantity",spinBox_7->value()); + settings->setValue("outbound.length",spinBox_8->value()); + + settings->setValue("SessionOptionString",SessionOptionString); + settings->endGroup(); + + settings->beginGroup("General"); + settings->setValue("Debug_Max_Message_count",spinBox->value()); + settings->setValue("Waittime_between_rechecking_offline_users",spinBox_3->value()*1000); + settings->setValue("current_Style",styleCombo->currentText()); + settings->setValue("current_Style_sheet",styleSheetCombo->currentText()); + settings->endGroup(); + + + this->close(); +} + + +void form_settingsgui::on_styleCombo_activated(const QString &styleName) +{ + qApp->setStyle(styleName); + +} + +void form_settingsgui::on_styleSheetCombo_activated(const QString &sheetName) +{ + loadStyleSheet(sheetName); +} + +void form_settingsgui::loadStyleSheet(const QString &sheetName) +{ + // external Stylesheets + QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss"); + + file.open(QFile::ReadOnly); + QString styleSheet = QLatin1String(file.readAll()); + + + qApp->setStyleSheet(styleSheet); +} + +void form_settingsgui::loadqss() +{ + + QFileInfoList slist = QDir(QApplication::applicationDirPath() + "/qss/").entryInfoList(); + foreach(QFileInfo st, slist) + { + if(st.fileName() != "." && st.fileName() != ".." && st.isFile()) + styleSheetCombo->addItem(st.fileName().remove(".qss")); + } +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.h new file mode 100644 index 000000000..7193552a7 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef SETTINGSGUI_H +#define SETTINGSGUI_H + +#include "ui_form_settingsgui.h" +#include +#include + + +class form_settingsgui : public QDialog, private Ui::form_settingsgui +{ + Q_OBJECT + +public: + form_settingsgui(QWidget *parent = 0, Qt::WFlags flags = 0); + ~form_settingsgui(); + +private slots: + void loadSettings(); + void saveSettings(); + void on_styleCombo_activated(const QString &styleName); + void on_styleSheetCombo_activated(const QString &styleSheetName); + +private: + QSettings* settings; + void loadStyleSheet(const QString &sheetName); + void loadqss(); + +}; +#endif + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.ui new file mode 100644 index 000000000..333c0040f --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.ui @@ -0,0 +1,1280 @@ + + form_settingsgui + + + + 0 + 0 + 600 + 500 + + + + + 0 + 0 + + + + + 600 + 500 + + + + + 600 + 500 + + + + Settings + + + + :/icons/settings.png:/icons/settings.png + + + false + + + true + + + + + 9 + 9 + 600 + 500 + + + + + 0 + 0 + + + + + 600 + 500 + + + + + 600 + 500 + + + + QFrame::NoFrame + + + QFrame::Plain + + + + 9 + + + 6 + + + + + + 0 + 0 + + + + + 0 + 300 + + + + + 128 + 500 + + + + + MS Shell Dlg 2 + 10 + 50 + false + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + false + + + QListView::TopToBottom + + + QListView::Fixed + + + QListView::SinglePass + + + 0 + + + + General + + + + :/icons/settings.png:/icons/settings.png + + + + + Network + + + + :/icons/socket24.png:/icons/socket24.png + + + + + User Details + + + + :/icons/userblue24.png:/icons/userblue24.png + + + + + Style + + + + :/icons/looknfeel24.png:/icons/looknfeel24.png + + + + + Security + + + + :/icons/encrypted24.png:/icons/encrypted24.png + + + + + + + + 0 + + + 6 + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 9 + + + 6 + + + + + + 75 + 24 + + + + + 16777215 + 75 + + + + OK + + + false + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 16 + 25 + + + + + + + + + 0 + 24 + + + + Help + + + + + + + + 75 + 24 + + + + + 75 + 16777215 + + + + Cancel + + + + + + + + + + Qt::Horizontal + + + + 181 + 20 + + + + + + + + + + 0 + + + + + + 10 + 100 + 401 + 80 + + + + Waittime between rechecking offline users + + + + + 10 + 30 + 131 + 16 + + + + Tine in sec. + + + + + + 160 + 30 + 81 + 22 + + + + + + + + 10 + 40 + 401 + 61 + + + + SAM log + + + + + 160 + 30 + 81 + 22 + + + + + + + 10 + 30 + 121 + 17 + + + + Max. Log Messages + + + + + + + 10 + 0 + 106 + 32 + + + + + 0 + + + 6 + + + + + + 0 + 0 + + + + + 0 + 30 + + + + + Sans Serif + 16 + 75 + true + true + true + false + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:16pt; font-weight:600; font-style:italic; text-decoration: underline;"> +<p style=" -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:400; font-style:normal; text-decoration:none;">General</span></p></body></html> + + + Qt::AlignCenter + + + + + + + + + + + + + Qt::AlignCenter + + + + + + + + + + + 10 + 0 + 118 + 32 + + + + + 0 + + + 6 + + + + + + 32 + 32 + + + + + + + + + + Qt::AlignCenter + + + + + + + + 0 + 30 + + + + + Sans Serif + 16 + 75 + true + true + true + false + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:16pt; font-weight:600; font-style:italic;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline;"><span style=" font-weight:400; font-style:normal; text-decoration:none;">Network</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + 10 + 130 + 411 + 281 + + + + Tunnel Options + + + + + 20 + 20 + 101 + 16 + + + + Tunnel Name + + + + + + 130 + 20 + 261 + 20 + + + + + + + 10 + 159 + 391 + 111 + + + + Outbound + + + + + 10 + 20 + 91 + 16 + + + + Length + + + + + + 10 + 50 + 81 + 16 + + + + Quantity + + + + + + 120 + 20 + 101 + 22 + + + + + + + 120 + 50 + 101 + 22 + + + + + + + 120 + 80 + 101 + 22 + + + + + + + 10 + 80 + 102 + 17 + + + + Backup Quantity + + + + + + + 10 + 40 + 391 + 121 + + + + Inbound + + + + + 10 + 50 + 81 + 16 + + + + Quantity + + + + + + 10 + 20 + 81 + 16 + + + + Length + + + + + + 120 + 80 + 101 + 22 + + + + + + + 120 + 50 + 101 + 22 + + + + + + + 120 + 20 + 101 + 22 + + + + + + + 10 + 80 + 102 + 17 + + + + Backup Quantity + + + + + + + + 10 + 40 + 411 + 81 + + + + SAM Connection + + + + + 10 + 20 + 101 + 16 + + + + SAM HOST IP + + + + + + 10 + 50 + 101 + 16 + + + + Destination + + + + + + 130 + 50 + 261 + 20 + + + + + + + 130 + 20 + 113 + 20 + + + + + + + 250 + 20 + 31 + 16 + + + + Port + + + + + + 290 + 20 + 101 + 22 + + + + 65000 + + + 7656 + + + + + + + + + 10 + 50 + 411 + 375 + + + + + + + + + 20 + 70 + 81 + 16 + + + + Age + + + + + false + + + + 100 + 70 + 91 + 22 + + + + + + false + + + + 100 + 110 + 71 + 18 + + + + Male + + + + + + 20 + 140 + 71 + 16 + + + + Interests + + + + + + 20 + 110 + 46 + 14 + + + + Gender + + + + + + 20 + 40 + 61 + 17 + + + + Nickname + + + + + false + + + + 190 + 110 + 71 + 18 + + + + Female + + + + + false + + + + 100 + 30 + 301 + 20 + + + + + + false + + + + 20 + 160 + 381 + 201 + + + + + + + + 1 + 37 + 179 + 16 + + + + + + + + + + + + + 10 + 0 + 147 + 32 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/icons/userblue24.png" /></p></body></html> + + + Qt::AlignCenter + + + + + + + + 0 + 30 + + + + + Sans Serif + 16 + 75 + true + true + true + false + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:16pt; font-weight:600; font-style:italic; text-decoration: underline;"> +<p style=" -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:400; font-style:normal; text-decoration:none;">User Details</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + 10 + 120 + 431 + 181 + + + + StyleSheet + + + + true + + + + 110 + 30 + 266 + 21 + + + + + 16777215 + 87 + + + + + 75 + true + + + + + 200 + 87 + + + + + Default + + + + + + + 20 + 30 + 81 + 20 + + + + + 0 + 0 + + + + Style Sheet: + + + + + + + 10 + 40 + 431 + 71 + + + + Style + + + + true + + + + 110 + 30 + 131 + 18 + + + + + 0 + 0 + + + + + + + 20 + 30 + 51 + 20 + + + + + 0 + 0 + + + + Style: + + + + + + + 11 + 0 + 77 + 28 + + + + + + + + + + + + + Qt::AlignCenter + + + + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"> +<p style=" -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt;">Style</span></p></body></html> + + + + + + + + + + + 10 + 40 + 411 + 91 + + + + + + + + false + + + + 20 + 50 + 391 + 18 + + + + Request Authorization + + + + + false + + + + 20 + 20 + 361 + 18 + + + + Block all unknown Users + + + + + + + 10 + 0 + 98 + 27 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/icons/encrypted24.png" /></p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"> +<p style=" -qt-block-indent:0; text-indent:0px; font-size:8pt;"><span style=" font-size:12pt; font-weight:600;">Security</span></p></body></html> + + + + + + + + + + + + + ok_Button + cancel_Button + help_Button + + + + + + + itemListWidget + currentRowChanged(int) + stackedWidget + setCurrentIndex(int) + + + 62 + 80 + + + 195 + 80 + + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/Thumbs.db b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/Thumbs.db new file mode 100644 index 000000000..780b9a96a Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/Thumbs.db differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/Tools.gif b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/Tools.gif new file mode 100644 index 000000000..4c626bb7b Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/Tools.gif differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/about.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/about.png new file mode 100644 index 000000000..68733266b Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/about.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/add_group.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/add_group.png new file mode 100644 index 000000000..99e0c90ea Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/add_group.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/add_user.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/add_user.png new file mode 100644 index 000000000..12f1a2be7 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/add_user.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/chatty.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/chatty.png new file mode 100644 index 000000000..bae29072d Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/chatty.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/dnd.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/dnd.png new file mode 100644 index 000000000..20d71a8ad Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/dnd.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/editcopy.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/editcopy.png new file mode 100644 index 000000000..51b4319df Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/editcopy.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/encrypted24.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/encrypted24.png new file mode 100644 index 000000000..b37d5b7c1 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/encrypted24.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/exit.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/exit.png new file mode 100644 index 000000000..3f77be3e0 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/exit.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/green.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/green.png new file mode 100644 index 000000000..6a6687677 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/green.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/i2pmessenger_win.rc b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/i2pmessenger_win.rc new file mode 100644 index 000000000..4415a832c --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/i2pmessenger_win.rc @@ -0,0 +1,3 @@ +#include "i2pmessenger_win.rc.h" + +IDI_ICON1 ICON "gui/icons/personal.ico" diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/i2pmessenger_win.rc.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/i2pmessenger_win.rc.h new file mode 100644 index 000000000..eb3bb7641 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/i2pmessenger_win.rc.h @@ -0,0 +1,25 @@ +/**************************************************************** + * I2P Messenger is distributed under the following license: + * + * Copyright (C) 2009 + * + * 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. + ****************************************************************/ + + + +#define IDI_ICON1 101 + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/invisible.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/invisible.png new file mode 100644 index 000000000..5af7e412f Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/invisible.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/looknfeel24.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/looknfeel24.png new file mode 100644 index 000000000..155e2d865 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/looknfeel24.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/personal.ico b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/personal.ico new file mode 100644 index 000000000..afc6e1d89 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/personal.ico differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/quick_restart.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/quick_restart.png new file mode 100644 index 000000000..928e87422 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/quick_restart.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/rebuild.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/rebuild.png new file mode 100644 index 000000000..d002ecac2 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/rebuild.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/red.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/red.png new file mode 100644 index 000000000..c61ff41a7 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/red.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/self.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/self.png new file mode 100644 index 000000000..65f5d9a8e Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/self.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/send.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/send.png new file mode 100644 index 000000000..9a7fbe1c8 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/send.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/settings.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/settings.png new file mode 100644 index 000000000..cedcf7f0f Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/settings.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/socket24.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/socket24.png new file mode 100644 index 000000000..994cd7c62 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/socket24.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/status_unknown.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/status_unknown.png new file mode 100644 index 000000000..2f0c0fa9f Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/status_unknown.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/userblue24.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/userblue24.png new file mode 100644 index 000000000..0f5315239 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/userblue24.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/usergreen24.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/usergreen24.png new file mode 100644 index 000000000..8f5071bb5 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/usergreen24.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/userlightgrey24.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/userlightgrey24.png new file mode 100644 index 000000000..98d9cc40c Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/userlightgrey24.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/useroffline24.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/useroffline24.png new file mode 100644 index 000000000..3dc3ef155 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/useroffline24.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/userred24.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/userred24.png new file mode 100644 index 000000000..99cba375f Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/userred24.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/window_fullscreen.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/window_fullscreen.png new file mode 100644 index 000000000..18a00007a Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/window_fullscreen.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/window_nofullscreen.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/window_nofullscreen.png new file mode 100644 index 000000000..bfd4fa597 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/window_nofullscreen.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/xa.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/xa.png new file mode 100644 index 000000000..e859acb94 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/xa.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/yellow.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/yellow.png new file mode 100644 index 000000000..a0634036e Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/yellow.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/resourcen.qrc b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/resourcen.qrc new file mode 100644 index 000000000..8593c8dab --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/resourcen.qrc @@ -0,0 +1,27 @@ + + + icons/Tools.gif + icons/green.png + icons/red.png + icons/send.png + icons/exit.png + icons/add_user.png + icons/settings.png + icons/status_unknown.png + icons/quick_restart.png + icons/editcopy.png + icons/window_fullscreen.png + icons/window_nofullscreen.png + icons/userblue24.png + icons/self.png + icons/socket24.png + icons/looknfeel24.png + icons/encrypted24.png + icons/yellow.png + icons/invisible.png + icons/chatty.png + icons/dnd.png + icons/xa.png + icons/about.png + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/qt_chat.pro b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/qt_chat.pro new file mode 100644 index 000000000..8f86cc3c0 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/qt_chat.pro @@ -0,0 +1,94 @@ +#=== this part is common (similar) for all plugin projects ===================== +TEMPLATE = lib +CONFIG += plugin release + +# this is directory, where PluginInterface.h is located +INCLUDEPATH += ../ + +# and, the result (*.so or *.dll) should appear in this directory +DESTDIR = ../bin +OBJECTS_DIR = temp/obj +RCC_DIR = temp/qrc +UI_DIR = temp/ui +MOC_DIR = temp/moc + + +# the name of the result file; +TARGET = $$qtLibraryTarget(i2pmessenger_plugin) + +HEADERS += ../PluginInterface.h \ + I2PMessengerPlugin.h +SOURCES += I2PMessengerPlugin.cpp + +#=============================================================================== + + +#CONFIG += qt release + +QT += network xml +#TEMPLATE = app + +DEPENDPATH += . \ + gui \ + src + +INCLUDEPATH += . \ + +SOURCES += gui/form_Main.cpp \ + src/Core.cpp \ + gui/form_newUser.cpp \ + gui/form_DebugMessages.cpp \ + src/User.cpp \ + src/ConnectionI2P.cpp \ + src/I2PSamMessageAnalyser.cpp \ + src/DebugMessageManager.cpp \ + src/UserConnectThread.cpp \ + src/Protocol.cpp \ + gui/form_chatwidget.cpp \ + gui/form_rename.cpp \ + src/PacketManager.cpp \ + gui/form_settingsgui.cpp \ + gui/form_HelpDialog.cpp \ + src/FileTransferSend.cpp \ + src/FileTransferRecive.cpp \ + gui/form_fileSend.cpp \ + gui/form_fileRecive.cpp + +HEADERS += gui/form_Main.h \ + src/Core.h \ + gui/form_newUser.h \ + gui/form_DebugMessages.h \ + src/User.h \ + src/ConnectionI2P.h \ + src/I2PSamMessageAnalyser.h \ + src/DebugMessageManager.h \ + src/UserConnectThread.h \ + src/Protocol.h \ + gui/form_chatwidget.h \ + gui/form_rename.h \ + src/PacketManager.h \ + gui/form_settingsgui.h \ + gui/form_HelpDialog.h \ + src/FileTransferSend.h \ + src/FileTransferRecive.h \ + gui/form_fileSend.h \ + gui/form_fileRecive.h + + + + +FORMS += gui/form_Main.ui \ + gui/form_DebugMessages.ui \ + gui/form_newUser.ui \ + gui/form_chatwidget.ui \ + gui/form_rename.ui \ + gui/form_settingsgui.ui \ + gui/form_HelpDialog.ui \ + gui/form_fileSend.ui \ + gui/form_fileRecive.ui + +RESOURCES += gui/resourcen.qrc + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.cpp new file mode 100644 index 000000000..c13bcfaf2 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.cpp @@ -0,0 +1,342 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "ConnectionI2P.h" + +cConnectionI2P::cConnectionI2P( + QString SamHost, + QString SamPort, + SESSION_Types::SESSION_STYLE SessionStyle, + QString SessionDestination, + SESSION_Types::SESSION_DIRECTION SessionDirection, + QString SessionOptions, + QObject *parent) +:SamHost(SamHost),SamPort(SamPort),SessionStyle(SessionStyle),SessionDestination(SessionDestination), +SessionDirection(SessionDirection),SessionOptions(SessionOptions)//, QObject(parent) +{ + + IncomingPackets= new QByteArray(); + tcpSocket= new QTcpSocket(parent); + + tcpSocket->moveToThread(this->thread()); + + Analyser= new I2PSamMessageAnalyser(); + this->HandShakeWasSuccesfullDone=false; + this->SessionWasSuccesfullCreated=false; + this->nextFreeID=1; + + connect(tcpSocket,SIGNAL(connected() ),this,SLOT(connected() ),Qt::DirectConnection ); + connect(tcpSocket,SIGNAL(readyRead() ),this, SLOT(readFromSocket()),Qt::DirectConnection); + +} + +cConnectionI2P::~cConnectionI2P() +{ + doDisconnect(); + delete tcpSocket; + delete Analyser; +} +void cConnectionI2P::doConnect() +{ + + if(tcpSocket->state()==QAbstractSocket::UnconnectedState) + { + tcpSocket->connectToHost(SamHost,SamPort.toInt( )); + } + if(!tcpSocket->waitForConnected(1000)) + doDisconnect(); + +} + +void cConnectionI2P::doDisconnect() +{ + + if(tcpSocket->state()!=0) + { + tcpSocket->disconnectFromHost(); + emit debugMessages("<-- I2P Socket Disconnected -->\n"); + } + else if(tcpSocket->state()==QAbstractSocket::UnconnectedState) + emit debugMessages("<-- I2P Socket Disconnected -->\n"); + + this->nextFreeID=1; +} + +void cConnectionI2P::connected() +{ + + emit debugMessages("<-- I2P Socket Connected -->\n"); + //emit debugMessages("<-- SAM Connection Handshake send -->\n"); + emit debugMessages(SAM_HANDSHAKE); + + if(tcpSocket->state()==QAbstractSocket::ConnectedState) + { + tcpSocket->write(SAM_HANDSHAKE); + tcpSocket->flush(); + } +} + +void cConnectionI2P::readFromSocket() +{ + + + + using namespace SAM_Message_Types; + + QByteArray newData =tcpSocket->readAll(); + + QByteArray CurrentPacket; + IncomingPackets->append(newData); + + + while(IncomingPackets->contains("\n")==true){ + + CurrentPacket=IncomingPackets->left(IncomingPackets->indexOf("\n",0)+1); + //else return;//Not the complead Packet recived ??? maybe possible ??? + + QString t(CurrentPacket.data()); + + SAM_MESSAGE sam=Analyser->Analyse(t); + switch(sam.type) + { //emit the signals + case HELLO_REPLAY:{ + emit debugMessages(t); + emit HelloReplayRecived(sam.result); + if(sam.result==OK){ + this->HandShakeWasSuccesfullDone=true; + doSessionCreate(); + } + break; + } + case SESSION_STATUS:{ + emit debugMessages(t); + if(sam.result==OK)this->SessionWasSuccesfullCreated=true; + + emit SessionStatusRecived(sam.result,sam.Destination,sam.Message); + break; + } + case STREAM_STATUS:{ + emit debugMessages(t); + if(sam.result==OK) + this->doSendStreamSessionLimit(sam.Id,0); + + emit StreamStatusRecived(sam.result,sam.Id,sam.Message); + break; + } + case STREAM_CONNECTED:{ + emit debugMessages(t); + + this->doSendStreamSessionLimit(sam.Id,0); + + emit StreamConnectedRecived(sam.Destination,sam.Id); + break; + } + case STREAM_CLOSED:{ + emit debugMessages(t); + emit StreamClosedRecived(sam.result,sam.Id,sam.Message); + break; + } + case STREAM_SEND:{ + emit debugMessages(t); + emit StreamSendRecived(sam.Id,sam.result,sam.state); + break; + } + + case STREAM_READY_TO_SEND:{ + emit debugMessages(t); + emit StreamReadyToSendRecived(sam.Id); + break; + } + case NAMING_REPLY:{ + emit debugMessages(t); + emit NamingReplyRecived(sam.result,sam.Name,sam.Value,sam.Message); + break; + } + case STREAM_RECEIVED:{ + + if( sam.Size.toLong() > (IncomingPackets->length() - CurrentPacket.length()) ) + return;//Not the complead Packet recived ??? maybe possible ??? + + QByteArray Data=IncomingPackets->mid(CurrentPacket.length(),sam.Size.toLong()); + emit debugMessages(t+Data); + emit StreamDataRecived(sam.Id,sam.Size,Data); + IncomingPackets->remove(CurrentPacket.length(),sam.Size.toLong()); + break; + } + + + case ERROR_IN_ANALYSE:{ + emit debugMessages("\n"+t); + break; + } + default: + { + emit debugMessages("\n"+t); + break; + } + } + IncomingPackets->remove(0,IncomingPackets->indexOf("\n",0)+1); + }//while +} + +void cConnectionI2P::doSessionCreate(){ +using namespace SESSION_Types; +ConnectionReadyCheck(); + +QByteArray Message="SESSION CREATE STYLE="; + + switch(this->SessionStyle) + { + case STREAM: + { + Message+="STREAM"; + break; + } + case DATAGRAMM: + { + Message+="DATAGRAMM"; + break; + } + case RAW: + { + Message+="RAW"; + break; + } + } + + Message+=" DESTINATION="+this->SessionDestination+" DIRECTION="; + + switch(this->SessionDirection) + { + case BOTH: + { + Message+="BOTH"; + break; + } + case RECEIVE: + { + Message+="RECEIVE"; + break; + } + case CREATE: + { + Message+="CREATE"; + break; + } + } + if(this->SessionOptions.isEmpty()==false) + Message+=" "+SessionOptions; + + Message+="\n"; + + //emit debugMessages("<-Send Create Session Message->\n"); + emit debugMessages(Message); + + tcpSocket->write(Message); + tcpSocket->flush(); + +} + +quint32 cConnectionI2P::get_NextFreeId() +{ + return nextFreeID++; +} + +QString cConnectionI2P::doStreamConnect(QString Destination) +{ + + ConnectionReadyCheck(); + quint32 ID=get_NextFreeId(); + QString IDtemp; + IDtemp.setNum(ID); + + QByteArray Message="STREAM CONNECT ID="; + Message+=IDtemp; + Message+=" DESTINATION="+Destination+"\n"; + + emit debugMessages(Message); + tcpSocket->write(Message); + tcpSocket->flush(); + return IDtemp; +} + +void cConnectionI2P::doStreamClose(QString ID) +{ + + ConnectionReadyCheck(); + QByteArray Message="STREAM CLOSE ID="; + Message+=ID+"\n"; + + emit debugMessages(Message); + tcpSocket->write(Message); + tcpSocket->flush(); +} + +void cConnectionI2P::doSendStreamSessionLimit(QString ID,quint64 value) +{ + ConnectionReadyCheck(); + QByteArray Message="STREAM RECEIVE ID="; + Message+=ID+" LIMIT="; + if(value==0) + Message+="NONE\n"; + else + { + QString Svalue; + Svalue.setNum(value,10); + Message+=Svalue+"\n"; + } + emit debugMessages(Message); + tcpSocket->write(Message); + tcpSocket->flush(); +} +void cConnectionI2P::doStreamSend(QString ID,QString Data) +{ + QByteArray t=""; + t.insert(0,Data); + doStreamSend(ID,t); +} +void cConnectionI2P::doStreamSend(QString ID,QByteArray Data) +{ + + ConnectionReadyCheck(); + + QString Size; + Size.setNum(Data.length()); + + QByteArray Message="STREAM SEND ID="; + Message+=ID+" SIZE="+Size+"\n"; + Message.append(Data); + + emit debugMessages(Message); + tcpSocket->write(Message); + tcpSocket->flush(); + +} +void cConnectionI2P::doNamingLookUP(QString Name) +{ + + ConnectionReadyCheck(); + + QByteArray Message="NAMING LOOKUP NAME="; + Message+=Name+"\n"; + emit debugMessages(Message); + tcpSocket->write(Message); + tcpSocket->flush(); + +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.h new file mode 100644 index 000000000..ef32379ef --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.h @@ -0,0 +1,123 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef CONENCTIONI2P_H +#define CONENCTIONI2P_H + +#include +#include +#include +#include + +#include "I2PSamMessageAnalyser.h" + +#define SAM_HANDSHAKE "HELLO VERSION MIN=2.0 MAX=2.0\n" + +namespace SESSION_Types +{ + enum SESSION_STYLE + { + STREAM, + DATAGRAMM, + RAW + }; + enum SESSION_DIRECTION + { + BOTH, + RECEIVE, + CREATE + }; +}; +//class cConnectionI2P +// +//Handshake with SAM an Session Creation are done atomatically +//all STREAMs will be init with no limit | limit is possible with the function doSendStreamSessionLimit +// +class cConnectionI2P :public QObject +{ + Q_OBJECT + + public: + cConnectionI2P( QString SamHost, + QString SamPort, + SESSION_Types::SESSION_STYLE SessionStyle, + QString SessionDestination, + SESSION_Types::SESSION_DIRECTION SessionDirection, + QString SessionOptions="", + QObject *parent = 0 + ); + + + ~cConnectionI2P(); + + public slots: + void doConnect(); + void doDisconnect(); + QString doStreamConnect(QString Destination);//base64key || return the new id for the stream + void doStreamSend(QString ID,QByteArray Data); + void doStreamSend(QString ID,QString Data); + void doStreamClose(QString ID); + void doSendStreamSessionLimit(QString ID,quint64 value=0); + void doNamingLookUP(QString Name); + + private slots: + void connected(); + void readFromSocket(); + + + signals: + void debugMessages(const QString Message); + void HelloReplayRecived(const SAM_Message_Types::RESULT result); + void SessionStatusRecived(const SAM_Message_Types::RESULT result,const QString Destination,const QString Message); + void StreamStatusRecived(const SAM_Message_Types::RESULT result,const QString ID,QString Message); + void StreamConnectedRecived(const QString Destinaton,const QString ID); + void StreamSendRecived(const QString ID,const SAM_Message_Types::RESULT result,SAM_Message_Types::STATE state); + void StreamClosedRecived(const SAM_Message_Types::RESULT result,QString ID,QString Message); + void StreamReadyToSendRecived(const QString ID); + void StreamDataRecived(const QString ID,const QString Size,const QByteArray Data); + void NamingReplyRecived(const SAM_Message_Types::RESULT result,QString Name,QString Value="",QString Message=""); + + private: + const QString SamHost; + const QString SamPort; + quint32 nextFreeID; + QByteArray* IncomingPackets; + QTcpSocket* tcpSocket; + I2PSamMessageAnalyser* Analyser; + + + bool HandShakeWasSuccesfullDone; + bool SessionWasSuccesfullCreated; + const SESSION_Types::SESSION_STYLE SessionStyle; + const QString SessionDestination; + const SESSION_Types::SESSION_DIRECTION SessionDirection; + const QString SessionOptions; + void doSessionCreate(); + quint32 get_NextFreeId(); + + inline void ConnectionReadyCheck() + { + if( HandShakeWasSuccesfullDone==false || + SessionWasSuccesfullCreated==false|| + tcpSocket->state()!=QAbstractSocket::ConnectedState) + return; + } + +}; +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.cpp new file mode 100644 index 000000000..81fa873e9 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.cpp @@ -0,0 +1,937 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "Core.h" + +cCore::cCore(){ + init(); +} + +cCore::~cCore(){ + + + + disconnect (I2P,SIGNAL(StreamClosedRecived(const SAM_Message_Types::RESULT, QString, QString)),this, + SLOT(StreamClosedRecived(const SAM_Message_Types::RESULT, QString, QString))); + + disconnect (I2P,SIGNAL(SessionStatusRecived(const SAM_Message_Types::RESULT, const QString, const QString)),this, + SLOT(SessionStatusRecived(const SAM_Message_Types::RESULT, const QString, QString))); + + disconnect (I2P,SIGNAL(StreamStatusRecived(const SAM_Message_Types::RESULT, const QString, const QString)),this, + SLOT(StreamStatusRecived(const SAM_Message_Types::RESULT, const QString, QString))); + + disconnect (I2P,SIGNAL(StreamConnectedRecived(const QString, const QString)),this, + SLOT(StreamConnectedRecived(const QString, const QString))); + + disconnect (I2P,SIGNAL(StreamReadyToSendRecived(const QString)),this, + SLOT(StreamReadyToSendRecived(const QString))); + + disconnect (I2P,SIGNAL(StreamSendRecived(const QString, const SAM_Message_Types::RESULT, SAM_Message_Types::STATE)),this, + SLOT(StreamSendRecived(const QString, const SAM_Message_Types::RESULT, SAM_Message_Types::STATE))); + + disconnect(I2P,SIGNAL(StreamDataRecived(const QString,const QString,const QByteArray)),this, + SLOT(StreamDataRecived(const QString, const QString, const QByteArray))); + + disconnect (I2P,SIGNAL(NamingReplyRecived(const SAM_Message_Types::RESULT, QString, QString, QString)),this, + SLOT(NamingReplyRecived(const SAM_Message_Types::RESULT, QString, QString, QString))); + + this->UserConnectThread->stop(); + this->saveUserList(); + this->closeAllActiveConenctions(); + for(int i=0;iusers.count();i++) + delete users.at(i); + + + + QList::Iterator it; + for(it=DataPacketsManagers.begin(); itDebugMessageHandler; + delete this->Protocol; + delete this->I2P; +} + +cDebugMessageManager* cCore::get_DebugMessageHandler(){ + return this->DebugMessageHandler; +} + +bool cCore::addNewUser(QString Name,QString I2PDestination,QString TorDestination,QString I2PStream_ID){ + //TODO I2PDestination verify check + //check if user already exist + if(I2PDestination.length()>0) + if(this->doesUserAllReadyExitsByI2PDestination(I2PDestination)==true) + return false; + + if(TorDestination.length()>0) + if(this->doesUserAllReadyExitsByTorDestination(TorDestination)==true) + return false; + + //add newuser + cUser* newuser=new cUser(Protocol,Name,I2PDestination,I2PStream_ID,TorDestination); + this->users.append(newuser); + saveUserList(); + + emit eventUserChanged(); + return true; +} +bool cCore::deleteUserByTorDestination(QString TorDestination){ +/* + for(int i=0;iget_TORDestination()==TorDestination){ + if(users.at(i)->get_ConnectionStatus()==ONLINE ||users.at(i)->get_ConnectionStatus()==TRYTOCONNECT) + I2P->doStreamClose(users.at(i)- + users.removeAt(i); + emit eventUserChanged(); + return true; + } + }*/ + return false; +} +bool cCore::deleteUserByI2PDestination(QString I2PDestination){ + for(int i=0;iget_I2PDestination()==I2PDestination){ + if(users.at(i)->get_ConnectionStatus()==ONLINE ||users.at(i)->get_ConnectionStatus()==TRYTOCONNECT) + { + deletePacketManagerByID(users.at(i)->get_I2PStreamID()); + this->StreamClose(users.at(i)->get_I2PStreamID()); + + } + + users.removeAt(i); + saveUserList(); + emit eventUserChanged(); + return true; + } + } + return false; +} + +bool cCore::doesUserAllReadyExitsByTorDestination(const QString TorDestination){ + + for(int i=0;iget_TORDestination()==TorDestination) { + return true; + } + } + + return false; +} +bool cCore::doesUserAllReadyExitsByI2PDestination(const QString I2PDestination){ + if(I2PDestination==MyDestination) return true; + + for(int i=0;iget_I2PDestination()==I2PDestination){ + + return true; + } + } + + return false; +} +void cCore::doNamingLookUP(QString Name){ + I2P->doNamingLookUP(Name); +} + +void cCore::init(){ + using namespace SESSION_Types; + this->MyDestination=""; + this->currentOnlineStatus=User::USERTRYTOCONNECT; + + QSettings* settings= new QSettings(QApplication::applicationDirPath()+"/application.ini",QSettings::IniFormat); + settings->beginGroup("Network"); + + this->I2P= new cConnectionI2P( settings->value("SamHost","127.0.0.1").toString(), + settings->value("SamPort","7656").toString(), + STREAM, + settings->value("Destination","test").toString(), + BOTH, + settings->value("SessionOptionString","").toString() + ,this); + + this->I2P=I2P; + + //signals from I2PConnection Core + connect (I2P,SIGNAL(StreamClosedRecived(const SAM_Message_Types::RESULT, QString, QString)),this, + SLOT(StreamClosedRecived(const SAM_Message_Types::RESULT, QString, QString)),Qt::DirectConnection); + + connect (I2P,SIGNAL(StreamStatusRecived(const SAM_Message_Types::RESULT, const QString, const QString)),this, + SLOT(StreamStatusRecived(const SAM_Message_Types::RESULT, const QString, QString)),Qt::DirectConnection); + + connect (I2P,SIGNAL(SessionStatusRecived(const SAM_Message_Types::RESULT, const QString, const QString)),this, + SLOT(SessionStatusRecived(const SAM_Message_Types::RESULT, const QString, QString)),Qt::DirectConnection); + + connect (I2P,SIGNAL(StreamConnectedRecived(const QString, const QString)),this, + SLOT(StreamConnectedRecived(const QString, const QString)),Qt::DirectConnection); + + connect (I2P,SIGNAL(StreamReadyToSendRecived(const QString)),this, + SLOT(StreamReadyToSendRecived(const QString)),Qt::DirectConnection); + + connect (I2P,SIGNAL(StreamSendRecived(const QString, const SAM_Message_Types::RESULT, SAM_Message_Types::STATE)),this, + SLOT(StreamSendRecived(const QString, const SAM_Message_Types::RESULT, SAM_Message_Types::STATE)),Qt::DirectConnection); + + connect (I2P,SIGNAL(StreamDataRecived(const QString, const QString, const QByteArray)),this, + SLOT(StreamDataRecived(const QString, const QString, const QByteArray)),Qt::DirectConnection); + + connect (I2P,SIGNAL(NamingReplyRecived(const SAM_Message_Types::RESULT, QString, QString, QString)),this, + SLOT(NamingReplyRecived(const SAM_Message_Types::RESULT, QString, QString, QString)),Qt::DirectConnection); + + this->DebugMessageHandler= new cDebugMessageManager(I2P); + this->Protocol= new cProtocol(this); + this->loadUserList(); + this->I2P->doConnect(); + + this->UserConnectThread= new cUserConnectThread(this,settings->value("Waittime_between_rechecking_offline_users","30000").toInt()); + +} +void cCore::saveUserList(){ + QFile file(QApplication::applicationDirPath()+"/users.config"); + file.open(QIODevice::WriteOnly | QIODevice::Text); + QTextStream out(&file); + + for(int i=0;iusers.count();i++){ + out<<"Nick:\t"<<(users.at(i)->get_Name())<get_I2PDestination())<get_TORDestination())<addNewUser(NickName,I2PDest,TorDest); + NickName.clear(); + I2PDest.clear(); + TorDest.clear(); + } + file.close(); + } +} + +void cCore::StreamClosedRecived(const SAM_Message_Types::RESULT result,QString ID,QString Message){ + + if(isThisID_a_FileSendID(ID)){ + //FileSend + for(int i=0;iget_StreamID()==ID){ + FileSends.at(i)->StreamClosed(result,ID,Message); + FileSends.removeAt(i); + return; + } + } + + } + else if(isThisID_a_FileReciveID(ID)){ + //Filerecive + for(int i=0;iget_StreamID()==ID){ + FileRecives.at(i)->StreamClosed(result,ID,Message); + FileRecives.removeAt(i); + return; + } + } + } + else if(this->isThisIDunknown(ID)==true){ + //if ID=UnKnown then remove the ID + this->removeUnknownID(ID); + } + + //known ID + + for(int i=0;iget_I2PStreamID()==ID){ + if( result==SAM_Message_Types::OK || + result==SAM_Message_Types::CANT_REACH_PEER || + result==SAM_Message_Types::TIMEOUT + ){ + users.at(i)->set_ConnectionStatus(OFFLINE); + deletePacketManagerByID(ID); + break; + } + else { + //on I2P_ERROR or PEER_NOT_FOUND + users.at(i)->set_ConnectionStatus(ERROR); + deletePacketManagerByID(ID); + break; + } + } + } + + emit eventUserChanged(); + +} + +void cCore::StreamStatusRecived(const SAM_Message_Types::RESULT result,const QString ID,QString Message){ + + if(isThisID_a_FileSendID(ID)){ + //FileSend + for(int i=0;iget_StreamID()==ID){ + FileSends.at(i)->StreamStatus(result,ID,Message); + if(result!=SAM_Message_Types::OK){ + FileSends.removeAt(i); + } + return; + } + } + + } + else if(isThisID_a_FileReciveID(ID)){ + //Filerecive + for(int i=0;iget_StreamID()==ID){ + FileRecives.at(i)->StreamStatus(result,ID,Message); + if(result!=SAM_Message_Types::OK){ + FileRecives.removeAt(i); + } + return; + } + } + } + else if(this->isThisIDunknown(ID)){ + if(result==SAM_Message_Types::OK){ + Protocol->newConnectionChat(ID); + + } + else{ + //I2P->doStreamClose(ID); + removeUnknownID(ID); + for(int i=0;iget_I2PStreamID()==ID){ + users.at(i)->set_ConnectionStatus(OFFLINE); + } + } + + + return; + } + return; + } + + for(int i=0;iget_I2PStreamID()==ID){ + if(result==SAM_Message_Types::OK){ + users.at(i)->set_ConnectionStatus(ONLINE); + users.at(i)->set_I2PStreamID(ID); + this->Protocol->newConnectionChat(ID); + } + else if( result==SAM_Message_Types::CANT_REACH_PEER || + result==SAM_Message_Types::TIMEOUT + ){ + + users.at(i)->set_ConnectionStatus(OFFLINE); + deletePacketManagerByID(ID); + } + else{ + //I2P Error + users.at(i)->set_ConnectionStatus(ERROR); + deletePacketManagerByID(ID); + } + + emit eventUserChanged(); + break; + } + } + +} +void cCore::SessionStatusRecived(const SAM_Message_Types::RESULT result,const QString Destination,const QString Message) +{ + if(result==(SAM_Message_Types::OK)){ + currentOnlineStatus=User::USERONLINE; + emit eventOnlineStatusChanged(); + I2P->doNamingLookUP("ME");//get the current Destination from this client + this->UserConnectThread->start(); + + } +} +void cCore::StreamConnectedRecived(const QString Destinaton,const QString ID){ + //Someone connected you + //this->Protocol->newConnection(ID); + cConnection t(ID,Destinaton); + this->unknownConnections.push_back(t); +} +bool cCore::removeUnknownID(QString ID) +{ + + for(int i=0;iunknownConnections.size();i++){ + if(unknownConnections.at(i).ID==ID){ + unknownConnections.removeAt(i); + + return true; + } + } + + return false; +} +QString cCore::get_UserProtocolVersionByStreamID(QString ID){ + + for(int i=0;i< users.size();i++) + if(users.at(i)->get_I2PStreamID()==ID){ + + return users.at(i)->get_ProtocolVersion(); + } + + return ""; +} +void cCore::set_UserProtocolVersionByStreamID(QString ID,QString Version){ + + for(int i=0;i< users.size();i++) + if(users.at(i)->get_I2PStreamID()==ID){ + users.at(i)->set_ProtocolVersion(Version); + + return; + } + +} + +void cCore::removeUnknownIDCreateUserIfNeeded(const QString ID,const QString ProtocolVersion){ + //TODO add some security thinks for adding !!! at the moment all user are allowed to connect + + QString Destinaton; + + for(int i=0;iget_I2PDestination()==Destinaton){ + if(users.at(i)->get_ConnectionStatus()==OFFLINE || users.at(i)->get_ConnectionStatus()==ERROR){ + users.at(i)->set_ProtocolVersion(ProtocolVersion); + users.at(i)->set_I2PStreamID(ID); + users.at(i)->set_ConnectionStatus(ONLINE); + } + else if(users.at(i)->get_ConnectionStatus()==ONLINE){ + //close both Streams + if(ID!=users.at(i)->get_I2PStreamID()) + { + I2P->doStreamClose(ID); + I2P->doStreamClose(users.at(i)->get_I2PStreamID()); + } + } + else if(users.at(i)->get_ConnectionStatus()==TRYTOCONNECT){ + //Stop the TRYTOCONNECT + if(ID!=users.at(i)->get_I2PStreamID()) + I2P->doStreamClose(users.at(i)->get_I2PStreamID()); + + users.at(i)->set_ProtocolVersion(ProtocolVersion); + users.at(i)->set_I2PStreamID(ID); + users.at(i)->set_ConnectionStatus(ONLINE); + } + + cPacketManager* newPacket=new cPacketManager(ID); + connect(newPacket,SIGNAL(aPacketIsComplead(const QString, const QByteArray)),Protocol, + SLOT(inputKnown(const QString,const QByteArray))); + + DataPacketsManagers.push_back(newPacket); + break; + } + } + + emit eventUserChanged(); +} + +void cCore::StreamReadyToSendRecived(const QString ID){ + + //FileSendsConnections + for(int i=0;iget_StreamID()==ID){ + FileSends.at(i)->StreamReadyToSend(true); + return; + } + } + + //the Rest (Chatconnections) + for(int i=0;iget_I2PStreamID()==ID){ + users.at(i)->set_ReadyToSend(true); + return; + } + } + +} +void cCore::StreamSendRecived(const QString ID,const SAM_Message_Types::RESULT result,SAM_Message_Types::STATE state){ +//FIXME what do when result = FAILED ?, impl. a stack ? + + //FileSendsConnections + for(int i=0;iget_StreamID()==ID){ + if(state==SAM_Message_Types::READY){ + FileSends.at(i)->StreamReadyToSend(true); + return; + } + else{ + FileSends.at(i)->StreamReadyToSend(false); + return; + } + } + } + + //the Rest (Chatconnections) + for(int i=0;iget_I2PStreamID()==ID){ + if(state==SAM_Message_Types::BUFFER_FULL)users.at(i)->set_ReadyToSend(false); + if(state==SAM_Message_Types::READY)users.at(i)->set_ReadyToSend(true); + } + } +} +const QList cCore::get_userList(){ + return users; +} +QString cCore::StreamConnect(QString Destination){ + QString ID; + + ID=I2P->doStreamConnect(Destination); + + cConnection t(ID,Destination); + this->unknownConnections.push_back(t); + return (ID); +} + +void cCore::StreamDataRecived(const QString ID,const QString Size,const QByteArray Data){ + + if(Data.isEmpty()==true)return; + + + + //FileRecive + for(int i=0;iget_StreamID()==ID){ + FileRecives.at(i)->operator <<(Data); + return; + } + } + + //FileSend + for(int i=0;iget_StreamID()==ID){ + FileSends.at(i)->operator <<(Data); + return; + } + } + //unknown connection + if(this->isThisIDunknown(ID)){ + QByteArray Data2=Protocol->inputUnknown(ID,Data); + + if(Data2.isEmpty()==true) + return; + else{ + QString StringSize=QString::number(Data2.length()); + + StreamDataRecived(ID,StringSize,Data2); + return; + } + } + + //normal connection + QList::Iterator it; + for(it=DataPacketsManagers.begin(); it!=DataPacketsManagers.end() ;++it){ + if((*(it))->getID()==ID){ + //(*(it))->operator <<(Data); + (*(*it))<get_ConnectionStatus()==ONLINE || + users.at(i)->get_ConnectionStatus()==TRYTOCONNECT) + { + deletePacketManagerByID(users.at(i)->get_I2PStreamID()); + I2P->doStreamClose(users.at(i)->get_I2PStreamID()); + //removeUnknownID(users.at(i)->get_I2PStreamID()); + + users.at(i)->set_ConnectionStatus(User::OFFLINE); + users.at(i)->set_OnlineState(USEROFFLINE); + + + } + //close all unknownConnections + for(int i=0;idoStreamClose(unknownConnections.at(i).ID); + removeUnknownID( unknownConnections.at(i).ID); + } + + emit eventUserChanged(); + +} + +bool cCore::isThisIDunknown(QString ID){ + + for(int i=0;iunknownConnections.size();i++) + if(unknownConnections.at(i).ID==ID){ + + return true; + } + + return false; +} +cUser* cCore::getUserByI2P_ID(QString ID){ + + for(int i=0;iget_I2PStreamID()==ID){ + + return users.at(i); + } + } + + return NULL; +} +cUser* cCore::getUserByI2P_Destination(QString Destination){ + + for(int i=0;iget_I2PDestination()==Destination){ + + return users.at(i); + } + } + + return NULL; +} +void cCore::NamingReplyRecived(const SAM_Message_Types::RESULT result,QString Name,QString Value,QString Message){ + if(result==SAM_Message_Types::OK && Name=="ME") + this->MyDestination=Value; +} +const QString cCore::getMyDestination()const{ + return this->MyDestination; +} +bool cCore::isThisDestinationInunknownConnections(QString Destination){ + for(int i=0;iisThisIDunknown(ID)==true) + return; + else + { + QList::Iterator it; + for(it=DataPacketsManagers.begin(); it!=DataPacketsManagers.end() ;++it){ + if((*(it))->getID()==ID){ + //delete (*(it)); + DataPacketsManagers.erase(it); + break; + + } + } + } +} + +QString cCore::get_connectionDump(){ + QString Message; + + Message+="< Current open Unknown IDs: >\n"; + for(int i=0;i::Iterator it; + for(it=DataPacketsManagers.begin(); it!=DataPacketsManagers.end();++it) + Message+= ((*(it))->getID()+"\n"); + + Message+="\n\n< Active FileTransfer: >\n"; + for(int i=0;iget_FileName()+"\n"; + Message+="StreamID:\t\t"+FileSends.at(i)->get_StreamID()+"\n"; + } + + Message+="\n\n< Active Filerecive: >\n"; + for(int i=0;iget_FileName()+"\n"; + Message+="StreamID:\t\t"+FileRecives.at(i)->get_StreamID()+"\n"; + } + + + Message+="\n\n< USER-Infos: >\n"; + for(int i=0;i< users.count();i++){ + Message+="Name:\t\t"+users.at(i)->get_Name()+"\n"; + Message+="ClientName:\t\t"+users.at(i)->get_ClientName()+"\n"; + Message+="ClientVersion:\t\t"+users.at(i)->get_ClientVersion()+"\n"; + Message+="ProtocolVersion:\t" +users.at(i)->get_ProtocolVersion()+"\n"; + Message+="I2PStreamID:\t\t" +users.at(i)->get_I2PStreamID()+"\n"; + + switch(users.at(i)->get_ConnectionStatus()) + { + case User::ONLINE: + { + Message+="ConnectionStatus:\tOnline\n\n"; + break; + } + case User::OFFLINE: + { + Message+="ConnectionStatus:\tOffline/Invisible\n\n"; + break; + } + case User::TRYTOCONNECT: + { + Message+="ConnectionStatus:\tTryToConnect\n\n"; + break; + + } + + case User::ERROR: + { + Message+="ConnectionStatus: (Stream)\tError\n\n"; + break; + + } + }; + } + return Message; +} + +bool cCore::renameuserByI2PDestination(const QString Destination, const QString newNickname){ + for(int i=0;iget_I2PDestination()==Destination){ + users.at(i)->set_Name(newNickname); + emit eventUserChanged(); + return true; + } + } + return false; +} + +ONLINESTATE cCore::getOnlineStatus() const +{ + return this->currentOnlineStatus; +} + +void cCore::setOnlineStatus(const ONLINESTATE newStatus) +{ + if(currentOnlineStatus==newStatus) return; + + if(newStatus==User::USEROFFLINE) + { + stopCore(); + this->currentOnlineStatus=newStatus; + } + else if(newStatus==User::USERTRYTOCONNECT) + { + if(currentOnlineStatus==User::USEROFFLINE) + { + restartCore(); + this->currentOnlineStatus=newStatus; + } + } + else + { + //send new Status to every connected User + this->currentOnlineStatus=newStatus; + + for(int i=0;iget_ConnectionStatus()==ONLINE) + { + switch(this->currentOnlineStatus) + { + case USERONLINE: + { + Protocol->send(USER_ONLINESTATUS_ONLINE,users.at(i)->get_I2PStreamID(),""); + break; + } + case USEROFFLINE: + case USERINVISIBLE: + { + Protocol->send(USER_ONLINESTATUS_OFFLINE,users.at(i)->get_I2PStreamID(),""); + break; + } + case USERAWAY: + { + Protocol->send(USER_ONLINESTATUS_AWAY,users.at(i)->get_I2PStreamID(),""); + break; + + } + case USERWANTTOCHAT: + { + Protocol->send(USER_ONLINESTATUS_WANTTOCHAT,users.at(i)->get_I2PStreamID(),""); + break; + } + case USERDONT_DISTURB: + { + Protocol->send(USER_ONLINESTATUS_DONT_DISTURB,users.at(i)->get_I2PStreamID(),""); + break; + } + default: + { + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Warning); + msgBox->setText("cCore(setOnlineStatus)"); + msgBox->setInformativeText("Unknown USERSTATE"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->show(); + + } + } + + + }//if + }//for + } + emit eventOnlineStatusChanged(); +} + +void cCore::stopCore() +{ + closeAllActiveConenctions(); + I2P->doDisconnect(); + UserConnectThread->stop(); + +} + +void cCore::restartCore() +{ + I2P->doConnect(); + UserConnectThread->start(); +} + +void cCore::startFileTransfer(QString FilePath, QString Destination) +{ + cFileTransferSend * t= new cFileTransferSend(this,FilePath,Destination); + FileSends.append(t); + +} + +bool cCore::isThisID_a_FileSendID(QString ID) +{ + for(int i=0;iget_StreamID()==ID){ + return true; + } + } + return false; +} + +bool cCore::isThisID_a_FileReciveID(QString ID) +{ + for(int i=0;iget_StreamID()==ID){ + return true; + } + } + return false; +} + +void cCore::addNewFileRecive(QString ID, QString FileName, QString FileSize) +{ + if(isThisIDunknown(ID)) removeUnknownID(ID); + + quint64 Size; + bool OK; + Size=FileSize.toULongLong(&OK,10); + if(OK==false) + { + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setIcon(QMessageBox::Critical); + msgBox->setText("cCore(addNewFileRecive)"); + msgBox->setInformativeText("Error convert QString to Quint64\nValue: "+FileSize +"\nFilerecive aborted"); + msgBox->setStandardButtons(QMessageBox::Ok); + msgBox->setDefaultButton(QMessageBox::Ok); + msgBox->setWindowModality(Qt::NonModal); + msgBox->exec(); + + //abort the Filerecive + this->StreamSendData(ID,QString("1"));//false + this->StreamClose(ID); + return; + } + cFileTransferRecive* t= new cFileTransferRecive(this,ID,FileName,Size); + FileRecives.append(t); + t->start(); +} + +void cCore::StreamSendData(QString ID, QByteArray Data) +{ + I2P->doStreamSend(ID,Data); +} + + +void cCore::StreamSendData(QString ID, QString Data) +{ + I2P->doStreamSend(ID,Data); +} + +void cCore::StreamClose(QString ID) +{ + if(FileSends.count()>0){ + for(int i=0;iget_StreamID()==ID){ + FileSends.removeAt(i); + break; + } + } + } + + if(FileRecives.count()>0){ + for(int i=0;iget_StreamID()==ID){ + FileRecives.removeAt(i); + break; + } + } + } + I2P->doStreamClose(ID); +} + +bool cCore::checkIfAFileTransferOrReciveisActive() +{ + if(FileSends.count()>0) return true; + if(FileRecives.count()>0) return true; + + return false; +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.h new file mode 100644 index 000000000..e4fc11189 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.h @@ -0,0 +1,155 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef CORE_H +#define CORE_H + +#include +#include +#include +#include +#include + +#include "User.h" +#include "ConnectionI2P.h" +#include "DebugMessageManager.h" +#include "I2PSamMessageAnalyser.h" + +#include "UserConnectThread.h" +#include "Protocol.h" +#include "PacketManager.h" +#include "FileTransferSend.h" +#include "FileTransferRecive.h" + + + +#define CLIENTVERSION "0.2.7 Beta" +#define CLIENTNAME "I2P-Messenger (QT)" + + + +struct cConnection +{ + cConnection ( QString ID,QString Destination ) + { + this->ID=ID; + this->Destination=Destination; + } + void operator= ( const cConnection& t ) + { + this->ID=t.ID; + this->Destination=t.Destination; + } + QString ID; + QString Destination; +}; + +using namespace SAM_Message_Types; +using namespace User; +class cUserConnectThread; + +class cCore :public QObject +{ + + Q_OBJECT + public: + cCore(); + ~cCore(); + cDebugMessageManager* get_DebugMessageHandler(); + const QList get_userList(); + bool isThisIDunknown ( QString ID ); + bool removeUnknownID ( QString ID ); + bool isThisDestinationInunknownConnections ( QString Destination ); + + void removeUnknownIDCreateUserIfNeeded( const QString ID,const QString ProtocolVersion ); + + QString get_UserProtocolVersionByStreamID ( QString ID ); + void set_UserProtocolVersionByStreamID ( QString ID,QString Version ); + cUser* getUserByI2P_ID ( QString ID ); + cUser* getUserByI2P_Destination ( QString Destination ); + const QString getMyDestination() const; + ONLINESTATE getOnlineStatus()const; + QString get_ClientName() {return CLIENTNAME;}; + QString get_ClientVersion(){return CLIENTVERSION;}; + QString get_ProtocolVersion(){return Protocol->get_ProtocolVersion();}; + void setOnlineStatus(const ONLINESTATE newStatus); + void startFileTransfer(QString FilePath,QString Destination); + void addNewFileRecive(QString ID,QString FileName,QString FileSize); + void StreamSendData(QString ID,QByteArray Data); + void StreamSendData(QString ID,QString Data); + void StreamClose(QString ID); + QString StreamConnect (QString Destination ); + bool checkIfAFileTransferOrReciveisActive(); + + + + public slots: + bool addNewUser (QString Name,QString I2PDestination,QString TorDestination,QString I2PStream_ID=""); + bool deleteUserByTorDestination (const QString TorDestination ); + bool deleteUserByI2PDestination (const QString I2PDestination ); + bool renameuserByI2PDestination (const QString Destination, const QString newNickname); + void doNamingLookUP ( QString Name ); + + + QString get_connectionDump(); + + private slots: + // + void StreamClosedRecived ( const SAM_Message_Types::RESULT result,QString ID,QString Message ); + void StreamStatusRecived ( const SAM_Message_Types::RESULT result,const QString ID,QString Message ); + void StreamConnectedRecived ( const QString Destinaton,const QString ID ); + void StreamReadyToSendRecived ( const QString ID ); + void StreamSendRecived ( const QString ID,const SAM_Message_Types::RESULT result,SAM_Message_Types::STATE state ); + void SessionStatusRecived ( const SAM_Message_Types::RESULT result,const QString Destination,const QString Message ); + void StreamDataRecived ( const QString ID,const QString Size,const QByteArray Data ); + void NamingReplyRecived ( const SAM_Message_Types::RESULT result,QString Name,QString Value="",QString Message="" ); + signals: + void eventUserChanged(); + void eventOnlineStatusChanged(); + + private: + cConnectionI2P* I2P; + cDebugMessageManager* DebugMessageHandler; + cProtocol* Protocol; + QList users; + QList unknownConnections; + cUserConnectThread* UserConnectThread; + QString MyDestination; + QList DataPacketsManagers; + ONLINESTATE currentOnlineStatus; + QList FileSends; + QList FileRecives; + + bool doesUserAllReadyExitsByTorDestination ( QString TorDestination ); + bool doesUserAllReadyExitsByI2PDestination ( QString I2PDestination ); + void init(); + void saveUserList(); + void loadUserList(); + void stopCore(); + void restartCore(); + void closeAllActiveConenctions(); + void deletePacketManagerByID ( QString ID ); + bool isThisID_a_FileSendID(QString ID); + bool isThisID_a_FileReciveID(QString ID); + + +}; +#endif + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/DebugMessageManager.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/DebugMessageManager.cpp new file mode 100644 index 000000000..32e276db0 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/DebugMessageManager.cpp @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "DebugMessageManager.h" + + +cDebugMessageManager::cDebugMessageManager(cConnectionI2P* I2P) +{ + + this->I2P=I2P; + + this->settings= new QSettings("./application.ini",QSettings::IniFormat); + settings->beginGroup("General"); + this->MaxMessageCount=settings->value("Debug_Max_Message_count","20").toInt(); + settings->endGroup(); + connect(I2P,SIGNAL(debugMessages(QString) ),this,SLOT(NewIncomingDebugMessage(const QString)) ); +} + +cDebugMessageManager::~cDebugMessageManager() +{ + disconnect(I2P,SIGNAL(debugMessages(QString)),this,SLOT(NewIncomingDebugMessage(const QString))); +} + +void cDebugMessageManager::clearAllMessages() +{ + Messages.clear(); +} + +const QStringList cDebugMessageManager::getAllMessages() +{ + return Messages; +} + +void cDebugMessageManager::NewIncomingDebugMessage(const QString Message){ + while(Messages.count()>= (signed int)MaxMessageCount){ + Messages.removeLast(); + } + + Messages.prepend(Message); + emit newDebugMessage(Message); +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/DebugMessageManager.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/DebugMessageManager.h new file mode 100644 index 000000000..4a05f6827 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/DebugMessageManager.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef DEBUGMESSAGEMANAGER_H +#define DEBUGMESSAGEMANAGER_H + +#include +#include + +#include "ConnectionI2P.h" + +class cDebugMessageManager:public QObject +{ + Q_OBJECT + + public: + cDebugMessageManager(cConnectionI2P* I2P); + ~cDebugMessageManager(); + + + public slots: + void clearAllMessages(); + const QStringList getAllMessages(); + + private slots: + void NewIncomingDebugMessage(const QString Message); + + signals: + void newDebugMessage(QString Message); + + private: + cConnectionI2P* I2P; + quint32 MaxMessageCount; + QSettings* settings; + QStringList Messages; +}; +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.cpp new file mode 100644 index 000000000..5436596b9 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.cpp @@ -0,0 +1,134 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "Core.h" +#include "FileTransferRecive.h" + + + +cFileTransferRecive::cFileTransferRecive(cCore * Core, QString StreamID, QString FileName, quint64 FileSize) +:StreamID(StreamID),FileName(FileName),FileSize(FileSize) +{ + this->Core=Core; + allreadyRecivedSize=0; + + +} + +cFileTransferRecive::~ cFileTransferRecive() +{ + delete Dialog; + delete FileForRecive; +} + +void cFileTransferRecive::StreamStatus(const SAM_Message_Types::RESULT result, const QString ID, QString Message) +{ + if(result==SAM_Message_Types::OK) + { + + } + else + { + FileForRecive->close(); + FileForRecive->remove(); + emit event_FileReciveError(); + + } + +} + +void cFileTransferRecive::StreamClosed(const SAM_Message_Types::RESULT result, QString ID, QString Message) +{ + if(allreadyRecivedSize==FileSize){ + + FileForRecive->close(); + emit event_FileRecivedFinishedOK(); + + } + else{ + FileForRecive->close(); + FileForRecive->remove(); + emit event_FileReciveAbort(); + } + +} + +void cFileTransferRecive::operator <<(QByteArray t) +{ + + allreadyRecivedSize+=t.length(); + FileForRecive->write(t); + FileForRecive->flush(); + + emit event_allreadyRecivedSizeChanged(allreadyRecivedSize); + + if(allreadyRecivedSize==FileSize) + { + Core->StreamClose(StreamID); + FileForRecive->close(); + emit event_FileRecivedFinishedOK(); + } +} + +void cFileTransferRecive::abbortFileRecive() +{ + Core->StreamClose(StreamID); + FileForRecive->close(); + FileForRecive->remove(); +} + +void cFileTransferRecive::start() +{ + QString SFileSize; + SFileSize.setNum(FileSize); + + + QMessageBox* msgBox= new QMessageBox(NULL); + msgBox->setText("Incoming FileTransfer"); + msgBox->setInformativeText("Do you want to accept it ?\nFileName: "+FileName+"\nFileSize: " +SFileSize+" Bit"); + msgBox->setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox->setDefaultButton(QMessageBox::Yes); + msgBox->setWindowModality(Qt::WindowModal); + int ret = msgBox->exec(); + + if(ret==QMessageBox::Yes){ + QString FilePath=QFileDialog::getSaveFileName(NULL,"File Save","./"+FileName); + + if(!FilePath.isEmpty()){ + FileForRecive= new QFile(FilePath); + FileForRecive->open(QIODevice::WriteOnly); + Core->StreamSendData(StreamID,QString("0"));//true + + Dialog= new form_fileRecive(this); + Dialog->show(); + } + else{ + Core->StreamSendData(StreamID,QString("1"));//false + Core->StreamClose(StreamID); + } + + } + else{ + Core->StreamSendData(StreamID,QString("1"));//false + Core->StreamClose(StreamID); + } +} + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.h new file mode 100644 index 000000000..a264e621b --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.h @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef FILETRANSFER_H +#define FILETRANSFER_H + +#include "gui/form_fileRecive.h" +#include "ConnectionI2P.h" + +class cCore; +class cFileTransferRecive:public QObject +{ + Q_OBJECT + public: + cFileTransferRecive(cCore* Core,QString StreamID,QString FileName,quint64 FileSize); + ~cFileTransferRecive(); + void start(); + + void StreamStatus(const SAM_Message_Types::RESULT result,const QString ID,QString Message); + void StreamClosed(const SAM_Message_Types::RESULT result,QString ID,QString Message); + void operator << ( QByteArray t ); + quint64 get_FileSize(){return FileSize;}; + QString get_FileName(){return FileName;}; + QString get_StreamID(){return StreamID;}; + + public slots: + void abbortFileRecive(); + + signals: + void event_allreadyRecivedSizeChanged(quint64 Size); + void event_FileReciveError(); + void event_FileRecivedFinishedOK(); + void event_FileReciveAbort(); + + private: + cCore* Core; + form_fileRecive* Dialog; + const quint64 FileSize; + quint64 allreadyRecivedSize; + const QString FileName; + const QString StreamID; + QFile* FileForRecive; +}; +#endif \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.cpp new file mode 100644 index 000000000..2704a431c --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.cpp @@ -0,0 +1,144 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "FileTransferSend.h" +#include "gui/form_fileSend.h" +#include "Core.h" + +cFileTransferSend::cFileTransferSend(cCore * Core, QString FilePath,QString Destination) +:FilePath(FilePath),Destination(Destination) +{ + this->Core=Core; + StreamID=Core->StreamConnect(Destination); + Core->removeUnknownID(StreamID); + + sendFirstPaket=true; + FileName=FilePath.mid(FilePath.lastIndexOf("/")+1); + FileTransferAccepted=false; + FileForSend = new QFile(FilePath); + FileSize=FileForSend->size(); + + Dialog=new form_fileSend(this); + Dialog->show(); +} + +void cFileTransferSend::abbortFileSend() +{ + FileForSend->close(); + Core->StreamClose(StreamID); +} + +void cFileTransferSend::StreamStatus(const SAM_Message_Types::RESULT result, const QString ID, QString Message) +{ + using namespace FileTransferProtocol; + + if(result==SAM_Message_Types::OK) + { + if(sendFirstPaket==true) + { + QString StringFileSize; + StringFileSize.setNum(FileSize); + + Core->StreamSendData(StreamID,FIRSTPAKET+StringFileSize+"\n"+FileName); + sendFirstPaket=false; + } + + } + else + { + FileForSend->close(); + emit event_FileTransferError(); + } + + +} + +void cFileTransferSend::StreamClosed(const SAM_Message_Types::RESULT result, QString ID, QString Message) +{ + if(result==SAM_Message_Types::OK){ + if(allreadySendedSize==FileSize){ + emit event_FileTransferFinishedOK(); + } + else + emit event_FileTransferAborted(); + } + else{ + emit event_FileTransferAborted(); + } + + FileForSend->close(); +} + +cFileTransferSend::~ cFileTransferSend() +{ + + delete FileForSend; + delete Dialog; +} + +void cFileTransferSend::StreamReadyToSend(bool t) +{ + if(t==false)return; + if(FileTransferAccepted==false)return; + + if(allreadySendedSize==FileSize) + { + emit event_FileTransferFinishedOK(); + Core->StreamClose(StreamID); + return; + } + + QByteArray Buffer; + + Buffer=FileForSend->read(MAXPAKETSIZE); + allreadySendedSize+=Buffer.length(); + + + Core->StreamSendData(StreamID,Buffer); + emit event_allreadySendedSizeChanged(allreadySendedSize); +} + +void cFileTransferSend::operator <<(QByteArray t) +{ + if(t.length()==1){ + if(t.contains("0")){//true + emit event_FileTransferAccepted(true); + FileTransferAccepted=true; + StartFileTransfer(); + + } + else{ + emit event_FileTransferAccepted(false); + Core->StreamClose(StreamID); + + } + } + else{ + emit event_FileTransferAccepted(false); + Core->StreamClose(StreamID); + } +} + +void cFileTransferSend::StartFileTransfer() +{ + allreadySendedSize=0; + FileForSend->open(QIODevice::ReadOnly); + StreamReadyToSend(true); +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.h new file mode 100644 index 000000000..eeeb3a063 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.h @@ -0,0 +1,78 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef FILETRANSFERSEND_H +#define FILETRANSFERSEND_H + +#include "ConnectionI2P.h" + +namespace FileTransferProtocol +{ + const QString PROTOCOLVERSION= "0.1"; + const QString FIRSTPAKET ="CHATSYSTEMFILETRANSFER\t"+PROTOCOLVERSION+"\n"; +//+sizeinbit\nFileName +}; + +//limited to 30Kb +#define MAXPAKETSIZE 30720 +class cCore; +class form_fileSend; +class cFileTransferSend:public QObject +{ + Q_OBJECT + + public: + cFileTransferSend(cCore* Core,QString FilePath,QString Destination); + ~cFileTransferSend(); + void StreamStatus(const SAM_Message_Types::RESULT result,const QString ID,QString Message); + void StreamClosed(const SAM_Message_Types::RESULT result,QString ID,QString Message); + void StreamReadyToSend(bool t); + void operator << ( QByteArray t ); + quint64 get_FileSize(){return FileSize;}; + QString get_StreamID(){return StreamID;}; + QString get_FileName(){return FileName;}; + + + public slots: + void abbortFileSend(); + + signals: + void event_allreadySendedSizeChanged(quint64 Size); + void event_FileTransferAccepted(bool t); + void event_FileTransferFinishedOK(); + void event_FileTransferError(); + void event_FileTransferAborted();//the otherSide abort it + + private: + void StartFileTransfer(); + + cCore* Core; + const QString FilePath; + qint64 FileSize; + qint64 allreadySendedSize; + const QString Destination; + QString StreamID; + QFile* FileForSend; + bool sendFirstPaket; + bool FileTransferAccepted; + QString FileName; + form_fileSend* Dialog; + +}; +#endif \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.cpp new file mode 100644 index 000000000..08ecc1604 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.cpp @@ -0,0 +1,218 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "I2PSamMessageAnalyser.h" + +I2PSamMessageAnalyser::I2PSamMessageAnalyser() +{ + //Constructor +} + +const SAM_MESSAGE I2PSamMessageAnalyser::Analyse(QString Message) +{ + using namespace SAM_Message_Types; + + SAM_MESSAGE t; + QStringList list =Message.split(" ",QString::SkipEmptyParts); + + + if((list[0]=="STREAM") && (list[1]=="RECEIVED")){ + t.type=STREAM_RECEIVED; + + //get ID + QStringList temp=list[2].split("="); + t.Id=temp[1]; + //get Size + temp= list[3].split("="); + t.Size=temp[1].remove("\n"); + } + else if((list[0].contains("STREAM")==true) && (list[1].contains("READY_TO_SEND")==true)){ + t.type=STREAM_READY_TO_SEND; + + //GET ID + QStringList temp=list[2].split("="); + t.Id=temp[1].remove("\n"); + } + else if((list[0]=="HELLO") && (list[1]=="REPLY")){ + t.type=HELLO_REPLAY; + + if(list[2].contains("RESULT=OK")==true) t.result=OK; + else if(list[2].contains("RESULT=NOVERSION")==true)t.result=NOVERSION; + + } + else if((list[0].contains("SESSION")==true) && (list[1].contains("STATUS")==true)){ + t.type=SESSION_STATUS; + + //Get Result + if(list[2].contains("RESULT=OK",Qt::CaseInsensitive))t.result=OK; + else if(list[2].contains("RESULT=DUPLICATED_DEST",Qt::CaseInsensitive))t.result=DUPLICATED_DEST; + else if(list[2].contains("RESULT=I2P_ERROR",Qt::CaseInsensitive))t.result=I2P_ERROR; + else if(list[2].contains("RESULT=INVALID_KEY",Qt::CaseInsensitive))t.result=INVALID_KEY; + else + t.type=ERROR_IN_ANALYSE; + //---------------- + + + //Get Destination + QStringList temp=list[3].split("="); + + t.Destination=temp[1].remove("\n"); + //---------------- + //Get Message + if(Message.contains("MESSAGE=",Qt::CaseInsensitive)){ + t.Message=Message.mid(Message.indexOf("MESSAGE=")+8); + t.Message.remove("\n"); + } + + //---------------- + + } + else if((list[0].contains("STREAM")==true) && (list[1].contains("STATUS")==true)){ + t.type=STREAM_STATUS; + + //Get Result + if(list[2].contains("RESULT=OK",Qt::CaseInsensitive))t.result=OK; + else if(list[2].contains("RESULT=CANT_REACH_PEER",Qt::CaseInsensitive))t.result=CANT_REACH_PEER; + else if(list[2].contains("RESULT=I2P_ERROR",Qt::CaseInsensitive))t.result=I2P_ERROR; + else if(list[2].contains("RESULT=INVALID_KEY",Qt::CaseInsensitive))t.result=INVALID_KEY; + else if(list[2].contains("RESULT=TIMEOUT",Qt::CaseInsensitive))t.result=TIMEOUT; + else + { + t.type=ERROR_IN_ANALYSE; + return t; + } + //---------------- + //Get ID + QStringList temp=list[3].split("="); + + t.Id=temp[1].remove("\n"); + //---------------- + //Get Message + if(Message.contains("MESSAGE=",Qt::CaseInsensitive)){ + t.Message=Message.mid(Message.indexOf("MESSAGE=")+8); + t.Message.remove("\n"); + } + //---------------- + + } + else if((list[0].contains("STREAM")==true) && (list[1].contains("CONNECTED")==true)){ + t.type=STREAM_CONNECTED; + + QStringList temp=list[2].split("="); + t.Destination=temp[1]; + + temp=list[3].split("="); + t.Id=temp[1].remove("\n"); + + } + else if((list[0].contains("STREAM")==true) && (list[1].contains("SEND")==true)){ + t.type=STREAM_SEND; + + //get ID + QStringList temp=list[2].split("="); + t.Id=temp[1]; + + //Get Result + if(list[3].contains("RESULT=OK",Qt::CaseInsensitive))t.result=OK; + else if(list[2].contains("RESULT=FAILED",Qt::CaseInsensitive))t.result=FAILED; + + //get STATE + if(list[4].contains("STATE=BUFFER_FULL",Qt::CaseInsensitive))t.state=BUFFER_FULL; + else if(list[4].contains("STATE=READY",Qt::CaseInsensitive))t.state=READY; + + } + else if((list[0].contains("STREAM")==true) && (list[1].contains("CLOSED")==true)){ + t.type=STREAM_CLOSED; + + //Get RESULT + if(list[2].contains("RESULT",Qt::CaseInsensitive)) + { + + if(list[2].contains("RESULT=OK",Qt::CaseInsensitive))t.result=OK; + else if(list[2].contains("RESULT=CANT_REACH_PEER",Qt::CaseInsensitive))t.result=CANT_REACH_PEER; + else if(list[2].contains("RESULT=I2P_ERROR",Qt::CaseInsensitive))t.result=I2P_ERROR; + else if(list[2].contains("RESULT=PEER_NOT_FOUND",Qt::CaseInsensitive))t.result=PEER_NOT_FOUND; + else if(list[2].contains("RESULT=TIMEOUT",Qt::CaseInsensitive))t.result=TIMEOUT; + else{ + t.type=ERROR_IN_ANALYSE; + return t; + } + + //Get ID + QStringList temp=list[3].split("="); + t.Id=temp[1]; + } + else + { + if(list[3].contains("RESULT=OK",Qt::CaseInsensitive))t.result=OK; + else if(list[3].contains("RESULT=CANT_REACH_PEER",Qt::CaseInsensitive))t.result=CANT_REACH_PEER; + else if(list[3].contains("RESULT=I2P_ERROR",Qt::CaseInsensitive))t.result=I2P_ERROR; + else if(list[3].contains("RESULT=PEER_NOT_FOUND",Qt::CaseInsensitive))t.result=PEER_NOT_FOUND; + else if(list[3].contains("RESULT=TIMEOUT",Qt::CaseInsensitive))t.result=TIMEOUT; + else{ + t.type=ERROR_IN_ANALYSE; + return t; + } + + //Get ID + QStringList temp=list[2].split("="); + t.Id=temp[1]; + + } + + //---------------- + //Get Message + if(Message.contains("MESSAGE=",Qt::CaseInsensitive)){ + t.Message=Message.mid(Message.indexOf("MESSAGE=")+8); + t.Message.remove("\n"); + } + //---------------- + } + else if((list[0].contains("NAMING")==true) && (list[1].contains("REPLY")==true)){ + t.type=NAMING_REPLY; + + //get Result + if(list[2].contains("RESULT=OK",Qt::CaseInsensitive))t.result=OK; + else if(list[2].contains("RESULT=INVALID_KEY",Qt::CaseInsensitive))t.result=INVALID_KEY; + else if(list[2].contains("RESULT=KEY_NOT_FOUND",Qt::CaseInsensitive))t.result=KEY_NOT_FOUND; + else{ + t.type=ERROR_IN_ANALYSE; + return t; + } + //get Name + QStringList temp=list[3].split("="); + t.Name=temp[1].remove("\n"); + + //get Value + if(list.count()-1>=4){ + QStringList temp=list[4].split("="); + t.Value=temp[1].remove("\n"); + } + //Get Message + if(Message.contains("MESSAGE=",Qt::CaseInsensitive)){ + t.Message=Message.mid(Message.indexOf("MESSAGE=")+8); + t.Message.remove("\n"); + } + } + else{ + t.type=ERROR_IN_ANALYSE; + } + + return t; +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.h new file mode 100644 index 000000000..1c158bd7a --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.h @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef I2PSAMMESSAGEANALYSER_H +#define I2PSAMMESSAGEANALYSER_H + +#include + +namespace SAM_Message_Types +{ + + + enum TYPE + { + HELLO_REPLAY, + SESSION_STATUS, + STREAM_STATUS, + STREAM_CONNECTED, + STREAM_SEND, + STREAM_READY_TO_SEND, + STREAM_CLOSED, + STREAM_RECEIVED, + NAMING_REPLY, + + ERROR_IN_ANALYSE + }; + + enum RESULT + { + OK, + DUPLICATED_DEST, + I2P_ERROR, + INVALID_KEY, + CANT_REACH_PEER, + TIMEOUT, + FAILED, + NOVERSION, + KEY_NOT_FOUND, + PEER_NOT_FOUND + }; + + enum STATE + { + BUFFER_FULL, + READY + }; +} + +struct SAM_MESSAGE +{ + public: + QString Message; + QString Id; + QString Destination; + QString Size; + QString Name; + QString Value; + SAM_Message_Types::TYPE type; + SAM_Message_Types::RESULT result; + SAM_Message_Types::STATE state; + /* + SAM_MESSAGE(TYPE t,RESULT r,QString Message,QString Id,QString Destination,QString Size) + :type(t),result(r),Message(Message),Id(Id),Destination(Destination),Size(Size) + { + } + */ +}; + + +class I2PSamMessageAnalyser: public QObject +{ + Q_OBJECT + public: + I2PSamMessageAnalyser(); + const SAM_MESSAGE Analyse(QString Message); +}; +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Main.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Main.cpp new file mode 100644 index 000000000..dff8d40fd --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Main.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include + +#include "gui/form_Main.h" + +int main(int argc, char *argv[]) +{ + + + QApplication app(argc, argv); + form_MainWindow* mainForm= new form_MainWindow(); + mainForm->show(); + return app.exec(); + app.closeAllWindows(); + + return 0; +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.cpp new file mode 100644 index 000000000..2754b054c --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.cpp @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "PacketManager.h" + + + +cPacketManager::cPacketManager ( QString ID ) +:ID ( ID ) +{ + Data.clear(); +} + +cPacketManager::~cPacketManager() +{ +} +void cPacketManager::operator << ( QByteArray t ) +{ + Data.push_back ( t ); + checkifOnePacketIsComplead(); +} +const QString cPacketManager::getID() +{ + return ID; +} + +void cPacketManager::checkifOnePacketIsComplead() +{ + if ( Data.length() >=8 ) + { + QString sPacketLength=Data.mid ( 0,4 ); + bool OK=false; + int iPacketLength =sPacketLength.toInt ( &OK,16 ); + if(OK==false) + { + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText("cPacketManager"); + msgBox.setInformativeText("cant parse PacketLength\nHexValue: "+sPacketLength ); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.exec(); + } + + + if ( Data.length() >=iPacketLength+4 ) + { + QByteArray CurrentPacket ( Data.mid ( 4 ),iPacketLength ); + Data.remove ( 0,iPacketLength+4 ); + emit aPacketIsComplead ( ID,CurrentPacket ); + checkifOnePacketIsComplead(); + } + } +} + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.h new file mode 100644 index 000000000..322b86770 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.h @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef PACKETMANAGER_H +#define PACKETMANAGER_H + +#include +#include + +class cPacketManager :public QObject +{ + Q_OBJECT + + + public: + cPacketManager() {} + cPacketManager ( QString ID ); + ~cPacketManager(); + void operator << ( QByteArray t ); + const QString getID(); + + void checkifOnePacketIsComplead(); + signals: + void aPacketIsComplead ( const QString ID,const QByteArray CurrentPacket ); + private: + const QString ID; + QByteArray Data; +}; +#endif \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.cpp new file mode 100644 index 000000000..1e455aa33 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.cpp @@ -0,0 +1,344 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "Protocol.h" +#include "Core.h" +#include "User.h" + +cProtocol::cProtocol(cCore * Core){ + this->Core=Core; + + connect (this,SIGNAL(eventUserChanged()),Core,SIGNAL(eventUserChanged())); + +} + +void cProtocol::newConnectionChat(const QString ID){ + using namespace Protocol_Info; + //send the ChatSystem\tProtocolVersion + Core->StreamSendData(ID,FIRSTPAKETCHAT); +} +void cProtocol::inputKnown(const QString ID, const QByteArray Data){ +using namespace Protocol_Info; + + if(Data.length()<4) + return; + + QString ProtocolInfoTag(Data.left(4)); + + //COMMANDS + if(ProtocolInfoTag=="1000"){//PING: + send(ECHO_OF_PING,ID,""); + } + else if(ProtocolInfoTag=="1001"){//GET_CLIENTVERSION: + send(ANSWER_OF_GET_CLIENTVERSION,ID,Core->get_ClientVersion()); + } + else if(ProtocolInfoTag=="1002"){//GET_CLIENTNAME: + send(ANSWER_OF_GET_CLIENTNAME,ID,Core->get_ClientName()); + } + else if(ProtocolInfoTag=="1003"){//GET_USER_ONLINESTATUS: + //TODO sendOnlineStatus + switch(Core->getOnlineStatus()) + { + case USERONLINE: + { + send(USER_ONLINESTATUS_ONLINE,ID,""); + break; + } + case USEROFFLINE: + case USERINVISIBLE: + { + send(USER_ONLINESTATUS_OFFLINE,ID,""); + break; + } + case USERAWAY: + { + send(USER_ONLINESTATUS_AWAY,ID,""); + break; + + } + case USERWANTTOCHAT: + { + send(USER_ONLINESTATUS_WANTTOCHAT,ID,""); + break; + } + case USERDONT_DISTURB: + { + send(USER_ONLINESTATUS_DONT_DISTURB,ID,""); + break; + } + default: + { + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText("cProtocol(inputKnown)"); + msgBox.setInformativeText("Unknown USERSTATE"); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.exec(); + + } + } + + } + + //end of commands + + + //Messages + else if(ProtocolInfoTag=="0001"){//ANSWER_OF_GET_CLIENTVERSION + cUser* thisUser=Core->getUserByI2P_ID(ID); + if(thisUser!=NULL){ + QString ClientVersion=Data.mid(4); + thisUser->set_ClientVersion(ClientVersion); + } + + } + else if(ProtocolInfoTag=="0002"){//ANSWER_OF_GET_CLIENTNAME + cUser* thisUser=Core->getUserByI2P_ID(ID); + if(thisUser!=NULL){ + QString Clientname=Data.mid(4); + thisUser->set_ClientName(Clientname); + } + + } + else if(ProtocolInfoTag=="0003"){//chatmessage + cUser* thisUser=Core->getUserByI2P_ID(ID); + if(thisUser!=NULL){ + QByteArray temp=Data.mid(4); + thisUser->IncomingNewChatMessage(temp); + emit eventUserChanged(); + } + } + else if(ProtocolInfoTag=="0004"){//USER_ONLINESTATUS_ONLINE + cUser* thisUser=Core->getUserByI2P_ID(ID); + if(thisUser!=NULL){ + QByteArray temp=Data.mid(4); + thisUser->set_OnlineState(USERONLINE); + emit eventUserChanged(); + } + } + else if(ProtocolInfoTag=="0005"){//USER_ONLINESTATUS_OFFLINE || USER_ONLINESTATUS_INVISIBLE + cUser* thisUser=Core->getUserByI2P_ID(ID); + if(thisUser!=NULL){ + QByteArray temp=Data.mid(4); + thisUser->set_OnlineState(USEROFFLINE); + emit eventUserChanged(); + + } + } + else if(ProtocolInfoTag=="0006"){//USER_ONLINESTATUS_WANTTOCHAT + cUser* thisUser=Core->getUserByI2P_ID(ID); + if(thisUser!=NULL){ + QByteArray temp=Data.mid(4); + thisUser->set_OnlineState(USERWANTTOCHAT); + emit eventUserChanged(); + + } + } + else if(ProtocolInfoTag=="0007"){//USER_ONLINESTATUS_AWAY + cUser* thisUser=Core->getUserByI2P_ID(ID); + if(thisUser!=NULL){ + QByteArray temp=Data.mid(4); + thisUser->set_OnlineState(USERAWAY); + emit eventUserChanged(); + } + } + else if(ProtocolInfoTag=="0008"){//USER_ONLINESTATUS_DONT_DISTURB + cUser* thisUser=Core->getUserByI2P_ID(ID); + if(thisUser!=NULL){ + QByteArray temp=Data.mid(4); + thisUser->set_OnlineState(USERDONT_DISTURB); + emit eventUserChanged(); + } + } + //end Messages +} + +QByteArray cProtocol::inputUnknown(const QString ID, const QByteArray Data){ +using namespace Protocol_Info; + + if(Core->isThisIDunknown(ID)==true){ + //check if First Paket = from a other CHATSYSTEM + if(Data.contains("CHATSYSTEM\t")==true){ + QByteArray temp=Data.mid(Data.indexOf("\t")+1,Data.indexOf("\n")-Data.indexOf("\t")-1); + QString version(temp); + + //dont send the firstpacket if you have connected someone + //(the firstpacket is sended from core::StreamStatusRecived) + bool OK=false; + int IDNumber =ID.toInt ( &OK,16 ); + if(OK==false) + { + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Critical); + msgBox.setText("cProtocol(inputUnknown)"); + msgBox.setInformativeText("cant parse StreamID\nHexValue: "+ID ); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.exec(); + } + + if(IDNumber<0) + newConnectionChat(ID);//someone connect you + + Core->removeUnknownIDCreateUserIfNeeded(ID,version); + //remove Firstpacket + QByteArray Data2=Data; + Data2.remove(0,Data.indexOf("\n")+1); + + return Data2; + } + else if(Data.contains("CHATSYSTEMFILETRANSFER\t")==true) + { + //FIRSTPAKET ="CHATSYSTEMFILETRANSFER\t"+PROTOCOLVERSION+"\nSizeinBit\nFileName"; + QByteArray Data2=Data; + + QString ProtovolVersion=Data2.mid(Data.indexOf("\t")+1,Data2.indexOf("\n")-Data2.indexOf("\t")-1); + Data2.remove(0,Data2.indexOf("\n")+1);//CHATSYSTEMFILETRANSFER\tPROTOCOLVERSION + + QString FileSize=Data2.mid(0,Data2.indexOf("\n")); + Data2.remove(0,Data2.indexOf("\n")+1); + + QString FileName=Data2; + + Core->removeUnknownID(ID); + Core->addNewFileRecive(ID,FileName,FileSize); + Data2.clear(); + return Data2; + + } + else{ + // not from a other CHATSYSTEM + Core->StreamSendData(ID,HTTPPAGE); + Core->StreamClose(ID); + Core->removeUnknownID(ID); + QByteArray Data2; + Data2.clear(); + + return Data2; + } + + } + //not possible + return Data; +} + +void cProtocol::send(const COMMANDS_TAGS TAG,const QString ID){ + using namespace Protocol_Info; + QString ProtocolInfoTag; + QString Data=""; + switch(TAG){ + case PING: + { + ProtocolInfoTag="1000"; + break; + } + case GET_CLIENTVERSION: + { + ProtocolInfoTag="1001"; + break; + } + case GET_CLIENTNAME: + { + ProtocolInfoTag="1002"; + break; + } + case GET_USER_ONLINESTATUS: + { + ProtocolInfoTag="1003"; + break; + } + default: + { + break; + } + + } + Data.insert(0,ProtocolInfoTag); + Data.insert(0,"0004");//No PaketData + Core->StreamSendData(ID,Data); +} + +void cProtocol::send(const MESSAGES_TAGS TAG,const QString ID,QString Data){ + QString ProtocolInfoTag; + + switch(TAG) + { + case ECHO_OF_PING: + { + ProtocolInfoTag="0000"; + break; + } + case ANSWER_OF_GET_CLIENTVERSION: + { + ProtocolInfoTag="0001"; + break; + } + case ANSWER_OF_GET_CLIENTNAME: + { + ProtocolInfoTag="0002"; + break; + } + case CHATMESSAGE: + { + ProtocolInfoTag="0003"; + break; + } + case USER_ONLINESTATUS_ONLINE: + { + ProtocolInfoTag="0004"; + break; + } + case USER_ONLINESTATUS_OFFLINE: + case USER_ONLINESTATUS_INVISIBLE: + { + ProtocolInfoTag="0005"; + break; + } + case USER_ONLINESTATUS_WANTTOCHAT: + { + ProtocolInfoTag="0006"; + break; + } + case USER_ONLINESTATUS_AWAY: + { + ProtocolInfoTag="0007"; + break; + } + case USER_ONLINESTATUS_DONT_DISTURB: + { + ProtocolInfoTag="0008"; + break; + } + + default: + { + break; + } + } + QString temp; + + + temp.setNum(Data.length()+4,16);//hex + QString Paketlength=QString("%1").arg(temp,4,'0'); + + Data.insert(0,ProtocolInfoTag); + Data.insert(0,Paketlength); + Core->StreamSendData(ID,Data); +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.h new file mode 100644 index 000000000..2ac7f4c53 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.h @@ -0,0 +1,95 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef PROTOCOL +#define PROTOCOL + +#include +#include + + +/* + First packet on connection must be: + CHATSYSTEM\tProtocolVersion\n + CHATSYSTEMFILETRANSFER\tProtocolVersion\nSizeinBit\nFileName + else + send //maybe with information about the user ??? + //maybe good for usersearch ? + + Every packet must be >= 8 Byte + 1-4 Byte = Paketlength in Byte (HEX) without the 4 Byte Paketlength + 5-8 Byte = PaketInfo + >8 Byte = PaketData +*/ + +namespace Protocol_Info{ + const QString PROTOCOLVERSION="0.2"; + const QString FIRSTPAKETCHAT="CHATSYSTEM\t"+PROTOCOLVERSION+"\n"; + const QString HTTPPAGE="
This is not a eepsite,this is a I2PMessenger Destination

\n\n\n"; +}; + +namespace PROTOCOL_TAGS{ + enum COMMANDS_TAGS{ + PING, + GET_PROTOCOLVERSION, + GET_CLIENTVERSION, + GET_CLIENTNAME, + GET_USER_ONLINESTATUS + }; + enum MESSAGES_TAGS{ + CHATMESSAGE, + ECHO_OF_PING, + ANSWER_OF_GET_CLIENTVERSION, + ANSWER_OF_GET_CLIENTNAME, + USER_ONLINESTATUS_ONLINE, + USER_ONLINESTATUS_OFFLINE, + USER_ONLINESTATUS_INVISIBLE, + USER_ONLINESTATUS_WANTTOCHAT, + USER_ONLINESTATUS_AWAY, + USER_ONLINESTATUS_DONT_DISTURB + }; + + +}; +using namespace Protocol_Info; +using namespace PROTOCOL_TAGS; +class cCore; +class cUser; +class cProtocol:public QObject{ +Q_OBJECT +public: + cProtocol(cCore* Core); + QString get_ProtocolVersion(){return PROTOCOLVERSION;}; +public slots: + QByteArray inputUnknown(const QString ID,const QByteArray Data); + void inputKnown(const QString ID, const QByteArray Data); + void send(const MESSAGES_TAGS TAG,const QString ID,QString Data); + void send(const COMMANDS_TAGS TAG,const QString ID); + void newConnectionChat(const QString ID); + +signals: + void eventUserChanged();//also used for newchatMessage +private: + cCore* Core; + + + +}; + +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.cpp new file mode 100644 index 000000000..983d1df0b --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.cpp @@ -0,0 +1,189 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "User.h" +#include "Protocol.h" + +cUser::cUser( cProtocol* Protocol, + QString Name, + QString I2PDestination, + QString I2PStream_ID, + QString TorDestination + ):I2PDestination(I2PDestination),TorDestination(TorDestination) +{ + this->Protocol=Protocol; + this->Name=Name; + this->ReadyToSend=true; + this->TORStream_ID=""; + this->I2PStream_ID=I2PStream_ID; + this->ConnectionStatus=OFFLINE; + this->HaveAllreadyOneChatWindow=false; + this->newUnreadMessages=false; + this->ClientName=""; + this->ClientVersion=""; + this->CurrentOnlineState=USEROFFLINE; +} + +const QString cUser::get_Name()const{ + return this->Name; +} +const QString cUser::get_I2PDestination()const{ + return this->I2PDestination; +} +const QString cUser::get_I2PStreamID()const{ + return this->I2PStream_ID; +} +const QString cUser::get_TORDestination()const{ + return this->TorDestination; +} +const QString cUser::get_TORStream_ID()const{ + return this->TORStream_ID; +} + +CONNECTIONTOUSER cUser::get_ConnectionStatus()const{ + return this->ConnectionStatus; +} + +void cUser::set_Name(QString newName){ + this->Name=newName; +} +void cUser::set_ConnectionStatus(CONNECTIONTOUSER Status){ + this->ConnectionStatus=Status; + + if(Status==ONLINE){ + //get some Infos from the CHATSYSTEM - client + Protocol->send(GET_CLIENTNAME,I2PStream_ID); + Protocol->send(GET_CLIENTVERSION,I2PStream_ID); + Protocol->send(GET_USER_ONLINESTATUS,I2PStream_ID); + } + + + if(Status==OFFLINE ||Status==ERROR) + { + I2PStream_ID=""; + this->CurrentOnlineState=USEROFFLINE; + } + //emit OnlineStateChanged(); +} +void cUser::set_I2PStreamID(QString ID){ + this->I2PStream_ID=ID; +} +void cUser::set_ReadyToSend(bool b){ + ReadyToSend=b; +} +void cUser::set_ProtocolVersion(QString Version){ + this->ProtocolVersion=Version; +} +const QString cUser::get_ProtocolVersion()const{ + return this->ProtocolVersion; +} + +void cUser::IncomingNewChatMessage(QString newMessage){ + this->Messages.push_back(Name+": "+newMessage+"
"); + this->newUnreadMessages=true; + emit newMessageRecived(); +} +void cUser::sendChatMessage(QString Message){ + using namespace PROTOCOL_TAGS; + if(this->ReadyToSend==false)return; + + if(ConnectionStatus==ONLINE && + CurrentOnlineState != USEROFFLINE && + CurrentOnlineState != USERINVISIBLE + ){ + Protocol->send(CHATMESSAGE,I2PStream_ID,Message); + this->Messages.push_back("Me: "+Message+"
"); + //this->Messages.push_back(Message); + emit newMessageRecived(); + } + else{ + + this->Messages.push_back("[SYSTEM]: Sending the Message when the user come online
When you close the client the Message is lost
"); + + unsendedMessages.push_back(Message); + emit newMessageRecived(); + + } +} +void cUser::set_HaveAllreadyOneChatWindow(bool t){ + HaveAllreadyOneChatWindow=t; +} +bool cUser::getHaveAllreadyOneChatWindow() const{ + return HaveAllreadyOneChatWindow; +} +const QStringList& cUser::get_ChatMessages(){ + newUnreadMessages=false; + return Messages; +} +void cUser::sendAllunsendedMessages(){ + using namespace PROTOCOL_TAGS; + if(unsendedMessages.empty())return; + + + for(int i=0;isend(CHATMESSAGE,I2PStream_ID,unsendedMessages.at(i)); + + + + this->Messages.push_back("[SYSTEM]: All unsended Messages where sended

"); + unsendedMessages.clear(); + this->newUnreadMessages=true; + emit newMessageRecived(); +} + +bool cUser::getHaveNewUnreadMessages(){ + return newUnreadMessages; +} + +const QString cUser::get_ClientName() const +{ + return ClientName; +} + +void cUser::set_ClientName(QString Name) +{ + ClientName=Name; +} + +const QString cUser::get_ClientVersion() const +{ + return ClientVersion; +} + +void cUser::set_ClientVersion(QString Version) +{ + this->ClientVersion=Version; +} + +ONLINESTATE cUser::get_OnlineState() const +{ + return CurrentOnlineState; +} + +void cUser::set_OnlineState(const ONLINESTATE newState) +{ + this->CurrentOnlineState=newState; + + if( CurrentOnlineState!=USEROFFLINE && + CurrentOnlineState!=USERINVISIBLE){ + this->sendAllunsendedMessages(); + } + + emit OnlineStateChanged(); +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.h new file mode 100644 index 000000000..063215128 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.h @@ -0,0 +1,117 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef USER_H +#define USER_H + +#include +#include + + +namespace User +{ + enum CONNECTIONTOUSER{ + OFFLINE, + ONLINE, + TRYTOCONNECT, + ERROR + }; + + enum ONLINESTATE{ + USERONLINE, + USEROFFLINE, + USERINVISIBLE, + USERWANTTOCHAT, + USERAWAY, + USERDONT_DISTURB, + USERTRYTOCONNECT + }; + +}//namespace user + +using namespace User; +class cProtocol; +class cUser: public QObject +{ + Q_OBJECT + public: + cUser( cProtocol* Protocol, + QString Name, + QString I2PDestination, + QString I2PStream_ID, + QString TorDestination + ); + + const QString get_Name()const; + const QString get_I2PDestination()const; + const QString get_I2PStreamID()const; + const QString get_TORDestination()const; + const QString get_TORStream_ID()const; + const QString get_ProtocolVersion()const; + const QString get_ClientName()const; + const QString get_ClientVersion()const; + CONNECTIONTOUSER get_ConnectionStatus()const; + ONLINESTATE get_OnlineState()const; + + const QStringList &get_ChatMessages(); + bool getHaveAllreadyOneChatWindow()const; + bool getHaveNewUnreadMessages(); + + void set_ConnectionStatus(CONNECTIONTOUSER Status); + void set_OnlineState(const ONLINESTATE newState); + void set_Name(QString newName); + void set_I2PStreamID(QString ID); + void set_ReadyToSend(bool b); + void set_ProtocolVersion(QString Version); + void set_HaveAllreadyOneChatWindow(bool t); + void set_ClientName(QString Name); + void set_ClientVersion(QString Version); + void IncomingNewChatMessage(QString newMessage); + + public slots: + void sendChatMessage(QString Message); + + signals: + void OnlineStateChanged(); + void newMessageRecived(); + private: + bool HaveAllreadyOneChatWindow; + bool newUnreadMessages; + void sendAllunsendedMessages(); + + const QString I2PDestination; + const QString TorDestination; + + QString Name; + QString I2PStream_ID; + QString TORStream_ID; + + bool ReadyToSend; + + CONNECTIONTOUSER ConnectionStatus; + ONLINESTATE CurrentOnlineState; + QString ProtocolVersion; + QString ClientName; + QString ClientVersion; + QStringList Messages; + QStringList unsendedMessages; + cProtocol* Protocol; +}; + +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/UserConnectThread.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/UserConnectThread.cpp new file mode 100644 index 000000000..dc2a3d118 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/UserConnectThread.cpp @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "UserConnectThread.h" + + +cUserConnectThread::cUserConnectThread(cCore* core,quint32 timeToWait=30000) +{ this->core=core; + this->timeToWait=timeToWait; + this->timer= new QTimer(); + connect(timer, SIGNAL(timeout()), this, SLOT(update())); +} + +cUserConnectThread::~cUserConnectThread() +{ + stop(); + disconnect(timer, SIGNAL(timeout()), this, SLOT(update())); +} + +void cUserConnectThread::update() +{ + QList users=core->get_userList(); + for(int i=0;iget_ConnectionStatus()==OFFLINE){ + if(core->isThisDestinationInunknownConnections(users.at(i)->get_I2PDestination())==false){ + users.at(i)->set_ConnectionStatus(TRYTOCONNECT); + users.at(i)->set_I2PStreamID(core->StreamConnect(users.at(i)->get_I2PDestination())); + + //users.at(i)->set_I2PStreamID(emit doStreamConnect(users.at(i)->get_I2PDestination())); + } + } + } +} +void cUserConnectThread::start() +{ + timer->start(timeToWait); +} +void cUserConnectThread::stop() +{ + timer->stop(); + +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/UserConnectThread.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/UserConnectThread.h new file mode 100644 index 000000000..1156e1123 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/UserConnectThread.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef USERCONNECTTHREAD_H +#define USERCONNECTTHREAD_H + +#include +#include + +#include "User.h" +#include "Core.h" + +class cCore; +class cUserConnectThread :public QObject +{ + Q_OBJECT + + public: + cUserConnectThread(cCore* core,quint32 timeToWait); + ~cUserConnectThread(); + //void run(); + void stop(); + void start(); + +signals: + QString doStreamConnect ( QString Destination ); + + private: + cCore* core; + QTimer* timer; + quint32 timeToWait; + + private slots: + void update(); +}; +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/templates/cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/templates/cpp new file mode 100644 index 000000000..8a1dfbe13 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/templates/cpp @@ -0,0 +1,19 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/templates/h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/templates/h new file mode 100644 index 000000000..8a1dfbe13 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/templates/h @@ -0,0 +1,19 @@ +/*************************************************************************** + * Copyright (C) 2008 by normal * + * normal@Desktop2 * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/