示例#1
0
void
TpObserver::observeChannels(
    const MethodInvocationContextPtr<>  &context,
    const AccountPtr                    &account,
    const ConnectionPtr                 &connection,
    const QList<ChannelPtr>             &channels,
    const ChannelDispatchOperationPtr   &dispatchOperation,
    const QList<ChannelRequestPtr>      &requestsSatisfied,
    const ObserverInfo                  &observerInfo)
{
    bool bOk;
    QString msg;
    Q_DEBUG ("TpObserver: Observer got something!");

    if (strContact.isEmpty ()) {
        context->setFinished ();
        Q_DEBUG ("TpObserver: But we weren't asked to notify anything");
        return;
    }

    msg = QString("TpObserver: There are %1 channels in channels list")
          .arg (channels.length ());
    Q_DEBUG (msg);

    foreach (ChannelPtr channel, channels) {
        if (!channel->isReady ()) {
            Q_DEBUG ("TpObserver: Channel is not ready");

            ChannelAccepter *closer =
                new ChannelAccepter(context,
                                    account,
                                    connection,
                                    channels,
                                    dispatchOperation,
                                    requestsSatisfied,
                                    observerInfo.allInfo (),
                                    channel,
                                    strContact,
                                    this);
            bOk = connect (closer, SIGNAL (callStarted ()),
                           this  , SIGNAL (callStarted ()));
            Q_ASSERT(bOk);
            Q_UNUSED(bOk);
            closer->init ();
            break;
        }
    }
}//TpObserver::observeChannels
void SimpleCallObserver::onNewChannels(const QList<ChannelPtr> &channels)
{
    foreach (const ChannelPtr &channel, channels) {
        if (channel->channelType() == TP_QT_IFACE_CHANNEL_TYPE_CALL) {
            CallChannelPtr callChannel = CallChannelPtr::qObjectCast(channel);
            if (!callChannel) {
                warning() << "Channel received to observe is not a subclass of "
                    "CallChannel. ChannelFactory set on this observer's account must "
                    "construct CallChannel subclasses for channels of type Call. "
                    "Ignoring channel";
                continue;
            }

            emit callStarted(callChannel);
        } else if (channel->channelType() == TP_QT_IFACE_CHANNEL_TYPE_STREAMED_MEDIA) {
            StreamedMediaChannelPtr smChannel = StreamedMediaChannelPtr::qObjectCast(channel);
            if (!smChannel) {
                warning() << "Channel received to observe is not a subclass of "
                    "StreamedMediaChannel. ChannelFactory set on this observer's account must "
                    "construct StreamedMediaChannel subclasses for channels of type StreamedMedia. "
                    "Ignoring channel";
                continue;
            }

            emit streamedMediaCallStarted(smChannel);
        } else {
            warning() << "Channel received to observe is not of type Call or StreamedMedia, "
                    "service confused. Ignoring channel";
            continue;
        }
    }
}
示例#3
0
void LLVoiceChannel::deactivate()
{
	if (mState >= STATE_RINGING)
	{
		// ignore session leave event
		mIgnoreNextSessionLeave = TRUE;
	}

	if (callStarted())
	{
		setState(STATE_HUNG_UP);
		
		//Default mic is OFF when leaving voice calls
		if (gSavedSettings.getBOOL("AutoDisengageMic") && 
			sCurrentVoiceChannel == this &&
			LLVoiceClient::getInstance()->getUserPTTState())
		{
			gSavedSettings.setBOOL("PTTCurrentlyEnabled", true);
			LLVoiceClient::getInstance()->inputUserControlState(true);
		}
	}
	LLVoiceClient::getInstance()->removeObserver(this);
	
	if (sCurrentVoiceChannel == this)
	{
		// default channel is proximal channel
		sCurrentVoiceChannel = LLVoiceChannelProximal::getInstance();
		sCurrentVoiceChannel->activate();
	}
}
示例#4
0
void LLVoiceChannelProximal::deactivate()
{
	if (callStarted())
	{
		setState(STATE_HUNG_UP);
	}
}
示例#5
0
void LLVoiceChannelGroup::deactivate()
{
	if (callStarted())
	{
		LLVoiceClient::getInstance()->leaveNonSpatialChannel();
	}
	LLVoiceChannel::deactivate();
}
示例#6
0
void LLVoiceChannel::handleStatusChange(EStatusType type)
{
	// status updates
	switch(type)
	{
	case STATUS_LOGIN_RETRY:
		//mLoginNotificationHandle = LLNotifyBox::showXml("VoiceLoginRetry")->getHandle();
		LLNotificationsUtil::add("VoiceLoginRetry");
		break;
	case STATUS_LOGGED_IN:
		//if (!mLoginNotificationHandle.isDead())
		//{
		//	LLNotifyBox* notifyp = (LLNotifyBox*)mLoginNotificationHandle.get();
		//	if (notifyp)
		//	{
		//		notifyp->close();
		//	}
		//	mLoginNotificationHandle.markDead();
		//}
		break;
	case STATUS_LEFT_CHANNEL:
		if (callStarted() && !mIgnoreNextSessionLeave && !sSuspended)
		{
			// if forceably removed from channel
			// update the UI and revert to default channel
			deactivate();
		}
		mIgnoreNextSessionLeave = FALSE;
		break;
	case STATUS_JOINING:
		if (callStarted())
		{
			setState(STATE_RINGING);
		}
		break;
	case STATUS_JOINED:
		if (callStarted())
		{
			setState(STATE_CONNECTED);
		}
	default:
		break;
	}
}
示例#7
0
void LLVoiceChannelGroup::activate()
{
	if (callStarted()) return;

	LLVoiceChannel::activate();

	if (callStarted())
	{
		// we have the channel info, just need to use it now
		LLVoiceClient::getInstance()->setNonSpatialChannel(
			mURI,
			mCredentials);

		if (!gAgent.isInGroup(mSessionID)) // ad-hoc channel
		{
			LLIMModel::LLIMSession* session = LLIMModel::getInstance()->findIMSession(mSessionID);
			// Adding ad-hoc call participants to Recent People List.
			// If it's an outgoing ad-hoc, we can use mInitialTargetIDs that holds IDs of people we
			// called(both online and offline) as source to get people for recent (STORM-210).
			if (session->isOutgoingAdHoc())
			{
				for (uuid_vec_t::iterator it = session->mInitialTargetIDs.begin();
					it!=session->mInitialTargetIDs.end();++it)
				{
					const LLUUID id = *it;
					LLRecentPeople::instance().add(id);
				}
			}
			// If this ad-hoc is incoming then trying to get ids of people from mInitialTargetIDs
			// would lead to EXT-8246. So in this case we get them from speakers list.
			else
			{
				LLIMModel::addSpeakersToRecent(mSessionID);
			}
		}

		//Mic default state is OFF on initiating/joining Ad-Hoc/Group calls
		if (LLVoiceClient::getInstance()->getUserPTTState() && LLVoiceClient::getInstance()->getPTTIsToggle())
		{
			LLVoiceClient::getInstance()->inputUserControlState(true);
		}
		
	}
}
示例#8
0
void LLVoiceChannelProximal::activate()
{
	if (callStarted()) return;

	if((LLVoiceChannel::sCurrentVoiceChannel != this) && (LLVoiceChannel::getState() == STATE_CONNECTED))
	{
		// we're connected to a non-spatial channel, so disconnect.
		LLVoiceClient::getInstance()->leaveNonSpatialChannel();	
	}
	LLVoiceChannel::activate();
	
}
示例#9
0
void LLVoiceChannelP2P::activate()
{
	if (callStarted()) return;

	//call will be counted as ended by user unless this variable is changed in handleStatusChange()
	mCallEndedByAgent = true;

	LLVoiceChannel::activate();

	if (callStarted())
	{
		// no session handle yet, we're starting the call
		if (mSessionHandle.empty())
		{
			mReceivedCall = FALSE;
			LLVoiceClient::getInstance()->callUser(mOtherUserID);
		}
		// otherwise answering the call
		else
		{
			LLVoiceClient::getInstance()->answerInvite(mSessionHandle);
			
			// using the session handle invalidates it.  Clear it out here so we can't reuse it by accident.
			mSessionHandle.clear();
		}

		// Add the party to the list of people with which we've recently interacted.
		LLRecentPeople::instance().add(mOtherUserID);

		//Default mic is ON on initiating/joining P2P calls
		if (!LLVoiceClient::getInstance()->getUserPTTState() && LLVoiceClient::getInstance()->getPTTIsToggle())
		{
			LLVoiceClient::getInstance()->inputUserControlState(true);
		}
	}
}
示例#10
0
// receiving session from other user who initiated call
void LLVoiceChannelP2P::setSessionHandle(const std::string& handle, const std::string &inURI)
{ 
	BOOL needs_activate = FALSE;
	if (callStarted())
	{
		// defer to lower agent id when already active
		if (mOtherUserID < gAgent.getID())
		{
			// pretend we haven't started the call yet, so we can connect to this session instead
			deactivate();
			needs_activate = TRUE;
		}
		else
		{
			// we are active and have priority, invite the other user again
			// under the assumption they will join this new session
			mSessionHandle.clear();
			LLVoiceClient::getInstance()->callUser(mOtherUserID);
			return;
		}
	}

	mSessionHandle = handle;

	// The URI of a p2p session should always be the other end's SIP URI.
	if(!inURI.empty())
	{
		setURI(inURI);
	}
	else
	{
		LL_WARNS("Voice") << "incoming SIP URL is not provided. Channel may not work properly." << LL_ENDL;
		// In the case of an incoming AvaLine call, the generated URI will be different from the
		// original one. This is because the P2P URI is based on avatar UUID but Avaline is not.
		// See LLVoiceClient::sessionAddedEvent()
		setURI(LLVoiceClient::getInstance()->sipURIFromID(mOtherUserID));
	}
	
	mReceivedCall = TRUE;

	if (needs_activate)
	{
		activate();
	}
}
示例#11
0
void SailfishPlatform::onActiveVoiceCallStatusChanged()
{
    VoiceCallHandler* handler = m_voiceCallManager->activeVoiceCall();

    if (!handler || handler->handlerId().isNull()) {
        return;
    }

    switch ((VoiceCallHandler::VoiceCallStatus)handler->status()) {
    case VoiceCallHandler::STATUS_ALERTING:
    case VoiceCallHandler::STATUS_DIALING:
        qDebug() << "Tell outgoing:" << handler->lineId();
        //emit outgoingCall(handlerId, handler->lineId(), m_voiceCallManager->findPersonByNumber(handler->lineId()));
        break;
    case VoiceCallHandler::STATUS_INCOMING:
    case VoiceCallHandler::STATUS_WAITING:
        qDebug() << "Tell incoming:" << handler->lineId();
        if(handler->getState() < VoiceCallHandler::StateRinging) {
            handler->setState(VoiceCallHandler::StateRinging);
            emit incomingCall(qHash(handler->handlerId()), handler->lineId(), m_voiceCallManager->findPersonByNumber(handler->lineId()));
        }
        break;
    case VoiceCallHandler::STATUS_NULL:
    case VoiceCallHandler::STATUS_DISCONNECTED:
        qDebug() << "Endphone " << handler->handlerId();
        if(handler->getState() < VoiceCallHandler::StateCleanedUp) {
            handler->setState(VoiceCallHandler::StateCleanedUp);
            emit callEnded(qHash(handler->handlerId()), false);
        }
        break;
    case VoiceCallHandler::STATUS_ACTIVE:
        qDebug() << "Startphone" << handler->handlerId();
        if(handler->getState() < VoiceCallHandler::StateAnswered) {
            handler->setState(VoiceCallHandler::StateAnswered);
            emit callStarted(qHash(handler->handlerId()));
        }
        break;
    case VoiceCallHandler::STATUS_HELD:
        qDebug() << "OnHold" << handler->handlerId();
        break;
    }
}
示例#12
0
void LLVoiceChannel::activate()
{
	if (callStarted())
	{
		return;
	}

	// deactivate old channel and mark ourselves as the active one
	if (sCurrentVoiceChannel != this)
	{
		// mark as current before deactivating the old channel to prevent
		// activating the proximal channel between IM calls
		LLVoiceChannel* old_channel = sCurrentVoiceChannel;
		sCurrentVoiceChannel = this;
		mCallDialogPayload["old_channel_name"] = "";
		if (old_channel)
		{
			mCallDialogPayload["old_channel_name"] = old_channel->getSessionName();
			old_channel->deactivate();
		}
	}

	if (mState == STATE_NO_CHANNEL_INFO)
	{
		// responsible for setting status to active
		getChannelInfo();
	}
	else
	{
		setState(STATE_CALL_STARTED);
	}
	
	LLVoiceClient::getInstance()->addObserver(this);
	
	//do not send earlier, channel should be initialized, should not be in STATE_NO_CHANNEL_INFO state
	sCurrentVoiceChannelChangedSignal(this->mSessionID);
}
示例#13
0
void LLVoiceChannelP2P::handleStatusChange(EStatusType type)
{
	LL_INFOS("Voice") << "P2P CALL CHANNEL STATUS CHANGE: incoming=" << int(mReceivedCall) << " newstatus=" << LLVoiceClientStatusObserver::status2string(type) << " (mState=" << mState << ")" << LL_ENDL;

	// status updates
	switch(type)
	{
	case STATUS_LEFT_CHANNEL:
		if (callStarted() && !mIgnoreNextSessionLeave && !sSuspended)
		{
			// *TODO: use it to show DECLINE voice notification
			if (mState == STATE_RINGING)
			{
				// other user declined call
				LLNotificationsUtil::add("P2PCallDeclined", mNotifyArgs);
			}
			else
			{
				// other user hung up, so we didn't end the call				
				mCallEndedByAgent = false;			
			}
			deactivate();
		}
		mIgnoreNextSessionLeave = FALSE;
		return;
	case STATUS_JOINING:
		// because we join session we expect to process session leave event in the future. EXT-7371
		// may be this should be done in the LLVoiceChannel::handleStatusChange.
		mIgnoreNextSessionLeave = FALSE;
		break;

	default:
		break;
	}

	LLVoiceChannel::handleStatusChange(type);
}
示例#14
0
MainWindow::MainWindow(
  QWidget *parent)
  : QMainWindow(parent),
    preferencesForm(0),
    videoMonitorForm(0),
    documentationForm(0),
    aboutForm(0),
    myGst(0),
    myDBus(0),
