/************************************************************************ Copyright (c) 2005-2012 by Juphoon System Software Co., Ltd. All rights reserved. This software is confidential and proprietary to Juphoon System Software Co., Ltd.. No part of this software may be reproduced, stored, transmitted, disclosed or used in any form or by any means other than as expressly provided by the written license agreement between JusTel and its licensee. THIS SOFTWARE IS PROVIDED BY JusTel "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JusTel BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Juphoon System Software Co., Ltd. ************************************************************************/ /************************************************* File name : rsession.h Module : UI Dialog Author : vic.ren Created on : 2012-11-05 Description : The session dialog Modify History: 1. Date: Author: Modification: 2012-11-05 Vic Ren Create *************************************************/ #include "JusCallPch.h" RSession::RSession(const QString &qsCurPhone, QObject *parent) : QObject(parent) , m_enSessMode(0) , m_qsCurPhone(qsCurPhone) , m_pSessVoice(ZNULL) , m_pSessVideo(ZNULL) , m_dwSessId(ZINVALIDID) { updateContact(); } void RSession::audioCall() { m_enSessMode |= EN_UI_SESS_MODE_AUDIO; if (!m_pSessVoice) { m_pSessVoice = new RSessVoice(this); connect(m_pSessVoice, SIGNAL(signalVoiceEnded()), this, SLOT(slotRmvSessMedia())); } startSess(); } void RSession::videoCall() { m_enSessMode |= EN_UI_SESS_MODE_VIDEO; if (!m_pSessVideo) { m_pSessVideo = new RSessVideo(this); connect(m_pSessVideo, SIGNAL(signalVideoEnded()), this, SLOT(slotRmvSessMedia())); connect(m_pSessVideo, SIGNAL(signalStartLocalVideo()), this, SLOT(slotStartLocalVideo())); connect(m_pSessVideo, SIGNAL(signalStartRemoteVideo()), this, SLOT(slotStartRomoteVideo())); } startSess(); } void RSession::show() { if (m_enSessMode & EN_UI_SESS_MODE_AUDIO) { m_pSessVoice->show(); if (!m_pSessVoice->isMinimized()) m_pSessVoice->activateWindow(); else m_pSessVoice->showNormal(); m_pSessVoice->raise(); } if (m_enSessMode & EN_UI_SESS_MODE_VIDEO) { if (!m_pSessVideo) return; m_pSessVideo->show(); if (!m_pSessVideo->isMinimized()) m_pSessVideo->activateWindow(); else m_pSessVideo->showNormal(); m_pSessVideo->raise(); } } void RSession::moveMediaToLog() { if (!m_pSessVoice && !m_pSessVideo) return; if (m_pSessVoice) m_pSessVoice->moveToPositon(); else if (m_pSessVideo) m_pSessVideo->moveToPositon(); // //if (m_pSessVoice) //{ // if (m_pSessVoice->width() > RClient::screenWidth() - nX) // { // nX = 0; // } // m_pSessVoice->move(nX, nY); //} //else if (m_pSessVideo) //{ // if (m_pSessVideo->width() > RClient::screenWidth() - nX) // { // nX = 0; // } // m_pSessVideo->move(nX, RClient::mediaY()); // m_pSessVideo->showControl(true); //} } void RSession::moveLogToMedia() { if (!m_pSessVideo) return; int nX, nY; if (m_pSessVoice) { nX = m_pSessVoice->x() + m_pSessVoice->width() + 20; nY = m_pSessVoice->y(); if (nX < 0) nX = 0; } else if (m_pSessVideo) { nX = m_pSessVideo->x() + m_pSessVideo->width() + 20; nY = m_pSessVideo->y(); if (nX < 0) nX = 0; } } void RSession::moveVideo(QPoint pt) { if (!m_pSessVideo) return; m_pSessVideo->moveVideo(pt); } void RSession::close() { if (m_pSessVoice) m_pSessVoice->close(); if (m_pSessVideo) m_pSessVideo->close(); RCallManager::Instance()->rmvSession(this); } void RSession::deleteLogQry() { } void RSession::updateContact() { m_qsCurUri = QString::fromUtf8(Mtc_UserFormUri(EN_MTC_USER_ID_USERNAME, m_qsCurPhone.toUtf8().constData())); } QString RSession::currentUri() { return m_qsCurUri; } void RSession::setCurPhone(const QString & qsPhone) { m_qsCurPhone = qsPhone; m_qsCurUri = QString::fromUtf8(Mtc_UserFormUri(EN_MTC_USER_ID_USERNAME, m_qsCurPhone.toUtf8().constData())); } QString RSession::currentPhone() { return m_qsCurPhone; } int RSession::phoneCount() { return m_qlstPhones.count(); } QString RSession::phone(int nIndex) { return m_qlstPhones.at(nIndex); } bool RSession::hasPhone(const QString & qsPhone) { return m_qlstPhones.contains(qsPhone); } QString RSession::name() { return m_qsName; } ZUINT RSession::sessId() { return m_dwSessId; } bool RSession::isTalking() { return Mtc_CallHasTalk(m_dwSessId); } bool RSession::logShowing() { return true; } bool RSession::hasVideo() { if (!m_pSessVideo) return false; return true; } bool RSession::hasAudio() { if (!m_pSessVoice) return false; return true; } void RSession::startSess() { m_dwSessId = Mtc_Call((ZCHAR *)currentUri().toUtf8().constData(), 0, ZTRUE, m_enSessMode & EN_UI_SESS_MODE_VIDEO); if (m_dwSessId == ZINVALIDID) showSessFailed(); else showSessOut(); } void RSession::showSessFailed() { if (m_pSessVoice) m_pSessVoice->showSessFailed(); if (m_pSessVideo) m_pSessVideo->showSessFailed(); } void RSession::showSessOut() { if (m_pSessVoice) m_pSessVoice->showSessOut(); if (m_pSessVideo) m_pSessVideo->showSessOut(); } void RSession::showSessOutgoing() { if (m_pSessVideo) m_pSessVideo->showSessOutgoing(); } void RSession::showSessIncoming(ZUINT dwSessId, ZINT enSessMode) { m_dwSessId = dwSessId; m_enSessMode |= enSessMode; if (m_enSessMode & EN_UI_SESS_MODE_VIDEO) { // m_pSessVideo = new RSessVideo(this); // connect(m_pSessVideo, SIGNAL(signalVideoEnded()), this, // SLOT(slotRmvSessMedia())); // connect(m_pSessVideo, SIGNAL(signalStartLocalVideo()), this, // SLOT(slotStartLocalVideo())); // connect(m_pSessVideo, SIGNAL(signalStartRemoteVideo()), this, // SLOT(slotStartRomoteVideo())); // m_pSessVideo->showSessIncoming(); } else if (m_enSessMode & EN_UI_SESS_MODE_AUDIO) { m_pSessVoice = new RSessVoice(this); connect(m_pSessVoice, SIGNAL(signalVoiceEnded()), this, SLOT(slotRmvSessMedia())); m_pSessVoice->showSessIncoming(); } } void RSession::showSessAlerted() { if (m_pSessVoice) m_pSessVoice->showSessAlerted(); if (m_pSessVideo) m_pSessVideo->showSessAlerted(); } void RSession::showSessConnecting() { if (m_pSessVoice) m_pSessVoice->showSessConnecting(); if (m_pSessVideo) m_pSessVideo->showSessConnecting(); } void RSession::showSessTalking() { if (m_pSessVoice) m_pSessVoice->showSessTalking(); if (m_pSessVideo) m_pSessVideo->showSessTalking(); } void RSession::showSessTermed() { if (m_pSessVoice) m_pSessVoice->showSessTermed(); if (m_pSessVideo) m_pSessVideo->showSessTermed(); } void RSession::slotStartLocalVideo() { if (!m_pSessVideo) return; m_pSessVideo->startLocalVideo(); } void RSession::slotStartRomoteVideo() { if (!m_pSessVideo) return; m_pSessVideo->startRemoteVideo(); } void RSession::slotRmvSessLog() { if (!(m_enSessMode & EN_UI_SESS_MODE_VIDEO) && !(m_enSessMode & EN_UI_SESS_MODE_AUDIO)) close(); } void RSession::slotRmvSessMedia() { m_dwSessId = ZINVALIDID; if (m_pSessVoice) { m_pSessVoice->deleteLater(); m_pSessVoice = ZNULL; } if (m_pSessVideo) { m_pSessVideo->deleteLater(); m_pSessVideo = ZNULL; } if (m_enSessMode & EN_UI_SESS_MODE_VIDEO) m_enSessMode ^= EN_UI_SESS_MODE_VIDEO; if (m_enSessMode & EN_UI_SESS_MODE_AUDIO) m_enSessMode ^= EN_UI_SESS_MODE_AUDIO; close(); }