update i2p messenger plugin to version 0.2.9

changes:
add:
- Timestamps on Chatmessages
- Copy Destination option to userlist
- soundEvents(at Unix/linux it need NAS(Network Audio System ))
- Tile in chatwindows = Chat with: username (onlinestate)
- textColor/textFont are restored, when reopen the Chatwindow (not if you close the Messenger and restart it)

changed:
- use a better workaround in chatwindow
- change paketsize from 32k to 1k (maybe better)
- chatwindow press enter so send the message, press shift + enter for a new line
- better destination check at addnewUser 

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1134 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2009-04-20 12:42:47 +00:00
parent bb681ae78f
commit 6d65bd0740
41 changed files with 1476 additions and 487 deletions

View File

@ -40,4 +40,3 @@ private:
};
#endif

View File

@ -22,25 +22,7 @@
#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){
@ -60,8 +42,12 @@ void form_MainWindow::init()
Core= new cCore();
fillComboBox();
createToolBar();
initToolBars();
applicationIsClosing=false;
Mute=false;
QListWidget* listWidget=this->listWidget;
connect (Core,SIGNAL(eventUserChanged()),this,
@ -100,6 +86,7 @@ void form_MainWindow::fillComboBox()
void form_MainWindow::onlineComboBoxChanged()
{
QComboBox* comboBox= this->comboBox;
QString text=comboBox->currentText();
if(text.contains("Online",Qt::CaseInsensitive)==true){
@ -136,6 +123,8 @@ void form_MainWindow::onlineComboBoxChanged()
msgBox->setDefaultButton(QMessageBox::Ok);
msgBox->setWindowModality(Qt::NonModal);
msgBox->show();
OnlineStateChanged();
}
}
else if(text.contains("TryToConnect",Qt::CaseInsensitive)==true){
@ -145,7 +134,7 @@ void form_MainWindow::onlineComboBoxChanged()
}
void form_MainWindow::createToolBar()
void form_MainWindow::initToolBars()
{
//toolBar->setIconSize(QSize(24, 24));
QToolBar* toolBar=this->toolBar;
@ -207,7 +196,7 @@ void form_MainWindow::closeApplication(){
emit closeAllWindows();
delete Core;
//delete trayIcon;
delete trayIcon;
applicationIsClosing=true;
this->close();
}
@ -339,16 +328,14 @@ void form_MainWindow::connecttreeWidgetCostumPopupMenu(QPoint point){
QAction* UserRename = new QAction("Rename",this);
connect(UserRename,SIGNAL(triggered()),this, SLOT(userRenameCLicked()));
QAction* CopyDestination = new QAction("Copy Destination",this);
connect(CopyDestination,SIGNAL(triggered()),this, SLOT(copyDestination()));
contextMnu.clear();
contextMnu.addAction(UserChat);
contextMnu.addAction(UserDelete);
contextMnu.addAction(UserRename);
QListWidgetItem *t=listWidget->item(listWidget->currentRow()+1);
QString Destination =t->text();
@ -362,6 +349,11 @@ void form_MainWindow::connecttreeWidgetCostumPopupMenu(QPoint point){
contextMnu.addAction(UserSendFile);
}
contextMnu.addSeparator();
contextMnu.addAction(UserRename);
contextMnu.addAction(UserDelete);
contextMnu.addAction(CopyDestination);
contextMnu.exec( mevent->globalPos());
}
@ -436,28 +428,39 @@ void form_MainWindow::toggleVisibilitycontextmenu()
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");
comboBox->addItem(QIcon(ICON_USER_ONLINE) , "Online"); //index 0
comboBox->addItem(QIcon(ICON_USER_WANTTOCHAT) , "WantToChat"); //1
comboBox->addItem(QIcon(ICON_USER_AWAY) , "Away"); //2
comboBox->addItem(QIcon(ICON_USER_DONT_DUSTURB) , "don't disturb"); //3
comboBox->addItem(QIcon(ICON_USER_INVISIBLE) , "Invisible"); //4
comboBox->addItem(QIcon(ICON_USER_OFFLINE) , "Offline"); //5
}
else if(Core->getOnlineStatus()==User::USEROFFLINE)
{
else if(Core->getOnlineStatus()==User::USEROFFLINE){
comboBox->clear();
comboBox->addItem(QIcon(ICON_USER_OFFLINE) , "Offline");
comboBox->addItem(QIcon(ICON_USER_TRYTOCONNECT) , "TryToConnect");
comboBox->setCurrentIndex(0);
}
else if(Core->getOnlineStatus()==User::USERWANTTOCHAT){
comboBox->setCurrentIndex(1);
}
else if(Core->getOnlineStatus()==User::USERAWAY){
comboBox->setCurrentIndex(2);
}
else if(Core->getOnlineStatus()==User::USERDONT_DISTURB){
comboBox->setCurrentIndex(3);
}
else if(Core->getOnlineStatus()==User::USERINVISIBLE){
comboBox->setCurrentIndex(4);
}
}
void form_MainWindow::openAboutDialog()
@ -512,12 +515,18 @@ void form_MainWindow::initStyle()
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->addAction(QIcon(ICON_QTCHAT), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
toggleMuteAction=
menu->addAction(QIcon(ICON_SOUND_ON), tr("Sound on"),this,SLOT(muteSound()));
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()
@ -541,6 +550,37 @@ void form_MainWindow::SendFile()
QString Destination =t->text();
if(!FilePath.isEmpty())
Core->startFileTransfer(FilePath,Destination);
Core->addNewFileTransfer(FilePath,Destination);
}
void form_MainWindow::copyDestination()
{
QListWidgetItem *t=listWidget->item(listWidget->currentRow()+1);
QString Destination =t->text();
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(Destination);
QMessageBox::information(this, "",
"The Destination is in the clipboard",QMessageBox::Close);
}
void form_MainWindow::muteSound()
{
if(this->Mute==false)
{
toggleMuteAction->setIcon(QIcon(ICON_SOUND_OFF));
toggleMuteAction->setText("Sound off");
Mute=true;
}
else
{
toggleMuteAction->setIcon(QIcon(ICON_SOUND_ON));
toggleMuteAction->setText("Sound on");
Mute=false;
}
Core->MuteSound(Mute);
}

View File

@ -32,6 +32,7 @@
#include <QFileDialog>
#include "ui_form_Main.h"
#include "gui_icons.h"
#include "form_settingsgui.h"
#include "form_newUser.h"
#include "form_DebugMessages.h"
@ -65,10 +66,11 @@ class form_MainWindow : public QMainWindow, private Ui::form_MainWindow
void openChatDialog ();
//Windows end
void namingMe();
void copyDestination();
void SendFile();
void closeApplication();
void eventUserChanged();
//void UserDoubleClicked ( QListWidgetItem * item );
void muteSound();
void connecttreeWidgetCostumPopupMenu ( QPoint point );
@ -84,19 +86,21 @@ class form_MainWindow : public QMainWindow, private Ui::form_MainWindow
void initStyle();
//void initTryIconMenu();
//void initTryIcon();
void initToolBars();
void fillComboBox();
void createToolBar();
cCore* Core;
bool applicationIsClosing;
cConnectionI2P* I2P;
form_newUserWindow* newUserWindow;
//QSystemTrayIcon *trayIcon;
//QAction *toggleVisibilityAction, *toolAct;
//QMenu *menu;
QSystemTrayIcon *trayIcon;
QAction* toggleVisibilityAction, *toolAct;
QAction* toggleMuteAction;
QMenu *menu;
bool Mute;
};
#endif

View File

