Ejemplo n.º 1
0
        protected virtual void OnProxyShowPasswordCheckButtonToggled(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            f_ProxyPasswordEntry.Visibility = f_ProxyShowPasswordCheckButton.Active;
        }
Ejemplo n.º 2
0
        public override void Disconnect(FrontendManager fm)
        {
            Trace.Call(fm);

            Client.Disconnect();
        }
Ejemplo n.º 3
0
 public JabbrProtocolManager(Session session) : base(session)
 {
     Trace.Call(session);
 }
Ejemplo n.º 4
0
 public void DisableChat(ChatModel page)
 {
     Trace.Call(page);
 }
Ejemplo n.º 5
0
 public EngineAssistant(Gtk.Window parent, FrontendConfig config) :
     this(parent, config, null)
 {
     Trace.Call(parent, config);
 }
Ejemplo n.º 6
0
 public void RemovePersonFromGroupChat(GroupChatModel cpage, PersonModel user)
 {
     Trace.Call(cpage, user);
 }
Ejemplo n.º 7
0
 public void SetStatus(string status)
 {
     Trace.Call(status);
 }
Ejemplo n.º 8
0
 public void ScrollToEnd()
 {
     Trace.Call();
     _OutputTextView.ScrollToEnd();
 }
Ejemplo n.º 9
0
        public void Enable()
        {
            Trace.Call();

            Enabled = true;
        }
Ejemplo n.º 10
0
        public void ScrollDown()
        {
            Trace.Call();

            // TODO
        }
Ejemplo n.º 11
0
        public void ScrollToStart()
        {
            Trace.Call();

            // TODO
        }
Ejemplo n.º 12
0
        public void ScrollUp()
        {
            Trace.Call();

            // TODO
        }
Ejemplo n.º 13
0
        private void CommandExec(CommandModel cmd)
        {
            Trace.Call(cmd);

            if (cmd.DataArray.Length < 2)
            {
                NotEnoughParameters(cmd);
                return;
            }
            var parameter     = cmd.Parameter;
            var parameters    = cmd.Parameter.Split(' ');
            var messageOutput = false;
            var executeOutput = false;

            if (parameters.Length > 0)
            {
                var shift = false;
                switch (parameters[0])
                {
                case "-c":
                    executeOutput = true;
                    shift         = true;
                    break;

                case "-o":
                    messageOutput = true;
                    shift         = true;
                    break;
                }
                if (shift)
                {
                    parameters = parameters.Skip(1).ToArray();
                    parameter  = String.Join(" ", parameters);
                }
            }
            SysDiag.DataReceivedEventHandler handler = (sender, e) => {
                if (String.IsNullOrEmpty(e.Data))
                {
                    return;
                }
                // eat trailing newlines
                var output = e.Data.TrimEnd('\r', '\n');
                if (executeOutput || messageOutput)
                {
                    if (messageOutput && output.StartsWith(cmd.CommandCharacter))
                    {
                        // escape command character
                        output = String.Format("{0}{1}",
                                               cmd.CommandCharacter, output);
                    }
                    Execute(new CommandModel(cmd.FrontendManager,
                                             cmd.Chat,
                                             cmd.CommandCharacter, output));
                }
                else
                {
                    var msg = new MessageBuilder().AppendText(output).ToMessage();
                    f_Session.AddMessageToFrontend(cmd, msg);
                }
            };

            string file;
            string args = null;

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                file = "sh";
                args = String.Format("-c '{0}'",
                                     parameter.Replace("'", @"\'"));
            }
            else
            {
                file = parameters[1];
                if (parameters.Length > 1)
                {
                    args = String.Join(" ", parameters.Skip(1).ToArray());
                }
            }
            var info = new SysDiag.ProcessStartInfo()
            {
                FileName               = file,
                Arguments              = args,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                UseShellExecute        = false
            };

            using (var process = new SysDiag.Process()) {
                process.StartInfo           = info;
                process.OutputDataReceived += handler;
                process.ErrorDataReceived  += handler;

                try {
                    process.Start();
                    process.StandardInput.Close();
                    process.BeginOutputReadLine();
                    process.BeginErrorReadLine();
                    process.WaitForExit();
                } catch (Exception ex) {
#if LOG4NET
                    f_Logger.Error(ex);
#endif
                    var command = info.FileName;
                    if (!String.IsNullOrEmpty(info.Arguments))
                    {
                        command += " " + info.Arguments;
                    }
                    var msg = new MessageBuilder().
                              AppendErrorText("Executing '{0}' failed with: {1}",
                                              command, ex.Message).
                              ToMessage();
                    f_Session.AddMessageToFrontend(cmd, msg);
                }
            }
        }
