diff --git a/core/servertcpqueries.cpp b/core/servertcpqueries.cpp index d5222b0..62bf8d0 100644 --- a/core/servertcpqueries.cpp +++ b/core/servertcpqueries.cpp @@ -5,9 +5,12 @@ ServerTcpQueries::ServerTcpQueries(int _port, QHostAddress serverAddress, QObjec mServerAddress = serverAddress; mPortNumber = _port; mMillisWait = 2000; - } - +/** + * Connects to the server, waits mMillisWait + * for the connection to be successful + * @return true on success + */ bool ServerTcpQueries::connect() { this->connectToHost(mServerAddress, mPortNumber); @@ -18,6 +21,11 @@ bool ServerTcpQueries::connect() } return true; } +/** + * Disconnects from the server, waits mMillisWait + * for the disconnect to be successful + * @return true on success + */ bool ServerTcpQueries::disconnect() { this->disconnectFromHost(); @@ -27,6 +35,11 @@ bool ServerTcpQueries::disconnect() qDebug() << "TcpSocketError: " << this->errorString() << Q_FUNC_INFO; return false; } +/** + * Parse the QByteArray and splits the data into QString + * @param arr QByteArray response from the server + * @return QVariantList containing all the QStrings + */ QVariantList ServerTcpQueries::parseData(QByteArray arr) const { QVariantList vec; @@ -43,303 +56,55 @@ QVariantList ServerTcpQueries::parseData(QByteArray arr) const } return vec; } -//bool SessionHandler::joinSession(QString _roomId, QString _roomPassword) -//q.prepare("SELECT r.id, r.password, u.username FROM room AS r, user AS u WHERE r.host = u.id AND r.id = :roomId AND r.password = :roomPassword"); -QVariantList ServerTcpQueries::querySelectFrom_room1(QString _roomId, QString _roomPassword) -{ - QVariantList returnList; - int code = 0; - QByteArray data; - //Array should be [code,pw size,pw,room size,room] - data.prepend(_roomPassword.toLocal8Bit().data()); - data.prepend(_roomPassword.size()); - data.prepend(_roomId.toLocal8Bit().data()); - data.prepend(_roomId.size()); - data.prepend(int(2)); - data.prepend(code); - if(connect()) - { - qDebug() << "tcp sql 0 writing data; " << data; - this->write(data); - if(this->waitForReadyRead(mMillisWait)) - { - QByteArray response = this->readAll(); - qDebug() << "tcp sql 0 reading data; " << response; - returnList = parseData(response); - } - else - { - returnList.append(-1); - } - } - else - { - returnList.append(-1); - } - disconnect(); - //qDebug() << returnList; - //returns [roomId,roomPassword,username] - return returnList; -} -//void SessionHandler::addUser() -// q.prepare("INSERT INTO roomSession (roomId, userId) VALUES (:roomId, :userId)"); -int ServerTcpQueries::queryInsertInto_roomSession(QString _roomId, QString _userId) -{ - int numberOfRowsAffected = -1; - int code = 1; - QByteArray data; - //Array should be [code,user size,user,room size,room] - data.prepend(_userId.toLocal8Bit().data()); - data.prepend(_userId.size()); - data.prepend(_roomId.toLocal8Bit().data()); - data.prepend(_roomId.size()); - data.prepend(int(2)); - data.prepend(code); - if(connect()) - { - qDebug() << "tcp sql 1 writing data; " << data; - this->write(data); - if(this->waitForReadyRead(mMillisWait)) - { - QByteArray response = this->readAll(); - qDebug() << "tcp sql 1 reading data; " << response; - numberOfRowsAffected = response[0]; - } - } - disconnect(); - return numberOfRowsAffected; -} -//bool SessionHandler::createSession(QString roomId, QString roomPassword) -//q.prepare("INSERT INTO room (id, host, password) VALUES (:id, :host, :password)"); -int ServerTcpQueries::queryInsertInto_room(QString _roomId, QString _host, QString _roomPassword) +int ServerTcpQueries::CUDQuery(int code, QVariantList vars) { int numberOfRowsAffected = -1; - int code = 2; QByteArray data; - data.prepend(_roomPassword.toLocal8Bit().data()); - data.prepend(_roomPassword.size()); - data.prepend(_host.toLocal8Bit().data()); - data.prepend(_host.size()); - data.prepend(_roomId.toLocal8Bit().data()); - data.prepend(_roomId.size()); - data.prepend(int(3)); - data.prepend(code); - if(connect()) + for(int i = 0; i < vars.size(); i++) { - qDebug() << "tcp sql 2 writing data; " << data; - this->write(data); - if(this->waitForReadyRead(mMillisWait)) - { - QByteArray response = this->readAll(); - qDebug() << "tcp sql 2 reading data; " << response; - numberOfRowsAffected = response[0]; - } + data.prepend(vars[i].toString().toLocal8Bit().data()); + data.prepend(vars[i].toString().size()); } - disconnect(); - return numberOfRowsAffected; -} -//bool SessionHandler::addGuestUserToDatabase() -//q.prepare("INSERT INTO user (streamId, username, password, isGuest) VALUES (substring(MD5(RAND()),1,16), :username, substring(MD5(RAND()),1,16), TRUE)"); -int ServerTcpQueries::queryInsertInto_user(QString _username) -{ - int numberOfRowsAffected = -1; - int code = 3; - QByteArray data; - data.prepend(_username.toLocal8Bit().data()); - data.prepend(_username.size()); - data.prepend(int(1)); + data.prepend(vars.size()); data.prepend(code); if(connect()) { - qDebug() << "tcp sql 3 writing data; " << data; + qDebug() <<"SQL TCP Query(" << code << ")" << " Sending data: " << data; this->write(data); if(this->waitForReadyRead(mMillisWait)) { QByteArray response = this->readAll(); - qDebug() << "tcp sql 3 reading data; " << response; numberOfRowsAffected = response[0]; } } disconnect(); return numberOfRowsAffected; } -//bool UserHandler::login(QString username, QString password) -// q.prepare("SELECT id, password FROM user WHERE username = :username"); -QVariantList ServerTcpQueries::querySelectFrom_user1(QString _username) -{ - QVariantList returnList; - int code = 4; - QByteArray data; - data.prepend(_username.toLocal8Bit().data()); - data.prepend(_username.size()); - data.prepend(int(1)); - data.prepend(code); - if(connect()) - { - qDebug() << "tcp sql 4 writing data; " << data; - this->write(data); - if(this->waitForReadyRead(mMillisWait)) - { - QByteArray response = this->readAll(); - qDebug() << "tcp sql 4 reading data; " << response; - returnList = parseData(response); - } - else - { - returnList.prepend(-1); - } - } - //Vet ikke om vi vil havne her noen gang? - else - { - - returnList.prepend(-1); - } - disconnect(); - //returns [id,password] - qDebug() << returnList; - return returnList; -} -//bool UserHandler::fillUser(int userId) -//q.prepare("SELECT streamId, username, password, timeCreated FROM user WHERE id = :userId"); -QVariantList ServerTcpQueries::querySelectFrom_user2(QString _userId) +QVariantList ServerTcpQueries::RQuery(int code, QVariantList vars) { QVariantList returnList; - int code = 5; QByteArray data; - data.prepend(_userId.toLocal8Bit().data()); - data.prepend(_userId.size()); - data.prepend(int(1)); - data.prepend(code); - if(connect()) + for(int i = 0; i < vars.size(); i++) { - qDebug() << "tcp sql 5 writing data; " << data; - this->write(data); - if(this->waitForReadyRead(mMillisWait)) - { - QByteArray response = this->readAll(); - qDebug() << "tcp sql 5 reading data; " << response; - returnList = parseData(response); - } - - } - disconnect(); - return returnList; -} -//bool UserHandler::getPersonalRoom() -//q.prepare("SELECT id, password FROM room WHERE host = :userId"); -QVariantList ServerTcpQueries::querySelectFrom_room2(QString _userId) -{ - QVariantList returnList; - int code = 6; - QByteArray data; - data.prepend(_userId.toLocal8Bit().data()); - data.prepend(_userId.size()); - data.prepend(int(1)); - data.prepend(code); - if(connect()) - { - qDebug() << "tcp sql 6 writing data; " << data; - this->write(data); - if(this->waitForReadyRead(mMillisWait)) - { - QByteArray response = this->readAll(); - if(response.size()>1) - { - qDebug() << "tcp sql 6 reading data; " << response; - returnList = parseData(response); - } - } + data.prepend(vars[i].toString().toLocal8Bit().data()); + data.prepend(vars[i].toString().size()); } - disconnect(); - return returnList; -} - -//bool UserHandler::updatePersonalRoom(QString roomId, QString roomPassword) -//q.prepare("UPDATE room SET id = :roomId, password = :roomPassword WHERE host = :host"); -int ServerTcpQueries::queryUpdate_room(QString roomId, QString roomPassword, QString _host) -{ - int numberOfRowsAffected = -1; - int code = 7; - QByteArray data; - data.prepend(_host.toLocal8Bit().data()); - data.prepend(_host.size()); - data.prepend(roomPassword.toLocal8Bit().data()); - data.prepend(roomPassword.size()); - data.prepend(roomId.toLocal8Bit().data()); - data.prepend(roomId.size()); - data.prepend(int(3)); + data.prepend(vars.size()); data.prepend(code); if(connect()) { - qDebug() << "tcp sql 7 writing data; " << data; + qDebug() <<"SQL TCP Query(" << code << ")" << " Sending data: " << data; this->write(data); if(this->waitForReadyRead(mMillisWait)) { QByteArray response = this->readAll(); - qDebug() << "tcp sql 7 reading data; " << response; - numberOfRowsAffected = response[0]; - } - } - disconnect(); - return numberOfRowsAffected; -} - - -//QString UserHandler::getGuestStreamId() -//q.prepare("SELECT streamId FROM user WHERE id = :id"); -QString ServerTcpQueries::querySelectFrom_user3(QString _userId) -{ - QVariantList returnList; - int code = 8; - QByteArray data; - data.prepend(_userId.toLocal8Bit().data()); - data.prepend(_userId.size()); - data.prepend(int(1)); - data.prepend(code); - if(connect()) - { - qDebug() << "tcp sql 8 writing data; " << data; - this->write(data); - if(this->waitForReadyRead(mMillisWait)) - { - QByteArray response = this->readAll(); - qDebug() << "tcp sql 8 reading data; " << response; returnList = parseData(response); } - } disconnect(); - return returnList[0].toString(); -} - -//int UserHandler::getGuestId() -//q.prepare("SELECT id FROM user WHERE username = :username"); -int ServerTcpQueries::querySelectFrom_user4(QString _username) -{ - QVariantList returnList; - int code = 9; - QByteArray data; - data.prepend(_username.toLocal8Bit().data()); - data.prepend(_username.size()); - data.prepend(int(1)); - data.prepend(code); - if(connect()) - { - qDebug() << "tcp sql 9 writing data; " << data; - this->write(data); - if(this->waitForReadyRead(mMillisWait)) - { - QByteArray response = this->readAll(); - qDebug() << "tcp sql 9 reading data; " << response; - returnList = parseData(response); - } - - } - disconnect(); - return returnList[0].toInt(); + return returnList; } @@ -351,16 +116,6 @@ int ServerTcpQueries::querySelectFrom_user4(QString _username) - - - - - - - - - - diff --git a/core/servertcpqueries.h b/core/servertcpqueries.h index 313953a..73421ff 100644 --- a/core/servertcpqueries.h +++ b/core/servertcpqueries.h @@ -7,23 +7,26 @@ class ServerTcpQueries : public QTcpSocket { public: ServerTcpQueries(int port, QHostAddress address, QObject* parent=nullptr); - QVariantList querySelectFrom_room1(QString _roomId, QString _roomPassword); - int queryInsertInto_roomSession(QString _roomId, QString _userId); - int queryInsertInto_room(QString _roomId, QString _host, QString _roomPassword); - int queryInsertInto_user(QString _username); - QVariantList querySelectFrom_user1(QString _username); - QVariantList querySelectFrom_user2(QString _userId); - QVariantList querySelectFrom_room2(QString _userId); - int queryUpdate_room(QString roomId, QString roomPassword, QString _host); - QString querySelectFrom_user3(QString _userId); - int querySelectFrom_user4(QString _username); + /*QVariantList query0SelectFromRoom(QString _roomId, QString _roomPassword); + int query1InsertIntoRoomSession(QString _roomId, QString _userId); + int query2InsertIntoRoom(QString _roomId, QString _host, QString _roomPassword); + int query3InsertIntoUser(QString _username); + QVariantList query4SelectFromUser(QString _username); + QVariantList query5SelectFromUser(QString _userId); + QVariantList query6SelectFromRoom(QString _userId); + int query7UpdateRoom(QString roomId, QString roomPassword, QString _host); + QString query8SelectFromUser(QString _userId); + int query9SelectFromUser(QString _username);*/ + int CUDQuery(int code, QVariantList vars); + QVariantList RQuery(int code, QVariantList vars); + private: - int mPortNumber; - QVariantList parseData(QByteArray arr); - QHostAddress mServerAddress; bool connect(); bool disconnect(); + QVariantList parseData(QByteArray arr) const; + int mPortNumber; int mMillisWait; + QHostAddress mServerAddress; }; #endif // SERVERTCPQUERIES_H diff --git a/core/systemcall.cpp b/core/systemcall.cpp index 9c7a919..ad37643 100644 --- a/core/systemcall.cpp +++ b/core/systemcall.cpp @@ -5,14 +5,17 @@ }*/ -QString SystemCall::exec(const char* cmd) { +QString SystemCall::exec(const char* cmd) +{ std::array buffer; std::string result; std::unique_ptr pipe(popen(cmd, "r"), pclose); - if (!pipe) { + if (!pipe) + { throw std::runtime_error("popen() failed!"); } - while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { + while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) + { result += buffer.data(); } return QString::fromStdString(result); diff --git a/handlers/audioplaybackhandler.cpp b/handlers/audioplaybackhandler.cpp index 2f0809f..a30cfea 100644 --- a/handlers/audioplaybackhandler.cpp +++ b/handlers/audioplaybackhandler.cpp @@ -236,11 +236,11 @@ void AudioPlaybackHandler::start() QString silenceEnd = "lavfi.silence_end"; if(silenceEnd.compare(silenceData->key)==0) { - imageHandler->toggleBorder(true,mIndex); + mImageHandler->toggleBorder(true,mIndex); } if(silenceStart.compare(silenceData->key)==0) { - imageHandler->toggleBorder(false,mIndex); + mImageHandler->toggleBorder(false,mIndex); } } } diff --git a/handlers/imagehandler.h b/handlers/imagehandler.h index 83b4394..50d86a8 100644 --- a/handlers/imagehandler.h +++ b/handlers/imagehandler.h @@ -45,7 +45,7 @@ public slots: void refreshScreens(); private: - std::mutex imgLock; + std::mutex mImageLock; QImage generateGenericImage(QString username) const; uint8_t getCorrectIndex(int index) const; std::map mImageMap; diff --git a/handlers/inputstreamhandler.cpp b/handlers/inputstreamhandler.cpp index 6fa6962..303fc45 100644 --- a/handlers/inputstreamhandler.cpp +++ b/handlers/inputstreamhandler.cpp @@ -230,6 +230,37 @@ void InputStreamHandler::addStreamToVector(int index, QString streamId, QString * @param streamId QString to find in mStreamIdVector * @return int index where streamId was found, or 0 if not found */ + +/* +int InputStreamHandler::findStreamIdIndex(QString streamId, QString displayName) +{ + qDebug() << "InputStreamHandler findStreamId index: " << streamId; + if(mStreamIdVector.size() >= 1) + { + for(size_t i = 0; i < mStreamIdVector.size(); i++) + { + if(QString::compare(streamId, mStreamIdVector[i], Qt::CaseSensitive) == 0) + { + return i; + } + } + //If the streamId does not exist, push it and buffers/locks + addStreamToVector(mStreamIdVector.size(), streamId, displayName); + return mStreamIdVector.size() - 1; + } + else + { + //If this stream is the first to join, push it and buffer/locks + addStreamToVector(0, streamId, displayName); + return 0; + } +} +*/ +/** + * Goes through the mStreamIdVector and locates the streamId + * @param streamId + * @return int index where the streamId is located in the vector + */ int InputStreamHandler::findStreamIdIndex(QString streamId) const { if(mStreamIdVector.size() >= 1) @@ -245,6 +276,66 @@ int InputStreamHandler::findStreamIdIndex(QString streamId) const return -1; } +std::vector InputStreamHandler::getAudioMutexVector() const +{ + return mAudioMutexVector; +} + +std::vector InputStreamHandler::getVideoMutexVector() const +{ + return mVideoMutexVector; +} + +std::vector InputStreamHandler::getAudioBufferVector() const +{ + return mAudioBufferVector; +} + +std::vector InputStreamHandler::getVideoBufferVector() const +{ + return mVideoBufferVector; +} + +std::vector InputStreamHandler::getVideoPlaybackStartedVector() const +{ + return mVideoPlaybackStartedVector; +} + +std::vector InputStreamHandler::getAudioPlaybackStartedVector() const +{ + return mAudioPlaybackStartedVector; +} + +std::vector *> InputStreamHandler::getAudioFutures() const +{ + return mAudioFutures; +} + +std::vector *> InputStreamHandler::getVideoFutures() const +{ + return mVideoFutures; +} + +std::vector InputStreamHandler::getAudioPlaybackHandlerVector() const +{ + return mAudioPlaybackHandlerVector; +} + +std::vector InputStreamHandler::getVideoPlaybackHandlerVector() const +{ + return mVideoPlaybackHandlerVector; +} + +std::vector InputStreamHandler::getStreamIdVector() const +{ + return mStreamIdVector; +} + +/** + * @brief InputStreamHandler::updateParticipantDisplayName + * @param streamId QString + * @param displayName + */ void InputStreamHandler::updateParticipantDisplayName(QString streamId, QString displayName) { uint8_t index = findStreamIdIndex(streamId); diff --git a/handlers/outputstreamhandler.cpp b/handlers/outputstreamhandler.cpp index bcc6374..ca27eac 100644 --- a/handlers/outputstreamhandler.cpp +++ b/handlers/outputstreamhandler.cpp @@ -108,7 +108,7 @@ int OutputStreamHandler::enableAudio() } mAudioHandler->toggleGrabFrames(mAudioEnabled); - audioFuture = QtConcurrent::run(mAudioHandler, &AudioHandler::grabFrames); + mAudioFuture = QtConcurrent::run(mAudioHandler, &AudioHandler::grabFrames); return 0; } @@ -118,7 +118,7 @@ void OutputStreamHandler::disableAudio() { mAudioEnabled = false; mAudioHandler->toggleGrabFrames(mAudioEnabled); - audioFuture.waitForFinished(); + mAudioFuture.waitForFinished(); qDebug() << "Audiohandler not active, deleting it"; delete mAudioHandler; mAudioHandler = nullptr; @@ -155,7 +155,7 @@ int OutputStreamHandler::enableVideo(bool screenShare) mVideoHandler->toggleGrabFrames(mVideoEnabled); qDebug() << "Before grab frames"; - videoFuture = QtConcurrent::run(mVideoHandler, &VideoHandler::grabFrames); + mVideoFuture = QtConcurrent::run(mVideoHandler, &VideoHandler::grabFrames); qDebug() << "Grab frames started"; return 0; } @@ -174,7 +174,7 @@ void OutputStreamHandler::disableVideo() av_usleep(500); qDebug() << "VideoHandler is still active"; }*/ - videoFuture.waitForFinished(); + mVideoFuture.waitForFinished(); qDebug() << "Videohandler not active, deleting it"; delete mVideoHandler; diff --git a/handlers/sessionhandler.cpp b/handlers/sessionhandler.cpp index 8f543c7..1d8ffba 100644 --- a/handlers/sessionhandler.cpp +++ b/handlers/sessionhandler.cpp @@ -112,7 +112,10 @@ QVariantList SessionHandler::getAudioInputDevices() const bool SessionHandler::joinSession(QString _roomId, QString _roomPassword) { qDebug() << "RoomId: " << _roomId; - const QVariantList response = mServerTcpQueries->querySelectFrom_room1(_roomId,_roomPassword); + QVariantList vars; + vars.append(_roomPassword); + vars.append(_roomId); + const QVariantList response = mServerTcpQueries->RQuery(0, vars); if(response.size() > 0) { if(response[0].toInt() == -1) @@ -155,10 +158,14 @@ QString SessionHandler::getRoomPassword() const void SessionHandler::addUser() { + QVariantList vars; + vars.append(mRoomId); + qDebug() << "User is guest: " << mUser->isGuest(); if (!mUser->isGuest()) { - const int numberOfRowsAffected = mServerTcpQueries->queryInsertInto_roomSession(mRoomId, QString::number(mUser->getUserId())); + vars.prepend(QString::number(mUser->getUserId())); + const int numberOfRowsAffected = mServerTcpQueries->CUDQuery(1, vars); if(numberOfRowsAffected <= 0) { qDebug() << "Failed Query" << Q_FUNC_INFO; @@ -168,7 +175,8 @@ void SessionHandler::addUser() { if (addGuestUserToDatabase()) { - const int numberOfRowsAffected = mServerTcpQueries->queryInsertInto_roomSession(mRoomId, QString::number(mUser->getGuestId())); + vars.prepend(QString::number(mUser->getGuestId())); + const int numberOfRowsAffected = mServerTcpQueries->CUDQuery(1, vars); if(numberOfRowsAffected <= 0) { qDebug() << "Failed Query" << Q_FUNC_INFO; @@ -190,7 +198,11 @@ bool SessionHandler::createSession(QString roomId, QString roomPassword) { if (!mUser->hasRoom()) { - int numberOfRowsAffected = mServerTcpQueries->queryInsertInto_room(roomId, QString::number(mUser->getUserId()),roomPassword); + QVariantList vars; + vars.append(roomId); + vars.append(QString::number(mUser->getUserId())); + vars.append(roomPassword); + int numberOfRowsAffected = mServerTcpQueries->CUDQuery(2, vars); if(numberOfRowsAffected<=0) { qDebug() << "Failed Query" << Q_FUNC_INFO; @@ -219,7 +231,9 @@ QString SessionHandler::getRoomHostUsername() const bool SessionHandler::addGuestUserToDatabase() { qDebug() << mUser->getGuestName(); - int numberOfRowsAffected = mServerTcpQueries->queryInsertInto_user(mUser->getGuestName()); + QVariantList vars; + vars.append(mUser->getGuestName()); + int numberOfRowsAffected = mServerTcpQueries->CUDQuery(3, vars); if(numberOfRowsAffected<=0) { qDebug() << "Failed Query" << Q_FUNC_INFO; diff --git a/handlers/tcpsockethandler.cpp b/handlers/tcpsockethandler.cpp index 9bcadec..bb2dfa8 100644 --- a/handlers/tcpsockethandler.cpp +++ b/handlers/tcpsockethandler.cpp @@ -158,6 +158,11 @@ void TcpSocketHandler::readyRead() }; } +QByteArray TcpSocketHandler::getHeader() const +{ + return mHeader; +} + //Send header to server, and receive headers from other participants back void TcpSocketHandler::writeHeader() diff --git a/handlers/tcpsockethandler.h b/handlers/tcpsockethandler.h index 3b8a3b5..990f462 100644 --- a/handlers/tcpsockethandler.h +++ b/handlers/tcpsockethandler.h @@ -32,6 +32,8 @@ class TcpSocketHandler : public QObject bool isReady() const; QByteArray getReply() const; + QByteArray getHeader() const; + public slots: void connected(); void disconnected(); diff --git a/handlers/userhandler.cpp b/handlers/userhandler.cpp index 32e1283..d6de2de 100644 --- a/handlers/userhandler.cpp +++ b/handlers/userhandler.cpp @@ -15,14 +15,16 @@ UserHandler::~UserHandler() } -bool UserHandler::isGuest() +bool UserHandler::isGuest() const { return mIsGuest; } bool UserHandler::login(QString username, QString password) { - const QVariantList queryData = mServerTcpQueries->querySelectFrom_user1(username); + QVariantList vars; + vars.append(username); + const QVariantList queryData = mServerTcpQueries->RQuery(4, vars); //Hvis lista er tom, så fant man ikke brukeren if(queryData.isEmpty()) { @@ -65,7 +67,9 @@ bool UserHandler::login(QString username, QString password) bool UserHandler::fillUser(int userId) { - const QVariantList queryData = mServerTcpQueries->querySelectFrom_user2(QString::number(userId)); + QVariantList vars; + vars.append(QString::number(userId)); + const QVariantList queryData = mServerTcpQueries->RQuery(5, vars); if(queryData.size() > 0) { mUserId = userId; @@ -80,9 +84,10 @@ bool UserHandler::fillUser(int userId) bool UserHandler::getPersonalRoom() { - // qDebug() << "mUserId " << mUserId; - const QVariantList queryData = mServerTcpQueries->querySelectFrom_room2(QString::number(mUserId)); - if(queryData.size()>0) + QVariantList vars; + vars.append(QString::number(mUserId)); + const QVariantList queryData = mServerTcpQueries->RQuery(6, vars); + if(queryData.size() > 0) { mPersonalRoomId = queryData[0].toString(); mPersonalRoomPassword = queryData[1].toString(); @@ -97,7 +102,11 @@ bool UserHandler::updatePersonalRoom(QString roomId, QString roomPassword) { return false; } - const int numberOfRowsAffected = mServerTcpQueries->queryUpdate_room(roomId, roomPassword, QString::number(mUserId)); + QVariantList vars; + vars.append(roomId); + vars.append(roomPassword); + vars.append(QString::number(mUserId)); + const int numberOfRowsAffected = mServerTcpQueries->CUDQuery(7, vars); if(numberOfRowsAffected <= 0) { qDebug() << "Failed Query" << Q_FUNC_INFO; @@ -146,7 +155,10 @@ QString UserHandler::getGuestName() const QString UserHandler::getGuestStreamId() const { - const QString queryData = mServerTcpQueries->querySelectFrom_user3(QString::number(getGuestId())); + QVariantList vars; + vars.append(QString::number(getGuestId())); + const QVariantList returnList = mServerTcpQueries->RQuery(8, vars); + const QString queryData = returnList[0].toString(); if(!queryData.isEmpty()) { return queryData; @@ -157,7 +169,10 @@ QString UserHandler::getGuestStreamId() const int UserHandler::getGuestId() const { - return mServerTcpQueries->querySelectFrom_user4(mGuestName); + QVariantList vars; + vars.append(mGuestName); + QVariantList returnList = mServerTcpQueries->RQuery(9, vars); + return returnList[0].toInt(); } bool UserHandler::logout() diff --git a/handlers/videohandler.cpp b/handlers/videohandler.cpp index b4d6d98..097a112 100644 --- a/handlers/videohandler.cpp +++ b/handlers/videohandler.cpp @@ -68,7 +68,6 @@ QString VideoHandler::buildScreenDeviceName() } } - QScreen* screen = QGuiApplication::primaryScreen(); int a, b, c, d; screen->geometry().getCoords(&a, &b, &c, &d); diff --git a/handlers/videoplaybackhandler.cpp b/handlers/videoplaybackhandler.cpp index 613a5d5..3a56734 100644 --- a/handlers/videoplaybackhandler.cpp +++ b/handlers/videoplaybackhandler.cpp @@ -143,7 +143,7 @@ void VideoPlaybackHandler::start() exit(1); } - imageHandler->readImage(videoDecoderCodecContext, frame, mIndex); + mImageHandler->readImage(videoDecoderCodecContext, frame, mIndex); av_frame_unref(frame); av_packet_unref(&packet); diff --git a/handlers/videoplaybackhandler.h b/handlers/videoplaybackhandler.h index 252f6a7..63069d3 100644 --- a/handlers/videoplaybackhandler.h +++ b/handlers/videoplaybackhandler.h @@ -13,7 +13,7 @@ class VideoPlaybackHandler : public Playback Q_OBJECT public: VideoPlaybackHandler(std::mutex* writeLock, QByteArray* buffer, - size_t bufferSize, ImageHandler* imageHandler, + size_t bufferSize, ImageHandler* mImageHandler, int index, QObject *parent = nullptr); ~VideoPlaybackHandler(); void start(); diff --git a/participant.cpp b/participant.cpp index 3d9444e..f675b4e 100644 --- a/participant.cpp +++ b/participant.cpp @@ -26,22 +26,22 @@ void Participant::setAudioIsDisabled(bool val) mAudioIsDisabled = val; } -QImage Participant::getImage() +QImage Participant::getImage() const { return mImage; } -QString Participant::getDisplayName() +QString Participant::getDisplayName() const { return mDisplayName; } -bool Participant::getIsTalking() +bool Participant::getIsTalking() const { return mIsTalking; } -bool Participant::getAudioIsDisabled() +bool Participant::getAudioIsDisabled() const { return mAudioIsDisabled; } diff --git a/participant.h b/participant.h index ed2c603..4744e57 100644 --- a/participant.h +++ b/participant.h @@ -12,10 +12,10 @@ class Participant void setDisplayName(QString val); void setIsTalking(bool val); void setAudioIsDisabled(bool val); - QImage getImage(); - QString getDisplayName(); - bool getIsTalking(); - bool getAudioIsDisabled(); + bool getIsTalking() const; + bool getAudioIsDisabled() const; + QImage getImage() const; + QString getDisplayName() const; private: QImage mImage; diff --git a/playback.cpp b/playback.cpp index feb3ba7..a0e5dab 100644 --- a/playback.cpp +++ b/playback.cpp @@ -10,7 +10,7 @@ Playback::Playback(std::mutex* _writeLock, QByteArray* buffer, mStruct->writeLock = _writeLock; mStruct->stopPlayback = &mStopPlayback; mIndex = index; - imageHandler = _imageHandler; + mImageHandler = _imageHandler; } Playback::~Playback() { @@ -48,7 +48,7 @@ int Playback::customReadPacket(void *opaque, uint8_t *buf, int buf_size) s->writeLock->lock(); QByteArray tempBuffer = QByteArray(s->buffer->data(), buf_size); - s->buffer->remove(0,buf_size); + s->buffer->remove(0, buf_size); s->writeLock->unlock(); diff --git a/playback.h b/playback.h index f11d74c..430fbd4 100644 --- a/playback.h +++ b/playback.h @@ -22,11 +22,11 @@ class Playback : public QObject std::mutex* writeLock; bool* stopPlayback; }; + int mIndex; + bool mStopPlayback = false; size_t mBufferSize; mBufferAndLockStruct* mStruct; - bool mStopPlayback = false; - int mIndex; - ImageHandler* imageHandler; + ImageHandler* mImageHandler; }; #endif // PLAYBACK_H diff --git a/settings.cpp b/settings.cpp index 90802f9..645f1df 100644 --- a/settings.cpp +++ b/settings.cpp @@ -76,32 +76,32 @@ void Settings::saveSettings() qDebug() << "Saved Settings to file"; } -bool Settings::getAudioOn() +bool Settings::getAudioOn() const { return mAudioOn; } -bool Settings::getVideoOn() +bool Settings::getVideoOn() const { return mVideoOn; } -QString Settings::getDisplayName() +QString Settings::getDisplayName() const { return mDisplayName; } -QString Settings::getDefaultAudioInput() +QString Settings::getDefaultAudioInput() const { return mDefaultAudioInput; } -QString Settings::getLastRoomId() +QString Settings::getLastRoomId() const { return mLastRoomId; } -QString Settings::getLastRoomPassword() +QString Settings::getLastRoomPassword() const { return mLastRoomPassword; } @@ -131,7 +131,7 @@ void Settings::setSaveLastRoom(bool val) mSaveLastRoom = val; } -bool Settings::getSaveLastRoom() +bool Settings::getSaveLastRoom() const { return mSaveLastRoom; } diff --git a/settings.h b/settings.h index 099c01c..78bba46 100644 --- a/settings.h +++ b/settings.h @@ -15,13 +15,6 @@ class Settings : public QObject Q_INVOKABLE void loadSettings(); Q_INVOKABLE void loadAndSaveDefaultSettings(); Q_INVOKABLE void saveSettings(); - Q_INVOKABLE bool getAudioOn(); - Q_INVOKABLE bool getVideoOn(); - Q_INVOKABLE bool getSaveLastRoom(); - Q_INVOKABLE QString getDisplayName(); - Q_INVOKABLE QString getDefaultAudioInput(); - Q_INVOKABLE QString getLastRoomId(); - Q_INVOKABLE QString getLastRoomPassword(); Q_INVOKABLE void setAudioOn(bool val); Q_INVOKABLE void setVideoOn(bool val); Q_INVOKABLE void setDisplayName(QString val); @@ -29,6 +22,13 @@ class Settings : public QObject Q_INVOKABLE void setSaveLastRoom(bool val); Q_INVOKABLE void setLastRoomId(QString val); Q_INVOKABLE void setLastRoomPassword(QString val); + Q_INVOKABLE bool getAudioOn() const; + Q_INVOKABLE bool getVideoOn() const; + Q_INVOKABLE bool getSaveLastRoom() const; + Q_INVOKABLE QString getDisplayName() const; + Q_INVOKABLE QString getDefaultAudioInput() const; + Q_INVOKABLE QString getLastRoomId() const; + Q_INVOKABLE QString getLastRoomPassword() const; private: bool mAudioOn;