@ -1,6 +1,30 @@
#include "form_chatwidget.h"
#include "src/User.h"
bool ChatEventEater::eventFilter(QObject *obj, QEvent *event)
{
if ( event->type() == QEvent::KeyPress )
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if ( obj->objectName() == "message")
{
if ( keyEvent->key() == Qt::Key_Return && keyEvent->modifiers() == Qt::NoModifier)
{
emit sendMessage();
return true;
}
else if (keyEvent->key() == Qt::Key_Return
&& keyEvent->modifiers() == Qt::ControlModifier)
{
emit sendMessage();
return true;
}
}
return QObject::eventFilter(obj, event);
}
return false;
}
form_ChatWidget::form_ChatWidget(cUser* user,QWidget* parent /* = 0 */)
@ -11,42 +35,54 @@ form_ChatWidget::form_ChatWidget(cUser* user,QWidget* parent /* = 0 */)
this->setAttribute(Qt::WA_DeleteOnClose,true);
this->user=user;
user->set_HaveAllreadyOneChatWindow(true);
QTextEdit *message=this->message;
m_event_eater = new ChatEventEater(this);
connect(m_event_eater, SIGNAL(sendMessage()),
send, SLOT(click()));
message->installEventFilter(m_event_eater);
connect(user,SIGNAL(newMessageRecived()),this,
SLOT(newMessageRecived()));
connect(user,SIGNAL(OnlineStateChanged()),this,
SLOT(changeWindowsTitle()));
connect(this,SIGNAL(sendChatMessage(QString)),user,
SLOT(sendChatMessage(QString)));
connect(message,SIGNAL(cursorPositionChanged()),this,
SLOT(WorkAround()));
mCurrentFont = QFont("Comic Sans MS", 10);
textColor = Qt::black;
mCurrentFont = user->get_textFont();
textColor = user->get_textColor();
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
"}"
);
*/
message->setTextColor(textColor);
message->setCurrentFont(mCurrentFont);
resize(450,400);
changeWindowsTitle();
newMessageRecived();
}
void form_ChatWidget::newMessageRecived(){
QTextEdit *chat=this->chat;
chat->clear();
@ -79,6 +115,7 @@ void form_ChatWidget::setTextColor(){
QPixmap pxm(24,24);
pxm.fill(textColor);
txtColor->setIcon(pxm);
user->set_textColor(textColor);
message->setTextColor(textColor);
@ -91,7 +128,7 @@ void form_ChatWidget::setFont()
bool ok;
mCurrentFont = QFontDialog::getFont(&ok, mCurrentFont, this);
user->set_textFont(mCurrentFont);
message->setCurrentFont(mCurrentFont);
message->setFocus();
}
@ -102,6 +139,7 @@ void form_ChatWidget::setBold(bool t){
QTextEdit *message=this->message;
QFont font = message->currentFont();
font.setBold(t);
user->set_textFont(mCurrentFont);
message->setCurrentFont(font);
}
@ -114,18 +152,83 @@ void form_ChatWidget::closeEvent(QCloseEvent *e){
void form_ChatWidget::sendMessageSignal(){
QTextEdit *message=this->message;
if(message->toPlainText().length()==0)return;
QFont font = message->currentFont();
QColor color= message->textColor();
emit sendChatMessage(message->toHtml());
//message->setHtml("");
message->setText(" ");
message->selectAll();
message->setTextColor(color);
message->setCurrentFont(font);
message->clear();
//message->document()->clear();
}
void form_ChatWidget::WorkAround()
{
QTextEdit *message=this->message;
if(message->textCursor().position()>1)return;
else if(message->textCursor().position()==1 && message->toPlainText().length()==1)
{
message->selectAll();
//message->textCursor().setPosition(QTextCursor::Start);
//message->textCursor().setPosition(QTextCursor::Left);
//message->textCursor().select(QTextCursor::Document);
//message->textCursor().movePosition(QTextCursor::End,QTextCursor::KeepAnchor);
message->setTextColor(textColor);
message->setCurrentFont(mCurrentFont);
message->moveCursor(QTextCursor::End,QTextCursor::MoveAnchor);
message->textCursor().clearSelection();
}
}
void form_ChatWidget::changeWindowsTitle()
{
QString OnlineStatus;
QString OnlineStatusIcon;
switch(user->get_OnlineState())
{
case USERTRYTOCONNECT:
case USERINVISIBLE:
case USEROFFLINE:{
OnlineStatus="offline";
this->setWindowIcon(QIcon(ICON_USER_OFFLINE));
break;
}
case USERONLINE:
{
OnlineStatus="online";
this->setWindowIcon(QIcon(ICON_USER_ONLINE));
break;
}
case USERWANTTOCHAT:
{
OnlineStatus="want to chat";
this->setWindowIcon(QIcon(ICON_USER_WANTTOCHAT));
break;
}
case USERAWAY:
{
OnlineStatus="away";
this->setWindowIcon(QIcon(ICON_USER_AWAY));
break;
}
case USERDONT_DISTURB:
{
OnlineStatus="don't disturb";
this->setWindowIcon(QIcon(ICON_USER_DONT_DUSTURB));
break;
}
}
this->setWindowTitle("Chat with: "+user->get_Name()+" ("+ OnlineStatus +")");
}

View File

@ -3,10 +3,26 @@
#include "ui_form_chatwidget.h"
#include "gui_icons.h"
#include <QtGui>
#include <Qt>
#include <QClipboard>
#include <QKeyEvent>
class ChatEventEater : public QObject
{
Q_OBJECT
public:
ChatEventEater(QWidget *parent = 0) : QObject(parent){ }
bool m_send_on_enter;
signals:
void sendMessage();
protected:
bool eventFilter(QObject *obj, QEvent *event);
};
class cUser;
class form_ChatWidget : public QWidget, public Ui::form_chatwidget
@ -22,6 +38,8 @@ private slots:
void newMessageRecived();
void setBold(bool t);
void setFont();
void WorkAround();
void changeWindowsTitle();
signals:
@ -32,5 +50,6 @@ private:
QStringList history;
cUser* user;
QFont mCurrentFont;
ChatEventEater *m_event_eater;
};
#endif
#endif

View File

@ -245,7 +245,7 @@
<item>
<widget class="QPushButton" name="send" >
<property name="text" >
<string>&amp;Senden</string>
<string>Senden</string>
</property>
</widget>
</item>

View File

@ -45,4 +45,4 @@ class form_fileRecive : public QDialog, public Ui::form_FileRecive
void init();
cFileTransferRecive* FileRecive;
};
#endif
#endif

View File

@ -45,4 +45,4 @@ class form_fileSend : public QDialog, public Ui::form_FileSend
void init();
cFileTransferSend* FileTransfer;
};
#endif
#endif

View File

@ -30,24 +30,73 @@ void form_newUserWindow::addnewUser()
QString Name=lineEdit->text();
QString I2PDestination=textEdit->toPlainText();
if(Name.isEmpty())
{
QMessageBox* msgBox= new QMessageBox(this);
msgBox->setIcon(QMessageBox::Warning);
msgBox->setText("Adding User");
msgBox->setInformativeText("You must add a nick for the User\nadding abborted");
msgBox->setStandardButtons(QMessageBox::Ok);
msgBox->setDefaultButton(QMessageBox::Ok);
msgBox->setWindowModality(Qt::NonModal);
msgBox->show();
return;
}
if(I2PDestination.length()!=516)
{
QMessageBox* msgBox= new QMessageBox(this);
msgBox->setIcon(QMessageBox::Warning);
msgBox->setText("Adding User");
msgBox->setInformativeText("The Destination is to short (must be 516)\nadding abborted");
msgBox->setStandardButtons(QMessageBox::Ok);
msgBox->setDefaultButton(QMessageBox::Ok);
msgBox->setWindowModality(Qt::NonModal);
msgBox->show();
return;
}
if(!I2PDestination.right(4).contains("AAAA",Qt::CaseInsensitive)){
//the last 4 char must be "AAAA"
QMessageBox* msgBox= new QMessageBox(this);
msgBox->setIcon(QMessageBox::Warning);
msgBox->setText("Adding User");
msgBox->setInformativeText("The Destination must end with AAAA\nadding abborted");
msgBox->setStandardButtons(QMessageBox::Ok);
msgBox->setDefaultButton(QMessageBox::Ok);
msgBox->setWindowModality(Qt::NonModal);
msgBox->show();
return;
}
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();
QMessageBox* msgBox= new QMessageBox(this);
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->setWindowModality(Qt::NonModal);
msgBox->show();
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);
if(Core->addNewUser(Name,I2PDestination,0)==false){
this->close();
QMessageBox* msgBox= new QMessageBox(NULL);
msgBox->setIcon(QMessageBox::Warning);
msgBox->setInformativeText("There allready exits one user with the same I2P,- or TorDestination");
msgBox->setStandardButtons(QMessageBox::Ok);
msgBox->setDefaultButton(QMessageBox::Ok);
msgBox->setWindowModality(Qt::NonModal);
msgBox->show();
this->close();
}
}

View File

@ -21,14 +21,7 @@
<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" >
<item row="3" column="0" >
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
@ -36,33 +29,6 @@
<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" >
@ -85,13 +51,6 @@
</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" >

View File

@ -31,8 +31,15 @@ form_settingsgui::form_settingsgui(QWidget *parent, Qt::WFlags flags)
styleCombo->addItems(QStyleFactory::keys());
loadSettings();
connect(ok_Button,SIGNAL(clicked() ),this,SLOT(saveSettings() ) );
connect(cancel_Button,SIGNAL(clicked() ),this,SLOT(close() ) );
connect(ok_Button, SIGNAL(clicked(bool) ),this,SLOT(saveSettings() ) );
connect(cancel_Button, SIGNAL(clicked(bool) ),this,SLOT(close() ) );
connect(cmd_openFile, SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile()));
connect(cmd_openFile_2,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile2()));
connect(cmd_openFile_3,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile3()));
connect(cmd_openFile_4,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile4()));
connect(cmd_openFile_5,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile5()));
connect(cmd_openFile_6,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile6()));
}
form_settingsgui::~form_settingsgui()
@ -42,8 +49,6 @@ form_settingsgui::~form_settingsgui()
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);
@ -76,7 +81,7 @@ void form_settingsgui::loadSettings()
lineEdit->setText(settings->value("TunnelName","I2PChat").toString());
spinBox_10->setValue(settings->value("SamPort","7656").toInt());
spinBox_4->setMinimum(0);
spinBox_4->setMinimum(1);
spinBox_4->setValue(settings->value("inbound.length","1").toInt());
spinBox_4->setMaximum(3);
@ -92,7 +97,7 @@ void form_settingsgui::loadSettings()
spinBox_7->setValue(settings->value("outbound.backupQuantity","1").toInt());
spinBox_7->setMaximum(3);
spinBox_8->setMinimum(0);
spinBox_8->setMinimum(1);
spinBox_8->setValue(settings->value("outbound.length","1").toInt());
spinBox_8->setMaximum(3);
@ -101,6 +106,36 @@ void form_settingsgui::loadSettings()
spinBox_9->setMaximum(3);
settings->endGroup();
settings->beginGroup("Sound");
settings->beginGroup("SoundFilePath");
txt_SoundFile->setText(settings->value("User_go_Online","").toString());
txt_SoundFile2->setText(settings->value("User_go_Offline","").toString());
txt_SoundFile3->setText(settings->value("FileSend_Finished","").toString());
txt_SoundFile4->setText(settings->value("FileRecive_Incoming","").toString());
txt_SoundFile5->setText(settings->value("FileRecive_Finished","").toString());
txt_SoundFile6->setText(settings->value("NewChatMessage","").toString());
if(!txt_SoundFile->text().isEmpty())checkBoxSound->setEnabled(true);
if(!txt_SoundFile2->text().isEmpty())checkBoxSound_2->setEnabled(true);
if(!txt_SoundFile3->text().isEmpty())checkBoxSound_3->setEnabled(true);
if(!txt_SoundFile4->text().isEmpty())checkBoxSound_4->setEnabled(true);
if(!txt_SoundFile5->text().isEmpty())checkBoxSound_5->setEnabled(true);
if(!txt_SoundFile6->text().isEmpty())checkBoxSound_6->setEnabled(true);
settings->endGroup();
settings->beginGroup("Enable");
checkBoxSound->setChecked(settings->value("User_go_Online",false).toBool());
checkBoxSound_2->setChecked(settings->value("User_go_Offline",false).toBool());
checkBoxSound_3->setChecked(settings->value("FileSend_Finished",false).toBool());
checkBoxSound_4->setChecked(settings->value("FileRecive_Incoming",false).toBool());
checkBoxSound_5->setChecked(settings->value("FileRecive_Finished",false).toBool());
checkBoxSound_6->setChecked(settings->value("NewChatMessage",false).toBool());
settings->endGroup();
settings->endGroup();
}
void form_settingsgui::saveSettings()
{
@ -133,6 +168,13 @@ void form_settingsgui::saveSettings()
temp.setNum(spinBox_8->value());
SessionOptionString+=temp;
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();
settings->beginGroup("Network");
settings->setValue("SamHost",lineEdit_3->text());
settings->setValue("Destination",lineEdit_2->text());
@ -149,15 +191,24 @@ void form_settingsgui::saveSettings()
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->beginGroup("Sound");
settings->beginGroup("Enable");
settings->setValue("User_go_Online",checkBoxSound->isChecked());
settings->setValue("User_go_Offline",checkBoxSound_2->isChecked());
settings->setValue("FileSend_Finished",checkBoxSound_3->isChecked());
settings->setValue("FileRecive_Incoming",checkBoxSound_4->isChecked());
settings->setValue("FileRecive_Finished",checkBoxSound_5->isChecked());
settings->setValue("NewChatMessage",checkBoxSound_6->isChecked());
settings->endGroup();
settings->beginGroup("SoundFilePath");
settings->setValue("User_go_Online",txt_SoundFile->text());
settings->setValue("User_go_Offline",txt_SoundFile2->text());
settings->setValue("FileSend_Finished",txt_SoundFile3->text());
settings->setValue("FileRecive_Incoming",txt_SoundFile4->text());
settings->setValue("FileRecive_Finished",txt_SoundFile5->text());
settings->setValue("NewChatMessage",txt_SoundFile6->text());
settings->endGroup();
settings->endGroup();
this->close();
}
@ -195,3 +246,68 @@ void form_settingsgui::loadqss()
styleSheetCombo->addItem(st.fileName().remove(".qss"));
}
}
////FilePath=QFileDialog::getOpenFileName(this,"Open File", ".", "all Files (*.*)");
void form_settingsgui::on_cmd_openFile()
{
txt_SoundFile->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)"));
if(txt_SoundFile->text().isEmpty()){
checkBoxSound->setChecked(false);
checkBoxSound->setEnabled(false);
}
else
checkBoxSound->setEnabled(true);
}
void form_settingsgui::on_cmd_openFile2()
{
txt_SoundFile2->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)"));
if(txt_SoundFile2->text().isEmpty()){
checkBoxSound_2->setChecked(false);
checkBoxSound_2->setEnabled(false);
}
else
checkBoxSound_2->setEnabled(true);
}
void form_settingsgui::on_cmd_openFile3()
{
txt_SoundFile3->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)"));
if(txt_SoundFile3->text().isEmpty()){
checkBoxSound_3->setChecked(false);
checkBoxSound_3->setEnabled(false);
}
else
checkBoxSound_3->setEnabled(true);
}
void form_settingsgui::on_cmd_openFile4()
{
txt_SoundFile4->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)"));
if(txt_SoundFile4->text().isEmpty()){
checkBoxSound_4->setChecked(false);
checkBoxSound_4->setEnabled(false);
}
else
checkBoxSound_4->setEnabled(true);
}
void form_settingsgui::on_cmd_openFile5()
{
txt_SoundFile5->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)"));
if(txt_SoundFile5->text().isEmpty()){
checkBoxSound_5->setChecked(false);
checkBoxSound_5->setEnabled(false);
}
else
checkBoxSound_5->setEnabled(true);
}
void form_settingsgui::on_cmd_openFile6()
{
txt_SoundFile6->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)"));
if(txt_SoundFile6->text().isEmpty()){
checkBoxSound_6->setChecked(false);
checkBoxSound_6->setEnabled(false);
}
else
checkBoxSound_6->setEnabled(true);
}