Ejemplo n.º 14
0
        private void DoExecute(CommandModel cmd)
        {
            Trace.Call(cmd);

            var handled = false;

            if (cmd.IsCommand)
            {
                switch (cmd.Command)
                {
                case "exec":
                    CommandExec(cmd);
                    handled = true;
                    break;

                case "echo":
                    CommandEcho(cmd);
                    handled = true;
                    break;
                }
            }
            if (handled)
            {
                // no need to send the command to the engine
                return;
            }

            DateTime start, stop;

            start = DateTime.UtcNow;

            handled = f_Session.Command(cmd);
            if (!handled)
            {
                IProtocolManager pm;
                if (cmd.Chat is SessionChatModel)
                {
                    pm = cmd.FrontendManager.CurrentProtocolManager;
                }
                else
                {
                    pm = cmd.Chat.ProtocolManager;
                }

                // we maybe have no network manager yet
                if (pm != null)
                {
                    handled = pm.Command(cmd);
                }
                else
                {
                    handled = false;
                }
            }
            if (!handled)
            {
                Unknown(cmd);
            }

            stop = DateTime.UtcNow;
            f_LastCommandTimeSpan = (stop - start);
        }
Ejemplo n.º 15
0
 public void UpdatePersonInGroupChat(GroupChatModel cpage, PersonModel olduser, PersonModel newuser)
 {
     Trace.Call(cpage, olduser, newuser);
 }
Ejemplo n.º 16
0
        public virtual void Disable()
        {
            Trace.Call();

            Enabled = false;
        }
Ejemplo n.º 17
0
        public void UpdateTopicInGroupChat(GroupChatModel cpage, MessageModel topic)
        {
            Trace.Call(cpage, topic);

            Console.WriteLine("Topic changed to: " + topic.ToString() + " on " + cpage.Name);
        }
Ejemplo n.º 18
0
        public virtual void ApplyConfig(UserConfig config)
        {
            Trace.Call(config);

            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            string bgStr = (string)config["Interface/Chat/BackgroundColor"];

            if (!String.IsNullOrEmpty(bgStr))
            {
                try {
                    Color color = ColorTools.GetColor(bgStr);
                    _BackgroundColor          = color;
                    _OutputTextView.BackColor = color;
                } catch (FormatException ex) {
#if LOG4NET
                    _Logger.Error("setting background color failed", ex);
#endif
                }
            }
            else
            {
                // Instead of a null colour, get the system colour "Window"
                _BackgroundColor          = SystemColors.Window;
                _OutputTextView.BackColor = SystemColors.Window;
            }

            string fgStr = (string)config["Interface/Chat/ForegroundColor"];
            if (!String.IsNullOrEmpty(fgStr))
            {
                try {
                    Color color = ColorTools.GetColor(fgStr);
                    _ForegroundColor          = color;
                    _OutputTextView.ForeColor = color;
                } catch (FormatException ex) {
#if LOG4NET
                    _Logger.Error("setting foreground color failed", ex);
#endif
                }
            }
            else
            {
                // Same for the text.
                _ForegroundColor          = SystemColors.WindowText;
                _OutputTextView.ForeColor = SystemColors.WindowText;
            }

            string fontFamily = (string)config["Interface/Chat/FontFamily"];
            string fontStyle  = (string)config["Interface/Chat/FontStyle"];
            int    fontSize   = 0;
            if (config["Interface/Chat/FontSize"] != null)
            {
                fontSize = (int)config["Interface/Chat/FontSize"];
            }
            Font font = null;
            if (String.IsNullOrEmpty(fontFamily))
            {
                // use Monospace by default
                float?defaultSize;
                try {
                    defaultSize = Font.Size;
                } catch (NullReferenceException) {
#if LOG4NET
                    _Logger.Error("could not get default system font size, using internal default");
#endif
                    // Mono bug?
                    defaultSize = 12f;
                }
                font = new Font(FontFamily.GenericMonospace, defaultSize.Value);
            }
            else
            {
                string fontWeigth = null;
                if (fontStyle.Contains(" "))
                {
                    int pos = fontStyle.IndexOf(" ");
                    fontWeigth = fontStyle.Substring(0, pos);
                    fontStyle  = fontStyle.Substring(pos + 1);
                }
                FontStyle style = (FontStyle)Enum.Parse(typeof(FontStyle), fontStyle);
                font = new Font(fontFamily, fontSize, style);
            }
            _Font = font;
            _OutputTextView.Font = font;
        }
