Exemplo n.º 1
0
        public XmppProtocolManager(Session session)
            : base(session)
        {
            Trace.Call(session);

            JabberClient = new JabberClient();
            JabberClient.Resource = "Smuxi";
            JabberClient.AutoLogin = true;
            JabberClient.AutoPresence = false;
            JabberClient.OnStreamInit += OnStreamInit;
            JabberClient.OnMessage += OnMessage;
            JabberClient.OnConnect += OnConnect;
            JabberClient.OnDisconnect += OnDisconnect;
            JabberClient.OnAuthenticate += OnAuthenticate;
            JabberClient.OnError += OnError;
            JabberClient.OnProtocol += OnProtocol;
            JabberClient.OnWriteText += OnWriteText;
            JabberClient.OnIQ += OnIQ;

            RosterManager = new RosterManager();
            RosterManager.Stream = JabberClient;
            RosterManager.OnRosterItem += OnRosterItem;

            PresenceManager = new PresenceManager();
            PresenceManager.Stream = JabberClient;
            JabberClient.OnPresence += OnPresence;

            ConferenceManager = new ConferenceManager();
            ConferenceManager.Stream = JabberClient;
            ConferenceManager.OnJoin += OnJoin;
            ConferenceManager.OnLeave += OnLeave;
            ConferenceManager.OnParticipantJoin += OnParticipantJoin;
            ConferenceManager.OnParticipantLeave += OnParticipantLeave;
        }
Exemplo n.º 2
0
        public XmppProtocolManager(Session session)
            : base(session)
        {
            Trace.Call(session);

            _JabberClient = new JabberClient();
            _JabberClient.Resource = Engine.VersionString;
            _JabberClient.AutoLogin = true;
            _JabberClient.AutoPresence = false;
            _JabberClient.OnMessage += new MessageHandler(_OnMessage);
            _JabberClient.OnConnect += OnConnect;
            _JabberClient.OnDisconnect += OnDisconnect;
            _JabberClient.OnAuthenticate += OnAuthenticate;
            _JabberClient.OnError += OnError;
            _JabberClient.OnProtocol += OnProtocol;
            _JabberClient.OnWriteText += OnWriteText;

            _RosterManager = new RosterManager();
            _RosterManager.Stream = _JabberClient;

            _ConferenceManager = new ConferenceManager();
            _ConferenceManager.Stream = _JabberClient;
            _ConferenceManager.OnJoin += OnJoin;
            _ConferenceManager.OnLeave += OnLeave;
            _ConferenceManager.OnParticipantJoin += OnParticipantJoin;
            _ConferenceManager.OnParticipantLeave += OnParticipantLeave;
        }
Exemplo n.º 3
0
 public CampfireProtocolManager(Session session)
     : base(session)
 {
     Trace.Call(session);
     RefreshInterval = TimeSpan.FromMinutes(5);
     RoomsUpdated = DateTime.MinValue;
     Users = new Dictionary<int, CampfirePersonModel>();
 }
Exemplo n.º 4
0
 public void FixtureSetUp()
 {
     Engine.Init();
     Session = new Session(Engine.Config,
                           Engine.ProtocolManagerFactory,
                           "local");
     Protocol = new TestProtocolManager(Session);
 }
Exemplo n.º 5
0
        protected ProtocolManagerBase(Session session)
        {
            Trace.Call(session);

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

            _Session = session;
        }
Exemplo n.º 6
0
        public CommandManager(Session session)
        {
            if (session == null) {
                throw new ArgumentNullException("session");
            }

            f_Session = session;

            f_TaskQueue = new TaskQueue("CommandManager");
            f_TaskQueue.ExceptionEvent += OnTaskQueueExceptionEvent;
            f_TaskQueue.AbortedEvent   += OnTaskQueueAbortedEvent;
        }
