예제 #1
0
        public void ApplyConfig(UserConfig userConfig)
        {
            Trace.Call(userConfig);

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

            string modeStr = (string) userConfig["Interface/Notification/NotificationAreaIconMode"];
            f_NotificationAreaIconMode = (NotificationAreaIconMode) Enum.Parse(
                typeof(NotificationAreaIconMode),
                modeStr
            );

            // initialize status icon for the first time
            if (f_NotificationAreaIconMode != NotificationAreaIconMode.Never &&
                f_StatusIcon == null) {
                f_StatusIcon = new Gtk.StatusIcon();
                f_StatusIcon.Pixbuf = new Gdk.Pixbuf(null, "icon.svg");
                f_StatusIcon.Activate += OnStatusIconActivated;
                f_StatusIcon.PopupMenu += OnStatusIconPopupMenu;
                f_StatusIcon.Tooltip = "Smuxi";
            }
            if (f_NotificationAreaIconMode == NotificationAreaIconMode.Never &&
                !f_MainWindow.Visible) {
                // force window unhide as the user would not be able to bring
                // it back without a notification icon!
                f_MainWindow.Visible = true;
            }

            CheckMainWindowState();
        }
예제 #2
0
파일: Notebook.cs 프로젝트: RoninBG/smuxi
        public void ApplyConfig(UserConfig userConfig)
        {
            switch ((string) userConfig["Interface/Notebook/TabPosition"]) {
                case "top":
                    TabPos = Gtk.PositionType.Top;
                    ShowTabs = true;
                    break;
                case "bottom":
                    TabPos = Gtk.PositionType.Bottom;
                    ShowTabs = true;
                    break;
                case "left":
                    TabPos = Gtk.PositionType.Left;
                    ShowTabs = true;
                    break;
                case "right":
                    TabPos = Gtk.PositionType.Right;
                    ShowTabs = true;
                    break;
                case "none":
                    ShowTabs = false;
                    break;
            }

            // TODO: Homogeneous = true;
        }
예제 #3
0
        public override void Load(UserConfig config, string protocol, string id)
        {
            if (config == null) {
                throw new ArgumentNullException("config");
            }
            if (String.IsNullOrEmpty(protocol)) {
                throw new ArgumentNullException("protocol");
            }
            if (String.IsNullOrEmpty(id)) {
                throw new ArgumentNullException("id");
            }
            base.Load(config, protocol, id);

            var obj = config[ConfigKeyPrefix + "PriorityOnline"];
            if (obj != null) {
                Priorities[PresenceStatus.Online] = (int) obj;
            }
            obj = config[ConfigKeyPrefix + "PriorityAway"];
            if (obj != null) {
                Priorities[PresenceStatus.Away] = (int) obj;
            }
            obj = config[ConfigKeyPrefix + "Resource"];
            if (obj != null) {
                Resource = (string) obj;
            }
        }
예제 #4
0
 public override void ApplyConfig(UserConfig config)
 {
     base.ApplyConfig(config);
     if (BackgroundColor.HasValue) _PersonListBox.BackColor = _TopicTextView.BackColor = BackgroundColor.Value;
     if (BackgroundColor.HasValue) _PersonListBox.ForeColor = _TopicTextView.ForeColor = ForegroundColor.Value;
     _PersonListBox.Font = _TopicTextView.Font = Font;
     _PersonListBox.Width = TextRenderer.MeasureText("999999999", Font).Width;
 }
        public MessagePatternListController(UserConfig userConfig)
        {
            if (userConfig == null) {
                throw new ArgumentNullException("userConfig");
            }

            UserConfig = userConfig;
        }
예제 #6
0
        public ServerListController(UserConfig userConfig)
        {
            if (userConfig == null) {
                throw new ArgumentNullException("userConfig");
            }

            _UserConfig = userConfig;
        }
예제 #7
0
파일: JoinWidget.cs 프로젝트: flugsio/smuxi
        public void ApplyConfig(UserConfig config)
        {
            if (config == null) {
                throw new ArgumentNullException("config");
            }

            var servers = new ServerListController(config);
            InitNetworks(servers.GetNetworks());
        }
예제 #8
0
 public virtual void Load(UserConfig config, string id)
 {
     if (config == null) {
         throw new ArgumentNullException("config");
     }
     if (String.IsNullOrEmpty(id)) {
         throw new ArgumentNullException("id");
     }
     Load(config, Protocol, id);
 }
예제 #9
0
        public void ApplyConfig(UserConfig config)
        {
            if (config == null) {
                throw new ArgumentNullException("config");
            }

            CommandCharacter = (string)
                config["Interface/Entry/CommandCharacter"];
            CompletionCharacter = (string)
                config["Interface/Entry/CompletionCharacter"];
            BashStyleCompletion = (bool)
                config["Interface/Entry/BashStyleCompletion"];
            CommandHistorySize = (int)
                config["Interface/Entry/CommandHistorySize"];
        }
예제 #10
0
        public FilterListWidget(Gtk.Window parent, UserConfig userConfig)
        {
            if (parent == null) {
                throw new ArgumentNullException("parent");
            }
            if (userConfig == null) {
                throw new ArgumentNullException("userConfig");
            }

            Build();
            Init();

            f_Parent = parent;
            f_Controller = new FilterListController(userConfig);
        }
예제 #11
0
        public virtual void Load(UserConfig config, int id)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            // don't use ConfigKeyPrefix, so exception guarantees can be kept
            string prefix = "MessagePatterns/" + id + "/";

            if (config[prefix + "MessagePartPattern"] == null)
            {
                // SmartLink does not exist
                throw new ArgumentException("MessagePattern ID not found in config", "id");
            }

            ID = id;
            // now we have a valid ID, ConfigKeyPrefix works
            var messagePartPattern = (string)config[ConfigKeyPrefix + "MessagePartPattern"];

            if (messagePartPattern.StartsWith("/") && messagePartPattern.EndsWith("/i"))
            {
                var regexPattern = messagePartPattern.Substring(1, messagePartPattern.Length - 3);
                MessagePartPattern = new Regex(regexPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            }
            else
            {
                MessagePartPattern = new Regex(messagePartPattern, RegexOptions.Compiled);
            }
            var messagePartType = (string)config[ConfigKeyPrefix + "MessagePartType"];

            switch (messagePartType.ToLower())
            {
            case "url":
                MessagePartType = typeof(UrlMessagePartModel);
                break;

            case "image":
                MessagePartType = typeof(ImageMessagePartModel);
                break;
            }
            LinkFormat = (string)config[ConfigKeyPrefix + "LinkFormat"];
            TextFormat = (string)config[ConfigKeyPrefix + "TextFormat"];
        }