Ejemplo n.º 19
0
 public void SetNetworkStatus(string status)
 {
     Trace.Call(status);
 }
Ejemplo n.º 20
0
        public virtual void AddMessage(MessageModel msg)
        {
            Trace.Call(msg);

            string timestamp;

            try {
                string format = (string)Frontend.UserConfig["Interface/Notebook/TimestampFormat"];
                timestamp = msg.TimeStamp.ToLocalTime().ToString(format);
            } catch (FormatException e) {
                timestamp = "Timestamp Format ERROR: " + e.Message;
            }

            timestamp += " ";
            _OutputTextView.SelectionHangingIndent = TextRenderer.MeasureText(timestamp, _Font).Width;

            _OutputTextView.AppendText(timestamp);

            bool hasHighlight = false;

            foreach (MessagePartModel msgPart in msg.MessageParts)
            {
#if LOG4NET
                _Logger.Debug("AddMessage(): msgPart.GetType(): " + msgPart.GetType());
#endif
                if (msgPart.IsHighlight)
                {
                    hasHighlight = true;
                }

                // TODO: implement all types
                if (msgPart is UrlMessagePartModel)
                {
                    UrlMessagePartModel fmsgui = (UrlMessagePartModel)msgPart;
                    /*TODO: Create a link in the TextView (possibly requiring WinAPI hacks...)*/
                    _OutputTextView.SelectionColor = Color.Blue;
                    _OutputTextView.SelectionFont  = new Font(_Font, FontStyle.Underline);

                    _OutputTextView.AppendText(fmsgui.Url);
                }
                else if (msgPart is TextMessagePartModel)
                {
                    /*TODO: Add required formatting to the TextView (possibly requiring WinAPI hacks...)*/
                    TextMessagePartModel fmsgti = (TextMessagePartModel)msgPart;
#if LOG4NET
                    _Logger.Debug("AddMessage(): fmsgti.Text: '" + fmsgti.Text + "'");
#endif
                    FontStyle fstyle = FontStyle.Regular;

                    if (fmsgti.ForegroundColor == TextColor.None)
                    {
                        _OutputTextView.SelectionColor = _ForegroundColor ?? Color.White;
                    }
                    else
                    {
#if LOG4NET
                        _Logger.Debug("AddMessage(): fmsgti.ForegroundColor: '" + fmsgti.ForegroundColor.ToString() + "'");
#endif
                        _OutputTextView.SelectionColor = ColorTools.GetColor(fmsgti.ForegroundColor);
                    }

                    if (fmsgti.BackgroundColor == TextColor.None)
                    {
                        _OutputTextView.SelectionBackColor = _BackgroundColor ?? Color.Black;
                    }
                    else
                    {
#if LOG4NET
                        _Logger.Debug("AddMessage(): fmsgti.BackgroundColor: '" + fmsgti.BackgroundColor.ToString() + "'");
#endif
                        _OutputTextView.SelectionBackColor = ColorTools.GetColor(fmsgti.BackgroundColor);
                    }


                    if (fmsgti.Underline)
                    {
#if LOG4NET
                        _Logger.Debug("AddMessage(): fmsgti.Underline is true");
#endif
                        fstyle |= FontStyle.Underline;
                    }
                    if (fmsgti.Bold)
                    {
#if LOG4NET
                        _Logger.Debug("AddMessage(): fmsgti.Bold is true");
#endif
                        fstyle |= FontStyle.Bold;
                    }
                    if (fmsgti.Italic)
                    {
#if LOG4NET
                        _Logger.Debug("AddMessage(): fmsgti.Italic is true");
#endif
                        fstyle |= FontStyle.Italic;
                    }

                    _OutputTextView.SelectionFont = new Font(Font, fstyle);

                    _OutputTextView.AppendText(fmsgti.Text);
                }
            }
            _OutputTextView.AppendText("\n");

            // HACK: out of scope?
            if (hasHighlight /*&& !Frontend.MainWindow.HasToplevelFocus*/)
            {
                /*TODO: Flash the main window*/
                if (Frontend.UserConfig["Sound/BeepOnHighlight"] != null &&
                    (bool)Frontend.UserConfig["Sound/BeepOnHighlight"])
                {
                    System.Media.SystemSounds.Beep.Play();
                }
            }

            // HACK: out of scope?
            if (((TabControl)this.Parent).SelectedTab != this)
            {
                string color = null;
                if (hasHighlight)
                {
                    _HasHighlight = hasHighlight;
                    color         = (string)Frontend.UserConfig["Interface/Notebook/Tab/HighlightColor"];
                }
                else if (!_HasHighlight)
                {
                    color = (string)Frontend.UserConfig["Interface/Notebook/Tab/ActivityColor"];
                }

                if (color != null)
                {
                    /*TODO: Color the associated Tab*/
                }
            }
        }
