From ddc6f94e3dd136823a5b6dcec6814dbe33752422 Mon Sep 17 00:00:00 2001 From: Hiroaki Yamamoto Date: Sun, 26 Sep 2010 19:10:09 +0900 Subject: [PATCH] *Implemented server interface. *Fixed settingdialog to disable server tab when server is running. --- client/tcpclient.cxx | 5 +- definition.h | 2 + jasmine.pro.user | 354 ++++++++-------------------------------------- jasmine.pro.user.1.3 | 311 ++++++++++++++++++++++++++++++++++++++++ ui/jasmine_mainwindow.cxx | 59 +++++--- ui/jasmine_mainwindow.h | 17 ++- ui/mainwindow_lang.h | 4 +- ui/settingdialog.cxx | 20 ++- ui/settingdialog.h | 3 +- 9 files changed, 451 insertions(+), 324 deletions(-) create mode 100644 jasmine.pro.user.1.3 diff --git a/client/tcpclient.cxx b/client/tcpclient.cxx index 78acb99..5e1a2d4 100644 --- a/client/tcpclient.cxx +++ b/client/tcpclient.cxx @@ -46,7 +46,7 @@ tcpClient &tcpClient::operator<<(QFile &file){ return (*this); } bool tcpClient::check_byte_written_and_wait_written(){ - if(want_disconnect) return false; + if(this->want_disconnect) return false; if(!this->waitForBytesWritten(this->timeout_time)){ this->setErrorString(tr("The data couldn't be written.")); emit this->error(QAbstractSocket::UnknownSocketError); @@ -56,7 +56,7 @@ bool tcpClient::check_byte_written_and_wait_written(){ } bool tcpClient::check_connection_and_wait_connected(){ - if(want_disconnect) return false; + if(this->want_disconnect) return false; if(this->state()!=QAbstractSocket::ConnectingState||this->state()!=QAbstractSocket::ConnectedState){ this->setErrorString(tr("This socket haven't connected to somewhere yet.")); emit this->error(QAbstractSocket::SocketAccessError); @@ -70,6 +70,7 @@ bool tcpClient::check_connection_and_wait_connected(){ return true; } bool tcpClient::check_and_wait_byte_available(){ + if(this->want_disconnect) return false; if(!this->waitForReadyRead(this->timeout_time)){ this->setErrorString(tr("The data couldn't be read.")); emit this->error(QAbstractSocket::UnknownSocketError); diff --git a/definition.h b/definition.h index 48aa67f..c86bd60 100644 --- a/definition.h +++ b/definition.h @@ -2,7 +2,9 @@ #include #define default_port 10630 + #define default_memberlist qApp->applicationDirPath().append("/memberlist.jsm") #define default_setting qApp->applicationDirPath().append("/setting.jst") #define default_status_interval 3000 +#define default_buffer_size 1024 typedef QPair AddressAndPort; diff --git a/jasmine.pro.user b/jasmine.pro.user index 50e5f3d..3fc79ee 100644 --- a/jasmine.pro.user +++ b/jasmine.pro.user @@ -1,311 +1,79 @@ - RunConfiguration0-BaseEnvironmentBase - 2 - - - RunConfiguration0-CommandLineArguments - - - - RunConfiguration0-ProFile - jasmine.pro - - - RunConfiguration0-RunConfiguration.name - jasmine - - - RunConfiguration0-UseDyldImageSuffix - false - - - RunConfiguration0-UseTerminal - false - - - RunConfiguration0-UserEnvironmentChanges - - - - RunConfiguration0-UserSetName - false - - - RunConfiguration0-UserSetWorkingDirectory - false - - - RunConfiguration0-UserWorkingDirectory - - - - RunConfiguration0-type - Qt4ProjectManager.Qt4RunConfiguration - - - activeRunConfiguration + ProjectExplorer.Project.ActiveTarget 0 - activebuildconfiguration - Release - - - buildConfiguration-Release - - Release - 2 - 0 - - 0 - - - - buildconfiguration-Release-buildstep0 - - Release - - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wgDBvzCe3u,guid=4c56e712291a8f6fcf95c62a0000002e - DESKTOP_SESSION=default - DISPLAY=:0.0 - DM_CONTROL=/var/run/xdmctl - GPG_AGENT_INFO=/tmp/gpg-MCQppK/S.gpg-agent:1871:1 - GS_LIB=/home/hyamamoto/.fonts - GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/hyamamoto/.gtkrc-2.0:/home/hyamamoto/.gtkrc-2.0-kde4:/home/hyamamoto/.kde4/share/config/gtkrc-2.0 - GTK_IM_MODULE=uim - GTK_RC_FILES=/etc/gtk/gtkrc:/home/hyamamoto/.gtkrc::/home/hyamamoto/.kde4/share/config/gtkrc - G_BROKEN_FILENAMES=1 - HISTCONTROL=erasedups - HISTSIZE=1000 - HOME=/home/hyamamoto - INPUTRC=/etc/inputrc - KDE_FULL_SESSION=true - KDE_MULTIHEAD=false - KDE_SESSION_UID=500 - KDE_SESSION_VERSION=4 - LANG=en_US.UTF-8 - LD_LIBRARY_PATH=/usr/lib/qtcreator: - LESS=-R - LOGNAME=hyamamoto - MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins - OOO_FORCE_DESKTOP=gnome - PATH=/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/lib/perl5/core_perl/bin:/opt/qt/bin - PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/qt/lib/pkgconfig - PS3=> - PS4=+ - PWD=/home/hyamamoto/Documents - QTDIR=/usr/share/qt - QT_IM_MODULE=uim - QT_PLUGIN_PATH=/home/hyamamoto/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/ - QT_XFT=true - SESSION_MANAGER=local/localhost:@/tmp/.ICE-unix/1912,unix/localhost:/tmp/.ICE-unix/1912 - SHELL=/bin/bash - SHLVL=1 - SSH_AGENT_PID=1874 - SSH_AUTH_SOCK=/tmp/ssh-SeeMhG1873/agent.1873 - USER=hyamamoto - WINDOWPATH=7 - XCURSOR_THEME=Oxygen_Black - XDG_CACHE_HOME=/home/hyamamoto/.cache - XDG_CONFIG_DIRS=/etc/xdg - XDG_CONFIG_HOME=/home/hyamamoto/.config - XDG_DATA_DIRS=/usr/share:/usr/local/share - XDG_DATA_HOME=/home/hyamamoto/.local/share - XDG_SESSION_COOKIE=1bbef3181df319a5eeb3839a00000393-1283300523.896579-1238674667 - XDM_MANAGED=method=classic - XMODIFIERS=@im=uim - - - /home/hyamamoto/Documents/Workspace/jasmine/jasmine.pro - -spec - linux-g++-64 - -r - - /usr/bin/qmake - false - /home/hyamamoto/Documents/Workspace/jasmine - - - - buildconfiguration-Release-buildstep1 + ProjectExplorer.Project.EditorSettings - Release - - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wgDBvzCe3u,guid=4c56e712291a8f6fcf95c62a0000002e - DESKTOP_SESSION=default - DISPLAY=:0.0 - DM_CONTROL=/var/run/xdmctl - GPG_AGENT_INFO=/tmp/gpg-MCQppK/S.gpg-agent:1871:1 - GS_LIB=/home/hyamamoto/.fonts - GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/hyamamoto/.gtkrc-2.0:/home/hyamamoto/.gtkrc-2.0-kde4:/home/hyamamoto/.kde4/share/config/gtkrc-2.0 - GTK_IM_MODULE=uim - GTK_RC_FILES=/etc/gtk/gtkrc:/home/hyamamoto/.gtkrc::/home/hyamamoto/.kde4/share/config/gtkrc - G_BROKEN_FILENAMES=1 - HISTCONTROL=erasedups - HISTSIZE=1000 - HOME=/home/hyamamoto - INPUTRC=/etc/inputrc - KDE_FULL_SESSION=true - KDE_MULTIHEAD=false - KDE_SESSION_UID=500 - KDE_SESSION_VERSION=4 - LANG=en_US.UTF-8 - LD_LIBRARY_PATH=/usr/lib/qtcreator: - LESS=-R - LOGNAME=hyamamoto - MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins - OOO_FORCE_DESKTOP=gnome - PATH=/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/lib/perl5/core_perl/bin:/opt/qt/bin - PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/qt/lib/pkgconfig - PS3=> - PS4=+ - PWD=/home/hyamamoto/Documents - QTDIR=/usr/share/qt - QT_IM_MODULE=uim - QT_PLUGIN_PATH=/home/hyamamoto/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/ - QT_XFT=true - SESSION_MANAGER=local/localhost:@/tmp/.ICE-unix/1912,unix/localhost:/tmp/.ICE-unix/1912 - SHELL=/bin/bash - SHLVL=1 - SSH_AGENT_PID=1874 - SSH_AUTH_SOCK=/tmp/ssh-SeeMhG1873/agent.1873 - USER=hyamamoto - WINDOWPATH=7 - XCURSOR_THEME=Oxygen_Black - XDG_CACHE_HOME=/home/hyamamoto/.cache - XDG_CONFIG_DIRS=/etc/xdg - XDG_CONFIG_HOME=/home/hyamamoto/.config - XDG_DATA_DIRS=/usr/share:/usr/local/share - XDG_DATA_HOME=/home/hyamamoto/.local/share - XDG_SESSION_COOKIE=1bbef3181df319a5eeb3839a00000393-1283300523.896579-1238674667 - XDM_MANAGED=method=classic - XMODIFIERS=@im=uim - - false - - -w - - /usr/bin/make - true - /home/hyamamoto/Documents/Workspace/jasmine + System - buildconfiguration-Release-cleanstep0 - - Release - - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-j0qHTciaiV,guid=79c313af903c5a3357a12e9a0000001e - DESKTOP_SESSION=default - DISPLAY=:0.0 - DM_CONTROL=/var/run/xdmctl - GPG_AGENT_INFO=/tmp/gpg-WoUHSX/S.gpg-agent:1860:1 - GS_LIB=/home/hyamamoto/.fonts - GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/hyamamoto/.gtkrc-2.0:/home/hyamamoto/.gtkrc-2.0-kde4:/home/hyamamoto/.kde4/share/config/gtkrc-2.0 - GTK_IM_MODULE=uim - GTK_RC_FILES=/etc/gtk/gtkrc:/home/hyamamoto/.gtkrc::/home/hyamamoto/.kde4/share/config/gtkrc - G_BROKEN_FILENAMES=1 - HISTCONTROL=erasedups - HISTSIZE=1000 - HOME=/home/hyamamoto - INPUTRC=/etc/inputrc - KDE_FULL_SESSION=true - KDE_MULTIHEAD=false - KDE_SESSION_UID=500 - KDE_SESSION_VERSION=4 - LANG=en_US.UTF-8 - LD_LIBRARY_PATH=/usr/lib/qtcreator: - LESS=-R - LOGNAME=hyamamoto - MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins - OOO_FORCE_DESKTOP=gnome - PATH=/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/lib/perl5/core_perl/bin:/opt/qt/bin - PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/qt/lib/pkgconfig - PS3=> - PS4=+ - PWD=/home/hyamamoto/Documents - QTDIR=/usr/share/qt - QT_IM_MODULE=uim - QT_PLUGIN_PATH=/home/hyamamoto/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/ - QT_XFT=true - SESSION_MANAGER=local/localhost:@/tmp/.ICE-unix/1904,unix/localhost:/tmp/.ICE-unix/1904 - SHELL=/bin/bash - SHLVL=1 - SSH_AGENT_PID=1865 - SSH_AUTH_SOCK=/tmp/ssh-MOqihy1862/agent.1862 - USER=hyamamoto - WINDOWPATH=7 - XCURSOR_THEME=Oxygen_Black - XDG_CACHE_HOME=/home/hyamamoto/.cache - XDG_CONFIG_DIRS=/etc/xdg - XDG_CONFIG_HOME=/home/hyamamoto/.config - XDG_DATA_DIRS=/usr/share:/usr/local/share - XDG_DATA_HOME=/home/hyamamoto/.local/share - XDG_SESSION_COOKIE=1bbef3181df319a5eeb3839a00000393-1282952255.881690-2042795028 - XDM_MANAGED=method=classic - XMODIFIERS=@im=uim - - true - - clean - -w - - /usr/bin/make - true - /home/hyamamoto/Documents/Workspace/jasmine - true - - clean - - - - - buildconfigurations - - Release - - - - buildstep0 + ProjectExplorer.Project.Target.0 - - + Desktop + Qt4ProjectManager.Target.DesktopTarget + 0 + 0 + + + + QtProjectManager.QMakeBuildStep + + + + + Qt4ProjectManager.MakeStep + false + + + + 2 + + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/hyamamoto/Documents/Workspace/jasmine-build-desktop + 2 + 0 + true + + 1 + + jasmine + Qt4ProjectManager.Qt4RunConfiguration + 2 + + jasmine.pro + false + false + + false + false + + + 1 - buildstep1 - - - - - - buildsteps - - trolltech.qt4projectmanager.qmake - trolltech.qt4projectmanager.make - - - - cleanstep0 - - - true - - - - cleansteps - - trolltech.qt4projectmanager.make - - - - defaultFileEncoding - System + ProjectExplorer.Project.TargetCount + 1 - project - + ProjectExplorer.Project.Updater.FileVersion + 4 diff --git a/jasmine.pro.user.1.3 b/jasmine.pro.user.1.3 new file mode 100644 index 0000000..50e5f3d --- /dev/null +++ b/jasmine.pro.user.1.3 @@ -0,0 +1,311 @@ + + + + RunConfiguration0-BaseEnvironmentBase + 2 + + + RunConfiguration0-CommandLineArguments + + + + RunConfiguration0-ProFile + jasmine.pro + + + RunConfiguration0-RunConfiguration.name + jasmine + + + RunConfiguration0-UseDyldImageSuffix + false + + + RunConfiguration0-UseTerminal + false + + + RunConfiguration0-UserEnvironmentChanges + + + + RunConfiguration0-UserSetName + false + + + RunConfiguration0-UserSetWorkingDirectory + false + + + RunConfiguration0-UserWorkingDirectory + + + + RunConfiguration0-type + Qt4ProjectManager.Qt4RunConfiguration + + + activeRunConfiguration + 0 + + + activebuildconfiguration + Release + + + buildConfiguration-Release + + Release + 2 + 0 + + 0 + + + + buildconfiguration-Release-buildstep0 + + Release + + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wgDBvzCe3u,guid=4c56e712291a8f6fcf95c62a0000002e + DESKTOP_SESSION=default + DISPLAY=:0.0 + DM_CONTROL=/var/run/xdmctl + GPG_AGENT_INFO=/tmp/gpg-MCQppK/S.gpg-agent:1871:1 + GS_LIB=/home/hyamamoto/.fonts + GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/hyamamoto/.gtkrc-2.0:/home/hyamamoto/.gtkrc-2.0-kde4:/home/hyamamoto/.kde4/share/config/gtkrc-2.0 + GTK_IM_MODULE=uim + GTK_RC_FILES=/etc/gtk/gtkrc:/home/hyamamoto/.gtkrc::/home/hyamamoto/.kde4/share/config/gtkrc + G_BROKEN_FILENAMES=1 + HISTCONTROL=erasedups + HISTSIZE=1000 + HOME=/home/hyamamoto + INPUTRC=/etc/inputrc + KDE_FULL_SESSION=true + KDE_MULTIHEAD=false + KDE_SESSION_UID=500 + KDE_SESSION_VERSION=4 + LANG=en_US.UTF-8 + LD_LIBRARY_PATH=/usr/lib/qtcreator: + LESS=-R + LOGNAME=hyamamoto + MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins + OOO_FORCE_DESKTOP=gnome + PATH=/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/lib/perl5/core_perl/bin:/opt/qt/bin + PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/qt/lib/pkgconfig + PS3=> + PS4=+ + PWD=/home/hyamamoto/Documents + QTDIR=/usr/share/qt + QT_IM_MODULE=uim + QT_PLUGIN_PATH=/home/hyamamoto/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/ + QT_XFT=true + SESSION_MANAGER=local/localhost:@/tmp/.ICE-unix/1912,unix/localhost:/tmp/.ICE-unix/1912 + SHELL=/bin/bash + SHLVL=1 + SSH_AGENT_PID=1874 + SSH_AUTH_SOCK=/tmp/ssh-SeeMhG1873/agent.1873 + USER=hyamamoto + WINDOWPATH=7 + XCURSOR_THEME=Oxygen_Black + XDG_CACHE_HOME=/home/hyamamoto/.cache + XDG_CONFIG_DIRS=/etc/xdg + XDG_CONFIG_HOME=/home/hyamamoto/.config + XDG_DATA_DIRS=/usr/share:/usr/local/share + XDG_DATA_HOME=/home/hyamamoto/.local/share + XDG_SESSION_COOKIE=1bbef3181df319a5eeb3839a00000393-1283300523.896579-1238674667 + XDM_MANAGED=method=classic + XMODIFIERS=@im=uim + + + /home/hyamamoto/Documents/Workspace/jasmine/jasmine.pro + -spec + linux-g++-64 + -r + + /usr/bin/qmake + false + /home/hyamamoto/Documents/Workspace/jasmine + + + + buildconfiguration-Release-buildstep1 + + Release + + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wgDBvzCe3u,guid=4c56e712291a8f6fcf95c62a0000002e + DESKTOP_SESSION=default + DISPLAY=:0.0 + DM_CONTROL=/var/run/xdmctl + GPG_AGENT_INFO=/tmp/gpg-MCQppK/S.gpg-agent:1871:1 + GS_LIB=/home/hyamamoto/.fonts + GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/hyamamoto/.gtkrc-2.0:/home/hyamamoto/.gtkrc-2.0-kde4:/home/hyamamoto/.kde4/share/config/gtkrc-2.0 + GTK_IM_MODULE=uim + GTK_RC_FILES=/etc/gtk/gtkrc:/home/hyamamoto/.gtkrc::/home/hyamamoto/.kde4/share/config/gtkrc + G_BROKEN_FILENAMES=1 + HISTCONTROL=erasedups + HISTSIZE=1000 + HOME=/home/hyamamoto + INPUTRC=/etc/inputrc + KDE_FULL_SESSION=true + KDE_MULTIHEAD=false + KDE_SESSION_UID=500 + KDE_SESSION_VERSION=4 + LANG=en_US.UTF-8 + LD_LIBRARY_PATH=/usr/lib/qtcreator: + LESS=-R + LOGNAME=hyamamoto + MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins + OOO_FORCE_DESKTOP=gnome + PATH=/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/lib/perl5/core_perl/bin:/opt/qt/bin + PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/qt/lib/pkgconfig + PS3=> + PS4=+ + PWD=/home/hyamamoto/Documents + QTDIR=/usr/share/qt + QT_IM_MODULE=uim + QT_PLUGIN_PATH=/home/hyamamoto/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/ + QT_XFT=true + SESSION_MANAGER=local/localhost:@/tmp/.ICE-unix/1912,unix/localhost:/tmp/.ICE-unix/1912 + SHELL=/bin/bash + SHLVL=1 + SSH_AGENT_PID=1874 + SSH_AUTH_SOCK=/tmp/ssh-SeeMhG1873/agent.1873 + USER=hyamamoto + WINDOWPATH=7 + XCURSOR_THEME=Oxygen_Black + XDG_CACHE_HOME=/home/hyamamoto/.cache + XDG_CONFIG_DIRS=/etc/xdg + XDG_CONFIG_HOME=/home/hyamamoto/.config + XDG_DATA_DIRS=/usr/share:/usr/local/share + XDG_DATA_HOME=/home/hyamamoto/.local/share + XDG_SESSION_COOKIE=1bbef3181df319a5eeb3839a00000393-1283300523.896579-1238674667 + XDM_MANAGED=method=classic + XMODIFIERS=@im=uim + + false + + -w + + /usr/bin/make + true + /home/hyamamoto/Documents/Workspace/jasmine + + + + buildconfiguration-Release-cleanstep0 + + Release + + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-j0qHTciaiV,guid=79c313af903c5a3357a12e9a0000001e + DESKTOP_SESSION=default + DISPLAY=:0.0 + DM_CONTROL=/var/run/xdmctl + GPG_AGENT_INFO=/tmp/gpg-WoUHSX/S.gpg-agent:1860:1 + GS_LIB=/home/hyamamoto/.fonts + GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/hyamamoto/.gtkrc-2.0:/home/hyamamoto/.gtkrc-2.0-kde4:/home/hyamamoto/.kde4/share/config/gtkrc-2.0 + GTK_IM_MODULE=uim + GTK_RC_FILES=/etc/gtk/gtkrc:/home/hyamamoto/.gtkrc::/home/hyamamoto/.kde4/share/config/gtkrc + G_BROKEN_FILENAMES=1 + HISTCONTROL=erasedups + HISTSIZE=1000 + HOME=/home/hyamamoto + INPUTRC=/etc/inputrc + KDE_FULL_SESSION=true + KDE_MULTIHEAD=false + KDE_SESSION_UID=500 + KDE_SESSION_VERSION=4 + LANG=en_US.UTF-8 + LD_LIBRARY_PATH=/usr/lib/qtcreator: + LESS=-R + LOGNAME=hyamamoto + MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins + OOO_FORCE_DESKTOP=gnome + PATH=/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/lib/perl5/core_perl/bin:/opt/qt/bin + PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/qt/lib/pkgconfig + PS3=> + PS4=+ + PWD=/home/hyamamoto/Documents + QTDIR=/usr/share/qt + QT_IM_MODULE=uim + QT_PLUGIN_PATH=/home/hyamamoto/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/ + QT_XFT=true + SESSION_MANAGER=local/localhost:@/tmp/.ICE-unix/1904,unix/localhost:/tmp/.ICE-unix/1904 + SHELL=/bin/bash + SHLVL=1 + SSH_AGENT_PID=1865 + SSH_AUTH_SOCK=/tmp/ssh-MOqihy1862/agent.1862 + USER=hyamamoto + WINDOWPATH=7 + XCURSOR_THEME=Oxygen_Black + XDG_CACHE_HOME=/home/hyamamoto/.cache + XDG_CONFIG_DIRS=/etc/xdg + XDG_CONFIG_HOME=/home/hyamamoto/.config + XDG_DATA_DIRS=/usr/share:/usr/local/share + XDG_DATA_HOME=/home/hyamamoto/.local/share + XDG_SESSION_COOKIE=1bbef3181df319a5eeb3839a00000393-1282952255.881690-2042795028 + XDM_MANAGED=method=classic + XMODIFIERS=@im=uim + + true + + clean + -w + + /usr/bin/make + true + /home/hyamamoto/Documents/Workspace/jasmine + true + + clean + + + + + buildconfigurations + + Release + + + + buildstep0 + + + + + + + buildstep1 + + + + + + buildsteps + + trolltech.qt4projectmanager.qmake + trolltech.qt4projectmanager.make + + + + cleanstep0 + + + true + + + + cleansteps + + trolltech.qt4projectmanager.make + + + + defaultFileEncoding + System + + + project + + + diff --git a/ui/jasmine_mainwindow.cxx b/ui/jasmine_mainwindow.cxx index d4248bf..0e790fe 100644 --- a/ui/jasmine_mainwindow.cxx +++ b/ui/jasmine_mainwindow.cxx @@ -11,19 +11,19 @@ #include using namespace structures; +using namespace network; mainWindow::mainWindow(){ setupUi(this); - //I'll reimpletemt the format of this memberlist file... - connect(this->sendFileButton,SIGNAL(clicked()),SLOT(on_sendFileAction_triggered())); - memberFilters<settingdialog=new SettingDialog(this); - this->memberList=new MemberList(this); + + this->settingdialog = new SettingDialog(this); + this->memberList = new MemberList(this); + this->sendTextEditor = new RtfEditor(this); + this->memberListPanel->addWidget(memberList); - this->sendTextEditor=new RtfEditor(this); this->sendPanel->insertWidget(0,this->sendTextEditor,this->receivePanel->stretch(0)); this->sendTextEditor->setFocus(); + QWidget::setTabOrder(this->sendTextEditor,this->sendButton); QWidget::setTabOrder(this->sendButton,this->sendFileButton); QWidget::setTabOrder(this->sendFileButton,this->addButton); @@ -31,11 +31,18 @@ mainWindow::mainWindow(){ QWidget::setTabOrder(this->removeButton,this->editButton); QWidget::setTabOrder(this->editButton,this->receiveText); - //These behaviors are not implemented. + //I'll reimpletemt the format of this memberlist file... + connect(this->sendFileButton,SIGNAL(clicked()),SLOT(on_sendFileAction_triggered())); + memberFilters<sendButton->setEnabled(false); this->sendFileButton->setEnabled(false); this->sendFileAction->setEnabled(false); - this->runServerAction->setEnabled(false); + this->runServerAction->setEnabled(false);*/ + + this->mainServer=new tcpServer(default_buffer_size,this); connect(this->receiveText,SIGNAL(anchorClicked(const QUrl &)),SLOT(linkClicked(const QUrl &))); connect(this->receiveText,SIGNAL(highlighted(const QUrl &)),SLOT(selectedLink(const QUrl &))); @@ -50,7 +57,7 @@ void mainWindow::closeEvent(QCloseEvent *event){ } void mainWindow::showEvent(QShowEvent *event){ if(rev==0) - this->status->showMessage("Don't forget almost all features are not implemented!"); + this->status->showMessage("Don't forget almost all features are not implemented!",default_status_interval); event->accept(); } int mainWindow::isInMember(const AddressAndPort &peer){ @@ -69,19 +76,33 @@ void mainWindow::on_sendFileAction_triggered(){ } void mainWindow::on_runServerAction_triggered(bool checked){ - //TODO:TcpServer - Q_UNUSED(checked) + if(checked){ + if(this->mainServer->isListening()) this->mainServer->close(); + if(this->mainServer->listen(this->setting.bindingAddr(),this->setting.port())){ + this->status->showMessage(server_running.arg(this->mainServer->serverAddress().toString()).arg(this->mainServer->serverPort()),default_status_interval); + this->serverSettingAction->setEnabled(false); + } + else this->mainServer->close(); + }else{ + if(!this->mainServer->isListening()) return; + this->mainServer->close(); + this->status->showMessage(server_stopped,default_status_interval); + this->serverSettingAction->setEnabled(true); + } } void mainWindow::settingDialog_accepted(){ - if(!this->settingdialog->IPAddress().isNull()) - this->setting.setIPAddr(this->settingdialog->IPAddress()); - else - QMessageBox::warning(this,invalid_IP_title,invalid_IP_body); - this->setting.setPort(this->settingdialog->port()); + if(!this->mainServer->isListening()){ + if(!this->settingdialog->IPAddress().isNull()) + this->setting.setIPAddr(this->settingdialog->IPAddress()); + else + QMessageBox::warning(this,invalid_IP_title,invalid_IP_body); + this->setting.setPort(this->settingdialog->port()); + } this->setting.setName(this->settingdialog->nickName()); this->setting.setNoloadMemberList(this->settingdialog->noloadMemberlist()); } void mainWindow::configAndShowSettingDialog(const SettingDialog::tab tab){ + this->settingdialog->setTabEnabled(SettingDialog::server,!this->mainServer->isListening()); this->settingdialog->setAddressAndPort(AddressAndPort(this->setting.bindingAddr(),this->setting.port())); this->settingdialog->setNickName(this->setting.name()); this->settingdialog->setNoloadMemberlist(this->setting.noloadMemberList()); @@ -207,8 +228,8 @@ void mainWindow::openConfig(const QString &file){ } void mainWindow::openMember(const QString &file){ /* - It is doubtful that QFileDialog has a bug: - If you select file by double clicking, fileSelected signal is emitted twice. + Does QFileDialog have a bug?? + If you select file by double clicking, fileSelected signal will be emitted twice. */ if(this->sender()!=NULL&&this->sender()==this->beforesender) return; this->beforesender=this->sender(); diff --git a/ui/jasmine_mainwindow.h b/ui/jasmine_mainwindow.h index 4d3ef46..a1aa824 100644 --- a/ui/jasmine_mainwindow.h +++ b/ui/jasmine_mainwindow.h @@ -5,8 +5,10 @@ #include "rtfeditor.h" #include "../settings.h" #include "../validator/ipaddressvalidator.h" +#include "../server/tcpserver.h" using namespace structures; +using namespace network; class mainWindow:public QMainWindow,private Ui::MainWindow{ Q_OBJECT @@ -51,14 +53,17 @@ protected: void closeEvent(QCloseEvent *); void showEvent(QShowEvent *); private: - QObject *beforesender; - MemberList *memberList; - RtfEditor *sendTextEditor; + QObject *beforesender; + QStringList memberFilters,logFilters; + + MemberList *memberList; + RtfEditor *sendTextEditor; + tcpServer *mainServer; + SettingDialog *settingdialog; + settings setting; + int isInMember(const AddressAndPort &); void configAndShowSettingDialog(const SettingDialog::tab); - SettingDialog *settingdialog; - QStringList memberFilters,logFilters; - settings setting; public: settings app_setting() const; }; diff --git a/ui/mainwindow_lang.h b/ui/mainwindow_lang.h index a5959e8..5d3dd27 100644 --- a/ui/mainwindow_lang.h +++ b/ui/mainwindow_lang.h @@ -37,4 +37,6 @@ QString save_prefix(QObject::tr("Save %1")), loadingSettingSucceeded_title(QObject::tr("Loading succeeded")), loadingSettingSucceeded_body(QObject::tr("Loading settings: %1 has been succeeded.")), - invalid_link(QObject::tr("Input link is not valid: %1")); + invalid_link(QObject::tr("Input link is not valid: %1")), + server_running(QObject::tr("Server is running now. (%1:%2)")), + server_stopped(QObject::tr("Server has been stopped.")); diff --git a/ui/settingdialog.cxx b/ui/settingdialog.cxx index a5b071b..62b1c6f 100644 --- a/ui/settingdialog.cxx +++ b/ui/settingdialog.cxx @@ -19,8 +19,8 @@ void SettingDialog::setPort(const quint16 port){this->port_control->setValue(por void SettingDialog::setNickName(const QString &name){this->nickName_control->setText(name);} void SettingDialog::setIPAddress(const QHostAddress &address){this->address->setText(address.toString());} void SettingDialog::setNoloadMemberlist(const bool yesno){this->no_load_memberlist->setChecked(yesno);} -void SettingDialog::setTab(tab t){ - switch(t){ +void SettingDialog::setTab(const tab id){ + switch(id){ case SettingDialog::server: server: this->settingTab->setCurrentIndex(0); @@ -35,6 +35,22 @@ void SettingDialog::setTab(tab t){ goto server; } } +void SettingDialog::setTabEnabled(const tab id,bool enable){ + switch(id){ + case SettingDialog::server: + server: + this->settingTab->setTabEnabled(0,enable); + break; + case SettingDialog::client: + this->settingTab->setTabEnabled(1,enable); + break; + case SettingDialog::misc: + this->settingTab->setTabEnabled(2,enable); + break; + default: + goto server; + } +} void SettingDialog::setAddressAndPort(AddressAndPort pair){ this->setIPAddress(pair.first); diff --git a/ui/settingdialog.h b/ui/settingdialog.h index 5a64bf4..dbec1c0 100644 --- a/ui/settingdialog.h +++ b/ui/settingdialog.h @@ -7,7 +7,6 @@ class SettingDialog:virtual public QDialog,virtual private Ui::settingDialogBase Q_OBJECT public: enum tab{server,client,misc}; - void setTab(tab t); SettingDialog(QWidget *parent=NULL); QHostAddress IPAddress()const; quint16 port()const; @@ -20,4 +19,6 @@ public slots: void setIPAddress(const QHostAddress &address); void setNickName(const QString &); void setNoloadMemberlist(const bool); + void setTab(const tab id); + void setTabEnabled(const tab id,bool enable); }; -- 2.11.0