View File

@ -39,6 +39,13 @@ private slots:
void saveSettings();
void on_styleCombo_activated(const QString &styleName);
void on_styleSheetCombo_activated(const QString &styleSheetName);
void on_cmd_openFile();
void on_cmd_openFile2();
void on_cmd_openFile3();
void on_cmd_openFile4();
void on_cmd_openFile5();
void on_cmd_openFile6();
private:
QSettings* settings;
@ -46,5 +53,7 @@ private:
void loadqss();
};
#endif

View File

@ -174,6 +174,15 @@
<normaloff>:/icons/encrypted24.png</normaloff>:/icons/encrypted24.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string>Sound</string>
</property>
<property name="icon" >
<iconset resource="resourcen.qrc" >
<normaloff>:/icons/sound.png</normaloff>:/icons/sound.png</iconset>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="3" >
@ -299,7 +308,7 @@
<item row="0" column="1" >
<widget class="QStackedWidget" name="stackedWidget" >
<property name="currentIndex" >
<number>0</number>
<number>5</number>
</property>
<widget class="QWidget" name="basic_page" >
<widget class="QGroupBox" name="groupBox_6" >
@ -336,6 +345,12 @@
<height>22</height>
</rect>
</property>
<property name="minimum" >
<number>30</number>
</property>
<property name="maximum" >
<number>99999</number>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox" >
@ -958,7 +973,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>10</x>
<y>0</y>
<width>147</width>
<width>150</width>
<height>32</height>
</rect>
</property>
@ -1136,7 +1151,7 @@ p, li { white-space: pre-wrap; }
<x>11</x>
<y>0</y>
<width>77</width>
<height>28</height>
<height>31</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
@ -1217,7 +1232,7 @@ p, li { white-space: pre-wrap; }&#xd;
<rect>
<x>10</x>
<y>0</y>
<width>98</width>
<width>104</width>
<height>27</height>
</rect>
</property>
@ -1246,6 +1261,358 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</widget>
<widget class="QWidget" name="Seite" >
<widget class="QWidget" name="layoutWidget_2" >
<property name="geometry" >
<rect>
<x>10</x>
<y>0</y>
<width>104</width>
<height>27</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4" >
<item row="0" column="0" >
<widget class="QLabel" name="label_24" >
<property name="text" >
<string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;img src=":/icons/sound.png" />&lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLabel" name="label_25" >
<property name="text" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">
&lt;p style=" -qt-block-indent:0; text-indent:0px; font-size:8pt;">&lt;span style=" font-size:12pt; font-weight:600;">Sound&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_11" >
<property name="geometry" >
<rect>
<x>0</x>
<y>40</y>
<width>441</width>
<height>381</height>
</rect>
</property>
<property name="title" >
<string>Sound Events</string>
</property>
<widget class="QGroupBox" name="groupBox_12" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>421</width>
<height>81</height>
</rect>
</property>
<property name="title" >
<string>User</string>
</property>
<widget class="QCheckBox" name="checkBoxSound" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>go Online</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxSound_2" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>10</x>
<y>50</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>go Offline</string>
</property>
</widget>
<widget class="QLineEdit" name="txt_SoundFile" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>90</x>
<y>20</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="txt_SoundFile2" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>90</x>
<y>50</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="cmd_openFile" >
<property name="geometry" >
<rect>
<x>380</x>
<y>20</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
<widget class="QPushButton" name="cmd_openFile_2" >
<property name="geometry" >
<rect>
<x>380</x>
<y>50</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_13" >
<property name="geometry" >
<rect>
<x>10</x>
<y>100</y>
<width>421</width>
<height>61</height>
</rect>
</property>
<property name="title" >
<string>FileSend</string>
</property>
<widget class="QLineEdit" name="txt_SoundFile3" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>90</x>
<y>20</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="cmd_openFile_3" >
<property name="geometry" >
<rect>
<x>380</x>
<y>20</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxSound_3" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>Finished</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_14" >
<property name="geometry" >
<rect>
<x>10</x>
<y>160</y>
<width>421</width>
<height>91</height>
</rect>
</property>
<property name="title" >
<string>FileRecive</string>
</property>
<widget class="QCheckBox" name="checkBoxSound_4" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>Incoming</string>
</property>
</widget>
<widget class="QLineEdit" name="txt_SoundFile4" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>90</x>
<y>20</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="cmd_openFile_4" >
<property name="geometry" >
<rect>
<x>380</x>
<y>20</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
<widget class="QPushButton" name="cmd_openFile_5" >
<property name="geometry" >
<rect>
<x>380</x>
<y>50</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxSound_5" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>10</x>
<y>50</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>Finished</string>
</property>
</widget>
<widget class="QLineEdit" name="txt_SoundFile5" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>90</x>
<y>50</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_15" >
<property name="geometry" >
<rect>
<x>10</x>
<y>260</y>
<width>421</width>
<height>111</height>
</rect>
</property>
<property name="title" >
<string>Chatmessage</string>
</property>
<widget class="QPushButton" name="cmd_openFile_6" >
<property name="geometry" >
<rect>
<x>380</x>
<y>20</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxSound_6" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>New</string>
</property>
</widget>
<widget class="QLineEdit" name="txt_SoundFile6" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>90</x>
<y>20</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
</widget>
</widget>
</widget>
</widget>
</item>
</layout>

View File