Ejemplo n.º 21
0
        public void RemoveChat(ChatModel page)
        {
            Trace.Call(page);

            Console.WriteLine("Removed page: " + page.Name + " type: " + page.ChatType);
        }
Ejemplo n.º 22
0
        public void Load(ServerModel server)
        {
            Trace.Call(server);

            Server = server;

            // protocol is part of the PKEY, not allowed to change
            f_ProtocolComboBox.Sensitive = false;

            Protocol             = server.Protocol;
            ServerID             = server.ServerID;
            f_HostnameEntry.Text = server.Hostname;
            f_NetworkComboBoxEntry.Entry.Text = server.Network;
            if (String.IsNullOrEmpty(server.Nickname))
            {
                var defaultNicknames = (string[])Frontend.UserConfig["Connection/Nicknames"];
                f_NicknameEntry.Text = String.Join(" ", defaultNicknames);
            }
            else
            {
                f_NicknameEntry.Text = server.Nickname;
            }
            if (String.IsNullOrEmpty(server.Realname))
            {
                var defaultRealname = (string)Frontend.UserConfig["Connection/Realname"];
                f_RealnameEntry.Text = defaultRealname;
            }
            else
            {
                f_RealnameEntry.Text = server.Realname;
            }
            f_UsernameEntry.Text = server.Username;
            // HACK: Twitter username is part of the PKEY, not allowed to change
            if (server.Protocol == "Twitter")
            {
                f_UsernameEntry.Sensitive = false;
            }
            else
            {
                f_UsernameEntry.Sensitive = true;
            }
            f_PasswordEntry.Text = server.Password;
            f_UseEncryptionCheckButton.Active             = server.UseEncryption;
            f_ValidateServerCertificateCheckButton.Active =
                server.ValidateServerCertificate;
            f_PortSpinButton.Value             = server.Port;
            OnStartupConnectCheckButton.Active = server.OnStartupConnect;
            if (server.OnConnectCommands == null ||
                server.OnConnectCommands.Count == 0)
            {
                f_OnConnectCommandsTextView.Buffer.Text = String.Empty;
            }
            else
            {
                // LAME: replace me when we have .NET 3.0
                string[] commands = new string[server.OnConnectCommands.Count];
                server.OnConnectCommands.CopyTo(commands, 0);
                f_OnConnectCommandsTextView.Buffer.Text = String.Join(
                    "\n", commands
                    );
            }
        }