예제 #12
0
        public void ApplyConfig(UserConfig userConfig)
        {
            if (userConfig == null)
            {
                throw new ArgumentNullException("userConfig");
            }

            NickColors       = (bool)userConfig["Interface/Notebook/Channel/NickColors"];
            StripColors      = (bool)userConfig["Interface/Notebook/StripColors"];
            StripFormattings = (bool)userConfig["Interface/Notebook/StripFormattings"];
            HighlightColor   = TextColor.Parse(
                (string)userConfig["Interface/Notebook/Tab/HighlightColor"]
                );
            HighlightWords = new List <string>(
                (string[])userConfig["Interface/Chat/HighlightWords"]
                );
            Emojis = (bool)userConfig["Interface/Chat/Emojis"];

            var patternController = new MessagePatternListController(userConfig);
            var userPatterns      = patternController.GetList();
            var builtinPatterns   = BuiltinPatterns;
            var patterns          = new List <MessagePatternModel>(builtinPatterns.Count +
                                                                   userPatterns.Count);

            // No need to lock BuiltinPatterns as List<T> is thread-safe for
            // multiple readers as long as there is no writer at the same time.
            // BuiltinPatterns is only written once before the first instance
            // of MessageBuilderSettings is created via the static initializer.
            patterns.AddRange(builtinPatterns);
            patterns.AddRange(userPatterns);
            if (Emojis)
            {
                // Emoji
                var regex = new Regex(@":(\w+):", RegexOptions.Compiled);
                patterns.Add(new MessagePatternModel(regex)
                {
                    MessagePartType = typeof(ImageMessagePartModel),
                    LinkFormat      = "smuxi-emoji://{1}",
                });
            }
            Patterns     = patterns;
            UserPatterns = userPatterns;
        }
예제 #13
0
 public virtual void Save(UserConfig config)
 {
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     config[ConfigKeyPrefix + "Hostname"]                  = Hostname;
     config[ConfigKeyPrefix + "Port"]                      = Port;
     config[ConfigKeyPrefix + "Network"]                   = Network;
     config[ConfigKeyPrefix + "Nickname"]                  = Nickname;
     config[ConfigKeyPrefix + "Realname"]                  = Realname;
     config[ConfigKeyPrefix + "Username"]                  = Username;
     config[ConfigKeyPrefix + "Password"]                  = Password;
     config[ConfigKeyPrefix + "UseEncryption"]             = UseEncryption;
     config[ConfigKeyPrefix + "ValidateServerCertificate"] =
         ValidateServerCertificate;
     config[ConfigKeyPrefix + "OnStartupConnect"]  = OnStartupConnect;
     config[ConfigKeyPrefix + "OnConnectCommands"] = OnConnectCommands;
 }
예제 #14
0
파일: ServerModel.cs 프로젝트: kzwkt/smuxi
        public virtual void Load(UserConfig config, string protocol, string id)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (String.IsNullOrEmpty(protocol))
            {
                throw new ArgumentNullException("protocol");
            }
            if (String.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }
            // don't use ConfigKeyPrefix, so exception guarantees can be kept
            string prefix = "Servers/" + protocol + "/" + id + "/";

            if (config[prefix + "Hostname"] == null)
            {
                // server does not exist
                throw new ArgumentException("ServerID not found in config", id);
            }
            ServerID = id;
            Protocol = protocol;
            // now we have a valid ServerID and Protocol, ConfigKeyPrefix works
            Hostname                  = (string)config[ConfigKeyPrefix + "Hostname"];
            Port                      = (int)config[ConfigKeyPrefix + "Port"];
            Network                   = (string)config[ConfigKeyPrefix + "Network"];
            Nickname                  = (string)config[ConfigKeyPrefix + "Nickname"];
            Realname                  = (string)config[ConfigKeyPrefix + "Realname"];
            Username                  = (string)config[ConfigKeyPrefix + "Username"];
            Password                  = (string)config[ConfigKeyPrefix + "Password"];
            UseEncryption             = (bool)config[ConfigKeyPrefix + "UseEncryption"];
            ValidateServerCertificate =
                (bool)config[ConfigKeyPrefix + "ValidateServerCertificate"];
            ClientCertificateFilename = (string)config[ConfigKeyPrefix + "ClientCertificateFilename"];
            if (config[ConfigKeyPrefix + "OnStartupConnect"] != null)
            {
                OnStartupConnect = (bool)config[ConfigKeyPrefix + "OnStartupConnect"];
            }
            OnConnectCommands = config[ConfigKeyPrefix + "OnConnectCommands"] as IList <string>;
        }
예제 #15
0
파일: Notebook.cs 프로젝트: pacificIT/smuxi
 public void ApplyConfig(UserConfig userConfig)
 {
     switch ((string) userConfig["Interface/Notebook/TabPosition"]) {
         case "top":
             Alignment = TabAlignment.Top;
             break;
         case "bottom":
             Alignment = TabAlignment.Bottom;
             break;
         case "left":
             Alignment = TabAlignment.Left;
             break;
         case "right":
             Alignment = TabAlignment.Right;
             break;
         case "none":
             //ShowTabs = false;
             break;
     }
 }
예제 #16
0
파일: ChatModel.cs 프로젝트: shubhtr/smuxi
        public void ApplyConfig(UserConfig config)
        {
            Trace.Call(config);

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

            MessagesSyncCount =
                (int)config["Interface/Notebook/EngineBufferLines"];

            var enumStr = (string)config["MessageBuffer/PersistencyType"];
            MessageBufferPersistencyType persistency;

            try {
                persistency = (MessageBufferPersistencyType)Enum.Parse(
                    typeof(MessageBufferPersistencyType), enumStr, true
                    );
            } catch (ArgumentException ex) {
#if LOG4NET
                _Logger.Error("ApplyConfig(): failed to parse " +
                              "PersistencyType: " + enumStr, ex);
#endif
                persistency = MessageBufferPersistencyType.Volatile;
            }
            InitMessageBuffer(persistency);

            string maxCapacityKey;
            if (persistency == MessageBufferPersistencyType.Volatile)
            {
                maxCapacityKey = "MessageBuffer/Volatile/MaxCapacity";
            }
            else
            {
                maxCapacityKey = "MessageBuffer/Persistent/MaxCapacity";
            }
            MessageBuffer.MaxCapacity = (int)config[maxCapacityKey];
        }
