From 466354c39d51b1aa839bcb1e4ac3bcd6da1a7683 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Thu, 24 Jul 2008 06:14:41 +0000 Subject: [PATCH] initial chat dialog work, no actual functionality added yet --- linux/Makefile.am | 13 ++++- src/chatdlg.cpp | 36 ++++++++++++++ src/chatdlg.h | 46 ++++++++++++++++++ src/chatdlgbase.ui | 110 +++++++++++++++++++++++++++++++++++++++++++ src/protocol.cpp | 54 +++++++++++++++++++++ src/protocol.h | 4 ++ windows/MocQT.bat | 10 ++-- windows/llcon.vcproj | 8 ++++ 8 files changed, 276 insertions(+), 5 deletions(-) create mode 100755 src/chatdlg.cpp create mode 100755 src/chatdlg.h create mode 100755 src/chatdlgbase.ui diff --git a/linux/Makefile.am b/linux/Makefile.am index 1a5457a7..06f551e2 100755 --- a/linux/Makefile.am +++ b/linux/Makefile.am @@ -10,8 +10,9 @@ llcon_SOURCES = ../src/buffer.cpp \ ../src/util.cpp \ ../src/llconclientdlg.cpp \ ../src/clientsettingsdlg.cpp \ - ../src/client.cpp \ ../src/llconserverdlg.cpp \ + ../src/chatdlg.cpp \ + ../src/client.cpp \ ../src/server.cpp \ ../src/settings.cpp \ ../src/protocol.cpp \ @@ -33,11 +34,13 @@ llcon_SOURCES = ../src/buffer.cpp \ ../src/multicolorled.h \ ../src/audiomixerboard.h \ ../src/llconserverdlg.h \ + ../src/chatdlg.h \ ../src/llconclientdlg.h \ ../src/clientsettingsdlg.h \ ../src/llconclientdlgbase.ui \ ../src/llconserverdlgbase.ui \ ../src/clientsettingsdlgbase.ui \ + ../src/chatdlgbase.ui \ ../src/aboutdlgbase.ui \ sound.h \ ../src/resources.qrc \ @@ -60,6 +63,8 @@ BUILT_SOURCES=moc/moc_server.cpp \ moc/clientsettingsdlgbase.h \ moc/moc_llconserverdlg.cpp \ moc/llconserverdlgbase.h \ + moc/moc_chatdlg.cpp \ + moc/chatdlgbase.h \ moc/aboutdlgbase.h \ moc/resources.cpp @@ -105,6 +110,9 @@ moc/moc_clientsettingsdlg.cpp: ../src/clientsettingsdlg.h moc/moc_llconserverdlg.cpp: ../src/llconserverdlg.h $(QT_MOC) ../src/llconserverdlg.h -o moc/moc_llconserverdlg.cpp +moc/moc_chatdlg.cpp: ../src/chatdlg.h + $(QT_MOC) ../src/chatdlg.h -o moc/moc_chatdlg.cpp + moc/aboutdlgbase.h: ../src/aboutdlgbase.ui $(QT_UIC) ../src/aboutdlgbase.ui -o moc/aboutdlgbase.h @@ -118,6 +126,9 @@ moc/clientsettingsdlgbase.h: ../src/clientsettingsdlgbase.ui moc/llconserverdlgbase.h: ../src/llconserverdlgbase.ui $(QT_UIC) ../src/llconserverdlgbase.ui -o moc/llconserverdlgbase.h +moc/chatdlgbase.h: ../src/chatdlgbase.ui + $(QT_UIC) ../src/chatdlgbase.ui -o moc/chatdlgbase.h + moc/resources.cpp: ../src/resources.qrc $(QT_RCC) ../src/resources.qrc -o moc/resources.cpp diff --git a/src/chatdlg.cpp b/src/chatdlg.cpp new file mode 100755 index 00000000..e6cf5796 --- /dev/null +++ b/src/chatdlg.cpp @@ -0,0 +1,36 @@ +/******************************************************************************\ + * Copyright (c) 2004-2008 + * + * Author(s): + * Volker Fischer + * + ****************************************************************************** + * + * 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 "chatdlg.h" + + +/* Implementation *************************************************************/ +CChatDlg::CChatDlg ( QWidget* parent, Qt::WindowFlags f ) +{ + setupUi ( this ); + + + // Connections ------------------------------------------------------------- + +} diff --git a/src/chatdlg.h b/src/chatdlg.h new file mode 100755 index 00000000..a2bee451 --- /dev/null +++ b/src/chatdlg.h @@ -0,0 +1,46 @@ +/******************************************************************************\ + * Copyright (c) 2004-2008 + * + * Author(s): + * Volker Fischer + * + ****************************************************************************** + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +\******************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "global.h" +#ifdef _WIN32 +# include "../windows/moc/chatdlgbase.h" +#else +# include "moc/chatdlgbase.h" +#endif + + +/* Classes ********************************************************************/ +class CChatDlg : public QDialog, private Ui_CChatDlgBase +{ + Q_OBJECT + +public: + CChatDlg ( QWidget* parent = 0, Qt::WindowFlags f = 0 ); +}; diff --git a/src/chatdlgbase.ui b/src/chatdlgbase.ui new file mode 100755 index 00000000..0b9c0d61 --- /dev/null +++ b/src/chatdlgbase.ui @@ -0,0 +1,110 @@ + + CChatDlgBase + + + + 0 + 0 + 535 + 397 + + + + + 0 + 0 + + + + Chat + + + :/new/prefix1/mainicon.png + + + true + + + + + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + &Close + + + false + + + false + + + + + + + + + TextViewChatWindow + lineEditLocalInputText + buttonClose + + + + + + + buttonClose + clicked() + CChatDlgBase + accept() + + + 20 + 20 + + + 20 + 20 + + + + + diff --git a/src/protocol.cpp b/src/protocol.cpp index 80a2508d..ef22948d 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -92,6 +92,11 @@ MESSAGES +------------------+----------------------+ +- Chat text PROTMESSID_CHAT_TEXT + + +------------------+----------------------+ + | 2 bytes number n | n bytes UTF-8 string | + +------------------+----------------------+ * @@ -360,6 +365,11 @@ for ( int i = 0; i < iNumBytes; i++ ) { EvaluateChanNameMes ( iPos, vecData ); break; + + case PROTMESSID_CHAT_TEXT: + + EvaluateChatTextMes ( iPos, vecData ); + break; } // send acknowledge message @@ -593,6 +603,31 @@ void CProtocol::CreateChanNameMes ( const QString strName ) CreateAndSendMessage ( PROTMESSID_CHANNEL_NAME, vecData ); } +void CProtocol::CreateChatTextMes ( const QString strName ) +{ + unsigned int iPos = 0; // init position pointer + const int iStrLen = strName.size(); // get string size + + // size of current list entry + const int iEntrLen = 2 /* str. size */ + iStrLen; + + // build data vector + CVector vecData ( iEntrLen ); + + // number of bytes for name string (2 bytes) + PutValOnStream ( vecData, iPos, static_cast ( iStrLen ), 2 ); + + // name string (n bytes) + for ( int j = 0; j < iStrLen; j++ ) + { + // byte-by-byte copying of the string data + PutValOnStream ( vecData, iPos, + static_cast ( strName[j].toAscii() ), 1 ); + } + + CreateAndSendMessage ( PROTMESSID_CHAT_TEXT, vecData ); +} + void CProtocol::EvaluateChanNameMes ( unsigned int iPos, const CVector& vecData ) { // number of bytes for name string (2 bytes) @@ -612,6 +647,25 @@ void CProtocol::EvaluateChanNameMes ( unsigned int iPos, const CVector& emit ChangeChanName ( strName ); } +void CProtocol::EvaluateChatTextMes ( unsigned int iPos, const CVector& vecData ) +{ + // number of bytes for name string (2 bytes) + const int iStrLen = + static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); + + // name string (n bytes) + QString strName = ""; + for ( int j = 0; j < iStrLen; j++ ) + { + // byte-by-byte copying of the string data + int iData = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + strName += QString ( (char*) &iData ); + } + + // invoke message action + emit ChatTextReceived ( strName ); +} + /******************************************************************************\ * Message generation (parsing) * diff --git a/src/protocol.h b/src/protocol.h index b194a807..4a004e01 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -46,6 +46,7 @@ #define PROTMESSID_SERVER_FULL 16 // server full message #define PROTMESSID_REQ_CONN_CLIENTS_LIST 17 // request connected client list #define PROTMESSID_CHANNEL_NAME 18 // set channel name for fader tag +#define PROTMESSID_CHAT_TEXT 19 // contains a chat text // lengths of message as defined in protocol.cpp file #define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2) @@ -70,6 +71,7 @@ public: void CreateNetwBlSiFactMes ( const int iNetwBlSiFact ); void CreateChanGainMes ( const int iChanID, const double dGain ); void CreateChanNameMes ( const QString strName ); + void CreateChatTextMes ( const QString strName ); void CreateConClientListMes ( const CVector& vecChanInfo ); @@ -138,6 +140,7 @@ protected: void EvaluateNetwBlSiFactMes ( unsigned int iPos, const CVector& vecData ); void EvaluateChanGainMes ( unsigned int iPos, const CVector& vecData ); void EvaluateChanNameMes ( unsigned int iPos, const CVector& vecData ); + void EvaluateChatTextMes ( unsigned int iPos, const CVector& vecData ); void EvaluateConClientListMes ( unsigned int iPos, const CVector& vecData ); int iOldRecID, iOldRecCnt; @@ -161,6 +164,7 @@ signals: void ChangeNetwBlSiFact ( int iNewNetwBlSiFact ); void ChangeChanGain ( int iChanID, double dNewGain ); void ChangeChanName ( QString strName ); + void ChatTextReceived ( QString strName ); void ConClientListMesReceived ( CVector vecChanInfo ); void ReqJittBufSize(); void ReqConnClientsList(); diff --git a/windows/MocQT.bat b/windows/MocQT.bat index 4b696062..2426870e 100755 --- a/windows/MocQT.bat +++ b/windows/MocQT.bat @@ -32,6 +32,7 @@ rem .h -------------- %qtdir%\bin\moc.exe ..\src\llconclientdlg.h -o moc\moc_llconclientdlg.cpp %qtdir%\bin\moc.exe ..\src\clientsettingsdlg.h -o moc\moc_clientsettingsdlg.cpp %qtdir%\bin\moc.exe ..\src\llconserverdlg.h -o moc\moc_llconserverdlg.cpp +%qtdir%\bin\moc.exe ..\src\chatdlg.h -o moc\moc_chatdlg.cpp %qtdir%\bin\moc.exe ..\src\server.h -o moc\moc_server.cpp %qtdir%\bin\moc.exe ..\src\client.h -o moc\moc_client.cpp %qtdir%\bin\moc.exe ..\src\socket.h -o moc\moc_socket.cpp @@ -40,10 +41,11 @@ rem .h -------------- rem .ui ------------- -%qtdir%\bin\uic.exe ..\src\aboutdlgbase.ui -o moc\aboutdlgbase.h -%qtdir%\bin\uic.exe ..\src\llconclientdlgbase.ui -o moc\llconclientdlgbase.h -%qtdir%\bin\uic.exe ..\src\clientsettingsdlgbase.ui -o moc\clientsettingsdlgbase.h -%qtdir%\bin\uic.exe ..\src\llconserverdlgbase.ui -o moc\llconserverdlgbase.h +%qtdir%\bin\uic.exe ..\src\aboutdlgbase.ui -o moc\aboutdlgbase.h +%qtdir%\bin\uic.exe ..\src\llconclientdlgbase.ui -o moc\llconclientdlgbase.h +%qtdir%\bin\uic.exe ..\src\clientsettingsdlgbase.ui -o moc\clientsettingsdlgbase.h +%qtdir%\bin\uic.exe ..\src\llconserverdlgbase.ui -o moc\llconserverdlgbase.h +%qtdir%\bin\uic.exe ..\src\chatdlgbase.ui -o moc\chatdlgbase.h rem .qrc ------------ %qtdir%\bin\rcc.exe ..\src\resources.qrc -o moc\resources.cpp diff --git a/windows/llcon.vcproj b/windows/llcon.vcproj index 8a5a98b1..220328d9 100755 --- a/windows/llcon.vcproj +++ b/windows/llcon.vcproj @@ -636,6 +636,10 @@ /> + + @@ -930,6 +934,10 @@ RelativePath="..\src\channel.h" > + +