From 0d01300762a8413c3b137e433ee4c02070798792 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 11 Nov 2009 16:59:49 +0000 Subject: sketch-out the outgoing call dialog code. WIP. --- indra/newview/llimview.cpp | 141 +++++++++++++++++++++++++++++++++++ indra/newview/llimview.h | 13 ++++ indra/newview/llviewerfloaterreg.cpp | 2 +- indra/newview/llvoicechannel.cpp | 6 ++ 4 files changed, 161 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 14f94d5a88..33bd483367 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -1099,6 +1099,147 @@ LLIMMgr::onConfirmForceCloseError( } +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLOutgoingCallDialog +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LLOutgoingCallDialog::LLOutgoingCallDialog(const LLSD& payload) : + LLModalDialog(payload), + mPayload(payload) +{ +} + +BOOL LLOutgoingCallDialog::postBuild() +{ + LLSD caller_id = mPayload["caller_id"]; + EInstantMessage type = (EInstantMessage)mPayload["type"].asInteger(); + + std::string call_type = getString("VoiceInviteP2P"); + std::string caller_name = mPayload["caller_name"].asString(); + if (caller_name == "anonymous") + { + caller_name = getString("anonymous"); + } + + setTitle(caller_name + " " + call_type); + + // If it is not a P2P invite, then it's an AdHoc invite + if ( type != IM_SESSION_P2P_INVITE ) + { + call_type = getString("VoiceInviteAdHoc"); + } + + LLUICtrl* caller_name_widget = getChild("caller name"); + caller_name_widget->setValue(caller_name + " " + call_type); + LLAvatarIconCtrl* icon = getChild("avatar_icon"); + icon->setValue(caller_id); + + //childSetAction("Reject", onReject, this); + + return TRUE; +} + +void LLOutgoingCallDialog::processCallResponse(S32 response) +{ + if (!gIMMgr) + return; + + LLUUID session_id = mPayload["session_id"].asUUID(); + EInstantMessage type = (EInstantMessage)mPayload["type"].asInteger(); + LLIMMgr::EInvitationType inv_type = (LLIMMgr::EInvitationType)mPayload["inv_type"].asInteger(); + bool voice = true; + switch(response) + { + case 2: // start IM: just don't start the voice chat + { + voice = false; + /* FALLTHROUGH */ + } + case 0: // accept + { + if (type == IM_SESSION_P2P_INVITE) + { + // create a normal IM session + session_id = gIMMgr->addP2PSession( + mPayload["session_name"].asString(), + mPayload["caller_id"].asUUID(), + mPayload["session_handle"].asString()); + + if (voice) + { + if (gIMMgr->startCall(session_id)) + { + // always open IM window when connecting to voice + LLIMFloater::show(session_id); + } + } + + gIMMgr->clearPendingAgentListUpdates(session_id); + gIMMgr->clearPendingInvitation(session_id); + } + else + { + LLUUID session_id = gIMMgr->addSession( + mPayload["session_name"].asString(), + type, + session_id); + if (session_id != LLUUID::null) + { + LLIMFloater::show(session_id); + } + + std::string url = gAgent.getRegion()->getCapability( + "ChatSessionRequest"); + + if (voice) + { + LLSD data; + data["method"] = "accept invitation"; + data["session-id"] = session_id; + LLHTTPClient::post( + url, + data, + new LLViewerChatterBoxInvitationAcceptResponder( + session_id, + inv_type)); + } + } + if (voice) + { + break; + } + } + case 1: // decline + { + if (type == IM_SESSION_P2P_INVITE) + { + if(gVoiceClient) + { + std::string s = mPayload["session_handle"].asString(); + gVoiceClient->declineInvite(s); + } + } + else + { + std::string url = gAgent.getRegion()->getCapability( + "ChatSessionRequest"); + + LLSD data; + data["method"] = "decline invitation"; + data["session-id"] = session_id; + LLHTTPClient::post( + url, + data, + NULL); + } + } + + gIMMgr->clearPendingAgentListUpdates(session_id); + gIMMgr->clearPendingInvitation(session_id); + } +} + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLIncomingCallDialog //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index c566b111ca..942a8f96d0 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -418,6 +418,19 @@ private: LLSD mPayload; }; +class LLOutgoingCallDialog : public LLModalDialog +{ +public: + LLOutgoingCallDialog(const LLSD& payload); + + /*virtual*/ BOOL postBuild(); + +private: + void processCallResponse(S32 response); + + LLSD mPayload; +}; + // Globals extern LLIMMgr *gIMMgr; diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index edbac69e1b..7cd660110f 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -195,7 +195,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("notifications_console", "floater_notifications_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("openobject", "floater_openobject.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - + LLFloaterReg::add("outgoing_call", "floater_outgoing_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("parcel_info", "floater_preview_url.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterPayUtil::registerFloater(); diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp index 89649407ff..04ae44e08d 100644 --- a/indra/newview/llvoicechannel.cpp +++ b/indra/newview/llvoicechannel.cpp @@ -378,9 +378,15 @@ void LLVoiceChannel::setURI(std::string uri) void LLVoiceChannel::setState(EState state) { + LLSD payload; + payload["session_id"] = mSessionID; + payload["session_name"] = mSessionName; + switch(state) { case STATE_RINGING: + LLFloaterReg::showInstance("outgoing_call", payload, TRUE); + llinfos << "RINGINGGGGGGGG " << mSessionName << llendl; gIMMgr->addSystemMessage(mSessionID, "ringing", mNotifyArgs); break; case STATE_CONNECTED: -- cgit v1.2.3