Ejemplo n.º 23
0
        protected virtual void OnApply(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            string engine = f_NameWidget.EngineNameEntry.Text;

            if (f_EngineName == null)
            {
                // check if an engine wit that name exists already
                string[] engines = (string[])f_Config["Engines/Engines"];
                foreach (string oldEngine in engines)
                {
                    if (engine == oldEngine)
                    {
                        Gtk.MessageDialog md = new Gtk.MessageDialog(this,
                                                                     Gtk.DialogFlags.Modal, Gtk.MessageType.Error,
                                                                     Gtk.ButtonsType.Close, _("An engine with this name already exists! Please specify a different one."));
                        md.Run();
                        md.Destroy();

                        // jump back to the name page
                        // HACK: assistant API is buggy here, the "Apply" button
                        // will trigger a next page signal, thus we have to jump
                        // to one page before the name page :(
                        CurrentPage = f_NamePage - 1;
                        return;
                    }
                }

                string[] newEngines;
                if (engines.Length == 0)
                {
                    // there was no existing engines
                    newEngines = new string[] { engine };
                }
                else
                {
                    newEngines = new string[engines.Length + 1];
                    engines.CopyTo(newEngines, 0);
                    newEngines[engines.Length] = engine;
                }

                if (engines.Length == 1)
                {
                    f_Config["Engines/Default"] = engine;
                }
                f_Config["Engines/Engines"] = newEngines;
            }

            if (f_NameWidget.MakeDefaultEngineCheckButton.Active)
            {
                f_Config["Engines/Default"] = engine;
            }

            f_Config["Engines/" + engine + "/Username"] =
                f_CredentialsWidget.UsernameEntry.Text.Trim();
            f_Config["Engines/" + engine + "/Password"] =
                f_CredentialsWidget.PasswordEntry.Text.Trim();
            f_Config["Engines/" + engine + "/Hostname"] =
                f_ConnectionWidget.HostEntry.Text.Trim();
            f_Config["Engines/" + engine + "/Port"] =
                f_ConnectionWidget.PortSpinButton.ValueAsInt;

            f_Config["Engines/" + engine + "/UseSshTunnel"] =
                f_ConnectionWidget.UseSshTunnelCheckButton.Active;
            f_Config["Engines/" + engine + "/SshUsername"] =
                f_CredentialsWidget.SshUsernameEntry.Text.Trim();
            if (f_CredentialsWidget.SshPasswordVBox.Visible)
            {
                f_Config["Engines/" + engine + "/SshPassword"] =
                    f_CredentialsWidget.SshPasswordEntry.Text;
            }
            f_Config["Engines/" + engine + "/SshKeyfile"] =
                f_CredentialsWidget.SshKeyfileChooserButton.Filename ?? String.Empty;
            f_Config["Engines/" + engine + "/SshHostname"] =
                f_ConnectionWidget.SshHostEntry.Text.Trim();
            f_Config["Engines/" + engine + "/SshPort"] =
                f_ConnectionWidget.SshPortSpinButton.ValueAsInt;

            // HACK: we don't really support any other channels/formatters (yet)
            f_Config["Engines/" + engine + "/Channel"]   = "TCP";
            f_Config["Engines/" + engine + "/Formatter"] = "binary";

            f_Config.Save();
        }
Ejemplo n.º 24
0
        protected virtual void CheckShowPasswordCheckButton()
        {
            Trace.Call();

            f_PasswordEntry.Visibility = f_ShowPasswordCheckButton.Active;
        }
Ejemplo n.º 25
0
        public override void Connect(FrontendManager fm, ServerModel server)
        {
            Trace.Call(fm, server);

            Server   = server;
            Username = server.Username;
            var chatName = String.Format("{0} {1}", Protocol, NetworkID);

            ProtocolChat = new ProtocolChatModel(NetworkID, chatName, this);
            ProtocolChat.InitMessageBuffer(MessageBufferPersistencyType.Volatile);
            Session.AddChat(Chat);
            Session.SyncChat(Chat);

            try {
                string url;
                if (server.Hostname.StartsWith("http://") ||
                    server.Hostname.StartsWith("https://"))
                {
                    url = server.Hostname;
                }
                else
                {
                    if (server.UseEncryption && server.Port == 443)
                    {
                        url = String.Format("https://{0}", server.Hostname);
                    }
                    else if (server.UseEncryption)
                    {
                        url = String.Format("https://{0}:{1}",
                                            server.Hostname, server.Port);
                    }
                    else if (!server.UseEncryption && server.Port == 80)
                    {
                        url = String.Format("http://{0}", server.Hostname);
                    }
                    else
                    {
                        url = String.Format("http://{0}:{1}",
                                            server.Hostname, server.Port);
                    }
                }
                // HACK: SignalR's ServerSentEventsTransport times out on Mono
                // for some reason and then fallbacks to LongPollingTransport
                // this takes 10 seconds though, so let's go LP directly
                Func <IClientTransport> transport = null;
                if (Type.GetType("Mono.Runtime") == null)
                {
                    transport = () => new AutoTransport(new DefaultHttpClient());
                }
                else
                {
                    transport = () => new LongPollingTransport();
                }
                var authProvider = new DefaultAuthenticationProvider(url);
                Client = new JabbRClient(url, authProvider, transport);
                Client.AutoReconnect      = true;
                Client.MessageReceived   += OnMessageReceived;
                Client.MeMessageReceived += OnMeMessageReceived;
                Client.UserLeft          += OnUserLeft;
                Client.UserJoined        += OnUserJoined;
                Client.JoinedRoom        += OnJoinedRoom;
                Client.PrivateMessage    += OnPrivateMessage;

                Me = CreatePerson(Username);
                Me.IdentityNameColored.ForegroundColor = new TextColor(0, 0, 255);
                Me.IdentityNameColored.BackgroundColor = TextColor.None;
                Me.IdentityNameColored.Bold            = true;

                Connect();
            } catch (Exception ex) {
#if LOG4NET
                Logger.Error(ex);
#endif
                var msg = CreateMessageBuilder().
                          AppendEventPrefix().
                          AppendErrorText(_("Connection failed! Reason: {0}"),
                                          ex.Message).
                          ToMessage();
                Session.AddMessageToChat(ProtocolChat, msg);
            }
        }
