本文整理汇总了C#中Smuxi.Engine.FrontendManager类的典型用法代码示例。如果您正苦于以下问题:C# FrontendManager类的具体用法?C# FrontendManager怎么用?C# FrontendManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FrontendManager类属于Smuxi.Engine命名空间,在下文中一共展示了FrontendManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommandModel
public CommandModel(FrontendManager fm, ChatModel chat, string cmdChar, string data)
{
Trace.Call(fm, chat == null ? "(null)" : chat.GetType().ToString(), cmdChar, data);
_Data = data;
_DataArray = data.Split(new char[] {' '});
_Parameter = String.Join(" ", _DataArray, 1, _DataArray.Length - 1);
_CommandCharacter = cmdChar;
if (data.StartsWith(cmdChar) &&
!data.StartsWith(cmdChar + cmdChar)) {
_IsCommand = true;
_Command = (_DataArray[0].Length > cmdChar.Length) ?
_DataArray[0].Substring(cmdChar.Length).ToLower() :
String.Empty;
} else if (data.StartsWith(cmdChar + cmdChar)) {
_Data = data.Substring(cmdChar.Length);
_DataArray[0] = _DataArray[0].Substring(cmdChar.Length);
}
_FrontendManager = fm;
_Chat = chat;
}
示例2: Connect
public override void Connect(FrontendManager fm, ServerModel server)
{
throw new System.NotImplementedException();
}
示例3: ConnectEngineToGUI
public static void ConnectEngineToGUI()
{
if (IsLocalEngine) {
// HACK: SessionManager.Register() is not used for local engines
_LocalSession.RegisterFrontendUI(_MainWindow.UI);
}
SyncConfig();
_FrontendManager = _Session.GetFrontendManager(_MainWindow.UI);
_FrontendManager.Sync();
// MS .NET doesn't like this with Remoting?
if (Type.GetType("Mono.Runtime") != null) {
// when are running on Mono, all should be good
if (_UserConfig.IsCaching) {
// when our UserConfig is cached, we need to invalidate the cache
// DISABLED: see FrontendManager._OnConfigChanged
//_FrontendManager.ConfigChangedDelegate = SyncConfig;
}
}
_MainWindow.ShowAll();
// make sure entry got attention :-P
_MainWindow.Entry.HasFocus = true;
// local sessions can't have network issues :)
if (_Session != _LocalSession) {
_FrontendManagerCheckerQueue = new TaskQueue("FrontendManagerCheckerQueue");
_FrontendManagerCheckerQueue.AbortedEvent += delegate {
#if LOG4NET
_Logger.Debug("_FrontendManagerCheckerQueue.AbortedEvent(): task queue aborted!");
#endif
};
_FrontendManagerCheckerQueue.ExceptionEvent +=
delegate(object sender, TaskQueueExceptionEventArgs e) {
#if LOG4NET
_Logger.Error("Exception in TaskQueue: ", e.Exception);
_Logger.Error("Inner-Exception: ", e.Exception.InnerException);
#endif
Frontend.ShowException(e.Exception);
};
_FrontendManagerCheckerQueue.Queue(delegate {
// keep looping as long as the checker returns true
while (CheckFrontendManagerStatus()) {
// FIXME: bail out somehow when we lost the connection
// without an exception in the meantime
// only check once per minute
Thread.Sleep(60 * 1000);
}
#if LOG4NET
_Logger.Debug("_FrontendManagerCheckerQueue(): " +
"CheckFrontendManagerStatus() returned false, "+
"time to say good bye!");
#endif
});
}
MainWindow.ChatViewManager.IsSensitive = true;
}
示例4: OpenChat
public override void OpenChat(FrontendManager fm, ChatModel chat)
{
Trace.Call(fm, chat);
throw new NotImplementedException();
}
示例5: Connect
public override void Connect(FrontendManager fm, string host, int port, string username, string password)
{
Trace.Call(fm, host, port, username, password);
_FrontendManager = fm;
Host = "login.oscar.aol.com";
Port = 5190;
// TODO: use config for single network chat or once per network manager
_NetworkChat = new ProtocolChatModel(NetworkID, NetworkID + " Messenger", this);
Session.AddChat(_NetworkChat);
Session.SyncChat(_NetworkChat);
_OscarSession = new OscarSession(username, password);
_OscarSession.ClientCapabilities = Capabilities.Chat | Capabilities.OscarLib;
_OscarSession.LoginCompleted += new LoginCompletedHandler(_OnLoginCompleted);
_OscarSession.LoginFailed += new LoginFailedHandler(_OnLoginFailed);
_OscarSession.LoginStatusUpdate += new LoginStatusUpdateHandler(_OnLoginStatusUpdate);
_OscarSession.ErrorMessage += new ErrorMessageHandler(_OnErrorMessage);
_OscarSession.WarningMessage += new WarningMessageHandler(_OnWarningMessage);
_OscarSession.StatusUpdate += new InformationMessageHandler(_OnStatusUpdate);
_OscarSession.ContactListFinished += new ContactListFinishedHandler(_OnContactListFinished);
_OscarSession.Messages.MessageReceived += new MessageReceivedHandler(_OnMessageReceived);
_OscarSession.Logon(Host, Port);
}
示例6: 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);
}
}
示例7: Connect
public override void Connect(FrontendManager fm, string host, int port, string username, string password)
{
Trace.Call(fm, host, port, username, password);
_UsersAddress = username;
_FrontendManager = fm;
Host = host;
Port = port;
// TODO: use config for single network chat or once per network manager
_NetworkChat = new ProtocolChatModel(NetworkID, "MSN Messenger", this);
Session.AddChat(_NetworkChat);
Session.SyncChat(_NetworkChat);
_MsnClient.Credentials.Account = username;
_MsnClient.Credentials.Password = password;
_MsnClient.Connect();
}
示例8: ConnectEngineToGUI
public static void ConnectEngineToGUI()
{
_FrontendManager = _Session.GetFrontendManager(_MainWindow.UI);
_FrontendManager.Sync();
if (_UserConfig.IsCaching) {
// when our UserConfig is cached, we need to invalidate the cache
_FrontendManager.ConfigChangedDelegate = new SimpleDelegate(_UserConfig.ClearCache);
}
// make sure entry got attention :-P
// BUG: MonoCurses
//_MainWindow.Entry.HasFocus = true;
}
示例9: OpenChat
public override void OpenChat(FrontendManager fm, ChatModel chat)
{
Trace.Call(fm, chat);
CommandModel cmd = new CommandModel(fm, _NetworkChat, chat.ID);
switch (chat.ChatType) {
case ChatType.Person:
CommandMessage(cmd);
break;
case ChatType.Group:
CommandJoin(cmd);
break;
}
}
示例10: 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();
}
示例11: 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;
}
}
示例12: OpenChat
public override void OpenChat(FrontendManager fm, ChatModel chat)
{
throw new System.NotImplementedException();
}
示例13: Disconnect
public override void Disconnect(FrontendManager fm)
{
throw new System.NotImplementedException();
}
示例14: OpenChat
public override void OpenChat(FrontendManager fm, ChatModel chat)
{
Trace.Call(fm, chat);
if (chat.ID == "Contacts") {
OpenContactChat();
return;
}
CommandModel cmd = new CommandModel(fm, NetworkChat, chat.ID);
switch (chat.ChatType) {
case ChatType.Person:
CommandMessageQuery(cmd);
break;
case ChatType.Group:
CommandJoin(cmd);
break;
}
}
示例15: Reconnect
public override void Reconnect(FrontendManager fm)
{
Trace.Call(fm);
JabberClient.Close();
JabberClient.Connect();
}