Exemplo n.º 7
0
        public IProtocolManager CreateProtocolManager(ProtocolManagerInfoModel info, Session session)
        {
            if (info == null) {
                throw new ArgumentNullException("info");
            }
            if (session == null) {
                throw new ArgumentNullException("session");
            }

            Type type = _ProtocolManagerTypes[info];
            return (IProtocolManager) Activator.CreateInstance(type, session);
        }
Exemplo n.º 8
0
        public SessionHookCommand(Session session,
                                  ChatModel chat,
                                  string commandCharacter)
        {
            if (session == null) {
                throw new ArgumentNullException("session");
            }

            Session = session;
            Chat = chat;
            CommandCharacter = commandCharacter;
            CommandName = "Session.Command";
        }
Exemplo n.º 9
0
        public XmppProtocolManager(Session session)
            : base(session)
        {
            Trace.Call(session);

            _JabberClient = new JabberClient();
            _JabberClient.Resource = Engine.VersionString;
            _JabberClient.AutoLogin = true;
            _JabberClient.AutoPresence = true;
            _JabberClient.OnMessage += new MessageHandler(_OnMessage);
            _JabberClient.OnConnect += new StanzaStreamHandler(_OnConnect);
            _JabberClient.OnDisconnect += new bedrock.ObjectHandler(_OnDisconnect);

            _JabberClient.OnReadText += new bedrock.TextHandler(_OnReadText);
            _JabberClient.OnWriteText += new bedrock.TextHandler(_OnWriteText);
        }
Exemplo n.º 10
0
        public XmppProtocolManager(Session session)
            : base(session)
        {
            Trace.Call(session);
            Contacts = new Dictionary<Jid, XmppPersonModel>();
            DiscoCache = new Dictionary<string, DiscoInfo>();

            ShowChatStates = true;
            OpenNewChatOnChatState = true;

            JabberClient = new XmppClientConnection();
            JabberClient.AutoRoster = true;
            JabberClient.AutoPresence = true;
            JabberClient.OnMessage += OnMessage;
            JabberClient.OnClose += OnClose;
            JabberClient.OnLogin += OnLogin;
            JabberClient.OnError += OnError;
            JabberClient.OnStreamError += OnStreamError;
            JabberClient.OnPresence += OnPresence;
            JabberClient.OnRosterItem += OnRosterItem;
            JabberClient.OnReadXml += OnReadXml;
            JabberClient.OnWriteXml += OnWriteXml;
            JabberClient.OnAuthError += OnAuthError;
            JabberClient.SendingServiceUnavailable += OnSendingServiceUnavailable;
            JabberClient.AutoAgents = false; // outdated feature
            JabberClient.EnableCapabilities = true;
            JabberClient.Capabilities.Node = "https://smuxi.im";
            JabberClient.ClientVersion = Engine.VersionString;

            // identify smuxi
            var ident = JabberClient.DiscoInfo.AddIdentity();
            ident.Category = "client";
            ident.Type = "pc";
            ident.Name = Engine.VersionString;

            // add features here (this is just for notification of other clients)
            JabberClient.DiscoInfo.AddFeature().Var = "http://jabber.org/protocol/caps";
            JabberClient.DiscoInfo.AddFeature().Var = "jabber:iq:last";
            JabberClient.DiscoInfo.AddFeature().Var = "http://jabber.org/protocol/muc";
            JabberClient.DiscoInfo.AddFeature().Var = "http://jabber.org/protocol/disco#info";
            JabberClient.DiscoInfo.AddFeature().Var = "http://jabber.org/protocol/xhtml-im";

            Disco = new DiscoManager(JabberClient);
            Disco.AutoAnswerDiscoInfoRequests = true;

            MucManager = new MucManager(JabberClient);
        }
