本文整理汇总了C#中Smuxi.Engine.FrontendManager.SetStatus方法的典型用法代码示例。如果您正苦于以下问题:C# FrontendManager.SetStatus方法的具体用法?C# FrontendManager.SetStatus怎么用?C# FrontendManager.SetStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smuxi.Engine.FrontendManager
的用法示例。
在下文中一共展示了FrontendManager.SetStatus方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Reconnect
public override void Reconnect(FrontendManager fm)
{
Trace.Call(fm);
fm.SetStatus(_("Reconnecting..."));
try {
string msg;
if (_IrcClient != null) {
if (_IrcClient.IsConnected) {
Session.AddTextToChat(
_NetworkChat,
String.Format(
"-!- " + _("Reconnecting to {0}..."),
_IrcClient.Address
)
);
ApplyConfig(Session.UserConfig, _ServerModel);
_IrcClient.Reconnect(true);
msg = String.Format(_("Connection to {0} established"),
_IrcClient.Address);
fm.SetStatus(msg);
Session.AddTextToChat(_NetworkChat, "-!- " + msg);
} else {
Connect(fm);
}
} else {
msg = _("Reconnect Error");
fm.SetStatus(msg);
Session.AddTextToChat(_NetworkChat, "-!- " + msg);
}
} catch (ConnectionException) {
fm.SetStatus(String.Empty);
fm.AddTextToChat(_NetworkChat, "-!- " + _("Not connected"));
}
fm.UpdateNetworkStatus();
}
示例2: Connect
public override void Connect(FrontendManager fm, ServerModel server)
{
Trace.Call(fm, server);
Network = server.Hostname.Substring(0, server.Hostname.IndexOf('.'));
Host = server.Hostname;
BaseUri = new Uri(String.Format("https://{0}", Host));
NetworkChat = new ProtocolChatModel(Network, "Campfire " + Network, this);
NetworkChat.InitMessageBuffer(MessageBufferPersistencyType.Volatile);
NetworkChat.ApplyConfig(Session.UserConfig);
Session.AddChat(NetworkChat);
Session.SyncChat(NetworkChat);
var msg = _("Connecting to campfire... ");
if (fm != null) {
fm.SetStatus(msg);
}
var bld = CreateMessageBuilder().AppendEventPrefix().AppendText(msg);
Session.AddMessageToChat(NetworkChat, bld.ToMessage());
if (!server.ValidateServerCertificate) {
var whitelist = Session.CertificateValidator.HostnameWhitelist;
lock (whitelist) {
// needed for favicon
if (!whitelist.Contains("campfirenow.com")) {
whitelist.Add("campfirenow.com");
}
// needed for receiving messages
if (!whitelist.Contains("streaming.campfirenow.com")) {
whitelist.Add("streaming.campfirenow.com");
}
if (!whitelist.Contains(Host)) {
whitelist.Add(Host);
}
}
}
Client = new JsonServiceClient(BaseUri.AbsoluteUri);
var creds = new NetworkCredential(server.Username, server.Password);
Client.Credentials = creds;
try {
var me = Client.Get<UserResponse>("/users/me.json").User;
Key = me.Api_Auth_Token;
Me = CreatePerson(me);
// The blue color is hardcoded for now
Me.IdentityNameColored.ForegroundColor = new TextColor(0x0000FF);
Me.IdentityNameColored.BackgroundColor = TextColor.None;
Me.IdentityNameColored.Bold = true;
} catch (Exception e) {
FailedToConnect("Failed to connect to Campfire", e);
return;
}
Client.Credentials = new NetworkCredential(Key, "X");
msg = _("Connected to campfire");
if (fm != null) {
fm.SetStatus(msg);
}
bld = CreateMessageBuilder().AppendEventPrefix().AppendText(msg);
Session.AddMessageToChat(NetworkChat, bld.ToMessage());
// Campfire lets us know what channels the user is currently in, so
// connect to those rooms automatically
Rooms = Client.Get<RoomsResponse>("/rooms.json").Rooms;
RoomsUpdated = DateTime.Now;
var myrooms = Client.Get<RoomsResponse>("/presence.json").Rooms;
if (myrooms.Length > 0) {
bld = CreateMessageBuilder().
AppendEventPrefix().
AppendText("Present in {0}",
String.Join(", ", myrooms.Select(r => r.Name).ToArray())
);
Session.AddMessageToChat(NetworkChat, bld.ToMessage());
}
foreach (var room in myrooms) {
var chat = new GroupChatModel(room.Id.ToString(), room.Name, null);
OpenChat(fm, chat);
}
}
示例3: Disconnect
public override void Disconnect(FrontendManager fm)
{
Trace.Call(fm);
fm.SetStatus(_("Disconnecting..."));
if (IsConnected) {
Session.AddTextToChat(_NetworkChat, "-!- " +
String.Format(_("Disconnecting from {0}..."),
_IrcClient.Address));
// else the Listen() thread would try to connect again
_Listening = false;
_IrcClient.Disconnect();
fm.SetStatus(String.Format(_("Disconnected from {0}"),
_IrcClient.Address));
Session.AddTextToChat(_NetworkChat, "-!- " +
_("Connection closed"));
// TODO: set someone else as current network manager?
} else {
fm.SetStatus(String.Empty);
fm.AddTextToChat(_NetworkChat, "-!- " + _("Not connected"));
}
if (_RunThread != null && _RunThread.IsAlive) {
try {
_RunThread.Abort();
} catch (Exception ex) {
#if LOG4NET
_Logger.Error("_RunThread.Abort() failed:", ex);
#endif
}
}
if (_LagWatcherThread != null && _LagWatcherThread.IsAlive) {
try {
_LagWatcherThread.Abort();
} catch (Exception ex) {
#if LOG4NET
_Logger.Error("_LagWatcherThread.Abort() failed:", ex);
#endif
}
}
fm.UpdateNetworkStatus();
}
示例4: Connect
public void Connect(FrontendManager fm)
{
Trace.Call(fm);
try {
string msg;
msg = String.Format(_("Connecting to {0} port {1}..."), _Host, _Port);
fm.SetStatus(msg);
Session.AddTextToChat(_NetworkChat, "-!- " + msg);
// TODO: add SSL support
_IrcClient.Connect(_Host, _Port);
fm.UpdateNetworkStatus();
msg = String.Format(_("Connection to {0} established"), _Host);
fm.SetStatus(msg);
Session.AddTextToChat(_NetworkChat, "-!- " + msg);
Session.AddTextToChat(_NetworkChat, "-!- " + _("Logging in..."));
string realname = (string) Session.UserConfig["Connection/Realname"];
if (realname.Trim().Length == 0) {
realname = "unset";
}
_IrcClient.Login(_Nicknames, realname, 0, _Username, _Password);
foreach (string command in (string[]) Session.UserConfig["Connection/OnConnectCommands"]) {
if (command.Length == 0) {
continue;
}
CommandModel cd = new CommandModel(_FrontendManager, _NetworkChat,
(string) Session.UserConfig["Interface/Entry/CommandCharacter"],
command);
bool handled;
handled = Session.Command(cd);
if (!handled) {
Command(cd);
}
}
_Listening = true;
} catch (CouldNotConnectException ex) {
fm.SetStatus(_("Connection failed!"));
Session.AddTextToChat(_NetworkChat, "-!- " + _("Connection failed! Reason: ") + ex.Message);
throw;
}
}
示例5: Connect
public void Connect(FrontendManager fm)
{
Trace.Call(fm);
try {
MessageBuilder builder;
if (!String.IsNullOrEmpty(_IrcClient.ProxyHost)) {
builder = CreateMessageBuilder();
builder.AppendEventPrefix();
builder.AppendText(_("Using proxy: {0}:{1}"),
_IrcClient.ProxyHost,
_IrcClient.ProxyPort);
Session.AddMessageToChat(Chat, builder.ToMessage());
}
string msg;
msg = String.Format(_("Connecting to {0} port {1}..."), _Host, _Port);
fm.SetStatus(msg);
Session.AddTextToChat(_NetworkChat, "-!- " + msg);
// TODO: add SSL support
_IrcClient.Connect(_Host, _Port);
fm.UpdateNetworkStatus();
msg = String.Format(_("Connection to {0} established"), _Host);
fm.SetStatus(msg);
Session.AddTextToChat(_NetworkChat, "-!- " + msg);
Session.AddTextToChat(_NetworkChat, "-!- " + _("Logging in..."));
string realname = (string) Session.UserConfig["Connection/Realname"];
if (realname.Trim().Length == 0) {
realname = "unset";
}
if (!Regex.IsMatch(_Username, "^[a-z0-9]+$", RegexOptions.IgnoreCase)) {
builder = CreateMessageBuilder();
builder.AppendEventPrefix();
builder.AppendWarningText(
"Warning: Your username (ident) contains special " +
"characters which the IRC server might refuse. " +
"If this happens please change your username in the " +
"server settings."
);
Session.AddMessageToChat(_NetworkChat, builder.ToMessage());
}
_IrcClient.Login(_Nicknames, realname, 0, _Username, _Password);
foreach (string command in (string[]) Session.UserConfig["Connection/OnConnectCommands"]) {
if (command.Length == 0) {
continue;
}
CommandModel cd = new CommandModel(_FrontendManager, _NetworkChat,
(string) Session.UserConfig["Interface/Entry/CommandCharacter"],
command);
bool handled;
handled = Session.Command(cd);
if (!handled) {
Command(cd);
}
}
_Listening = true;
} catch (CouldNotConnectException ex) {
fm.SetStatus(_("Connection failed!"));
Session.AddTextToChat(_NetworkChat, "-!- " + _("Connection failed! Reason: ") + ex.Message);
throw;
}
}
示例6: Connect
public override void Connect(FrontendManager fm, string host, int port,
string username, string password)
{
Trace.Call(fm, host, port, username, "XXX");
f_Username = username;
var proxyType = (string) Session.UserConfig["Connection/ProxyType"];
if (proxyType.ToLower() == "http") {
var uriBuilder = new UriBuilder();
uriBuilder.Scheme = "http";
uriBuilder.Host = (string) Session.UserConfig["Connection/ProxyHostname"];
uriBuilder.Port = (int) Session.UserConfig["Connection/ProxyPort"];
uriBuilder.UserName = (string) Session.UserConfig["Connection/ProxyUsername"];
uriBuilder.Password = (string) Session.UserConfig["Connection/ProxyPassword"];
var proxyUri = uriBuilder.ToString();
f_WebProxy = new WebProxy(proxyUri);
}
f_OptionalProperties = new OptionalProperties();
if (f_WebProxy != null) {
f_OptionalProperties.Proxy = f_WebProxy;
}
f_ProtocolChat = new ProtocolChatModel(NetworkID, "Twitter " + username, this);
Session.AddChat(f_ProtocolChat);
Session.SyncChat(f_ProtocolChat);
string msg;
msg = String.Format(_("Connecting to Twitter..."));
fm.SetStatus(msg);
Session.AddTextToChat(f_ProtocolChat, "-!- " + msg);
try {
var key = GetApiKey();
f_OAuthTokens = new OAuthTokens();
f_OAuthTokens.ConsumerKey = key[0];
f_OAuthTokens.ConsumerSecret = key[1];
MessageBuilder builder;
var servers = new ServerListController(Session.UserConfig);
var server = servers.GetServer(Protocol, username);
if (server != null) {
if (password == null) {
// no password passed, use server password
password = server.Password;
}
}
password = password ?? String.Empty;
var access = password.Split('|');
if (password.Length == 0 || access.Length == 1) {
// new account or basic auth user that needs to be migrated
var reqToken = OAuthUtility.GetRequestToken(key[0], key[1],
"oob", f_WebProxy);
f_RequestToken = reqToken.Token;
var authUri = OAuthUtility.BuildAuthorizationUri(f_RequestToken);
builder = CreateMessageBuilder();
builder.AppendEventPrefix();
builder.AppendText(_("Twitter authorization required."));
Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage());
/*
_("Twitter authorization required, please open the " +
"following URL and enter the returned PIN using the " +
"/pin command: {0}"),
String.Empty
);
*/
builder = CreateMessageBuilder();
builder.AppendEventPrefix();
// TRANSLATOR: do NOT change the position of {0}!
builder.AppendText(
_("Please open the following URL and click " +
"\"Allow\" to allow Smuxi to connect to your " +
"Twitter account: {0}"),
String.Empty
);
Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage());
builder = CreateMessageBuilder();
builder.AppendEventPrefix();
builder.AppendText(" ");
builder.AppendUrl(authUri.AbsoluteUri);
Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage());
builder = CreateMessageBuilder();
builder.AppendEventPrefix();
builder.AppendText(
_("Once you have allowed Smuxi to access your " +
"Twitter account, Twitter will provide a PIN.")
);
Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage());
builder = CreateMessageBuilder();
builder.AppendEventPrefix();
builder.AppendText(_("Please type: /pin PIN_FROM_TWITTER"));
Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage());
} else {
f_OAuthTokens.AccessToken = access[0];
//.........这里部分代码省略.........
示例7: Reconnect
public override void Reconnect(FrontendManager fm)
{
Trace.Call(fm);
fm.SetStatus("Reconnecting...");
try {
string msg;
if (_IrcClient != null) {
if (_IrcClient.IsConnected) {
Session.AddTextToChat(_NetworkChat, "-!- Reconnecting to " + _IrcClient.Address + "...");
_IrcClient.Reconnect(true);
msg = "Connection to " + _IrcClient.Address + " established";
fm.SetStatus(msg);
Session.AddTextToChat(_NetworkChat, "-!- "+msg);
} else {
Connect(fm);
}
} else {
fm.SetStatus("Reconnect Error");
Session.AddTextToChat(_NetworkChat, "-!- Reconnect Error");
}
} catch (ConnectionException) {
fm.SetStatus("Not connected!");
fm.AddTextToChat(_NetworkChat, "-!- Not connected");
}
fm.UpdateNetworkStatus();
}