2008-04-22 00:31:37 +00:00
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
2008-07-21 21:12:59 +00:00
|
|
|
using OpenMetaverse;
|
|
|
|
|
using OpenMetaverse.Packets;
|
2008-04-22 00:31:37 +00:00
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2008-04-22 00:31:37 +00:00
|
|
|
{
|
|
|
|
|
public class VoiceAccountCommand : Command
|
|
|
|
|
{
|
|
|
|
|
private AutoResetEvent ProvisionEvent = new AutoResetEvent(false);
|
|
|
|
|
private string VoiceAccount = null;
|
|
|
|
|
private string VoicePassword = null;
|
|
|
|
|
|
|
|
|
|
public VoiceAccountCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
Name = "voiceaccount";
|
|
|
|
|
Description = "obtain voice account info. Usage: voiceaccount";
|
2008-07-25 08:55:36 +00:00
|
|
|
Category = CommandCategory.Voice;
|
2008-04-22 00:31:37 +00:00
|
|
|
|
|
|
|
|
Client = testClient;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool registered = false;
|
|
|
|
|
|
|
|
|
|
private bool IsVoiceManagerRunning()
|
|
|
|
|
{
|
|
|
|
|
if (null == Client.VoiceManager) return false;
|
|
|
|
|
|
|
|
|
|
if (!registered)
|
|
|
|
|
{
|
|
|
|
|
Client.VoiceManager.OnProvisionAccount += Voice_OnProvisionAccount;
|
|
|
|
|
registered = true;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-25 05:15:05 +00:00
|
|
|
public override string Execute(string[] args, UUID fromAgentID)
|
2008-04-22 00:31:37 +00:00
|
|
|
{
|
|
|
|
|
if (!IsVoiceManagerRunning())
|
|
|
|
|
return String.Format("VoiceManager not running for {0}", Client.Self.Name);
|
|
|
|
|
|
|
|
|
|
if (!Client.VoiceManager.RequestProvisionAccount())
|
|
|
|
|
{
|
|
|
|
|
return "RequestProvisionAccount failed. Not available for the current grid?";
|
|
|
|
|
}
|
|
|
|
|
ProvisionEvent.WaitOne(30 * 1000, false);
|
|
|
|
|
|
|
|
|
|
if (String.IsNullOrEmpty(VoiceAccount) && String.IsNullOrEmpty(VoicePassword))
|
|
|
|
|
{
|
|
|
|
|
return String.Format("Voice account information lookup for {0} failed.", Client.Self.Name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return String.Format("Voice Account for {0}: user \"{1}\", password \"{2}\"",
|
|
|
|
|
Client.Self.Name, VoiceAccount, VoicePassword);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Voice_OnProvisionAccount(string username, string password)
|
|
|
|
|
{
|
|
|
|
|
VoiceAccount = username;
|
|
|
|
|
VoicePassword = password;
|
|
|
|
|
|
|
|
|
|
ProvisionEvent.Set();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|