Exemplo n.º 11
0
        public FrontendManager(Session session, IFrontendUI ui)
        {
            Trace.Call(session, ui);

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

            _Session = session;
            _UI = ui;
            f_TaskQueue = new TaskQueue("FrontendManager");
            f_TaskQueue.ExceptionEvent += OnTaskQueueExceptionEvent;
            f_TaskQueue.AbortedEvent   += OnTaskQueueAbortedEvent;

            // register event for config invalidation
            _Session.Config.Changed += _OnConfigChanged;
        }
Exemplo n.º 12
0
        public FrontendManager(Session session, IFrontendUI ui)
        {
            Trace.Call(session, ui);

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

            _Session = session;
            _UI = ui;
            f_TaskQueue = new TaskQueue("FrontendManager");
            f_TaskQueue.ExceptionEvent += OnTaskQueueExceptionEvent;
            f_TaskQueue.AbortedEvent   += OnTaskQueueAbortedEvent;

            // register event for config invalidation
            // BUG: when the frontend disconnects there are dangling methods registered!
            //_Session.Config.Changed += new EventHandler(_OnConfigChanged);
        }
Exemplo n.º 13
0
        public SessionManager(Config config, ProtocolManagerFactory protocolManagerFactory)
        {
            Trace.Call(config, protocolManagerFactory);

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

            _Config = config;
            _ProtocolManagerFactory = protocolManagerFactory;

            EngineAssemblyVersion = Engine.AssemblyVersion;
            EngineProtocolVersion = Engine.ProtocolVersion;

            string[] users = (string[])Engine.Config["Engine/Users/Users"];
            if (users == null) {
                Console.WriteLine("No Engine/Users/*, aborting...\n");
                Environment.Exit(1);
            }
            foreach (string user in users) {
                // skip local session
                if (user == "local") {
                    continue;
                }
            #if LOG4NET
                _Logger.Debug("Creating Session for User "+user);
            #endif
                var session = new Session(_Config, _ProtocolManagerFactory, user);
                session.ExecuteOnStartupCommands();
                session.ProcessAutoConnect();
                _Sessions.Add(user, session);
            }
        }
Exemplo n.º 14
0
        public MsnpProtocolManager(Session session)
            : base(session)
        {
            Trace.Call(session);

            _MsnClient = new Messenger();
            _MsnClient.Credentials.ClientID = "*****@*****.**";
            _MsnClient.Credentials.ClientCode = "Q1P7W2E4J9R8U3S5";

            _MsnClient.NameserverProcessor.ConnectionEstablished += new EventHandler(NameserverProcessor_ConnectionEstablished);
            _MsnClient.NameserverProcessor.ConnectionClosed += new EventHandler(NameserverProcessor_ConnectionClosed);
            _MsnClient.Nameserver.AuthenticationError += new HandlerExceptionEventHandler(_NameServerAuthenticationError);
            _MsnClient.Nameserver.SignedIn += new EventHandler(Nameserver_SignedIn);
            _MsnClient.Nameserver.SignedOff += new SignedOffEventHandler(Nameserver_SignedOff);
            //            _MsnClient.NameserverProcessor.ConnectingException += new ProcessorExceptionEventHandler(NameserverProcessor_ConnectingException);
            //            _MsnClient.Nameserver.ExceptionOccurred += new HandlerExceptionEventHandler(Nameserver_ExceptionOccurred);
            //            _MsnClient.Nameserver.AuthenticationError += new HandlerExceptionEventHandler(Nameserver_AuthenticationError);
            //            _MsnClient.Nameserver.ServerErrorReceived += new ErrorReceivedEventHandler(Nameserver_ServerErrorReceived);
            _MsnClient.ConversationCreated += new ConversationCreatedEventHandler(MsnClient_ConversationCreated);

            //            _Conversation.Switchboard.SessionClosed += new .SBChangedEventHandler(SessionClosed);
            //            _Conversation.Switchboard.ContactJoined += new .ContactChangedEventHandler(ContactJoined);
            //            _Conversation.Switchboard.ContactLeft   += new .ContactChangedEventHandler(ContactLeft);
        }