예제 #17
0
        private void ApplyConfig(UserConfig config, ServerModel server)
        {
            if (server.Username.Contains("@"))
            {
                var jid_user = server.Username.Split('@')[0];
                var jid_host = server.Username.Split('@')[1];
                _JabberClient.NetworkHost = server.Hostname;
                _JabberClient.User        = jid_user;
                _JabberClient.Server      = jid_host;
            }
            else
            {
                _JabberClient.Server = server.Hostname;
                _JabberClient.User   = server.Username;
            }
            _JabberClient.Port     = server.Port;
            _JabberClient.Password = server.Password;

            // XMPP specific settings
            if (server is XmppServerModel)
            {
                var xmppServer = (XmppServerModel)server;
                _JabberClient.Resource = xmppServer.Resource;
            }

            // fallback
            if (String.IsNullOrEmpty(_JabberClient.Resource))
            {
                _JabberClient.Resource = "smuxi";
            }

            _JabberClient.OnInvalidCertificate -= ValidateCertificate;

            _JabberClient.AutoStartTLS = server.UseEncryption;
            if (!server.ValidateServerCertificate)
            {
                _JabberClient.OnInvalidCertificate += ValidateCertificate;
            }
        }
예제 #18
0
        public void Remove(int key)
        {
            Trace.Call(key);

            string section = "MessagePatterns/" + key + "/";

            string[] keys = PatternIDs;
            if (keys == null)
            {
                keys = new string[] {};
            }
            var keyList = new List <string>(keys);
            int idx     = keyList.IndexOf(key.ToString());

            if (idx == -1)
            {
                // key not found
                return;
            }
            keyList.RemoveAt(idx);
            UserConfig.Remove(section);
            PatternIDs = keyList.ToArray();
        }
예제 #19
0
        public void ApplyConfig(UserConfig userConfig)
        {
            if (userConfig == null)
            {
                throw new ArgumentNullException("userConfig");
            }

            NickColors       = (bool)userConfig["Interface/Notebook/Channel/NickColors"];
            StripColors      = (bool)userConfig["Interface/Notebook/StripColors"];
            StripFormattings = (bool)userConfig["Interface/Notebook/StripFormattings"];
            HighlightColor   = TextColor.Parse(
                (string)userConfig["Interface/Notebook/Tab/HighlightColor"]
                );
            HighlightWords = new List <string>(
                (string[])userConfig["Interface/Chat/HighlightWords"]
                );

            var patternController = new MessagePatternListController(userConfig);
            var userPatterns      = patternController.GetList();
            var builtinPatterns   = BuiltinPatterns;
            var patterns          = new List <MessagePatternModel>(builtinPatterns.Count +
                                                                   userPatterns.Count);

            // No need to lock BuiltinPatterns as List<T> is thread-safe for
            // multiple readers as long as there is no writer at the same time.
            // BuiltinPatterns is only written once before the first instance
            // of MessageBuilderSettings is created via the static initializer.
            patterns.AddRange(builtinPatterns);
            patterns.AddRange(userPatterns);
            Patterns     = patterns;
            UserPatterns = userPatterns;

            // The Patterns property has to be initialized before we set the
            // Emojis property as it will modify the existing Patterns collection
            Emojis = (bool)userConfig["Interface/Chat/Emojis"];
        }
예제 #20
0
파일: Entry.cs 프로젝트: pacificIT/smuxi
        public virtual void ApplyConfig(UserConfig config)
        {
            Trace.Call(config);

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

            var theme = new ThemeSettings(config);
            if (theme.BackgroundColor == null) {
                ModifyBase(Gtk.StateType.Normal);
            } else {
                ModifyBase(Gtk.StateType.Normal, theme.BackgroundColor.Value);
            }
            if (theme.ForegroundColor == null) {
                ModifyText(Gtk.StateType.Normal);
            } else {
                ModifyText(Gtk.StateType.Normal, theme.ForegroundColor.Value);
            }
            ModifyFont(theme.FontDescription);

            Settings.ApplyConfig(config);

            // replace nick completer if needed
            if (Settings.BashStyleCompletion && !(NickCompleter is LongestPrefixNickCompleter)) {
                NickCompleter = new LongestPrefixNickCompleter();
            } else if (!Settings.BashStyleCompletion && !(NickCompleter is TabCycleNickCompleter)) {
                NickCompleter = new TabCycleNickCompleter();
            }

            // set the completion character
            NickCompleter.CompletionChar = Settings.CompletionCharacter;
        }
예제 #21
0
        public void ApplyConfig(UserConfig config)
        {
            _ThemeSettings = new ThemeSettings(config);
            if (_ThemeSettings.BackgroundColor == null) {
                ModifyBase(Gtk.StateType.Normal);
            } else {
                ModifyBase(Gtk.StateType.Normal, _ThemeSettings.BackgroundColor.Value);
            }
            if (_ThemeSettings.ForegroundColor == null) {
                ModifyText(Gtk.StateType.Normal);
            } else {
                ModifyText(Gtk.StateType.Normal, _ThemeSettings.ForegroundColor.Value);
            }
            ModifyFont(_ThemeSettings.FontDescription);

            string wrapModeStr = (string) config["Interface/Chat/WrapMode"];
            if (!String.IsNullOrEmpty(wrapModeStr)) {
                Gtk.WrapMode wrapMode = (Gtk.WrapMode) Enum.Parse(
                    typeof(Gtk.WrapMode),
                    wrapModeStr
                );
                if (wrapMode == Gtk.WrapMode.Word) {
                    wrapMode = Gtk.WrapMode.WordChar;
                }
                WrapMode = wrapMode;
            }

            _BufferLines = (int) config["Interface/Notebook/BufferLines"];
        }