Ejemplo n.º 26
0
        protected virtual void CheckProtocolComboBox()
        {
            Trace.Call();

            // HACK: hardcoded default list, not so nice
            // suggest sane port defaults
            // TODO: this should be replaced with some ProtocolInfo class
            // that contains exactly this kind of information
            switch (f_ProtocolComboBox.ActiveText)
            {
            case "IRC":
                ShowHostname         = true;
                ShowNetwork          = true;
                ShowNickname         = true;
                ShowRealname         = true;
                ShowPassword         = true;
                SupportUseEncryption = true;

                f_HostnameEntry.Sensitive        = true;
                f_NetworkComboBoxEntry.Sensitive = true;

                f_PortSpinButton.Value     = 6667;
                f_PortSpinButton.Sensitive = true;
                break;

            case "Facebook":
                ShowHostname           = false;
                ShowNetwork            = false;
                ShowNickname           = false;
                ShowRealname           = false;
                ShowPassword           = true;
                SupportUseEncryption   = true;
                f_HostnameEntry.Text   = "chat.facebook.com";
                f_PortSpinButton.Value = 5222;
                break;

            case "XMPP":
                ShowHostname         = true;
                ShowNetwork          = false;
                ShowNickname         = false;
                ShowRealname         = false;
                ShowPassword         = true;
                SupportUseEncryption = true;

                f_HostnameEntry.Sensitive         = true;
                f_NetworkComboBoxEntry.Entry.Text = String.Empty;
                f_NetworkComboBoxEntry.Sensitive  = false;

                f_PortSpinButton.Value     = 5222;
                f_PortSpinButton.Sensitive = true;
                break;

            // this protocols have static servers
            case "AIM":
            case "ICQ":
            case "MSNP":
                ShowHostname         = false;
                ShowNetwork          = false;
                ShowNickname         = false;
                ShowRealname         = false;
                ShowPassword         = true;
                SupportUseEncryption = false;

                f_HostnameEntry.Text              = String.Empty;
                f_HostnameEntry.Sensitive         = false;
                f_NetworkComboBoxEntry.Entry.Text = String.Empty;
                f_NetworkComboBoxEntry.Sensitive  = false;

                f_PortSpinButton.Value     = 0;
                f_PortSpinButton.Sensitive = false;
                break;

            case "Twitter":
                ShowHostname         = false;
                ShowNetwork          = false;
                ShowNickname         = false;
                ShowRealname         = false;
                ShowPassword         = false;
                SupportUseEncryption = true;
                // engine always uses https
                f_UseEncryptionCheckButton.Active    = true;
                f_UseEncryptionCheckButton.Sensitive = false;

                f_HostnameEntry.Text              = String.Empty;
                f_PortSpinButton.Value            = 443;
                f_PortSpinButton.Sensitive        = false;
                f_NetworkComboBoxEntry.Entry.Text = String.Empty;
                f_PasswordEntry.Text              = String.Empty;
                break;

            case "Campfire":
                ShowHostname         = true;
                ShowNetwork          = false;
                ShowNickname         = false;
                ShowRealname         = false;
                ShowPassword         = true;
                SupportUseEncryption = true;
                // engine always uses https
                f_UseEncryptionCheckButton.Active    = true;
                f_UseEncryptionCheckButton.Sensitive = false;

                f_HostnameEntry.Text              = ".campfirenow.com";
                f_HostnameEntry.Sensitive         = true;
                f_PortSpinButton.Value            = 443;
                f_PortSpinButton.Sensitive        = false;
                f_NetworkComboBoxEntry.Entry.Text = String.Empty;
                f_PasswordEntry.Text              = String.Empty;
                break;

            case "JabbR":
                ShowHostname         = true;
                ShowNetwork          = false;
                ShowNickname         = false;
                ShowRealname         = false;
                ShowPassword         = true;
                SupportUseEncryption = true;

                f_HostnameEntry.Text              = "jabbr.net";
                f_HostnameEntry.Sensitive         = true;
                f_PortSpinButton.Value            = 443;
                f_PortSpinButton.Sensitive        = true;
                f_UseEncryptionCheckButton.Active = true;
                f_NetworkComboBoxEntry.Entry.Text = String.Empty;
                f_PasswordEntry.Text              = String.Empty;
                break;

            case "Slack":
                // https://my.slack.com/account/gateways
                ShowHostname = true;
                // we map the 4rd level domain (foo.irc.slacke.com) to the
                // network name as it is guaranteed to be unique, see
                // CheckHostnameEntry()
                ShowNetwork = false;
                // on Slack the nickname has to match the username
                ShowNickname = false;
                // the realname is ignored by the IRC bridge
                ShowRealname         = false;
                ShowPassword         = true;
                SupportUseEncryption = true;

                // use TLS by default
                f_UseEncryptionCheckButton.Active = true;

                f_HostnameEntry.Text      = ".irc.slack.com";
                f_HostnameEntry.Sensitive = true;

                // Slack only supports 6667 or 6697
                f_PortSpinButton.Sensitive = false;

                f_NetworkComboBoxEntry.Entry.Text = String.Empty;
                f_PasswordEntry.Text = String.Empty;
                break;

            // in case we don't know / handle the protocol here, make
            // sure we grant maximum flexibility for the input
            default:
                ShowHostname         = true;
                ShowNetwork          = true;
                ShowNickname         = true;
                ShowRealname         = true;
                ShowPassword         = true;
                SupportUseEncryption = true;

                f_HostnameEntry.Sensitive                        = true;
                f_PortSpinButton.Sensitive                       = true;
                f_UseEncryptionCheckButton.Sensitive             = true;
                f_ValidateServerCertificateCheckButton.Sensitive = true;
                break;
            }
        }