Exemplo n.º 15
0
        public TwitterProtocolManager(Session session)
            : base(session)
        {
            Trace.Call(session);

            f_FriendsTimelineChat = new GroupChatModel(
                TwitterChatType.FriendsTimeline.ToString(),
                _("Home Timeline"),
                this
            );
            f_GroupChats.Add(f_FriendsTimelineChat);

            f_RepliesChat = new GroupChatModel(
                TwitterChatType.Replies.ToString(),
                _("Replies"),
                this
            );
            f_GroupChats.Add(f_RepliesChat);

            f_DirectMessagesChat = new GroupChatModel(
                TwitterChatType.DirectMessages.ToString(),
                _("Direct Messages"),
                this
            );
            f_GroupChats.Add(f_DirectMessagesChat);
        }
Exemplo n.º 16
0
 public MsnProtocolManager(Session session)
     : base(session)
 {
 }
Exemplo n.º 17
0
 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();
 }
Exemplo n.º 18
0
 public static void DisconnectEngineFromGUI()
 {
     _FrontendManager.IsFrontendDisconnecting = true;
     //_Session.DeregisterFrontendUI(_MainWindow.UI);
     //_MainWindow.Hide();
     //_MainWindow.Notebook.RemoveAllPages();
     _FrontendManager = null;
     _Session = null;
 }
Exemplo n.º 19
0
        public TwitterProtocolManager(Session session)
            : base(session)
        {
            Trace.Call(session);

            f_FriendsTimelineChat = new GroupChatModel(
                TwitterChatType.FriendsTimeline.ToString(),
                _("Home Timeline"),
                this
            );
            f_FriendsTimelineChat.InitMessageBuffer(
                MessageBufferPersistencyType.Volatile
            );
            f_FriendsTimelineChat.ApplyConfig(Session.UserConfig);
            f_GroupChats.Add(f_FriendsTimelineChat);

            f_RepliesChat = new GroupChatModel(
                TwitterChatType.Replies.ToString(),
                _("Replies"),
                this
            );
            f_RepliesChat.InitMessageBuffer(
                MessageBufferPersistencyType.Volatile
            );
            f_RepliesChat.ApplyConfig(Session.UserConfig);
            f_GroupChats.Add(f_RepliesChat);

            f_DirectMessagesChat = new GroupChatModel(
                TwitterChatType.DirectMessages.ToString(),
                _("Direct Messages"),
                this
            );
            f_DirectMessagesChat.InitMessageBuffer(
                MessageBufferPersistencyType.Volatile
            );
            f_DirectMessagesChat.ApplyConfig(Session.UserConfig);
            f_GroupChats.Add(f_DirectMessagesChat);
        }
Exemplo n.º 20
0
 public JabberProtocolManager(Session session)
     : base(session)
 {
 }
Exemplo n.º 21
0
        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;
        }
Exemplo n.º 22
0
        public static void InitRemoteEngine(string engine)
        {
            var manager = new EngineManager(_FrontendConfig,
                                            _MainWindow.UI);
            try {
                try {
                    Console.WriteLine(
                        _("Connecting to remote engine '{0}'..."), engine
                    );
                    manager.Connect(engine);
                    Console.WriteLine(_("Connection established"));
                } catch (Exception ex) {
            #if LOG4NET
                    _Logger.Error(ex);
            #endif
                    Console.WriteLine(
                        _("Connection failed! Error: {1}"),
                        engine,
                        ex.Message
                    );
                    Environment.Exit(1);
                }

                _Session = manager.Session;
                _UserConfig = manager.UserConfig;
                _EngineVersion = manager.EngineVersion;
                ConnectEngineToGUI();
            } catch (Exception ex) {
            #if LOG4NET
                _Logger.Error(ex);
            #endif
                manager.Disconnect();
                throw;
            }
        }