예제 #22
0
        public ThemeSettings(UserConfig config)
        {
            if (config == null) {
                throw new ArgumentNullException("config");
            }

            string bgStr = (string) config["Interface/Chat/BackgroundColor"];
            if (!String.IsNullOrEmpty(bgStr)) {
                Gdk.Color bgColor = Gdk.Color.Zero;
                if (Gdk.Color.Parse(bgStr, ref bgColor)) {
                    f_BackgroundColor = bgColor;
                }
            } else {
                f_BackgroundColor = null;
            }

            string fgStr = (string) config["Interface/Chat/ForegroundColor"];
            if (!String.IsNullOrEmpty(fgStr)) {
                Gdk.Color fgColor = Gdk.Color.Zero;
                if (Gdk.Color.Parse(fgStr, ref fgColor)) {
                    f_ForegroundColor = fgColor;
                }
            } else {
                f_ForegroundColor = null;
            }

            string colorStr;
            Gdk.Color color;
            colorStr = (string) config["Interface/Notebook/Tab/HighlightColor"];
            color = Gdk.Color.Zero;
            if (Gdk.Color.Parse(colorStr, ref color)) {
                f_HighlightColor = color;
            }

            colorStr = (string) config["Interface/Notebook/Tab/ActivityColor"];
            color = Gdk.Color.Zero;
            if (Gdk.Color.Parse(colorStr, ref color)) {
                f_ActivityColor = color;
            }

            colorStr = (string) config["Interface/Notebook/Tab/NoActivityColor"];
            color = Gdk.Color.Zero;
            if (Gdk.Color.Parse(colorStr, ref color)) {
                f_NoActivityColor = color;
            }

            colorStr = (string) config["Interface/Notebook/Tab/EventColor"];
            color = Gdk.Color.Zero;
            if (Gdk.Color.Parse(colorStr, ref color)) {
                f_EventColor = color;
            }

            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"];
            }
            Pango.FontDescription fontDescription = new Pango.FontDescription();
            if (String.IsNullOrEmpty(fontFamily)) {
                // HACK: use fixed-sys by default if present
                if (File.Exists("Fixedsys500c.ttf")) {
                    fontDescription.Family = "FixedsysTTF, monospace";
                    // fixed-sys only looks good in size 11
                    fontDescription.Size = 11 * 1024;
                    fontDescription.Weight = Pango.Weight.Bold;
                    fontDescription.Style = Pango.Style.Normal;
                } else {
                    // use Monospace and Bold by default
                    fontDescription.Family = "monospace";
                    // black bold font on white background looks odd
                    //fontDescription.Weight = Pango.Weight.Bold;
                }
            } else {
                fontDescription.Family = fontFamily;
                string frontWeigth = null;
                if (fontStyle.Contains(" ")) {
                    int pos = fontStyle.IndexOf(" ");
                    frontWeigth = fontStyle.Substring(0, pos);
                    fontStyle = fontStyle.Substring(pos + 1);
                }
                fontDescription.Style = (Pango.Style) Enum.Parse(typeof(Pango.Style), fontStyle);
                if (frontWeigth != null) {
                    fontDescription.Weight = (Pango.Weight) Enum.Parse(typeof(Pango.Weight), frontWeigth);
                }
                fontDescription.Size = fontSize * 1024;
            }
            f_FontDescription = fontDescription;
        }
예제 #23
0
        public void Save()
        {
            Trace.Call();

            UserConfig.Save();
        }
예제 #24
0
        public virtual void ApplyConfig(UserConfig userConfig)
        {
            if (userConfig == null) {
                throw new ArgumentNullException("userConfig");
            }

            NickColors = (bool) userConfig["Interface/Notebook/Channel/NickColors"];
            StripColors = (bool) userConfig["Interface/Notebook/StripColors"];
            StripFormattings = (bool) userConfig["Interface/Notebook/StripFormattings"];
        }
예제 #25
0
파일: Frontend.cs 프로젝트: knocte/smuxi
        public static void ApplyConfig(UserConfig userConfig)
        {
            Trace.Call(userConfig);

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

            _MainWindow.ApplyConfig(userConfig);
        }
예제 #26
0
파일: ChatView.cs 프로젝트: Jaykul/smuxi
        public virtual void ApplyConfig(UserConfig config)
        {
            Trace.Call(config);

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

            _ThemeSettings = new ThemeSettings(config);

            _OutputMessageTextView.ApplyConfig(config);
        }
예제 #27
0
        private void ApplyConfig(UserConfig config, XmppServerModel server)
        {
            if (server.Username.Contains("@")) {
                var jid_user = server.Username.Split('@')[0];
                var jid_host = server.Username.Split('@')[1];
                JabberClient.NetworkHost = server.Hostname;
                JabberClient.User = jid_user;
                JabberClient.Server = jid_host;
            } else {
                JabberClient.Server = server.Hostname;
                JabberClient.User = server.Username;
            }
            JabberClient.Port = server.Port;
            JabberClient.Password = server.Password;

            Me = CreatePerson(
                String.Format("{0}@{1}",
                    JabberClient.User,
                    JabberClient.Server
                ),
                JabberClient.User
            );
            Me.IdentityNameColored.ForegroundColor = new TextColor(0, 0, 255);
            Me.IdentityNameColored.BackgroundColor = TextColor.None;
            Me.IdentityNameColored.Bold = true;

            // XMPP specific settings
            JabberClient.Resource = server.Resource;

            JabberClient.OnInvalidCertificate -= ValidateCertificate;

            JabberClient.AutoStartTLS = server.UseEncryption;
            if (!server.ValidateServerCertificate) {
                JabberClient.OnInvalidCertificate += ValidateCertificate;
            }

            var proxySettings = new ProxySettings();
            proxySettings.ApplyConfig(Session.UserConfig);
            var protocol = server.UseEncryption ? "xmpps" : "xmpp";
            var serverUri = String.Format("{0}://{1}:{2}", protocol,
                                          server.Hostname, server.Port);
            var proxy = proxySettings.GetWebProxy(serverUri);
            if (proxy == null) {
                JabberClient.Proxy = XmppProxyType.None;
            } else {
                var proxyScheme = proxy.Address.Scheme;
                var xmppProxyType = XmppProxyType.None;
                try {
                    // HACK: map proxy scheme to SmartIrc4net's ProxyType
                    xmppProxyType = (XmppProxyType) Enum.Parse(
                        typeof(XmppProxyType), proxyScheme, true
                    );
                } catch (ArgumentException ex) {
            #if LOG4NET
                    _Logger.Error("ApplyConfig(): Couldn't parse proxy type: " +
                                  proxyScheme, ex);
            #endif
                }
                JabberClient.Proxy = xmppProxyType;
                JabberClient.ProxyHost = proxy.Address.Host;
                JabberClient.ProxyPort = proxy.Address.Port;
                JabberClient.ProxyUsername = proxySettings.ProxyUsername;
                JabberClient.ProxyPassword = proxySettings.ProxyPassword;
            }
        }
예제 #28
0
        public void ApplyConfig(UserConfig config)
        {
            _ThemeSettings = new ThemeSettings(config);
            if (_ThemeSettings.BackgroundColor == null) {
                ModifyBase(Gtk.StateType.Normal);
            } else {
                ModifyBase(Gtk.StateType.Normal, _ThemeSettings.BackgroundColor.Value);
            }
            if (_ThemeSettings.ForegroundColor == null) {
                ModifyText(Gtk.StateType.Normal);
            } else {
                ModifyText(Gtk.StateType.Normal, _ThemeSettings.ForegroundColor.Value);
            }
            ModifyFont(_ThemeSettings.FontDescription);

            string wrapModeStr = (string) config["Interface/Chat/WrapMode"];
            if (!String.IsNullOrEmpty(wrapModeStr)) {
                Gtk.WrapMode wrapMode = (Gtk.WrapMode) Enum.Parse(
                    typeof(Gtk.WrapMode),
                    wrapModeStr
                );
                if (wrapMode == Gtk.WrapMode.Word) {
                    wrapMode = Gtk.WrapMode.WordChar;
                }
                WrapMode = wrapMode;
            }

            _BufferLines = (int) config["Interface/Notebook/BufferLines"];

            #if LOG4NET
            DateTime start = DateTime.UtcNow;
            #endif

            ResizeEmoji();

            #if LOG4NET
            DateTime stop = DateTime.UtcNow;
            double duration = stop.Subtract(start).TotalMilliseconds;
            _Logger.Debug("ApplyConfig(): ResizeEmoji()" +
                " done, took: " + Math.Round(duration) + " ms");
            #endif
        }