Ejemplo n.º 27
0
        void OnLoggedOn(IEnumerable <Room> rooms)
        {
            Trace.Call(rooms);

            try {
                foreach (var room in rooms)
                {
                    var  groupChat = (GroupChatModel)GetChat(room.Name, ChatType.Group);
                    bool newChat;
                    if (groupChat == null)
                    {
                        groupChat = new GroupChatModel(room.Name, room.Name, this);
                        groupChat.InitMessageBuffer(MessageBufferPersistencyType.Volatile);
                        newChat = true;
                    }
                    else
                    {
                        groupChat.UnsafePersons.Clear();
                        newChat = false;
                    }

                    var task = Client.GetRoomInfo(room.Name);
                    task.Wait();
                    // check task.Exception
                    var roomInfo = task.Result;
                    groupChat.Topic = CreateMessageBuilder <JabbrMessageBuilder>().
                                      AppendMessage(roomInfo.Topic).
                                      ToMessage();
                    foreach (var user in roomInfo.Users)
                    {
                        groupChat.UnsafePersons.Add(user.Name,
                                                    CreatePerson(user));
                    }
                    // add ourself if needed
                    if (!groupChat.UnsafePersons.ContainsKey(Username))
                    {
                        groupChat.UnsafePersons.Add(Username, Me);
                    }
                    foreach (var msg in roomInfo.RecentMessages)
                    {
                        AddMessage(groupChat, msg);
                    }
                    if (newChat)
                    {
                        Session.AddChat(groupChat);
                    }
                    else
                    {
                        Session.EnableChat(groupChat);
                    }
                    Session.SyncChat(groupChat);
                }
            } catch (Exception ex) {
#if LOG4NET
                Logger.Error(ex);
#endif
                var msg = CreateMessageBuilder().
                          AppendEventPrefix().
                          AppendErrorText(_("Retrieving chat information failed. " +
                                            "Reason: {0}"),
                                          ex.Message).
                          ToMessage();
                Session.AddMessageToChat(ProtocolChat, msg);
            }
        }