@ -0,0 +1,46 @@
/***************************************************************************
* 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 GUI_ICONS_H
#define GUI_ICONS_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"
#define ICON_SOUND_ON ":/icons/sound.png"
#define ICON_SOUND_OFF ":/icons/sound_off.png"
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -23,5 +23,7 @@
<file>icons/dnd.png</file>
<file>icons/xa.png</file>
<file>icons/about.png</file>
<file>icons/sound.png</file>
<file>icons/sound_off.png</file>
</qresource>
</RCC>

View File

@ -34,7 +34,8 @@ DEPENDPATH += . \
INCLUDEPATH += . \
SOURCES += gui/form_Main.cpp \
SOURCES += src/Main.cpp \
gui/form_Main.cpp \
src/Core.cpp \
gui/form_newUser.cpp \
gui/form_DebugMessages.cpp \
@ -46,13 +47,14 @@ SOURCES += gui/form_Main.cpp \
src/Protocol.cpp \
gui/form_chatwidget.cpp \
gui/form_rename.cpp \
src/PacketManager.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
gui/form_HelpDialog.cpp \
src/FileTransferSend.cpp \
src/FileTransferRecive.cpp \
gui/form_fileSend.cpp \
gui/form_fileRecive.cpp \
src/SoundManager.cpp
HEADERS += gui/form_Main.h \
src/Core.h \
@ -66,13 +68,15 @@ HEADERS += gui/form_Main.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
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 \
src/SoundManager.h \
gui/gui_icons.h
@ -83,12 +87,13 @@ FORMS += gui/form_Main.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
gui/form_HelpDialog.ui \
gui/form_fileSend.ui \
gui/form_fileRecive.ui
RESOURCES += gui/resourcen.qrc

View File

@ -134,33 +134,33 @@ void cConnectionI2P::readFromSocket()
case STREAM_STATUS:{
emit debugMessages(t);
if(sam.result==OK)
this->doSendStreamSessionLimit(sam.Id,0);
this->doSendStreamSessionLimit(sam.ID,0);
emit StreamStatusRecived(sam.result,sam.Id,sam.Message);
emit StreamStatusRecived(sam.result,sam.ID,sam.Message);
break;
}
case STREAM_CONNECTED:{
emit debugMessages(t);
this->doSendStreamSessionLimit(sam.Id,0);
this->doSendStreamSessionLimit(sam.ID,0);
emit StreamConnectedRecived(sam.Destination,sam.Id);
emit StreamConnectedRecived(sam.Destination,sam.ID);
break;
}
case STREAM_CLOSED:{
emit debugMessages(t);
emit StreamClosedRecived(sam.result,sam.Id,sam.Message);
emit StreamClosedRecived(sam.result,sam.ID,sam.Message);
break;
}
case STREAM_SEND:{
emit debugMessages(t);
emit StreamSendRecived(sam.Id,sam.result,sam.state);
emit StreamSendRecived(sam.ID,sam.result,sam.state);
break;
}
case STREAM_READY_TO_SEND:{
emit debugMessages(t);
emit StreamReadyToSendRecived(sam.Id);
emit StreamReadyToSendRecived(sam.ID);
break;
}
case NAMING_REPLY:{
@ -175,7 +175,7 @@ void cConnectionI2P::readFromSocket()
QByteArray Data=IncomingPackets->mid(CurrentPacket.length(),sam.Size.toLong());
emit debugMessages(t+Data);
emit StreamDataRecived(sam.Id,sam.Size,Data);
emit StreamDataRecived(sam.ID,sam.Size,Data);
IncomingPackets->remove(CurrentPacket.length(),sam.Size.toLong());
break;
}
@ -253,46 +253,43 @@ QByteArray Message="SESSION CREATE STYLE=";
}
quint32 cConnectionI2P::get_NextFreeId()
qint32 cConnectionI2P::get_NextFreeId()
{
return nextFreeID++;
}
QString cConnectionI2P::doStreamConnect(QString Destination)
qint32 cConnectionI2P::doStreamConnect(QString Destination)
{
ConnectionReadyCheck();
quint32 ID=get_NextFreeId();
QString IDtemp;
IDtemp.setNum(ID);
qint32 ID=get_NextFreeId();
QByteArray Message="STREAM CONNECT ID=";
Message+=IDtemp;
Message+=QString::number(ID,10);
Message+=" DESTINATION="+Destination+"\n";
emit debugMessages(Message);
tcpSocket->write(Message);
tcpSocket->flush();
return IDtemp;
return ID;
}
void cConnectionI2P::doStreamClose(QString ID)
{
void cConnectionI2P::doStreamClose(qint32 ID)
{
ConnectionReadyCheck();
QByteArray Message="STREAM CLOSE ID=";
Message+=ID+"\n";
Message+=QString::number(ID,10)+"\n";
emit debugMessages(Message);
tcpSocket->write(Message);
tcpSocket->flush();
}
void cConnectionI2P::doSendStreamSessionLimit(QString ID,quint64 value)
void cConnectionI2P::doSendStreamSessionLimit(qint32 ID,quint64 value)
{
ConnectionReadyCheck();
QByteArray Message="STREAM RECEIVE ID=";
Message+=ID+" LIMIT=";
Message+=QString::number(ID,10)+" LIMIT=";
if(value==0)
Message+="NONE\n";
else
@ -305,23 +302,22 @@ void cConnectionI2P::doSendStreamSessionLimit(QString ID,quint64 value)
tcpSocket->write(Message);
tcpSocket->flush();
}
void cConnectionI2P::doStreamSend(QString ID,QString Data)
void cConnectionI2P::doStreamSend(qint32 ID,QString Data)
{
QByteArray t="";
t.insert(0,Data);
doStreamSend(ID,t);
}
void cConnectionI2P::doStreamSend(QString ID,QByteArray Data)
void cConnectionI2P::doStreamSend(qint32 ID,QByteArray Data)
{
ConnectionReadyCheck();
QString Size;
Size.setNum(Data.length());
QByteArray Message="STREAM SEND ID=";
Message+=ID+" SIZE="+Size+"\n";
Message.append(Data);
Message+=QString::number(ID,10)+" SIZE="+Size+"\n";
Message.append(Data+="\n");
emit debugMessages(Message);
tcpSocket->write(Message);

View File

@ -69,11 +69,11 @@ class cConnectionI2P :public QObject
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);
qint32 doStreamConnect(QString Destination);//base64key || return the new id for the stream
void doStreamSend(qint32 ID,QByteArray Data);
void doStreamSend(qint32 ID,QString Data);
void doStreamClose(qint32 ID);
void doSendStreamSessionLimit(qint32 ID,quint64 value=0);
void doNamingLookUP(QString Name);
private slots:
@ -85,18 +85,18 @@ class cConnectionI2P :public QObject
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 StreamStatusRecived(const SAM_Message_Types::RESULT result,const qint32 ID,QString Message);
void StreamConnectedRecived(const QString Destinaton,const qint32 ID);
void StreamSendRecived(const qint32 ID,const SAM_Message_Types::RESULT result,SAM_Message_Types::STATE state);
void StreamClosedRecived(const SAM_Message_Types::RESULT result,qint32 ID,QString Message);
void StreamReadyToSendRecived(const qint32 ID);
void StreamDataRecived(const qint32 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;
qint32 nextFreeID;
QByteArray* IncomingPackets;
QTcpSocket* tcpSocket;
I2PSamMessageAnalyser* Analyser;
@ -109,7 +109,7 @@ class cConnectionI2P :public QObject
const SESSION_Types::SESSION_DIRECTION SessionDirection;
const QString SessionOptions;
void doSessionCreate();
quint32 get_NextFreeId();
qint32 get_NextFreeId();
inline void ConnectionReadyCheck()
{

View File

@ -24,41 +24,12 @@ cCore::cCore(){
}
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();
this->closeAllActiveConnections();
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);
@ -67,52 +38,59 @@ cCore::~cCore(){
delete this->DebugMessageHandler;
delete this->Protocol;
delete this->I2P;
delete this->SoundManager;
}
cDebugMessageManager* cCore::get_DebugMessageHandler(){
return this->DebugMessageHandler;
}
bool cCore::addNewUser(QString Name,QString I2PDestination,QString TorDestination,QString I2PStream_ID){
bool cCore::addNewUser(QString Name,QString I2PDestination,qint32 I2PStream_ID){
//TODO I2PDestination verify check
//check if user already exist
if(I2PDestination.length()!=516){
//Destination must be 516 length
return false;
}
if(!I2PDestination.right(4).contains("AAAA",Qt::CaseInsensitive)){
//the last 4 char must be "AAAA"
return false;
}
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);
cUser* newuser=new cUser(Protocol,Name,I2PDestination,I2PStream_ID);
connect(newuser,SIGNAL(newIncomingMessageRecived()),SoundManager,
SLOT(event_NewChatMessage()));
connect(newuser,SIGNAL(connectionOnline()),SoundManager,
SLOT(event_User_go_Online()));
connect(newuser,SIGNAL(connectionOffline()),SoundManager,
SLOT(event_User_go_Offline()));
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());
deletePacketManagerByID(users.at(i)->get_I2PStreamID());
}
users.removeAt(i);
@ -124,16 +102,7 @@ bool cCore::deleteUserByI2PDestination(QString I2PDestination){
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;
@ -169,37 +138,39 @@ void cCore::init(){
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(StreamClosedRecived(const SAM_Message_Types::RESULT, qint32, QString)),this,
SLOT(StreamClosedRecived(const SAM_Message_Types::RESULT, qint32, 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(StreamStatusRecived(const SAM_Message_Types::RESULT, const qint32, const QString)),this,
SLOT(StreamStatusRecived(const SAM_Message_Types::RESULT, const qint32, 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(StreamConnectedRecived(const QString, const qint32)),this,
SLOT(StreamConnectedRecived(const QString, const qint32)),Qt::DirectConnection);
connect (I2P,SIGNAL(StreamReadyToSendRecived(const QString)),this,
SLOT(StreamReadyToSendRecived(const QString)),Qt::DirectConnection);
connect (I2P,SIGNAL(StreamReadyToSendRecived(const qint32)),this,
SLOT(StreamReadyToSendRecived(const qint32)),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(StreamSendRecived(const qint32, const SAM_Message_Types::RESULT, SAM_Message_Types::STATE)),this,
SLOT(StreamSendRecived(const qint32, 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(StreamDataRecived(const qint32, const QString, const QByteArray)),this,
SLOT(StreamDataRecived(const qint32, 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->SoundManager=new cSoundManager();
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());
delete settings;
}
void cCore::saveUserList(){
QFile file(QApplication::applicationDirPath()+"/users.config");
@ -208,8 +179,7 @@ void cCore::saveUserList(){
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;
<<"I2PDest:\t"<<(users.at(i)->get_I2PDestination())<<endl;
}
out.flush();
file.close();
@ -221,25 +191,26 @@ void cCore::loadUserList(){
QTextStream in(&file);
in.skipWhiteSpace();
QString NickName;QString I2PDest;QString TorDest;
QString NickName;QString I2PDest;
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);
if(temp[0]=="I2PDest:"){
I2PDest=temp[1];
this->addNewUser(NickName,I2PDest);
NickName.clear();
I2PDest.clear();
TorDest.clear();
}
else if(temp[0]=="TorDest:"){
//ignore it
}
file.close();
}
}
void cCore::StreamClosedRecived(const SAM_Message_Types::RESULT result,QString ID,QString Message){
void cCore::StreamClosedRecived(const SAM_Message_Types::RESULT result,qint32 ID,QString Message){
if(isThisID_a_FileSendID(ID)){
//FileSend
@ -276,23 +247,21 @@ void cCore::StreamClosedRecived(const SAM_Message_Types::RESULT result,QString I
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;
}
}
}
deletePacketManagerByID(ID);
emit eventUserChanged();
}
void cCore::StreamStatusRecived(const SAM_Message_Types::RESULT result,const QString ID,QString Message){
void cCore::StreamStatusRecived(const SAM_Message_Types::RESULT result,const qint32 ID,QString Message){
if(isThisID_a_FileSendID(ID)){
//FileSend
@ -300,6 +269,7 @@ void cCore::StreamStatusRecived(const SAM_Message_Types::RESULT result,const QSt
if(FileSends.at(i)->get_StreamID()==ID){
FileSends.at(i)->StreamStatus(result,ID,Message);
if(result!=SAM_Message_Types::OK){
I2P->doStreamClose(ID);
FileSends.removeAt(i);
}
return;
@ -313,6 +283,7 @@ void cCore::StreamStatusRecived(const SAM_Message_Types::RESULT result,const QSt
if(FileRecives.at(i)->get_StreamID()==ID){
FileRecives.at(i)->StreamStatus(result,ID,Message);
if(result!=SAM_Message_Types::OK){
I2P->doStreamClose(ID);
FileRecives.removeAt(i);
}
return;
@ -322,41 +293,53 @@ void cCore::StreamStatusRecived(const SAM_Message_Types::RESULT result,const QSt
else if(this->isThisIDunknown(ID)){
if(result==SAM_Message_Types::OK){
Protocol->newConnectionChat(ID);
return;
}
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);
users.at(i)->set_ConnectionStatus(ONLINE);
//this->Protocol->newConnectionChat(ID);
}
else if( result==SAM_Message_Types::CANT_REACH_PEER ||
result==SAM_Message_Types::TIMEOUT
){
if(users.at(i)->get_OnlineState()!=USEROFFLINE && users.at(i)->get_OnlineState()!=USERTRYTOCONNECT)
{
users.at(i)->IncomingMessageFromSystem("The Connection is broken: "+Message+"\nConnection closed");
I2P->doStreamClose(ID);
}
deletePacketManagerByID(ID);
users.at(i)->set_ConnectionStatus(OFFLINE);
deletePacketManagerByID(ID);
}
else{
//I2P Error
users.at(i)->set_ConnectionStatus(ERROR);
else if( result==SAM_Message_Types::INVALID_KEY){
users.at(i)->IncomingMessageFromSystem("Invalid User - Destination: please delete the user\n");
if(users.at(i)->get_ConnectionStatus()==ONLINE)
I2P->doStreamClose(ID);
deletePacketManagerByID(ID);
users.at(i)->set_ConnectionStatus(ERROR);
}
else if(result==SAM_Message_Types::I2P_ERROR){
users.at(i)->IncomingMessageFromSystem("I2P_Error: "+Message);
if(users.at(i)->get_ConnectionStatus()==ONLINE)
I2P->doStreamClose(ID);
deletePacketManagerByID(ID);
users.at(i)->set_ConnectionStatus(ERROR);
}
emit eventUserChanged();
@ -375,26 +358,24 @@ void cCore::SessionStatusRecived(const SAM_Message_Types::RESULT result,const QS
}
}
void cCore::StreamConnectedRecived(const QString Destinaton,const QString ID){
void cCore::StreamConnectedRecived(const QString Destinaton,const qint32 ID){
//Someone connected you
//this->Protocol->newConnection(ID);
cConnection t(ID,Destinaton);
this->unknownConnections.push_back(t);
}
bool cCore::removeUnknownID(QString ID)
bool cCore::removeUnknownID(qint32 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){
QString cCore::get_UserProtocolVersionByStreamID(qint32 ID){
for(int i=0;i< users.size();i++)
if(users.at(i)->get_I2PStreamID()==ID){
@ -404,7 +385,7 @@ QString cCore::get_UserProtocolVersionByStreamID(QString ID){
return "";
}
void cCore::set_UserProtocolVersionByStreamID(QString ID,QString Version){
void cCore::set_UserProtocolVersionByStreamID(qint32 ID,QString Version){
for(int i=0;i< users.size();i++)
if(users.at(i)->get_I2PStreamID()==ID){
@ -415,7 +396,7 @@ void cCore::set_UserProtocolVersionByStreamID(QString ID,QString Version){
}
void cCore::removeUnknownIDCreateUserIfNeeded(const QString ID,const QString ProtocolVersion){
void cCore::removeUnknownIDCreateUserIfNeeded(const qint32 ID,const QString ProtocolVersion){
//TODO add some security thinks for adding !!! at the moment all user are allowed to connect
QString Destinaton;
@ -424,46 +405,68 @@ void cCore::removeUnknownIDCreateUserIfNeeded(const QString ID,const QString Pro
if(unknownConnections.at(i).ID==ID){
Destinaton=unknownConnections.at(i).Destination;
removeUnknownID(ID);
break;
}
removeUnknownID(ID);
if(doesUserAllReadyExitsByI2PDestination(Destinaton)==false){
addNewUser("Unknown",Destinaton,"",ID);
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){
if(users.at(i)->get_ConnectionStatus()==OFFLINE){
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 qint32, const QByteArray)),Protocol,
SLOT(inputKnown(const qint32,const QByteArray)));
DataPacketsManagers.push_back(newPacket);
}
else if(users.at(i)->get_ConnectionStatus()==ONLINE){
//close both Streams
/*
//close both Streams
if(ID!=users.at(i)->get_I2PStreamID())
{
I2P->doStreamClose(ID);
I2P->doStreamClose(users.at(i)->get_I2PStreamID());
}
*/
//close new connection and use the old
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
/*
//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);
*/
//close the tryconnection use the new one
if(ID!=users.at(i)->get_I2PStreamID())
I2P->doStreamClose(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 qint32, const QByteArray)),Protocol,
SLOT(inputKnown(const qint32,const QByteArray)));
DataPacketsManagers.push_back(newPacket);
}
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;
}
}
@ -471,7 +474,7 @@ void cCore::removeUnknownIDCreateUserIfNeeded(const QString ID,const QString Pro
emit eventUserChanged();
}
void cCore::StreamReadyToSendRecived(const QString ID){
void cCore::StreamReadyToSendRecived(const qint32 ID){
//FileSendsConnections
for(int i=0;i<FileSends.size();i++){
@ -490,7 +493,7 @@ void cCore::StreamReadyToSendRecived(const QString ID){
}
}
void cCore::StreamSendRecived(const QString ID,const SAM_Message_Types::RESULT result,SAM_Message_Types::STATE state){
void cCore::StreamSendRecived(const qint32 ID,const SAM_Message_Types::RESULT result,SAM_Message_Types::STATE state){
//FIXME what do when result = FAILED ?, impl. a stack ?
//FileSendsConnections
@ -518,8 +521,8 @@ void cCore::StreamSendRecived(const QString ID,const SAM_Message_Types::RESULT r
const QList<cUser*> cCore::get_userList(){
return users;
}
QString cCore::StreamConnect(QString Destination){
QString ID;
qint32 cCore::StreamConnect(QString Destination){
qint32 ID;
ID=I2P->doStreamConnect(Destination);
@ -528,12 +531,10 @@ QString cCore::StreamConnect(QString Destination){
return (ID);
}
void cCore::StreamDataRecived(const QString ID,const QString Size,const QByteArray Data){
void cCore::StreamDataRecived(const qint32 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){
@ -552,14 +553,25 @@ void cCore::StreamDataRecived(const QString ID,const QString Size,const QByteArr
//unknown connection
if(this->isThisIDunknown(ID)){
QByteArray Data2=Protocol->inputUnknown(ID,Data);
if(Data2.isEmpty()==true)
return;
else{
QList<cPacketManager*>::Iterator it;
for(it=DataPacketsManagers.begin(); it!=DataPacketsManagers.end() ;++it){
if((*(it))->getID()==ID){
//(*(it))->operator <<(Data);
(*(*it))<<Data2;
return;
}
}
/*
QString StringSize=QString::number(Data2.length());
StreamDataRecived(ID,StringSize,Data2);
return;
*/
}
}
@ -569,7 +581,6 @@ void cCore::StreamDataRecived(const QString ID,const QString Size,const QByteArr
if((*(it))->getID()==ID){
//(*(it))->operator <<(Data);
(*(*it))<<Data;
return;
}
}
@ -581,7 +592,7 @@ void cCore::StreamDataRecived(const QString ID,const QString Size,const QByteArr
//if it happen forget the Data
}
void cCore::closeAllActiveConenctions(){
void cCore::closeAllActiveConnections(){
//close all known Online||TrytoConnect Connections
for(int i=0;i<users.size();i++)
@ -594,8 +605,7 @@ void cCore::closeAllActiveConenctions(){
users.at(i)->set_ConnectionStatus(User::OFFLINE);
users.at(i)->set_OnlineState(USEROFFLINE);
}
//close all unknownConnections
for(int i=0;i<unknownConnections.size();i++)
@ -604,11 +614,13 @@ void cCore::closeAllActiveConenctions(){
removeUnknownID( unknownConnections.at(i).ID);
}
//DataPacketsManagers.clear();
emit eventUserChanged();
}
bool cCore::isThisIDunknown(QString ID){
bool cCore::isThisIDunknown(qint32 ID){
for(int i=0;i<this->unknownConnections.size();i++)
if(unknownConnections.at(i).ID==ID){
@ -618,7 +630,7 @@ bool cCore::isThisIDunknown(QString ID){
return false;
}
cUser* cCore::getUserByI2P_ID(QString ID){
cUser* cCore::getUserByI2P_ID(qint32 ID){
for(int i=0;i<users.size();i++){
if(users.at(i)->get_I2PStreamID()==ID){
@ -654,7 +666,7 @@ bool cCore::isThisDestinationInunknownConnections(QString Destination){
return false;
}
void cCore::deletePacketManagerByID(QString ID){
void cCore::deletePacketManagerByID(qint32 ID){
if(this->isThisIDunknown(ID)==true)
return;
else
@ -676,24 +688,24 @@ QString cCore::get_connectionDump(){
Message+="< Current open Unknown IDs: >\n";
for(int i=0;i<unknownConnections.size();i++)
Message+=unknownConnections.at(i).ID;
Message+=QString::number(unknownConnections.at(i).ID,10)+"\n";
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+= (QString::number((*(it))->getID(),10)+"\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+="StreamID:\t\t"+QString::number(FileSends.at(i)->get_StreamID(),10)+"\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+="StreamID:\t\t"+QString::number(FileRecives.at(i)->get_StreamID(),10)+"\n";
}
@ -703,7 +715,7 @@ QString cCore::get_connectionDump(){
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";
Message+="I2PStreamID:\t\t" +QString::number(users.at(i)->get_I2PStreamID(),10)+"\n";
switch(users.at(i)->get_ConnectionStatus())
{
@ -828,10 +840,9 @@ void cCore::setOnlineStatus(const ONLINESTATE newStatus)
void cCore::stopCore()
{
closeAllActiveConenctions();
I2P->doDisconnect();
UserConnectThread->stop();
closeAllActiveConnections();
I2P->doDisconnect();
}
void cCore::restartCore()
@ -840,14 +851,17 @@ void cCore::restartCore()
UserConnectThread->start();
}
void cCore::startFileTransfer(QString FilePath, QString Destination)
void cCore::addNewFileTransfer(QString FilePath, QString Destination)
{
cFileTransferSend * t= new cFileTransferSend(this,FilePath,Destination);
connect (t,SIGNAL(event_FileTransferFinishedOK()),SoundManager,
SLOT(event_FileSend_Finished()));
FileSends.append(t);
}
bool cCore::isThisID_a_FileSendID(QString ID)
bool cCore::isThisID_a_FileSendID(qint32 ID)
{
for(int i=0;i<FileSends.size();i++){
if(FileSends.at(i)->get_StreamID()==ID){
@ -857,7 +871,7 @@ bool cCore::isThisID_a_FileSendID(QString ID)
return false;
}
bool cCore::isThisID_a_FileReciveID(QString ID)
bool cCore::isThisID_a_FileReciveID(qint32 ID)
{
for(int i=0;i<FileRecives.size();i++){
if(FileRecives.at(i)->get_StreamID()==ID){
@ -867,7 +881,7 @@ bool cCore::isThisID_a_FileReciveID(QString ID)
return false;
}
void cCore::addNewFileRecive(QString ID, QString FileName, QString FileSize)
void cCore::addNewFileRecive(qint32 ID, QString FileName, QString FileSize)
{
if(isThisIDunknown(ID)) removeUnknownID(ID);
@ -890,23 +904,28 @@ void cCore::addNewFileRecive(QString ID, QString FileName, QString FileSize)
this->StreamClose(ID);
return;
}
SoundManager->event_FileRecive_Incoming();
cFileTransferRecive* t= new cFileTransferRecive(this,ID,FileName,Size);
connect(t,SIGNAL(event_FileRecivedFinishedOK()),SoundManager,
SLOT(event_FileRecive_Finished()));
FileRecives.append(t);
t->start();
}
void cCore::StreamSendData(QString ID, QByteArray Data)
void cCore::StreamSendData(qint32 ID, QByteArray Data)
{
I2P->doStreamSend(ID,Data);
}
void cCore::StreamSendData(QString ID, QString Data)
void cCore::StreamSendData(qint32 ID, QString Data)
{
I2P->doStreamSend(ID,Data);
}
void cCore::StreamClose(QString ID)
void cCore::StreamClose(qint32 ID)
{
if(FileSends.count()>0){
for(int i=0;i<FileSends.count();i++){
@ -935,3 +954,9 @@ bool cCore::checkIfAFileTransferOrReciveisActive()
return false;
}
void cCore::MuteSound(bool t)
{
SoundManager->doMute(t);
}

View File

@ -37,17 +37,18 @@
#include "PacketManager.h"
#include "FileTransferSend.h"
#include "FileTransferRecive.h"
#include "SoundManager.h"
#define CLIENTVERSION "0.2.7 Beta"
#define CLIENTVERSION "0.2.9 Beta"
#define CLIENTNAME "I2P-Messenger (QT)"
struct cConnection
{
cConnection ( QString ID,QString Destination )
cConnection ( qint32 ID,QString Destination )
{
this->ID=ID;
this->Destination=Destination;
@ -57,14 +58,13 @@ struct cConnection
this->ID=t.ID;
this->Destination=t.Destination;
}
QString ID;
qint32 ID;
QString Destination;
};
using namespace SAM_Message_Types;
using namespace User;
class cUserConnectThread;
class cCore :public QObject
{
@ -74,15 +74,15 @@ class cCore :public QObject
~cCore();
cDebugMessageManager* get_DebugMessageHandler();
const QList<cUser*> get_userList();
bool isThisIDunknown ( QString ID );
bool removeUnknownID ( QString ID );
bool isThisIDunknown ( qint32 ID );
bool removeUnknownID ( qint32 ID );
bool isThisDestinationInunknownConnections ( QString Destination );
void removeUnknownIDCreateUserIfNeeded( const QString ID,const QString ProtocolVersion );
void removeUnknownIDCreateUserIfNeeded( const qint32 ID,const QString ProtocolVersion );
QString get_UserProtocolVersionByStreamID ( QString ID );
void set_UserProtocolVersionByStreamID ( QString ID,QString Version );
cUser* getUserByI2P_ID ( QString ID );
QString get_UserProtocolVersionByStreamID ( qint32 ID );
void set_UserProtocolVersionByStreamID ( qint32 ID,QString Version );
cUser* getUserByI2P_ID ( qint32 ID );
cUser* getUserByI2P_Destination ( QString Destination );
const QString getMyDestination() const;
ONLINESTATE getOnlineStatus()const;
@ -90,35 +90,35 @@ class cCore :public QObject
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 );
void addNewFileTransfer(QString FilePath,QString Destination);
void addNewFileRecive(qint32 ID,QString FileName,QString FileSize);
void StreamSendData(qint32 ID,QByteArray Data);
void StreamSendData(qint32 ID,QString Data);
void StreamClose(qint32 ID);
qint32 StreamConnect (QString Destination );
bool checkIfAFileTransferOrReciveisActive();
public slots:
bool addNewUser (QString Name,QString I2PDestination,QString TorDestination,QString I2PStream_ID="");
bool deleteUserByTorDestination (const QString TorDestination );
bool addNewUser (QString Name,QString I2PDestination,qint32 I2PStream_ID=0);
bool deleteUserByI2PDestination (const QString I2PDestination );
bool renameuserByI2PDestination (const QString Destination, const QString newNickname);
void doNamingLookUP ( QString Name );
void MuteSound(bool t);
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 StreamClosedRecived ( const SAM_Message_Types::RESULT result,qint32 ID,QString Message );
void StreamStatusRecived ( const SAM_Message_Types::RESULT result,const qint32 ID,QString Message );
void StreamConnectedRecived ( const QString Destinaton,const qint32 ID );
void StreamReadyToSendRecived ( const qint32 ID );
void StreamSendRecived ( const qint32 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 StreamDataRecived ( const qint32 ID,const QString Size,const QByteArray Data );
void NamingReplyRecived ( const SAM_Message_Types::RESULT result,QString Name,QString Value="",QString Message="" );
signals:
void eventUserChanged();
@ -136,20 +136,19 @@ class cCore :public QObject
ONLINESTATE currentOnlineStatus;
QList<cFileTransferSend*> FileSends;
QList<cFileTransferRecive*> FileRecives;
cSoundManager* SoundManager;
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);
void closeAllActiveConnections();
void deletePacketManagerByID ( qint32 ID );
bool isThisID_a_FileSendID(qint32 ID);
bool isThisID_a_FileReciveID(qint32 ID);
};
#endif

View File

@ -23,13 +23,11 @@
cFileTransferRecive::cFileTransferRecive(cCore * Core, QString StreamID, QString FileName, quint64 FileSize)
cFileTransferRecive::cFileTransferRecive(cCore * Core, qint32 StreamID, QString FileName, quint64 FileSize)
:StreamID(StreamID),FileName(FileName),FileSize(FileSize)
{
this->Core=Core;
allreadyRecivedSize=0;
}
cFileTransferRecive::~ cFileTransferRecive()
@ -38,7 +36,7 @@ cFileTransferRecive::~ cFileTransferRecive()
delete FileForRecive;
}
void cFileTransferRecive::StreamStatus(const SAM_Message_Types::RESULT result, const QString ID, QString Message)
void cFileTransferRecive::StreamStatus(const SAM_Message_Types::RESULT result, const qint32 ID, QString Message)
{
if(result==SAM_Message_Types::OK)
{
@ -54,7 +52,7 @@ void cFileTransferRecive::StreamStatus(const SAM_Message_Types::RESULT result, c
}
void cFileTransferRecive::StreamClosed(const SAM_Message_Types::RESULT result, QString ID, QString Message)
void cFileTransferRecive::StreamClosed(const SAM_Message_Types::RESULT result, qint32 ID, QString Message)
{
if(allreadyRecivedSize==FileSize){
@ -131,4 +129,22 @@ void cFileTransferRecive::start()
}
}
void cFileTransferRecive::start_withAutoAccept(QString Path)
{
QString SFileSize;
SFileSize.setNum(FileSize);
QString FilePath=Path+="/"+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();
}
}

View File

@ -28,16 +28,17 @@ class cFileTransferRecive:public QObject
{
Q_OBJECT
public:
cFileTransferRecive(cCore* Core,QString StreamID,QString FileName,quint64 FileSize);
cFileTransferRecive(cCore* Core,qint32 StreamID,QString FileName,quint64 FileSize);
~cFileTransferRecive();
void start();
void start_withAutoAccept(QString Path);
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 StreamStatus(const SAM_Message_Types::RESULT result,const qint32 ID,QString Message);
void StreamClosed(const SAM_Message_Types::RESULT result,qint32 ID,QString Message);
void operator << ( QByteArray t );
quint64 get_FileSize(){return FileSize;};
QString get_FileName(){return FileName;};
QString get_StreamID(){return StreamID;};
qint32 get_StreamID(){return StreamID;};
public slots:
void abbortFileRecive();
@ -54,7 +55,7 @@ class cFileTransferRecive:public QObject
const quint64 FileSize;
quint64 allreadyRecivedSize;
const QString FileName;
const QString StreamID;
const qint32 StreamID;
QFile* FileForRecive;
};
#endif
#endif

View File

@ -45,7 +45,7 @@ void cFileTransferSend::abbortFileSend()
Core->StreamClose(StreamID);
}
void cFileTransferSend::StreamStatus(const SAM_Message_Types::RESULT result, const QString ID, QString Message)
void cFileTransferSend::StreamStatus(const SAM_Message_Types::RESULT result, const qint32 ID, QString Message)
{
using namespace FileTransferProtocol;
@ -70,7 +70,7 @@ void cFileTransferSend::StreamStatus(const SAM_Message_Types::RESULT result, con
}
void cFileTransferSend::StreamClosed(const SAM_Message_Types::RESULT result, QString ID, QString Message)
void cFileTransferSend::StreamClosed(const SAM_Message_Types::RESULT result, qint32 ID, QString Message)
{
if(result==SAM_Message_Types::OK){
if(allreadySendedSize==FileSize){

View File

@ -30,7 +30,8 @@ namespace FileTransferProtocol
};
//limited to 30Kb
#define MAXPAKETSIZE 30720
//#define MAXPAKETSIZE 30720
#define MAXPAKETSIZE 1024
class cCore;
class form_fileSend;
class cFileTransferSend:public QObject
@ -40,12 +41,12 @@ class cFileTransferSend:public QObject
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 StreamStatus(const SAM_Message_Types::RESULT result,const qint32 ID,QString Message);
void StreamClosed(const SAM_Message_Types::RESULT result,qint32 ID,QString Message);
void StreamReadyToSend(bool t);
void operator << ( QByteArray t );
quint64 get_FileSize(){return FileSize;};
QString get_StreamID(){return StreamID;};
qint32 get_StreamID(){return StreamID;};
QString get_FileName(){return FileName;};
@ -67,7 +68,7 @@ class cFileTransferSend:public QObject
qint64 FileSize;
qint64 allreadySendedSize;
const QString Destination;
QString StreamID;
qint32 StreamID;
QFile* FileForSend;
bool sendFirstPaket;
bool FileTransferAccepted;
@ -75,4 +76,4 @@ class cFileTransferSend:public QObject
form_fileSend* Dialog;
};
#endif
#endif

View File

@ -37,7 +37,10 @@ const SAM_MESSAGE I2PSamMessageAnalyser::Analyse(QString Message)
//get ID
QStringList temp=list[2].split("=");
t.Id=temp[1];
QString sID=temp[1];
t.ID=QStringToQint32(sID);
//get Size
temp= list[3].split("=");
t.Size=temp[1].remove("\n");
@ -47,7 +50,9 @@ const SAM_MESSAGE I2PSamMessageAnalyser::Analyse(QString Message)
//GET ID
QStringList temp=list[2].split("=");
t.Id=temp[1].remove("\n");
QString sID=temp[1].remove("\n");
t.ID=QStringToQint32(sID);
}
else if((list[0]=="HELLO") && (list[1]=="REPLY")){
t.type=HELLO_REPLAY;
@ -97,11 +102,13 @@ const SAM_MESSAGE I2PSamMessageAnalyser::Analyse(QString Message)
t.type=ERROR_IN_ANALYSE;
return t;
}
//----------------
//Get ID
QStringList temp=list[3].split("=");
QString sID=temp[1].remove("\n");
t.Id=temp[1].remove("\n");
t.ID=QStringToQint32(sID);
//----------------
//Get Message
if(Message.contains("MESSAGE=",Qt::CaseInsensitive)){
@ -115,10 +122,13 @@ const SAM_MESSAGE I2PSamMessageAnalyser::Analyse(QString Message)
t.type=STREAM_CONNECTED;
QStringList temp=list[2].split("=");
QString sID;
t.Destination=temp[1];
temp=list[3].split("=");
t.Id=temp[1].remove("\n");
sID=temp[1].remove("\n");
t.ID=QStringToQint32(sID);
}
else if((list[0].contains("STREAM")==true) && (list[1].contains("SEND")==true)){
@ -126,7 +136,8 @@ const SAM_MESSAGE I2PSamMessageAnalyser::Analyse(QString Message)
//get ID
QStringList temp=list[2].split("=");
t.Id=temp[1];
QString sID=temp[1];
t.ID=QStringToQint32(sID);
//Get Result
if(list[3].contains("RESULT=OK",Qt::CaseInsensitive))t.result=OK;
@ -156,7 +167,8 @@ const SAM_MESSAGE I2PSamMessageAnalyser::Analyse(QString Message)
//Get ID
QStringList temp=list[3].split("=");
t.Id=temp[1];
QString sID=temp[1];
t.ID=QStringToQint32(sID);
}
else
{
@ -172,7 +184,9 @@ const SAM_MESSAGE I2PSamMessageAnalyser::Analyse(QString Message)
//Get ID
QStringList temp=list[2].split("=");
t.Id=temp[1];
QString sID=temp[1];
t.ID=QStringToQint32(sID);
}
@ -216,3 +230,22 @@ const SAM_MESSAGE I2PSamMessageAnalyser::Analyse(QString Message)
return t;
}
qint32 I2PSamMessageAnalyser::QStringToQint32(QString value)
{
bool OK=false;
qint32 iValue =value.toInt ( &OK,10 );
if(OK==false)
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText("I2PSamMessageAnalyser");
msgBox.setInformativeText("cant parse value: "+value );
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
return iValue;
}

View File

@ -66,7 +66,7 @@ struct SAM_MESSAGE
{
public:
QString Message;
QString Id;
qint32 ID;
QString Destination;
QString Size;
QString Name;
@ -89,5 +89,8 @@ class I2PSamMessageAnalyser: public QObject
public:
I2PSamMessageAnalyser();
const SAM_MESSAGE Analyse(QString Message);
private:
qint32 QStringToQint32(QString value);
};
#endif

View File

@ -21,7 +21,7 @@
cPacketManager::cPacketManager ( QString ID )
cPacketManager::cPacketManager ( qint32 ID )
:ID ( ID )
{
Data.clear();
@ -32,10 +32,10 @@ cPacketManager::~cPacketManager()
}
void cPacketManager::operator << ( QByteArray t )
{
Data.push_back ( t );
Data.append ( t );
checkifOnePacketIsComplead();
}
const QString cPacketManager::getID()
qint32 cPacketManager::getID()
{
return ID;
}
@ -51,7 +51,7 @@ void cPacketManager::checkifOnePacketIsComplead()
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText("cPacketManager");
msgBox.setText("cPacketManager ("+QString(ID)+")");
msgBox.setInformativeText("cant parse PacketLength\nHexValue: "+sPacketLength );
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
@ -67,5 +67,6 @@ void cPacketManager::checkifOnePacketIsComplead()
checkifOnePacketIsComplead();
}
}
return;
}

View File

@ -29,17 +29,17 @@ class cPacketManager :public QObject
public:
cPacketManager() {}
cPacketManager ( QString ID );
//cPacketManager() {}
cPacketManager ( qint32 ID );
~cPacketManager();
void operator << ( QByteArray t );
const QString getID();
qint32 getID();
void checkifOnePacketIsComplead();
signals:
void aPacketIsComplead ( const QString ID,const QByteArray CurrentPacket );
void aPacketIsComplead ( const qint32 ID,const QByteArray CurrentPacket );
private:
const QString ID;
const qint32 ID;
QByteArray Data;
};
#endif
#endif

View File

@ -28,12 +28,12 @@ cProtocol::cProtocol(cCore * Core){
}
void cProtocol::newConnectionChat(const QString ID){
void cProtocol::newConnectionChat(const qint32 ID){
using namespace Protocol_Info;
//send the ChatSystem\tProtocolVersion
Core->StreamSendData(ID,FIRSTPAKETCHAT);
}
void cProtocol::inputKnown(const QString ID, const QByteArray Data){
void cProtocol::inputKnown(const qint32 ID, const QByteArray Data){
using namespace Protocol_Info;
if(Data.length()<4)
@ -84,13 +84,14 @@ using namespace Protocol_Info;
}
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();
QMessageBox* msgBox= new QMessageBox(NULL);
msgBox->setIcon(QMessageBox::Warning);
msgBox->setText("cProtocol(inputKnown)");
msgBox->setInformativeText("Unknown USERSTATE");
msgBox->setStandardButtons(QMessageBox::Ok);
msgBox->setDefaultButton(QMessageBox::Ok);
msgBox->setWindowModality(Qt::NonModal);
msgBox->show();
}
}
@ -170,7 +171,7 @@ using namespace Protocol_Info;
//end Messages
}
QByteArray cProtocol::inputUnknown(const QString ID, const QByteArray Data){
QByteArray cProtocol::inputUnknown(const qint32 ID, const QByteArray Data){
using namespace Protocol_Info;
if(Core->isThisIDunknown(ID)==true){
@ -181,26 +182,14 @@ using namespace Protocol_Info;
//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)
if(ID < 0)
newConnectionChat(ID);//someone connect you
Core->removeUnknownIDCreateUserIfNeeded(ID,version);
//remove Firstpacket
QByteArray Data2=Data;
Data2.remove(0,Data.indexOf("\n")+1);
Data2=Data2.remove(0,Data.indexOf("\n")+1);
return Data2;
}
@ -239,7 +228,7 @@ using namespace Protocol_Info;
return Data;
}
void cProtocol::send(const COMMANDS_TAGS TAG,const QString ID){
void cProtocol::send(const COMMANDS_TAGS TAG,const qint32 ID){
using namespace Protocol_Info;
QString ProtocolInfoTag;
QString Data="";
@ -275,7 +264,7 @@ void cProtocol::send(const COMMANDS_TAGS TAG,const QString ID){
Core->StreamSendData(ID,Data);
}
void cProtocol::send(const MESSAGES_TAGS TAG,const QString ID,QString Data){
void cProtocol::send(const MESSAGES_TAGS TAG,const qint32 ID,QString Data){
QString ProtocolInfoTag;
switch(TAG)

View File

@ -77,11 +77,11 @@ 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);
QByteArray inputUnknown(const qint32 ID,const QByteArray Data);
void inputKnown(const qint32 ID, const QByteArray Data);
void send(const MESSAGES_TAGS TAG,const qint32 ID,QString Data);
void send(const COMMANDS_TAGS TAG,const qint32 ID);
void newConnectionChat(const qint32 ID);
signals:
void eventUserChanged();//also used for newchatMessage

View File

@ -0,0 +1,101 @@
/***************************************************************************
* 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 "SoundManager.h"
cSoundManager::cSoundManager()
{
isMute=false;
reInit();
}
void cSoundManager::doMute(bool t)
{
isMute=t;
}
void cSoundManager::event_User_go_Online()
{
if(isMute==true) return;
if(enable_eventUser_go_Online)
QSound::play(SoundFileUser_go_Online);
}
void cSoundManager::event_User_go_Offline()
{
if(isMute==true) return;
if(enable_eventUser_go_Offline)
QSound::play(SoundFileUser_go_Offline);
}
void cSoundManager::event_FileSend_Finished()
{
if(isMute==true) return;
if(enable_eventFileSend_Finished)
QSound::play(SoundFileFileSend_Finished);
}
void cSoundManager::event_FileRecive_Incoming()
{
if(isMute==true) return;
if(enable_eventFileRecive_Incoming)
QSound::play(SoundFileFileRecive_Incoming);
}
void cSoundManager::event_FileRecive_Finished()
{
if(isMute==true) return;
if(enable_eventFileRecive_Finished)
QSound::play(SoundFileFileRecive_Finished);
}
void cSoundManager::event_NewChatMessage()
{
if(isMute==true) return;
if(enable_eventNewChatMessage)
{
QSound::play(SoundFileNewChatMessage);
}
}
void cSoundManager::reInit()
{
QSettings* settings= new QSettings(QApplication::applicationDirPath()+"/application.ini",QSettings::IniFormat);
settings->beginGroup("Sound");
settings->beginGroup("Enable");
enable_eventUser_go_Online=settings->value("User_go_Online",false).toBool();
enable_eventUser_go_Offline=settings->value("User_go_Offline",false).toBool();
enable_eventFileSend_Finished=settings->value("FileSend_Finished",false).toBool();
enable_eventFileRecive_Incoming=settings->value("FileRecive_Incoming",false).toBool();
enable_eventFileRecive_Finished=settings->value("FileRecive_Finished",false).toBool();
enable_eventNewChatMessage=settings->value("NewChatMessage",false).toBool();
settings->endGroup();
settings->beginGroup("SoundFilePath");
SoundFileUser_go_Online=settings->value("User_go_Online","").toString();
SoundFileUser_go_Offline=settings->value("User_go_Offline","").toString();
SoundFileFileSend_Finished=settings->value("FileSend_Finished","").toString();
SoundFileFileRecive_Incoming=settings->value("FileRecive_Incoming","").toString();
SoundFileFileRecive_Finished=settings->value("FileRecive_Finished","").toString();
SoundFileNewChatMessage=settings->value("NewChatMessage","").toString();
settings->endGroup();
settings->endGroup();
delete settings;
}

View File

@ -0,0 +1,61 @@
/***************************************************************************
* 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 SOUND_MANAGER_H
#define SOUND_MANAGER_H
#include <QSound>
#include <QSettings>
#include <QtGui>
class cSoundManager :public QObject
{
Q_OBJECT
public:
cSoundManager();
public slots:
void doMute(bool t);
void event_User_go_Online();
void event_User_go_Offline();
void event_FileSend_Finished();
void event_FileRecive_Incoming();
void event_FileRecive_Finished();
void event_NewChatMessage();
void reInit();
private:
bool isMute;
QString SoundFileUser_go_Online;
QString SoundFileUser_go_Offline;
QString SoundFileFileSend_Finished;
QString SoundFileFileRecive_Incoming;
QString SoundFileFileRecive_Finished;
QString SoundFileNewChatMessage;
bool enable_eventUser_go_Online;
bool enable_eventUser_go_Offline;
bool enable_eventFileSend_Finished;
bool enable_eventFileRecive_Incoming;
bool enable_eventFileRecive_Finished;
bool enable_eventNewChatMessage;
};
#endif

View File

@ -23,14 +23,12 @@
cUser::cUser( cProtocol* Protocol,
QString Name,
QString I2PDestination,
QString I2PStream_ID,
QString TorDestination
):I2PDestination(I2PDestination),TorDestination(TorDestination)
qint32 I2PStream_ID
):I2PDestination(I2PDestination)
{
this->Protocol=Protocol;
this->Name=Name;
this->ReadyToSend=true;
this->TORStream_ID="";
this->I2PStream_ID=I2PStream_ID;
this->ConnectionStatus=OFFLINE;
this->HaveAllreadyOneChatWindow=false;
@ -38,6 +36,9 @@ cUser::cUser( cProtocol* Protocol,
this->ClientName="";
this->ClientVersion="";
this->CurrentOnlineState=USEROFFLINE;
this->textColor=Qt::black;
this->textFont=QFont("Comic Sans MS", 10);
}
const QString cUser::get_Name()const{
@ -46,15 +47,9 @@ const QString cUser::get_Name()const{
const QString cUser::get_I2PDestination()const{
return this->I2PDestination;
}
const QString cUser::get_I2PStreamID()const{
qint32 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;
@ -64,24 +59,27 @@ void cUser::set_Name(QString newName){
this->Name=newName;
}
void cUser::set_ConnectionStatus(CONNECTIONTOUSER Status){
this->ConnectionStatus=Status;
if(Status==ONLINE){
this->ConnectionStatus=Status;
//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);
//emit connectionOnline();
}
if(Status==OFFLINE ||Status==ERROR)
{
I2PStream_ID="";
I2PStream_ID=0;
this->CurrentOnlineState=USEROFFLINE;
this->ConnectionStatus=Status;
}
//emit OnlineStateChanged();
}
void cUser::set_I2PStreamID(QString ID){
void cUser::set_I2PStreamID(qint32 ID){
this->I2PStream_ID=ID;
}
void cUser::set_ReadyToSend(bool b){
@ -95,9 +93,10 @@ const QString cUser::get_ProtocolVersion()const{
}
void cUser::IncomingNewChatMessage(QString newMessage){
this->Messages.push_back(Name+": "+newMessage+"<br>");
this->Messages.push_back(Name+"("+ QTime::currentTime().toString("hh:mm:ss") +"): "+newMessage+"<br>");
this->newUnreadMessages=true;
emit newMessageRecived();
emit newIncomingMessageRecived();
}
void cUser::sendChatMessage(QString Message){
using namespace PROTOCOL_TAGS;
@ -108,13 +107,13 @@ void cUser::sendChatMessage(QString Message){
CurrentOnlineState != USERINVISIBLE
){
Protocol->send(CHATMESSAGE,I2PStream_ID,Message);
this->Messages.push_back("Me: "+Message+"<br>");
this->Messages.push_back("Me("+QTime::currentTime().toString("hh:mm:ss") +"): "+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>");
this->Messages.push_back("[SYSTEM]("+QTime::currentTime().toString("hh:mm:ss") +"): 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();
@ -141,7 +140,7 @@ void cUser::sendAllunsendedMessages(){
this->Messages.push_back("[SYSTEM]: All unsended Messages where sended<br><br>");
this->Messages.push_back("[SYSTEM]("+QTime::currentTime().toString("hh:mm:ss")+"): All unsended Messages were sended<br><br>");
unsendedMessages.clear();
this->newUnreadMessages=true;
emit newMessageRecived();
@ -161,6 +160,7 @@ void cUser::set_ClientName(QString Name)
ClientName=Name;
}
const QString cUser::get_ClientVersion() const
{
return ClientVersion;
@ -178,12 +178,47 @@ ONLINESTATE cUser::get_OnlineState() const
void cUser::set_OnlineState(const ONLINESTATE newState)
{
this->CurrentOnlineState=newState;
if( CurrentOnlineState!=USEROFFLINE &&
CurrentOnlineState!=USERINVISIBLE){
if(newState!=USEROFFLINE &&
newState!=USERINVISIBLE){
if(CurrentOnlineState==USEROFFLINE || CurrentOnlineState==USERINVISIBLE)
emit connectionOnline();
this->sendAllunsendedMessages();
}
else if(newState==USEROFFLINE || newState==USERINVISIBLE){
if(newState!=CurrentOnlineState)
emit connectionOffline();
}
this->CurrentOnlineState=newState;
emit OnlineStateChanged();
}
QColor cUser::get_textColor()
{
return textColor;
}
void cUser::set_textColor(QColor textColor)
{
this->textColor=textColor;
}
void cUser::set_textFont(QFont textFont)
{
this->textFont=textFont;
}
QFont cUser::get_textFont()
{
return textFont;
}
void cUser::IncomingMessageFromSystem(QString newMessage)
{
this->Messages.push_back("[System]("+ QTime::currentTime().toString("hh:mm:ss") +"): "+newMessage+"<br>");
this->newUnreadMessages=true;
emit newMessageRecived();
emit newIncomingMessageRecived();
}

View File

@ -22,6 +22,7 @@
#include <QtGui>
#include <QStringList>
#include <QTime>
namespace User
@ -54,18 +55,18 @@ class cUser: public QObject
cUser( cProtocol* Protocol,
QString Name,
QString I2PDestination,
QString I2PStream_ID,
QString TorDestination
qint32 I2PStream_ID
);
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;
qint32 get_I2PStreamID()const;
const QString get_ProtocolVersion()const;
const QString get_ClientName()const;
const QString get_ClientVersion()const;
QColor get_textColor();
QFont get_textFont();
CONNECTIONTOUSER get_ConnectionStatus()const;
ONLINESTATE get_OnlineState()const;
@ -76,13 +77,17 @@ class cUser: public QObject
void set_ConnectionStatus(CONNECTIONTOUSER Status);
void set_OnlineState(const ONLINESTATE newState);
void set_Name(QString newName);
void set_I2PStreamID(QString ID);
void set_I2PStreamID(qint32 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);
void IncomingMessageFromSystem(QString newMessage);
void set_textColor(QColor textColor);
void set_textFont(QFont textFont);
public slots:
void sendChatMessage(QString Message);
@ -90,17 +95,18 @@ class cUser: public QObject
signals:
void OnlineStateChanged();
void newMessageRecived();
void newIncomingMessageRecived();
void connectionOnline();
void connectionOffline();
private:
bool HaveAllreadyOneChatWindow;
bool newUnreadMessages;
void sendAllunsendedMessages();
const QString I2PDestination;
const QString TorDestination;
QString Name;
QString I2PStream_ID;
QString TORStream_ID;
qint32 I2PStream_ID;
bool ReadyToSend;
@ -112,6 +118,10 @@ class cUser: public QObject
QStringList Messages;
QStringList unsendedMessages;
cProtocol* Protocol;
//Settings for the chatwindow
QColor textColor;
QFont textFont;
};
#endif