예제 #29
0
        public void Clear()
        {
            Trace.Call();

            f_Config = null;
            f_Chats.Clear();
            f_Notebook.RemoveAllPages();
            SyncedChats.Clear();
            SyncManager.Clear();
        }
예제 #30
0
        public virtual void ApplyConfig(UserConfig config)
        {
            Trace.Call(config);

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

            var prefix = "Interface/Notebook/";
            AutoSwitchPersonChats =
                config[prefix + "AutoSwitchPersonChats"] as bool? ?? false;
            AutoSwitchGroupChats =
                config[prefix + "AutoSwitchGroupChats"] as bool? ?? true;

            f_Config = config;
            foreach (ChatView chat in f_Chats) {
                chat.ApplyConfig(f_Config);
            }
        }
예제 #31
0
파일: Engine.cs 프로젝트: shubhtr/smuxi
        public static void Init()
        {
            if (_IsInitialized)
            {
                return;
            }
            _IsInitialized = true;

            var asm = Assembly.GetEntryAssembly();

            if (asm == null)
            {
                asm = Assembly.GetAssembly(typeof(Engine));
            }
            var asm_name = asm.GetName(false);

            var distVersion = Defines.DistVersion;

            if (!String.IsNullOrEmpty(distVersion))
            {
                distVersion = String.Format(" ({0})", distVersion);
            }
            _VersionString = String.Format(
                "{0} {1}{2} - running on {3} {4}",
                Path.GetFileNameWithoutExtension(asm_name.Name),
                AssemblyVersion,
                distVersion,
                Platform.OperatingSystem,
                Platform.Architecture
                );

            _Config = new Config();
            _Config.Load();

            // migration config settins from 1.0 or earlier to 1.1
            if (_Config.PreviousVersion == null ||
                _Config.PreviousVersion < new Version(1, 1))
            {
                // migrate all existing IRC connections for Slack to the
                // SlackProtocolManager
                var users = (string[])_Config["Engine/Users/Users"];
                if (users != null)
                {
                    foreach (var user in users)
                    {
                        var userConfig       = new UserConfig(_Config, user);
                        var serverController = new ServerListController(userConfig);
                        var servers          = serverController.GetServerList();
                        foreach (var server in servers)
                        {
                            if (server.Protocol != "IRC")
                            {
                                continue;
                            }
                            if (!server.Hostname.EndsWith(".irc.slack.com"))
                            {
                                continue;
                            }
#if LOG4NET
                            f_Logger.InfoFormat(
                                "Migrating Slack server '{0}' of user '{1}' " +
                                "from IRC to Slack protocol manager",
                                server,
                                user
                                );
#endif
                            // this is Slack IRC bridge connection
                            var migratedServer = new ServerModel(server);
                            migratedServer.ServerID = null;
                            migratedServer.Protocol = "Slack";
                            serverController.AddServer(migratedServer);
                            // remove old Slack server with IRC as protocol
                            serverController.RemoveServer(server.Protocol,
                                                          server.ServerID);
                        }
                    }
                }
                _Config["Engine/ConfigVersion"] = _Config.CurrentVersion.ToString();
            }

            _Config.Save();

            string location = Path.GetDirectoryName(asm.Location);
            if (String.IsNullOrEmpty(location) &&
                Environment.OSVersion.Platform == PlatformID.Unix)
            {
                // we are mkbundled
                var locationBuilder = new StringBuilder(8192);
                if (Mono.Unix.Native.Syscall.readlink("/proc/self/exe", locationBuilder) >= 0)
                {
                    location = Path.GetDirectoryName(locationBuilder.ToString());
                }
            }
            _ProtocolManagerFactory = new ProtocolManagerFactory();
            _ProtocolManagerFactory.LoadAllProtocolManagers(location);
        }
예제 #32
0
파일: Frontend.cs 프로젝트: knocte/smuxi
        public static void ReconnectEngineToGUI(bool cleanly)
        {
            Trace.Call(cleanly);

            if (_InReconnectHandler) {
            #if LOG4NET
                _Logger.Debug("ReconnectEngineToGUI(): already in reconnect " +
                              "handler, ignoring reconnect...");
            #endif
                return;
            }

            _InReconnectHandler = true;
            var disconnectedEvent = new AutoResetEvent(false);
            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    // delay the disconnect to give the reconnect some extra
                    // time as NetworkManager is not accurate about when the
                    // network is really ready
                    GLib.Timeout.Add(5 * 1000, delegate {
                        Frontend.DisconnectEngineFromGUI(cleanly);
                        disconnectedEvent.Set();
                        return false;
                    });

                    var successful = false;
                    var attempt = 1;
                    while (!successful) {
                        Gtk.Application.Invoke(delegate {
                            MainWindow.NetworkStatus = null;
                            MainWindow.Status = String.Format(
                                _("Reconnecting to engine... (attempt {0})"),
                                attempt++
                            );
                        });
                        try {
                            disconnectedEvent.WaitOne();
                            _MainWindow.EngineManager.Reconnect();
                            successful = true;
                        } catch (Exception ex) {
            #if LOG4NET
                            _Logger.Debug("ReconnectEngineToGUI(): Exception", ex);
            #endif
                            disconnectedEvent.Set();
                            Thread.Sleep(30 * 1000);
                        }
                    }
                    _UserConfig = _MainWindow.EngineManager.UserConfig;
                    EngineAssemblyVersion = _MainWindow.EngineManager.EngineAssemblyVersion;
                    EngineProtocolVersion = _MainWindow.EngineManager.EngineProtocolVersion;
                    Session = _MainWindow.EngineManager.Session;

                    Gtk.Application.Invoke(delegate {
                        Frontend.ConnectEngineToGUI();
                    });
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                } finally {
                    _InReconnectHandler = false;
                }
            });
        }