Exemplo n.º 23
0
        public static void Init(string[] args)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";

            if (!(args.Length >= 1)) {
                Console.Error.WriteLine("Usage: smuxi-test.exe profile");
                Environment.Exit(1);
            }

            #if LOG4NET
            _Logger.Info("smuxi-test starting");
            #endif

            _FrontendConfig = new FrontendConfig("Test");
            _FrontendConfig.Load();

            string profile = args[0];
            if (String.IsNullOrEmpty(profile)) {
                Console.Error.WriteLine("profile parameter must not be empty!");
                Environment.Exit(1);
            }

            IFrontendUI ui = new TestUI();

            Session session = null;
            if (profile == "local") {
                Engine.Engine.Init();
                session = new Engine.Session(Engine.Engine.Config,
                                             Engine.Engine.ProtocolManagerFactory,
                                             "local");
                session.RegisterFrontendUI(ui);
            } else {
                // remote engine
                EngineManager engineManager = new EngineManager(_FrontendConfig, ui);
                engineManager.Connect(profile);
                session = engineManager.Session;
            }

            if (session == null) {
                Console.Error.WriteLine("Session is null, something went wrong setting up or connecting to the engine!");
                Environment.Exit(1);
            }

            _Session = session;
            _UserConfig = session.UserConfig;
            _FrontendManager = session.GetFrontendManager(ui);
            _FrontendManager.Sync();

            if (_UserConfig.IsCaching) {
                // when our UserConfig is cached, we need to invalidate the cache
                _FrontendManager.ConfigChangedDelegate = new SimpleDelegate(_UserConfig.ClearCache);
            }

            while (true) {
                string line = Console.ReadLine();
                // TODO: remove the entered line from output
                //Console.WriteLine(Escape+"M");

                _ExecuteCommand(line);
            }
        }
