added I2PMessenger Plugin
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1105 b45a01b8-16f6-495d-af2f-9b41ad6348cc
283
retroshare-gui/src/gui/plugins/i2pmessenger_plugin/Doxyfile
Normal file
@ -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
|
@ -0,0 +1,31 @@
|
||||
//#include <QApplication>
|
||||
//#include <QString>
|
||||
//#include <QPushButton>
|
||||
|
||||
#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)
|
@ -0,0 +1,27 @@
|
||||
#ifndef _HWA_PLUGIN_H_
|
||||
#define _HWA_PLUGIN_H_
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
#include <PluginInterface.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
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
|
@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
<Body>
|
||||
<div align="center">
|
||||
<br><br>
|
||||
<b><big>
|
||||
<PRE>
|
||||
Applicationversion: [APPVERSIONSTRING]
|
||||
Protocolversion: [PROTOCOLVERSIONSTRING]
|
||||
</PRE>
|
||||
</b></big>
|
||||
</div>
|
||||
</Body>
|
||||
</html>
|
@ -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
|
@ -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;i<temp.count();i++){
|
||||
this->textEdit->append(temp[i]);
|
||||
}
|
||||
|
||||
QTextCursor cursor = textEdit->textCursor();
|
||||
cursor.movePosition(QTextCursor::Start);
|
||||
textEdit->setTextCursor(cursor);
|
||||
|
||||
}
|
||||
void form_DebugMessages::clearDebugMessages(){
|
||||
DebugMessageManager->clearAllMessages();
|
||||
textEdit->clear();
|
||||
}
|
@ -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 <QtGui>
|
||||
#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
|
@ -0,0 +1,77 @@
|
||||
<ui version="4.0" >
|
||||
<class>form_DebugMessages</class>
|
||||
<widget class="QDialog" name="form_DebugMessages" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>DebugMessages</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QTextEdit" name="textEdit" />
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmd_connectionDump" >
|
||||
<property name="text" >
|
||||
<string>ConnectionDump</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmd_clear" >
|
||||
<property name="text" >
|
||||
<string>&Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmd_close" >
|
||||
<property name="text" >
|
||||
<string>C&lose</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>cmd_close</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>form_DebugMessages</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>296</x>
|
||||
<y>276</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>199</x>
|
||||
<y>149</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -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 <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QTextStream>
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include <QCursor>
|
||||
#include <QPoint>
|
||||
#include <QMouseEvent>
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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 <QFileDialog>
|
||||
|
||||
#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
|
||||
|
@ -0,0 +1,684 @@
|
||||
<ui version="4.0" >
|
||||
<class>form_HelpDialog</class>
|
||||
<widget class="QDialog" name="form_HelpDialog" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>501</width>
|
||||
<height>328</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="palette" >
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Button" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>208</red>
|
||||
<green>208</green>
|
||||
<blue>208</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Light" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Midlight" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>247</red>
|
||||
<green>247</green>
|
||||
<blue>247</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Dark" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>104</red>
|
||||
<green>104</green>
|
||||
<blue>104</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Mid" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>139</red>
|
||||
<green>139</green>
|
||||
<blue>139</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Text" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="BrightText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ButtonText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Base" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Window" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>240</red>
|
||||
<green>240</green>
|
||||
<blue>240</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Shadow" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Highlight" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>128</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="HighlightedText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Link" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="LinkVisited" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="AlternateBase" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>231</red>
|
||||
<green>231</green>
|
||||
<blue>231</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Button" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>208</red>
|
||||
<green>208</green>
|
||||
<blue>208</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Light" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Midlight" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>247</red>
|
||||
<green>247</green>
|
||||
<blue>247</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Dark" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>104</red>
|
||||
<green>104</green>
|
||||
<blue>104</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Mid" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>139</red>
|
||||
<green>139</green>
|
||||
<blue>139</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Text" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="BrightText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ButtonText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Base" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Window" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>240</red>
|
||||
<green>240</green>
|
||||
<blue>240</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Shadow" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Highlight" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>192</red>
|
||||
<green>192</green>
|
||||
<blue>192</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="HighlightedText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Link" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="LinkVisited" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="AlternateBase" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>231</red>
|
||||
<green>231</green>
|
||||
<blue>231</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>104</red>
|
||||
<green>104</green>
|
||||
<blue>104</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Button" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>208</red>
|
||||
<green>208</green>
|
||||
<blue>208</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Light" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Midlight" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>247</red>
|
||||
<green>247</green>
|
||||
<blue>247</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Dark" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>104</red>
|
||||
<green>104</green>
|
||||
<blue>104</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Mid" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>139</red>
|
||||
<green>139</green>
|
||||
<blue>139</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Text" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>104</red>
|
||||
<green>104</green>
|
||||
<blue>104</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="BrightText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ButtonText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>104</red>
|
||||
<green>104</green>
|
||||
<blue>104</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Base" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>240</red>
|
||||
<green>240</green>
|
||||
<blue>240</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Window" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>240</red>
|
||||
<green>240</green>
|
||||
<blue>240</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Shadow" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Highlight" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>128</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="HighlightedText" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Link" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="LinkVisited" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="AlternateBase" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<red>231</red>
|
||||
<green>231</green>
|
||||
<blue>231</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="font" >
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>8</pointsize>
|
||||
<weight>50</weight>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
<underline>false</underline>
|
||||
<strikeout>false</strikeout>
|
||||
</font>
|
||||
</property>
|
||||
<property name="contextMenuPolicy" >
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap" >
|
||||
<pixmap>:/images/info16.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string><!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></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QTabWidget" name="tabWidget" >
|
||||
<property name="currentIndex" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab" >
|
||||
<attribute name="title" >
|
||||
<string>About</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="3" >
|
||||
<widget class="QTextBrowser" name="about" >
|
||||
<property name="html" >
|
||||
<string><!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></string>
|
||||
</property>
|
||||
<property name="openExternalLinks" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2" >
|
||||
<attribute name="title" >
|
||||
<string>Authors</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="authors" >
|
||||
<property name="undoRedoEnabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="lineWrapMode" >
|
||||
<enum>QTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="readOnly" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html" >
|
||||
<string><!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></string>
|
||||
</property>
|
||||
<property name="acceptRichText" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags" >
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3" >
|
||||
<attribute name="title" >
|
||||
<string>Thanks to</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="thanks" >
|
||||
<property name="undoRedoEnabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="lineWrapMode" >
|
||||
<enum>QTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="readOnly" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html" >
|
||||
<string><!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></string>
|
||||
</property>
|
||||
<property name="acceptRichText" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags" >
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>authors</tabstop>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="images.qrc" />
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -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 <QSystemTrayIcon>
|
||||
|
||||
#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<cUser*> users=Core->get_userList();
|
||||
listWidget->clear();
|
||||
|
||||
|
||||
for(int i=0;i<users.count();i++){
|
||||
QListWidgetItem* newItem= new QListWidgetItem(listWidget);
|
||||
QListWidgetItem* ChildWidthI2PDestinationAsText= new QListWidgetItem(listWidget);
|
||||
|
||||
if(users.at(i)->getHaveNewUnreadMessages()==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);
|
||||
|
||||
}
|
@ -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 <QtGui>
|
||||
#include <QClipboard>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include <QCursor>
|
||||
#include <QPoint>
|
||||
#include <QMouseEvent>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QSettings>
|
||||
#include <QFileDialog>
|
||||
|
||||
#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
|
@ -0,0 +1,68 @@
|
||||
<ui version="4.0" >
|
||||
<class>form_MainWindow</class>
|
||||
<widget class="QMainWindow" name="form_MainWindow" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>233</width>
|
||||
<height>427</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>I2PChat</string>
|
||||
</property>
|
||||
<property name="windowIcon" >
|
||||
<iconset resource="resourcen.qrc" >:/icons/userblue24.png</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QComboBox" name="comboBox" >
|
||||
<property name="insertPolicy" >
|
||||
<enum>QComboBox::NoInsert</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QListWidget" name="listWidget" >
|
||||
<property name="contextMenuPolicy" >
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers" >
|
||||
<set>QAbstractItemView::AllEditTriggers</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar" />
|
||||
<widget class="QToolBar" name="toolBar" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="movable" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea" >
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resourcen.qrc" />
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -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(i<Messages.count()){
|
||||
QString test =Messages.at(i);
|
||||
this->addMessage(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);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#ifndef FORM_CHATWIDGET_h
|
||||
#define FORM_CHATWIDGET_h
|
||||
|
||||
|
||||
#include "ui_form_chatwidget.h"
|
||||
#include <QtGui>
|
||||
#include <Qt>
|
||||
|
||||
#include <QClipboard>
|
||||
|
||||
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
|
@ -0,0 +1,297 @@
|
||||
<ui version="4.0" >
|
||||
<class>form_chatwidget</class>
|
||||
<widget class="QWidget" name="form_chatwidget" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>707</width>
|
||||
<height>575</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>User Chat</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QSplitter" name="splitter" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="autoFillBackground" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QTextBrowser" name="chat" >
|
||||
<property name="openExternalLinks" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayout" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="txtBold" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>B</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset>
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="txtUnder" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>U</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset>
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="txtItalic" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>I</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset>
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="txtColor" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>C</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset>
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="txtFont" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>F</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="message" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="send" >
|
||||
<property name="text" >
|
||||
<string>&Senden</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../temp/client.qrc" />
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>txtItalic</sender>
|
||||
<signal>clicked(bool)</signal>
|
||||
<receiver>message</receiver>
|
||||
<slot>setFontItalic(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>644</x>
|
||||
<y>258</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>348</x>
|
||||
<y>401</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>txtUnder</sender>
|
||||
<signal>clicked(bool)</signal>
|
||||
<receiver>message</receiver>
|
||||
<slot>setFontUnderline(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>614</x>
|
||||
<y>258</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>348</x>
|
||||
<y>401</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -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();
|
||||
}
|
@ -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 <QtGui>
|
||||
|
||||
#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
|
@ -0,0 +1,206 @@
|
||||
<ui version="4.0" >
|
||||
<class>form_FileRecive</class>
|
||||
<widget class="QDialog" name="form_FileRecive" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>530</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>530</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>530</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement" >
|
||||
<size>
|
||||
<width>530</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox_2" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>251</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>Status</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>145</width>
|
||||
<height>100</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_3" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Reciveing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_4" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Finished</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_3" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>266</x>
|
||||
<y>9</y>
|
||||
<width>254</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>FileInfo</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget_2" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>231</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>FileName:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<string>FileSize:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLabel" name="label_6" >
|
||||
<property name="text" >
|
||||
<string>Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" >
|
||||
<widget class="QLabel" name="label_7" >
|
||||
<property name="text" >
|
||||
<string>SizeTyp</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>240</y>
|
||||
<width>75</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>abort</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>140</y>
|
||||
<width>511</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>FileSend</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>54</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>progress</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QProgressBar" name="progressBar" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>481</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>480</x>
|
||||
<y>70</y>
|
||||
<width>21</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>100</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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 <QtGui>
|
||||
|
||||
#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
|
@ -0,0 +1,242 @@
|
||||
<ui version="4.0" >
|
||||
<class>form_FileSend</class>
|
||||
<widget class="QDialog" name="form_FileSend" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>530</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>530</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>530</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement" >
|
||||
<size>
|
||||
<width>530</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox_2" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>251</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>Status</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>145</width>
|
||||
<height>100</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>FileInfo sended</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_2" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>FileTransfer Accepted</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_3" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Transfering</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_4" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Finished</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_3" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>266</x>
|
||||
<y>9</y>
|
||||
<width>254</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>FileInfo</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget_2" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>231</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>FileName:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<string>FileSize:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLabel" name="label_6" >
|
||||
<property name="text" >
|
||||
<string>Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" >
|
||||
<widget class="QLabel" name="label_7" >
|
||||
<property name="text" >
|
||||
<string>SizeTyp</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>240</y>
|
||||
<width>75</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>abort</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>140</y>
|
||||
<width>511</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>FileSend</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>54</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>progress</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QProgressBar" name="progressBar" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>481</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>480</x>
|
||||
<y>70</y>
|
||||
<width>21</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>100</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_8" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>21</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -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();
|
||||
}
|
@ -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 <QtGui>
|
||||
#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
|
@ -0,0 +1,167 @@
|
||||
<ui version="4.0" >
|
||||
<class>form_newUserWindow</class>
|
||||
<widget class="QDialog" name="form_newUserWindow" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>465</width>
|
||||
<height>434</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>new User</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QLineEdit" name="lineEdit_2" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Network:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>I2P</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_2" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Tor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Nickname:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Destination Tor:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Destination I2P:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QTextEdit" name="textEdit" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<spacer name="horizontalSpacer" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>258</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>form_newUserWindow</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>form_newUserWindow</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -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();
|
||||
}
|
@ -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 <QtGui>
|
||||
#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
|
@ -0,0 +1,122 @@
|
||||
<ui version="4.0" >
|
||||
<class>form_renameWindow</class>
|
||||
<widget class="QDialog" name="form_renameWindow" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>324</width>
|
||||
<height>152</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="3" >
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<string>New Nickname</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Old Nickname</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="lineEdit" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>New Nickname</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="lineEdit_2" />
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>268</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>125</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QPushButton" name="okButton" >
|
||||
<property name="text" >
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" >
|
||||
<widget class="QPushButton" name="CancelButton" >
|
||||
<property name="text" >
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>CancelButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>form_renameWindow</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>277</x>
|
||||
<y>129</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>161</x>
|
||||
<y>75</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -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"));
|
||||
}
|
||||
}
|
@ -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 <QtGui>
|
||||
#include <QSettings>
|
||||
|
||||
|
||||
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
|
||||
|
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 933 B |
After Width: | Height: | Size: 894 B |
After Width: | Height: | Size: 784 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 774 B |
@ -0,0 +1,3 @@
|
||||
#include "i2pmessenger_win.rc.h"
|
||||
|
||||
IDI_ICON1 ICON "gui/icons/personal.ico"
|
@ -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
|
||||
|
After Width: | Height: | Size: 932 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 931 B |
After Width: | Height: | Size: 644 B |
After Width: | Height: | Size: 768 B |
After Width: | Height: | Size: 860 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1005 B |
After Width: | Height: | Size: 623 B |
After Width: | Height: | Size: 647 B |
After Width: | Height: | Size: 953 B |
After Width: | Height: | Size: 701 B |
@ -0,0 +1,27 @@
|
||||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>icons/Tools.gif</file>
|
||||
<file>icons/green.png</file>
|
||||
<file>icons/red.png</file>
|
||||
<file>icons/send.png</file>
|
||||
<file>icons/exit.png</file>
|
||||
<file>icons/add_user.png</file>
|
||||
<file>icons/settings.png</file>
|
||||
<file>icons/status_unknown.png</file>
|
||||
<file>icons/quick_restart.png</file>
|
||||
<file>icons/editcopy.png</file>
|
||||
<file>icons/window_fullscreen.png</file>
|
||||
<file>icons/window_nofullscreen.png</file>
|
||||
<file>icons/userblue24.png</file>
|
||||
<file>icons/self.png</file>
|
||||
<file>icons/socket24.png</file>
|
||||
<file>icons/looknfeel24.png</file>
|
||||
<file>icons/encrypted24.png</file>
|
||||
<file>icons/yellow.png</file>
|
||||
<file>icons/invisible.png</file>
|
||||
<file>icons/chatty.png</file>
|
||||
<file>icons/dnd.png</file>
|
||||
<file>icons/xa.png</file>
|
||||
<file>icons/about.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
@ -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("<ERROR_IN_ANALYSE>\n"+t);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
emit debugMessages("<Unknown Packet>\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();
|
||||
|
||||
}
|
@ -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 <QtGui>
|
||||
#include <QTcpSocket>
|
||||
#include <Qt>
|
||||
#include <QSocketNotifier>
|
||||
|
||||
#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
|
937
retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.cpp
Normal file
@ -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;i<this->users.count();i++)
|
||||
delete users.at(i);
|
||||
|
||||
|
||||
|
||||
QList<cPacketManager*>::Iterator it;
|
||||
for(it=DataPacketsManagers.begin(); it<DataPacketsManagers.end() ;++it){
|
||||
DataPacketsManagers.erase(it);
|
||||
}
|
||||
|
||||
delete this->DebugMessageHandler;
|
||||
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;i<users.count();i++){
|
||||
if(users.at(i)->get_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;i<users.count();i++){
|
||||
if(users.at(i)->get_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;i<users.count();i++){
|
||||
if(users.at(i)->get_TORDestination()==TorDestination) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
bool cCore::doesUserAllReadyExitsByI2PDestination(const QString I2PDestination){
|
||||
if(I2PDestination==MyDestination) return true;
|
||||
|
||||
for(int i=0;i<users.count();i++){
|
||||
if(users.at(i)->get_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;i<this->users.count();i++){
|
||||
out<<"Nick:\t"<<(users.at(i)->get_Name())<<endl
|
||||
<<"I2PDest:\t"<<(users.at(i)->get_I2PDestination())<<endl
|
||||
<<"TorDest:\t"<<(users.at(i)->get_TORDestination())<<endl;
|
||||
}
|
||||
out.flush();
|
||||
file.close();
|
||||
}
|
||||
void cCore::loadUserList(){
|
||||
QFile file(QApplication::applicationDirPath()+"/users.config");
|
||||
if (!file.open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
return;
|
||||
|
||||
QTextStream in(&file);
|
||||
in.skipWhiteSpace();
|
||||
QString NickName;QString I2PDest;QString TorDest;
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
QStringList temp=line.split("\t");
|
||||
|
||||
if(temp[0]=="Nick:")NickName=temp[1];
|
||||
else if(temp[0]=="I2PDest:")I2PDest=temp[1];
|
||||
else if(temp[0]=="TorDest:"){
|
||||
TorDest=temp[1];
|
||||
this->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;i<FileSends.size();i++){
|
||||
if(FileSends.at(i)->get_StreamID()==ID){
|
||||
FileSends.at(i)->StreamClosed(result,ID,Message);
|
||||
FileSends.removeAt(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(isThisID_a_FileReciveID(ID)){
|
||||
//Filerecive
|
||||
for(int i=0;i<FileRecives.size();i++){
|
||||
if(FileRecives.at(i)->get_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;i<users.count();i++){
|
||||
if(users.at(i)->get_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;i<FileSends.size();i++){
|
||||
if(FileSends.at(i)->get_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;i<FileRecives.size();i++){
|
||||
if(FileRecives.at(i)->get_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;i<users.count();i++){
|
||||
if(users.at(i)->get_I2PStreamID()==ID){
|
||||
users.at(i)->set_ConnectionStatus(OFFLINE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=0;i<users.count();i++){
|
||||
if(users.at(i)->get_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;i<this->unknownConnections.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;i<unknownConnections.size();i++)
|
||||
if(unknownConnections.at(i).ID==ID){
|
||||
|
||||
Destinaton=unknownConnections.at(i).Destination;
|
||||
break;
|
||||
}
|
||||
|
||||
removeUnknownID(ID);
|
||||
|
||||
|
||||
if(doesUserAllReadyExitsByI2PDestination(Destinaton)==false){
|
||||
addNewUser("Unknown",Destinaton,"",ID);
|
||||
}
|
||||
|
||||
for(int i=0;i<users.count();i++){
|
||||
if(users.at(i)->get_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;i<FileSends.size();i++){
|
||||
if(FileSends.at(i)->get_StreamID()==ID){
|
||||
FileSends.at(i)->StreamReadyToSend(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//the Rest (Chatconnections)
|
||||
for(int i=0;i<users.count();i++){
|
||||
if(users.at(i)->get_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;i<FileSends.size();i++){
|
||||
if(FileSends.at(i)->get_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;i<users.count();i++){
|
||||
if(users.at(i)->get_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<cUser*> 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;i<FileRecives.size();i++){
|
||||
if(FileRecives.at(i)->get_StreamID()==ID){
|
||||
FileRecives.at(i)->operator <<(Data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//FileSend
|
||||
for(int i=0;i<FileSends.size();i++){
|
||||
if(FileSends.at(i)->get_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<cPacketManager*>::Iterator it;
|
||||
for(it=DataPacketsManagers.begin(); it!=DataPacketsManagers.end() ;++it){
|
||||
if((*(it))->getID()==ID){
|
||||
//(*(it))->operator <<(Data);
|
||||
(*(*it))<<Data;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Ignore Data
|
||||
//if you close a stream i can happen that the QSocket already have recive same data of that Stream (and send it to the Socket)
|
||||
//if it happen forget the Data
|
||||
}
|
||||
|
||||
void cCore::closeAllActiveConenctions(){
|
||||
//close all known Online||TrytoConnect Connections
|
||||
|
||||
for(int i=0;i<users.size();i++)
|
||||
if(users.at(i)->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;i<unknownConnections.size();i++)
|
||||
{
|
||||
I2P->doStreamClose(unknownConnections.at(i).ID);
|
||||
removeUnknownID( unknownConnections.at(i).ID);
|
||||
}
|
||||
|
||||
emit eventUserChanged();
|
||||
|
||||
}
|
||||
|
||||
bool cCore::isThisIDunknown(QString ID){
|
||||
|
||||
for(int i=0;i<this->unknownConnections.size();i++)
|
||||
if(unknownConnections.at(i).ID==ID){
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
cUser* cCore::getUserByI2P_ID(QString ID){
|
||||
|
||||
for(int i=0;i<users.size();i++){
|
||||
if(users.at(i)->get_I2PStreamID()==ID){
|
||||
|
||||
return users.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
cUser* cCore::getUserByI2P_Destination(QString Destination){
|
||||
|
||||
for(int i=0;i<users.size();i++){
|
||||
if(users.at(i)->get_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;i<unknownConnections.size();i++){
|
||||
if(unknownConnections.at(i).Destination==Destination)return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void cCore::deletePacketManagerByID(QString ID){
|
||||
if(this->isThisIDunknown(ID)==true)
|
||||
return;
|
||||
else
|
||||
{
|
||||
QList<cPacketManager*>::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<unknownConnections.size();i++)
|
||||
Message+=unknownConnections.at(i).ID;
|
||||
|
||||
Message+="\n\n< Current open Known IDs(packetManager): >\n";
|
||||
|
||||
QList<cPacketManager*>::Iterator it;
|
||||
for(it=DataPacketsManagers.begin(); it!=DataPacketsManagers.end();++it)
|
||||
Message+= ((*(it))->getID()+"\n");
|
||||
|
||||
Message+="\n\n< Active FileTransfer: >\n";
|
||||
for(int i=0;i<FileSends.count();i++){
|
||||
Message+="FileName:\t\t:"+FileSends.at(i)->get_FileName()+"\n";
|
||||
Message+="StreamID:\t\t"+FileSends.at(i)->get_StreamID()+"\n";
|
||||
}
|
||||
|
||||
Message+="\n\n< Active Filerecive: >\n";
|
||||
for(int i=0;i<FileRecives.count();i++){
|
||||
Message+="FileName:\t\t"+FileRecives.at(i)->get_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;i<users.size();i++){
|
||||
if(users.at(i)->get_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;i<users.size();i++){
|
||||
if(users.at(i)->get_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;i<FileSends.size();i++){
|
||||
if(FileSends.at(i)->get_StreamID()==ID){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cCore::isThisID_a_FileReciveID(QString ID)
|
||||
{
|
||||
for(int i=0;i<FileRecives.size();i++){
|
||||
if(FileRecives.at(i)->get_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;i<FileSends.count();i++){
|
||||
if(FileSends.at(i)->get_StreamID()==ID){
|
||||
FileSends.removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(FileRecives.count()>0){
|
||||
for(int i=0;i<FileRecives.count();i++){
|
||||
if(FileRecives.at(i)->get_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;
|
||||
}
|
155
retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.h
Normal file
@ -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 <QtGui>
|
||||
#include <QSettings>
|
||||
#include <QtXml>
|
||||
#include <QTextStream>
|
||||
#include <QList>
|
||||
|
||||
#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<cUser*> 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:
|
||||
// <SIGNALS FROM cConnectionI2P>
|
||||
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<cUser*> users;
|
||||
QList<cConnection> unknownConnections;
|
||||
cUserConnectThread* UserConnectThread;
|
||||
QString MyDestination;
|
||||
QList<cPacketManager*> DataPacketsManagers;
|
||||
ONLINESTATE currentOnlineStatus;
|
||||
QList<cFileTransferSend*> FileSends;
|
||||
QList<cFileTransferRecive*> 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
|
||||
|
@ -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);
|
||||
}
|
@ -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 <QtGui>
|
||||
#include <QSettings>
|
||||
|
||||
#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
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
@ -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);
|
||||
}
|
@ -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
|
@ -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;
|
||||
}
|
@ -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 <QtGui>
|
||||
|
||||
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
|
@ -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 <QtGui>
|
||||
#include <QApplication>
|
||||
|
||||
#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;
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 <Qt>
|
||||
#include <QtGui>
|
||||
|
||||
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
|
@ -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);
|
||||
}
|
@ -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 <QtGui>
|
||||
#include <QThread>
|
||||
|
||||
|
||||
/*
|
||||
First packet on connection must be:
|
||||
CHATSYSTEM\tProtocolVersion\n
|
||||
CHATSYSTEMFILETRANSFER\tProtocolVersion\nSizeinBit\nFileName
|
||||
else
|
||||
send <the html info-page > //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="<html><header></header><body>This is not a eepsite,this is a I2PMessenger Destination<br><br></body></html>\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
|
189
retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.cpp
Normal file
@ -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+"<br>");
|
||||
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+"<br>");
|
||||
//this->Messages.push_back(Message);
|
||||
emit newMessageRecived();
|
||||
}
|
||||
else{
|
||||
|
||||
this->Messages.push_back("[SYSTEM]: Sending the Message when the user come online<br>When you close the client the Message is lost<br>");
|
||||
|
||||
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;i<unsendedMessages.count();i++)
|
||||
Protocol->send(CHATMESSAGE,I2PStream_ID,unsendedMessages.at(i));
|
||||
|
||||
|
||||
|
||||
this->Messages.push_back("[SYSTEM]: All unsended Messages where sended<br><br>");
|
||||
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();
|
||||
}
|
117
retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.h
Normal file
@ -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 <QtGui>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
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
|
@ -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<cUser*> users=core->get_userList();
|
||||
for(int i=0;i<users.count();i++){
|
||||
if(users.at(i)->get_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();
|
||||
|
||||
}
|
@ -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 <QList>
|
||||
#include <QTimer>
|
||||
|
||||
#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
|
@ -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. *
|
||||
***************************************************************************/
|
@ -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. *
|
||||
***************************************************************************/
|