예제 #33
0
 public virtual void Load(UserConfig config, string protocol, string id)
 {
     if (config == null) {
         throw new ArgumentNullException("config");
     }
     if (String.IsNullOrEmpty(protocol)) {
         throw new ArgumentNullException("protocol");
     }
     if (String.IsNullOrEmpty(id)) {
         throw new ArgumentNullException("id");
     }
     // don't use ConfigKeyPrefix, so exception guarantees can be kept
     string prefix = "Servers/" + protocol + "/" + id + "/";
     if (config[prefix + "Hostname"] == null) {
         // server does not exist
         throw new ArgumentException("ServerID not found in config", id);
     }
     ServerID    = id;
     Protocol    = protocol;
     // now we have a valid ServerID and Protocol, ConfigKeyPrefix works
     Hostname    = (string) config[ConfigKeyPrefix + "Hostname"];
     Port        = (int)    config[ConfigKeyPrefix + "Port"];
     Network     = (string) config[ConfigKeyPrefix + "Network"];
     Username    = (string) config[ConfigKeyPrefix + "Username"];
     Password    = (string) config[ConfigKeyPrefix + "Password"];
     UseEncryption = (bool) config[ConfigKeyPrefix + "UseEncryption"];
     ValidateServerCertificate =
         (bool) config[ConfigKeyPrefix + "ValidateServerCertificate"];
     if (config[ConfigKeyPrefix + "OnStartupConnect"] != null) {
         OnStartupConnect = (bool) config[ConfigKeyPrefix + "OnStartupConnect"];
     }
     OnConnectCommands  = config[ConfigKeyPrefix + "OnConnectCommands"] as IList<string>;
 }
예제 #34
0
 public virtual void Save(UserConfig config)
 {
     if (config == null) {
         throw new ArgumentNullException("config");
     }
     config[ConfigKeyPrefix + "Hostname"] = Hostname;
     config[ConfigKeyPrefix + "Port"]     = Port;
     config[ConfigKeyPrefix + "Network"]  = Network;
     config[ConfigKeyPrefix + "Username"] = Username;
     config[ConfigKeyPrefix + "Password"] = Password;
     config[ConfigKeyPrefix + "UseEncryption"] = UseEncryption;
     config[ConfigKeyPrefix + "ValidateServerCertificate"] =
         ValidateServerCertificate;
     config[ConfigKeyPrefix + "OnStartupConnect"] = OnStartupConnect;
     config[ConfigKeyPrefix + "OnConnectCommands"] = OnConnectCommands;
 }
예제 #35
0
        public void ApplyConfig(UserConfig userConfig)
        {
            if (userConfig == null) {
                throw new ArgumentNullException("userConfig");
            }

            NickColors = (bool) userConfig["Interface/Notebook/Channel/NickColors"];
            StripColors = (bool) userConfig["Interface/Notebook/StripColors"];
            StripFormattings = (bool) userConfig["Interface/Notebook/StripFormattings"];
            HighlightColor = TextColor.Parse(
                (string) userConfig["Interface/Notebook/Tab/HighlightColor"]
            );
            HighlightWords = new List<string>(
                (string[]) userConfig["Interface/Chat/HighlightWords"]
            );

            var patternController = new MessagePatternListController(userConfig);
            var userPatterns = patternController.GetList();
            var builtinPatterns = BuiltinPatterns;
            var patterns = new List<MessagePatternModel>(builtinPatterns.Count +
                                                         userPatterns.Count);
            // No need to lock BuiltinPatterns as List<T> is thread-safe for
            // multiple readers as long as there is no writer at the same time.
            // BuiltinPatterns is only written once before the first instance
            // of MessageBuilderSettings is created via the static initializer.
            patterns.AddRange(builtinPatterns);
            patterns.AddRange(userPatterns);
            Patterns = patterns;
            UserPatterns = userPatterns;
        }
예제 #36
0
파일: Frontend.cs 프로젝트: tuukka/smuxi
 public static void InitLocalEngine()
 {
     Engine.Engine.Init();
     _EngineVersion = Engine.Engine.Version;
     _Session = new Engine.Session(Engine.Engine.Config,
                                   Engine.Engine.ProtocolManagerFactory,
                                   "local");
     _Session.RegisterFrontendUI(_MainWindow.UI);
     _UserConfig = _Session.UserConfig;
     ConnectEngineToGUI();
 }
예제 #37
0
        public override void ApplyConfig(UserConfig config)
        {
            Trace.Call(config);

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

            base.ApplyConfig(config);

            // topic
            _TopicTextView.ApplyConfig(config);
            string topic_pos = (string) config["Interface/Notebook/Channel/TopicPosition"];
            if (_TopicScrolledWindow.IsAncestor(_OutputVBox)) {
                _OutputVBox.Remove(_TopicScrolledWindow);
            }
            if (OutputScrolledWindow.IsAncestor(_OutputVBox)) {
                _OutputVBox.Remove(OutputScrolledWindow);
            }
            if (topic_pos == "top") {
                _OutputVBox.PackStart(_TopicScrolledWindow, false, false, 0);
                _OutputVBox.PackStart(OutputScrolledWindow, true, true, 0);
            } else if  (topic_pos == "bottom") {
                _OutputVBox.PackStart(OutputScrolledWindow, true, true, 0);
                _OutputVBox.PackStart(_TopicScrolledWindow, false, false, 0);
            } else if (topic_pos == "none") {
                _OutputVBox.PackStart(OutputScrolledWindow, true, true, 0);
            } else {
            #if LOG4NET
                _Logger.Error("ApplyConfig(): unsupported value in Interface/Notebook/Channel/TopicPosition: " + topic_pos);
            #endif
            }
            _OutputVBox.ShowAll();

            // person list
            if (ThemeSettings.BackgroundColor == null) {
                _PersonTreeView.ModifyBase(Gtk.StateType.Normal);
            } else {
                _PersonTreeView.ModifyBase(Gtk.StateType.Normal, ThemeSettings.BackgroundColor.Value);
            }
            if (ThemeSettings.ForegroundColor == null) {
                _PersonTreeView.ModifyText(Gtk.StateType.Normal);
            } else {
                _PersonTreeView.ModifyText(Gtk.StateType.Normal, ThemeSettings.ForegroundColor.Value);
            }
            _PersonTreeView.ModifyFont(ThemeSettings.FontDescription);

            string userlist_pos = (string) config["Interface/Notebook/Channel/UserListPosition"];
            if (userlist_pos == "left") {
                userlist_pos = "right";
            }
            if (_PersonTreeViewFrame.IsAncestor(_OutputHPaned)) {
                _OutputHPaned.Remove(_PersonTreeViewFrame);
            }
            if (_OutputVBox.IsAncestor(_OutputHPaned)) {
                _OutputHPaned.Remove(_OutputVBox);
            }
            if (userlist_pos == "left") {
                _OutputHPaned.Pack1(_PersonTreeViewFrame, false, true);
                _OutputHPaned.Pack2(_OutputVBox, true, true);
            } else if (userlist_pos == "right") {
                _OutputHPaned.Pack1(_OutputVBox, true, false);
                _OutputHPaned.Pack2(_PersonTreeViewFrame, false, false);
            } else if (userlist_pos == "none") {
                _OutputHPaned.Pack1(_OutputVBox, true, true);
            } else {
            #if LOG4NET
                _Logger.Error("ApplyConfig(): unsupported value in Interface/Notebook/Channel/UserListPosition: " + userlist_pos);
            #endif
            }
            _OutputHPaned.ShowAll();

            NickColors = (bool) config["Interface/Notebook/Channel/NickColors"];
        }