Exemplo n.º 24
0
        public IrcProtocolManager(Session session)
            : base(session)
        {
            Trace.Call(session);

            _IrcClient = new IrcFeatures();
            _IrcClient.AutoRetry = true;
            // keep retrying to connect forever
            _IrcClient.AutoRetryLimit = 0;
            _IrcClient.AutoRetryDelay = 120;
            _IrcClient.AutoReconnect = true;
            _IrcClient.AutoRelogin = true;
            _IrcClient.AutoRejoin = true;
            // HACK: SmartIrc4net <= 0.4.5.1 is not resetting the nickname list
            // after disconnect. This causes random nicks to be used when there
            // are many reconnects like when the network connection goes flaky,
            // see: http://projects.qnetp.net/issues/show/163
            _IrcClient.AutoNickHandling = false;
            _IrcClient.ActiveChannelSyncing = true;
            _IrcClient.CtcpVersion      = Engine.VersionString;
            _IrcClient.SendDelay        = 250;
            _IrcClient.OnRawMessage     += new IrcEventHandler(_OnRawMessage);
            _IrcClient.OnChannelMessage += new IrcEventHandler(_OnChannelMessage);
            _IrcClient.OnChannelAction  += new ActionEventHandler(_OnChannelAction);
            _IrcClient.OnChannelNotice  += new IrcEventHandler(_OnChannelNotice);
            _IrcClient.OnChannelActiveSynced += new IrcEventHandler(_OnChannelActiveSynced);
            _IrcClient.OnQueryMessage   += new IrcEventHandler(_OnQueryMessage);
            _IrcClient.OnQueryAction    += new ActionEventHandler(_OnQueryAction);
            _IrcClient.OnQueryNotice    += new IrcEventHandler(_OnQueryNotice);
            _IrcClient.OnJoin           += new JoinEventHandler(_OnJoin);
            _IrcClient.OnNames          += new NamesEventHandler(_OnNames);
            _IrcClient.OnPart           += new PartEventHandler(_OnPart);
            _IrcClient.OnKick           += new KickEventHandler(_OnKick);
            _IrcClient.OnNickChange     += new NickChangeEventHandler(_OnNickChange);
            _IrcClient.OnOp             += new OpEventHandler(_OnOp);
            _IrcClient.OnDeop           += new DeopEventHandler(_OnDeop);
            _IrcClient.OnVoice          += new VoiceEventHandler(_OnVoice);
            _IrcClient.OnDevoice        += new DevoiceEventHandler(_OnDevoice);
            _IrcClient.OnModeChange     += new IrcEventHandler(_OnModeChange);
            _IrcClient.OnTopic          += new TopicEventHandler(_OnTopic);
            _IrcClient.OnTopicChange    += new TopicChangeEventHandler(_OnTopicChange);
            _IrcClient.OnQuit           += new QuitEventHandler(_OnQuit);
            _IrcClient.OnRegistered     += new EventHandler(_OnRegistered);
            _IrcClient.OnDisconnected   += new EventHandler(_OnDisconnected);
            _IrcClient.OnAutoConnectError += OnAutoConnectError;
            _IrcClient.OnAway           += new AwayEventHandler(_OnAway);
            _IrcClient.OnUnAway         += new IrcEventHandler(_OnUnAway);
            _IrcClient.OnNowAway        += new IrcEventHandler(_OnNowAway);
            _IrcClient.OnCtcpRequest    += new CtcpEventHandler(_OnCtcpRequest);
            _IrcClient.OnCtcpReply      += new CtcpEventHandler(_OnCtcpReply);
            _IrcClient.OnWho            += OnWho;
            _IrcClient.OnInvite         += OnInvite;
            _IrcClient.OnReadLine       += OnReadLine;
            _IrcClient.OnWriteLine      += OnWriteLine;

            _IrcClient.CtcpUserInfo = (string) Session.UserConfig["Connection/Realname"];
            // disabled as we don't use / support DCC yet
            _IrcClient.CtcpDelegates.Remove("dcc");
            // finger we handle ourself, no little helga here!
            _IrcClient.CtcpDelegates["finger"] = delegate(CtcpEventArgs e) {
                _IrcClient.SendMessage(
                    SendType.CtcpReply, e.Data.Nick,
                    String.Format("{0} {1}",
                        e.CtcpCommand,
                        _IrcClient.CtcpUserInfo
                    )
                );
            };
            // time we handle ourself
            _IrcClient.CtcpDelegates["time"] = delegate(CtcpEventArgs e) {
                _IrcClient.SendMessage(
                    SendType.CtcpReply, e.Data.Nick,
                    String.Format("{0} {1}",
                        e.CtcpCommand,
                        DateTime.Now.ToString(
                            "ddd MMM dd HH:mm:ss yyyy",
                            DateTimeFormatInfo.InvariantInfo
                        )
                    )
                );
            };
        }
Exemplo n.º 25
0
 public static void InitLocalEngine()
 {
     Engine.Engine.Init();
     _LocalSession = new Engine.Session(Engine.Engine.Config,
                                  Engine.Engine.ProtocolManagerFactory,
                                  "local");
     Session = _LocalSession;
     Session.ExecuteOnStartupCommands();
     Session.ProcessAutoConnect();
     Session.RegisterFrontendUI(_MainWindow.UI);
     _UserConfig = Session.UserConfig;
     ConnectEngineToGUI();
 }
Exemplo n.º 26
0
 public FacebookProtocolManager(Session session)
     : base(session)
 {
     Trace.Call(session);
 }
Exemplo n.º 27
0
 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");
     }
     _EngineVersion = Engine.Engine.Version;
     Session = _LocalSession;
     _UserConfig = _Session.UserConfig;
 }
Exemplo n.º 28
0
 public JabbrProtocolManager(Session session)
     : base(session)
 {
     Trace.Call(session);
 }
Exemplo n.º 29
0
 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;
 }
Exemplo n.º 30
0
 public TestProtocolManager(Session session)
     : base(session)
 {
 }