diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.h index f0d9ff549..faffa04c0 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_HelpDialog.h @@ -40,4 +40,3 @@ private: }; #endif - diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.cpp index 44aa96eb5..10c9156ba 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.cpp @@ -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); +} diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.h index 3e2e22dde..f4841c48d 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_Main.h @@ -32,6 +32,7 @@ #include #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 diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.cpp index 41908be5d..18acca326 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.cpp @@ -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(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 +")"); +} + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.h index 26c7934bb..aa0bfcf95 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.h @@ -3,10 +3,26 @@ #include "ui_form_chatwidget.h" +#include "gui_icons.h" + #include #include - #include +#include +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 \ No newline at end of file +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.ui index 322dd6665..2d65dda41 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.ui +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_chatwidget.ui @@ -245,7 +245,7 @@ - &Senden + Senden diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.h index ef0a8e74b..17d6f5a2f 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileRecive.h @@ -45,4 +45,4 @@ class form_fileRecive : public QDialog, public Ui::form_FileRecive void init(); cFileTransferRecive* FileRecive; }; -#endif \ No newline at end of file +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.h index ce5b74814..1839c43c0 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_fileSend.h @@ -45,4 +45,4 @@ class form_fileSend : public QDialog, public Ui::form_FileSend void init(); cFileTransferSend* FileTransfer; }; -#endif \ No newline at end of file +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.cpp index 7e3c01a35..90704d343 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.cpp @@ -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(); + } } diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.ui index 33a395ab5..c97a7c51a 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.ui +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_newUser.ui @@ -21,14 +21,7 @@ 6 - - - - false - - - - + 6 @@ -36,33 +29,6 @@ 0 - - - - Network: - - - - - - - false - - - I2P - - - - - - - false - - - Tor - - - @@ -85,13 +51,6 @@ - - - - Destination Tor: - - - diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.cpp index 69f3d9a27..bee599860 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.cpp @@ -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); + +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.h index 7193552a7..9d706225e 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.h @@ -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 diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.ui b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.ui index 333c0040f..ede91b7b9 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.ui +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/form_settingsgui.ui @@ -174,6 +174,15 @@ :/icons/encrypted24.png:/icons/encrypted24.png + + + Sound + + + + :/icons/sound.png:/icons/sound.png + + @@ -299,7 +308,7 @@ - 0 + 5 @@ -336,6 +345,12 @@ 22 + + 30 + + + 99999 + @@ -958,7 +973,7 @@ p, li { white-space: pre-wrap; } 10 0 - 147 + 150 32 @@ -1136,7 +1151,7 @@ p, li { white-space: pre-wrap; } 11 0 77 - 28 + 31 @@ -1217,7 +1232,7 @@ p, li { white-space: pre-wrap; } 10 0 - 98 + 104 27 @@ -1246,6 +1261,358 @@ p, li { white-space: pre-wrap; } + + + + + 10 + 0 + 104 + 27 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/icons/sound.png" /></p></body></html> + + + + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"> +<p style=" -qt-block-indent:0; text-indent:0px; font-size:8pt;"><span style=" font-size:12pt; font-weight:600;">Sound</span></p></body></html> + + + + + + + + + 0 + 40 + 441 + 381 + + + + Sound Events + + + + + 10 + 20 + 421 + 81 + + + + User + + + + false + + + + 10 + 20 + 80 + 23 + + + + go Online + + + + + false + + + + 10 + 50 + 80 + 23 + + + + go Offline + + + + + false + + + + 90 + 20 + 281 + 24 + + + + + + false + + + + 90 + 50 + 281 + 24 + + + + + + + 380 + 20 + 31 + 21 + + + + ... + + + + + + 380 + 50 + 31 + 21 + + + + ... + + + + + + + 10 + 100 + 421 + 61 + + + + FileSend + + + + false + + + + 90 + 20 + 281 + 24 + + + + + + + 380 + 20 + 31 + 21 + + + + ... + + + + + false + + + + 10 + 20 + 80 + 23 + + + + Finished + + + + + + + 10 + 160 + 421 + 91 + + + + FileRecive + + + + false + + + + 10 + 20 + 80 + 23 + + + + Incoming + + + + + false + + + + 90 + 20 + 281 + 24 + + + + + + + 380 + 20 + 31 + 21 + + + + ... + + + + + + 380 + 50 + 31 + 21 + + + + ... + + + + + false + + + + 10 + 50 + 80 + 23 + + + + Finished + + + + + false + + + + 90 + 50 + 281 + 24 + + + + + + + + 10 + 260 + 421 + 111 + + + + Chatmessage + + + + + 380 + 20 + 31 + 21 + + + + ... + + + + + false + + + + 10 + 20 + 80 + 23 + + + + New + + + + + false + + + + 90 + 20 + 281 + 24 + + + + + + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/gui_icons.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/gui_icons.h new file mode 100644 index 000000000..da87c94ac --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/gui_icons.h @@ -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 \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/1leftarrow.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/1leftarrow.png new file mode 100644 index 000000000..5f8b761b1 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/1leftarrow.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/Thumbs.db b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/Thumbs.db index 780b9a96a..221a50028 100644 Binary files a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/Thumbs.db and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/Thumbs.db differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/sound.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/sound.png new file mode 100644 index 000000000..fe37e137e Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/sound.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/sound_off.png b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/sound_off.png new file mode 100644 index 000000000..a7b048e8b Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/icons/sound_off.png differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/resourcen.qrc b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/resourcen.qrc index 8593c8dab..915020361 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/resourcen.qrc +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/gui/resourcen.qrc @@ -23,5 +23,7 @@ icons/dnd.png icons/xa.png icons/about.png + icons/sound.png + icons/sound_off.png diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/qt_chat.pro b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/qt_chat.pro index 8f86cc3c0..226d44f74 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/qt_chat.pro +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/qt_chat.pro @@ -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 + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/sounds/File.wav b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/sounds/File.wav new file mode 100644 index 000000000..1cbc55f73 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/sounds/File.wav differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/sounds/Notify.wav b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/sounds/Notify.wav new file mode 100644 index 000000000..76fd968c8 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/sounds/Notify.wav differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/sounds/Startup.wav b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/sounds/Startup.wav new file mode 100644 index 000000000..f9f45e1b4 Binary files /dev/null and b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/sounds/Startup.wav differ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.cpp index c13bcfaf2..6d477cfc1 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.cpp @@ -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); diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.h index ef32379ef..49c32cedf 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/ConnectionI2P.h @@ -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() { diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.cpp index 81fa873e9..640a722f2 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.cpp @@ -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;iusers.count();i++) delete users.at(i); - - QList::Iterator it; for(it=DataPacketsManagers.begin(); itDebugMessageHandler; 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;iget_TORDestination()==TorDestination){ - if(users.at(i)->get_ConnectionStatus()==ONLINE ||users.at(i)->get_ConnectionStatus()==TRYTOCONNECT) - I2P->doStreamClose(users.at(i)- - users.removeAt(i); - emit eventUserChanged(); - return true; - } - }*/ - return false; -} + bool cCore::deleteUserByI2PDestination(QString I2PDestination){ for(int i=0;iget_I2PDestination()==I2PDestination){ if(users.at(i)->get_ConnectionStatus()==ONLINE ||users.at(i)->get_ConnectionStatus()==TRYTOCONNECT) { - deletePacketManagerByID(users.at(i)->get_I2PStreamID()); this->StreamClose(users.at(i)->get_I2PStreamID()); - + 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;iget_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;iusers.count();i++){ out<<"Nick:\t"<<(users.at(i)->get_Name())<get_I2PDestination())<get_TORDestination())<get_I2PDestination())<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;iget_I2PStreamID()==ID){ - users.at(i)->set_ConnectionStatus(OFFLINE); - } - } - - - return; } - return; + } for(int i=0;iget_I2PStreamID()==ID){ if(result==SAM_Message_Types::OK){ - users.at(i)->set_ConnectionStatus(ONLINE); users.at(i)->set_I2PStreamID(ID); - this->Protocol->newConnectionChat(ID); + 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;iunknownConnections.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;iget_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 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;iget_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::Iterator it; + for(it=DataPacketsManagers.begin(); it!=DataPacketsManagers.end() ;++it){ + if((*(it))->getID()==ID){ + //(*(it))->operator <<(Data); + (*(*it))<getID()==ID){ //(*(it))->operator <<(Data); (*(*it))<set_ConnectionStatus(User::OFFLINE); users.at(i)->set_OnlineState(USEROFFLINE); - - + } //close all unknownConnections for(int i=0;iunknownConnections.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;iget_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::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;iget_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;iget_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;iget_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;iget_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;idoMute(t); +} + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.h index e4fc11189..19f178470 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Core.h @@ -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 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: // - 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 FileSends; QList 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 - diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.cpp index 5436596b9..8654756c2 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.cpp @@ -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(); + } +} + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.h index a264e621b..c2f7752b6 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferRecive.h @@ -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 \ No newline at end of file +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.cpp index 2704a431c..43382662d 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.cpp @@ -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){ diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.h index eeeb3a063..4c14c822a 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/FileTransferSend.h @@ -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 \ No newline at end of file +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.cpp index 08ecc1604..02bd5fcf9 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.cpp @@ -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; +} + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.h index 1c158bd7a..6dfc076e1 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/I2PSamMessageAnalyser.h @@ -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 diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.cpp index 2754b054c..13ddf81e3 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.cpp @@ -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; } diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.h index 322b86770..0e5d52778 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/PacketManager.h @@ -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 \ No newline at end of file +#endif diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.cpp index 1e455aa33..3a0058b63 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.cpp @@ -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) diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.h index 2ac7f4c53..b1bd4d44b 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/Protocol.h @@ -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 diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/SoundManager.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/SoundManager.cpp new file mode 100644 index 000000000..169790704 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/SoundManager.cpp @@ -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; +} + diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/SoundManager.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/SoundManager.h new file mode 100644 index 000000000..d484503d2 --- /dev/null +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/SoundManager.h @@ -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 +#include +#include + + +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 \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.cpp b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.cpp index 983d1df0b..8ff3468be 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.cpp +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.cpp @@ -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+"
"); + this->Messages.push_back(Name+"("+ QTime::currentTime().toString("hh:mm:ss") +"): "+newMessage+"
"); 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+"
"); + this->Messages.push_back("Me("+QTime::currentTime().toString("hh:mm:ss") +"): "+Message+"
"); //this->Messages.push_back(Message); emit newMessageRecived(); } else{ - this->Messages.push_back("[SYSTEM]: Sending the Message when the user come online
When you close the client the Message is lost
"); + this->Messages.push_back("[SYSTEM]("+QTime::currentTime().toString("hh:mm:ss") +"): Sending the Message when the user come online
When you close the client the Message is lost
"); unsendedMessages.push_back(Message); emit newMessageRecived(); @@ -141,7 +140,7 @@ void cUser::sendAllunsendedMessages(){ - this->Messages.push_back("[SYSTEM]: All unsended Messages where sended

"); + this->Messages.push_back("[SYSTEM]("+QTime::currentTime().toString("hh:mm:ss")+"): All unsended Messages were sended

"); 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+"
"); + this->newUnreadMessages=true; + emit newMessageRecived(); + emit newIncomingMessageRecived(); +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.h b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.h index 063215128..fa2be12e2 100644 --- a/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.h +++ b/retroshare-gui/src/gui/plugins/i2pmessenger_plugin/src/User.h @@ -22,6 +22,7 @@ #include #include +#include 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