예제 #38
0
파일: Frontend.cs 프로젝트: knocte/smuxi
 public static void InitLocalEngine()
 {
     if (!Engine.Engine.IsInitialized) {
         // only initialize a local engine once
         Engine.Engine.Init();
         _LocalSession = new Engine.Session(Engine.Engine.Config,
                                            Engine.Engine.ProtocolManagerFactory,
                                            "local");
         _LocalSession.ExecuteOnStartupCommands();
         _LocalSession.ProcessAutoConnect();
     }
     EngineAssemblyVersion = Engine.Engine.AssemblyVersion;
     EngineProtocolVersion = Engine.Engine.ProtocolVersion;
     Session = _LocalSession;
     _UserConfig = _Session.UserConfig;
 }
예제 #39
0
        public void ApplyConfig(UserConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            var proxyType = (string)config["Connection/ProxyType"];

            ProxyType     = (ProxyType)Enum.Parse(typeof(ProxyType), proxyType, true);
            ProxyHostname = (string)config["Connection/ProxyHostname"];
            ProxyPort     = (int)config["Connection/ProxyPort"];
            ProxyUsername = (string)config["Connection/ProxyUsername"];
            ProxyPassword = (string)config["Connection/ProxyPassword"];

            switch (ProxyType)
            {
            case ProxyType.None:
                DefaultWebProxy = null;
                SystemWebProxy  = null;
                break;

            case ProxyType.System:
                // TODO: add GNOME (gconf) support
                var no_proxy = Environment.GetEnvironmentVariable("no_proxy");
                var proxy    = WebRequest.GetSystemWebProxy();
                if (!String.IsNullOrEmpty(no_proxy) && proxy is WebProxy)
                {
                    var webProxy = (WebProxy)proxy;
                    // BypassArrayList expects regexes while no_proxy
                    // contains domains
                    var bypassUriRegexes = new List <string>();
                    foreach (var domain in no_proxy.Split(','))
                    {
                        string domainRegex = null;
                        if (domain.StartsWith("."))
                        {
                            domainRegex = String.Format(
                                @"^[a-z]+://(.+\.)?{0}",
                                Regex.Escape(domain.Substring(1))
                                );
                        }
                        else if (!Regex.IsMatch(domain, @"^[a-z]+://"))
                        {
                            domainRegex = String.Format(
                                @"^[a-z]+://{0}",
                                Regex.Escape(domain)
                                );
                        }
                        else
                        {
                            domainRegex = Regex.Escape(domain);
                        }
                        bypassUriRegexes.Add(domainRegex);
                    }
                    webProxy.BypassArrayList.AddRange(bypassUriRegexes);
                }
                DefaultWebProxy = null;
                SystemWebProxy  = proxy;
                break;

            default:
                var uriBuilder = new UriBuilder();
                uriBuilder.Scheme   = ProxyType.ToString().ToLower();
                uriBuilder.Host     = ProxyHostname;
                uriBuilder.Port     = ProxyPort;
                uriBuilder.UserName = ProxyUsername;
                uriBuilder.Password = ProxyPassword;
                var proxyUri = uriBuilder.ToString();
                DefaultWebProxy = new WebProxy(proxyUri);
                SystemWebProxy  = null;
                break;
            }
        }
예제 #40
0
        public override void ApplyConfig(UserConfig config)
        {
            Trace.Call(config);

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

            base.ApplyConfig(config);

            ProxySettings.ApplyConfig(config);
        }