Ejemplo n.º 28
0
 public void AddPersonToGroupChat(GroupChatModel cpage, PersonModel user)
 {
     Trace.Call(cpage, user);
 }
Ejemplo n.º 29
0
        public override void Disconnect(FrontendManager fm)
        {
            Trace.Call(fm);

            _JabberClient.Close(false);
        }
Ejemplo n.º 30
0
        void WriteToConfig()
        {
            Trace.Call();

            var conf = Frontend.UserConfig;

            // manually handled widgets
            if (f_ProxySwitch.Active)
            {
                Gtk.TreeIter iter;
                f_ProxyTypeComboBox.GetActiveIter(out iter);
                var proxyType = (ProxyType)f_ProxyTypeComboBox.Model.GetValue(iter, 0);
                conf["Connection/ProxyType"] = proxyType.ToString();
            }
            else
            {
                conf["Connection/ProxyType"] = ProxyType.None.ToString();
            }

            conf["Interface/Notebook/StripColors"]      = !f_ShowColorsCheckButton.Active;
            conf["Interface/Notebook/StripFormattings"] = !f_ShowFormattingsCheckButton.Active;

            if (f_CustomFontRadioButton.Active)
            {
                string fontName = f_FontButton.FontName;
                Pango.FontDescription fontDescription = Pango.FontDescription.FromString(fontName);
                conf["Interface/Chat/FontFamily"] = fontDescription.Family;
                conf["Interface/Chat/FontStyle"]  = fontDescription.Weight + " " + fontDescription.Style;
                conf["Interface/Chat/FontSize"]   = fontDescription.Size / 1024;
            }
            else
            {
                conf["Interface/Chat/FontFamily"] = String.Empty;
                conf["Interface/Chat/FontStyle"]  = String.Empty;
                conf["Interface/Chat/FontSize"]   = 0;
            }

            // mapped widgets
            foreach (var confEntry in ConfigKeyToWidgetNameMap)
            {
                var confKey   = confEntry.Key;
                var confValue = conf[confKey];
                var widgetId  = confEntry.Value;
                var widget    = Builder.GetObject(widgetId);
                if (widget is Gtk.SpinButton)
                {
                    var spinButton = (Gtk.SpinButton)widget;
                    if (confValue is Int32)
                    {
                        conf[confKey] = spinButton.ValueAsInt;
                    }
                }
                else if (widget is Gtk.ColorButton)
                {
                    var colorButton = (Gtk.ColorButton)widget;
                    if (confValue is string)
                    {
                        conf[confKey] = ColorConverter.GetHexCode(colorButton.Color);
                    }
                }
                else if (widget is Gtk.CheckButton)
                {
                    var checkButton = (Gtk.CheckButton)widget;
                    if (confValue is bool)
                    {
                        conf[confKey] = checkButton.Active;
                    }
#if GTK_SHARP_3
                }
                else if (widget is Gtk.Switch)
                {
                    var @switch = (Gtk.Switch)widget;
                    if (confValue is bool)
                    {
                        conf[confKey] = @switch.Active;
                    }
#endif
                }
                else if (widget is Gtk.TextView)
                {
                    var textView = (Gtk.TextView)widget;
                    if (confValue is string[])
                    {
                        conf[confKey] = textView.Buffer.Text.Split('\n');
                    }
                    else
                    {
                        conf[confKey] = textView.Buffer.Text;
                    }
                }
                else if (widget is Gtk.Entry)
                {
                    var entry = (Gtk.Entry)widget;
                    if (confValue is string[])
                    {
                        conf[confKey] = entry.Text.Split('\n');
                    }
                    else
                    {
                        conf[confKey] = entry.Text;
                    }
                }
            }

            // reset colors as there is no distinct key if they are custom or not
            if (f_SystemWideFontColorRadioButton.Active)
            {
                conf["Interface/Chat/ForegroundColor"] = String.Empty;
                conf["Interface/Chat/BackgroundColor"] = String.Empty;
            }

            conf.Save();
        }