//    myUrlDialog(0),
    lastActiveStatus(Playing_Status), // this is a hack
    audioChoice(Microphone_Audio),
    videoChoice(No_Video),
    elapsedTime(0),
    ui(new Ui::MainWindow)
{
  ui->setupUi(this);

  ui->pauseButton->setEnabled(false);
  ui->stopButton->setEnabled(false);

  updateStatus(Idle_Status);

  setAttribute(Qt::WA_Maemo5StackedWindow);

  preferencesForm = new OrePreferencesForm(this);
  videoMonitorForm = new OreVideoMonitorForm(this);

  myGst = new OreGst(this, videoMonitorForm->getWindowId());
  myDBus = new OreDBus();
//  myUrlDialog = new OreMJpegDialog(this);

  connect(
    myDBus, SIGNAL(callStarted()),
    this, SLOT(startRecordingCall()));

  connect(
    myDBus, SIGNAL(callTerminated()),
    this, SLOT(stopRecordingCall()));

  connect(
    myDBus, SIGNAL(playingAllowed()),
    this, SLOT(startPlaying()));

  connect(
    myDBus, SIGNAL(playingDenied()),
    this, SLOT(stopPlaying()));

  connect(
    preferencesForm, SIGNAL(encodingChanged(AudioEncoding)),
    myGst, SLOT(setAudioEncoding(AudioEncoding)));

  secondTimer.setInterval(1000);

  connect(
    &secondTimer, SIGNAL(timeout()),
    this, SLOT(updateStatusTime()));

  // Set up the combo boxes:
  QSettings settings("pietrzak.org", "Orecchiette");
  if (settings.contains("AudioSourceChoice"))
  {
    QString asc = settings.value("AudioSourceChoice").toString();

    if (asc == "Microphone_Audio")
    {
      ui->audioComboBox->setCurrentIndex(1);
    }
    else if (asc == "Speaker_Audio")
    {
      ui->audioComboBox->setCurrentIndex(2);
    }
    else if (asc == "MicrophoneAndSpeaker_Audio")
    {
      ui->audioComboBox->setCurrentIndex(3);
    }
    else
    {
      ui->audioComboBox->setCurrentIndex(0);
    }
  }

  if (settings.contains("VideoSourceChoice"))
  {
    QString vsc = settings.value("VideoSourceChoice").toString();

    if (vsc == "Screen_Video")
    {
      ui->videoComboBox->setCurrentIndex(1);
    }
    else if (vsc == "BackCamera_Video")
    {
      ui->videoComboBox->setCurrentIndex(2);
    }
    else if (vsc == "FrontCamera_Video")
    {
      ui->videoComboBox->setCurrentIndex(3);
    }
/*
    else if (vsc == "MJpegStream_Video")
    {
      ui->videoComboBox->setCurrentIndex(4);
    }
*/
    else
    {
      ui->videoComboBox->setCurrentIndex(0);
    }
  }

  if (preferencesForm)
  {
/*
    switch (preferencesForm->source)
    {
    case OrePreferencesForm::Microphone:
      ui->inputButton->click();
      break;
    case OrePreferencesForm::Speaker:
      ui->outputButton->click();
      break;
    case OrePreferencesForm::Both:
    default:
      ui->bothButton->click();
      break;
    }
*/

    if (preferencesForm->recordOnStartUp())
    {
      // Act like the Record button's been pressed immediately after initialization
      ui->recordButton->click();
    }
  }
}
示例#15
0
void
ChannelAccepter::decrefCleanup ()
{
    QMutexLocker locker(&mutex);
    nRefCount--;
    if (0 != nRefCount)
    {
        return;
    }

    Q_DEBUG ("TpObserver: Everything ready. Cleaning up");

    bool bCleanupLater = false;
    do { // Not a loop
        if (bFailure) {
            Q_WARN ("TpObserver: Failed while waiting for something");
            break;
        }

        QString msg;
        msg = QString("TpObserver: Channel type = %1. isRequested = %2")
              .arg (currentChannel->channelType ())
              .arg (currentChannel->isRequested ());
        Q_DEBUG (msg);

        ContactPtr contact = currentChannel->initiatorContact ();
        msg = QString("TpObserver: Contact id = %1. alias = %2")
              .arg (contact->id ())
              .arg (contact->alias ());
        Q_DEBUG (msg);

        int interested = 0;
        if (0 == currentChannel->channelType().compare (
                    TPQT_CHANNEL_TYPE_STREAMED_MEDIA))
        {
            interested++;
        }
        if (!currentChannel->isRequested ())
        {
            interested++;
        }
        if (contact->id ().contains (strCheckNumber))
        {
            interested++;
        }

        if (3 != interested)
        {
            Q_DEBUG ("TpObserver: Channel that we're not interested in");
            break;
        }

        Q_DEBUG ("TpObserver: Incoming call from our number!");
        emit callStarted ();
    } while (0); // Not a loop

    if (!bCleanupLater)
    {
        context->setFinished ();
        this->deleteLater ();
    }
}//ChannelAccepter::decrefCleanup
示例#16
0
BOOL LLVoiceChannel::isActive()
{ 
	// only considered active when currently bound channel matches what our channel
	return callStarted() && LLVoiceClient::getInstance()->getCurrentChannel() == mURI; 
}
示例#17
0
BOOL LLVoiceChannelProximal::isActive()
{
	return callStarted() && LLVoiceClient::getInstance()->inProximalChannel(); 
}