예제 #41
0
파일: EngineManager.cs 프로젝트: RAOF/smuxi
        public void Connect(string engine)
        {
            Trace.Call(engine);

            if (engine == null) {
                throw new ArgumentNullException("engine");
            }
            if (engine.Length == 0) {
                throw new ArgumentException(_("Engine must not be empty."), "engine");
            }

            bool engineFound = false;
            foreach (var entry in (string[]) f_FrontendConfig["Engines/Engines"]) {
                if (entry == engine) {
                    engineFound = true;
                    break;
                }
            }
            if (!engineFound) {
                throw new ArgumentException(_("Engine does not exist."), "engine");
            }

            f_Engine = engine;
            string username = (string) f_FrontendConfig["Engines/"+engine+"/Username"];
            string password = (string) f_FrontendConfig["Engines/"+engine+"/Password"];
            string hostname = (string) f_FrontendConfig["Engines/"+engine+"/Hostname"];
            string bindAddress = (string) f_FrontendConfig["Engines/"+engine+"/BindAddress"];
            int port = (int) f_FrontendConfig["Engines/"+engine+"/Port"];
            //string formatter = (string) _FrontendConfig["Engines/"+engine+"/Formatter"];
            string channel = (string) f_FrontendConfig["Engines/"+engine+"/Channel"];

            // SSH tunnel support
            bool useSshTunnel = false;
            if (f_FrontendConfig["Engines/"+engine+"/UseSshTunnel"] != null) {
                useSshTunnel = (bool) f_FrontendConfig["Engines/"+engine+"/UseSshTunnel"];
            }
            string sshProgram = (string) f_FrontendConfig["Engines/"+engine+"/SshProgram"];
            string sshParameters = (string) f_FrontendConfig["Engines/"+engine+"/SshParameters"];
            string sshHostname = (string) f_FrontendConfig["Engines/"+engine+"/SshHostname"];
            int sshPort = -1;
            if (f_FrontendConfig["Engines/"+engine+"/SshPort"] != null) {
                sshPort = (int) f_FrontendConfig["Engines/"+engine+"/SshPort"];
            }
            string sshUsername = (string) f_FrontendConfig["Engines/"+engine+"/SshUsername"];
            string sshPassword = (string) f_FrontendConfig["Engines/"+engine+"/SshPassword"];
            var sshKeyfile = (string) f_FrontendConfig["Engines/"+engine+"/SshKeyfile"];

            // OPT: always use SSH compression (both openssh and plink support it)
            // this reduces the .NET remoting traffic by about 75%
            if (String.IsNullOrEmpty(sshParameters) ||
                !sshParameters.Contains(" -C")) {
                sshParameters += " -C";
            }

            int remotingPort = 0;
            if (useSshTunnel) {
                // find free remoting back-channel port
                TcpListener remotingPortListener = new TcpListener(IPAddress.Loopback, 0);
                remotingPortListener.Start();
                remotingPort = ((IPEndPoint)remotingPortListener.LocalEndpoint).Port;

                // find free local forward port
                TcpListener localForwardListener = new TcpListener(IPAddress.Loopback, 0);
                localForwardListener.Start();
                int localForwardPort = ((IPEndPoint)localForwardListener.LocalEndpoint).Port;

                // only stop the listeners after we got all ports we need
                // else it might re-use a port!
                remotingPortListener.Stop();
                localForwardListener.Stop();
            #if LOG4NET
                f_Logger.Debug("Connect(): found free local backward port (for remoting back-channel): " + remotingPort);
                f_Logger.Debug("Connect(): found free local forward port: " + localForwardPort);
            #endif

                // HACK: we can't use localForwardPort here as .NET remoting
                // will announce the server port in the server Session object
                // thus the client will try to reach it using the original
                // server port :(
                f_SshTunnelManager = new SshTunnelManager(
                    sshProgram, sshParameters, sshUsername, sshPassword,
                    sshKeyfile, sshHostname, sshPort,
                    //"127.0.0.1", localForwardPort, "127.0.0.1", port,
                    "127.0.0.1", port, "127.0.0.1", port,
                    "127.0.0.1", remotingPort, "127.0.0.1", remotingPort
                );
                f_SshTunnelManager.Setup();
                f_SshTunnelManager.Connect();

                // so we want to connect via the SSH tunnel now
                hostname = "127.0.0.1";
                // HACK: see above
                //port = localForwardPort;

                // the smuxi-server has to connect to us via the SSH tunnel too
                bindAddress = "127.0.0.1";
            }

            IDictionary props = new Hashtable();
            // ugly remoting expects the port as string ;)
            props["port"] = remotingPort.ToString();
            string connection_url = null;
            SessionManager sessm = null;
            switch (channel) {
                case "TCP":
                    // Make sure the channel is really using our random
                    // remotingPort. Already registered channel will for sure
                    // not to that and thus the back-connection fails!
                    if (f_ChannelName != null) {
                        IChannel oldChannel = ChannelServices.GetChannel(f_ChannelName);
                        if (oldChannel != null) {
            #if LOG4NET
                            f_Logger.Debug("Connect(): found old remoting channel, unregistering...");
            #endif
                            ChannelServices.UnregisterChannel(oldChannel);
                        }
                    }

                    // frontend -> engine
                    BinaryClientFormatterSinkProvider cprovider =
                        new BinaryClientFormatterSinkProvider();

                    // engine -> frontend (back-connection)
                    BinaryServerFormatterSinkProvider sprovider =
                        new BinaryServerFormatterSinkProvider();
                    // required for MS .NET 1.1
                    sprovider.TypeFilterLevel = TypeFilterLevel.Full;

                    if (bindAddress != null) {
                        props["machineName"] = bindAddress;
                    }
                    var tcpChannel = new TcpChannel(props, cprovider, sprovider);
                    f_ChannelName = tcpChannel.ChannelName;
                    ChannelServices.RegisterChannel(tcpChannel, false);

                    // make sure the listen port of channel is ready before we
                    // connect to the engine, as it will make a call back!
                    while (true) {
                        using (TcpClient tcpClient = new TcpClient()) {
                            try {
                                tcpClient.Connect(hostname, port);
            #if LOG4NET
                                f_Logger.Debug("Connect(): listen port of remoting channel is ready");
            #endif
                                break;
                            } catch (SocketException ex) {
            #if LOG4NET
                                f_Logger.Debug("Connect(): listen port of remoting channel is not reading yet, retrying...", ex);
            #endif
                            }
                            System.Threading.Thread.Sleep(1000);
                        }
                    }

                    connection_url = "tcp://"+hostname+":"+port+"/SessionManager";
            #if LOG4NET
                    f_Logger.Info("Connecting to: "+connection_url);
            #endif
                    sessm = (SessionManager)Activator.GetObject(typeof(SessionManager),
                        connection_url);
                    break;
            #if CHANNEL_TCPEX
                case "TcpEx":
                    //props.Remove("port");
                    //props["name"] = "tcpex";
                    connection_url = "tcpex://"+hostname+":"+port+"/SessionManager";
                    if (ChannelServices.GetChannel("ExtendedTcp") == null) {
                        ChannelServices.RegisterChannel(new TcpExChannel(props, null, null));
                    }
            #if LOG4NET
                    _Logger.Info("Connecting to: "+connection_url);
            #endif
                    sessm = (SessionManager)Activator.GetObject(typeof(SessionManager),
                        connection_url);
                    break;
            #endif
            #if CHANNEL_BIRDIRTCP
                case "BirDirTcp":
                    string ip = System.Net.Dns.Resolve(hostname).AddressList[0].ToString();
                    connection_url = "birdirtcp://"+ip+":"+port+"/SessionManager";
                    if (ChannelServices.GetChannel("birdirtcp") == null) {
                        ChannelServices.RegisterChannel(new BidirTcpClientChannel());
                    }
            #if LOG4NET
                    _Logger.Info("Connecting to: "+connection_url);
            #endif
                    sessm = (SessionManager)Activator.GetObject(typeof(SessionManager),
                        connection_url);
                    break;
            #endif
                case "HTTP":
                    connection_url = "http://"+hostname+":"+port+"/SessionManager";
                    if (ChannelServices.GetChannel("http") == null) {
                        ChannelServices.RegisterChannel(new HttpChannel(), false);
                    }
            #if LOG4NET
                    f_Logger.Info("Connecting to: "+connection_url);
            #endif
                    sessm = (SessionManager)Activator.GetObject(typeof(SessionManager),
                        connection_url);
                    break;
                default:
                    throw new ApplicationException(String.Format(
                                    _("Unknown channel ({0}) - "+
                                      "only the following channel types are supported:"),
                                    channel) + " HTTP TCP");
            }
            f_SessionManager = sessm;
            f_EngineUrl = connection_url;

            f_Session = sessm.Register(username, MD5.FromString(password), f_FrontendUI);
            if (f_Session == null) {
                throw new ApplicationException(_("Registration with engine failed!  "+
                               "The username and/or password were wrong - please verify them."));
            }

            f_EngineVersion = sessm.EngineVersion;
            f_UserConfig = new UserConfig(f_Session.Config,
                                         username);
            f_UserConfig.IsCaching = true;
            f_UserConfig.FrontendConfig = f_FrontendConfig;
        }