/// <summary>
    /// Saves the game.
    /// </summary>
    public void SaveGame()
    {
        var save = new SaveGame();

        if (HeroManager != null)
        {
            HeroManager.Save(ref save);
        }
        if (AbilityManager != null)
        {
            AbilityManager.Save(ref save);
        }
        if (RosterManager != null)
        {
            RosterManager.Save(ref save);
        }
        if (InventoryManager != null)
        {
            InventoryManager.Save(ref save);
        }
        if (WorldManager != null)
        {
            WorldManager.Save(ref save);
        }
        save.LastRewardTime = lastRewardTime;
        save.IsFilled       = true;

        SaveGameManager.SaveGame(save);
    }
Example #2
0
 public void RemoveFriend(NewUser user)
 {
     Xmpp.PresenceManager.Unsubscribe(user.User);
     RosterManager.RemoveRosterItem(user.User);
     Friends.Remove(user);
     OnDataRecieved.Invoke(this, DataRecType.FriendList, this);
 }
        public void TestAdd()
        {
            RosterManager rm = new RosterManager();

            RosterIQ riq = new RosterIQ(doc);

            riq.Type = IQType.set;
            Roster r = riq.Instruction;
            Item   i = r.AddItem();

            i.JID          = new JID("foo", "bar", null);
            i.Nickname     = "FOO";
            i.Subscription = Subscription.both;

            rm.AddRoster(riq);
            Assert.AreEqual(Subscription.both, rm["foo@bar"].Subscription);
            Assert.AreEqual("FOO", rm["foo@bar"].Nickname);

            riq            = new RosterIQ(doc);
            riq.Type       = IQType.set;
            r              = riq.Instruction;
            i              = r.AddItem();
            i.JID          = new JID("foo", "bar", null);
            i.Nickname     = "BAR";
            i.Subscription = Subscription.to;
            rm.AddRoster(riq);
            Assert.AreEqual(Subscription.to, rm["foo@bar"].Subscription);
            Assert.AreEqual("BAR", rm["foo@bar"].Nickname);
        }
Example #4
0
        public XmppProtocolManager(Session session) : base(session)
        {
            Trace.Call(session);

            _JabberClient                 = new JabberClient();
            _JabberClient.Resource        = Engine.VersionString;
            _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;

            _ConferenceManager                     = new ConferenceManager();
            _ConferenceManager.Stream              = _JabberClient;
            _ConferenceManager.OnJoin             += OnJoin;
            _ConferenceManager.OnLeave            += OnLeave;
            _ConferenceManager.OnParticipantJoin  += OnParticipantJoin;
            _ConferenceManager.OnParticipantLeave += OnParticipantLeave;
        }
Example #5
0
        void XmppClient_OnRosterEnd(object sender, Matrix.EventArgs e)
        {
            Log.Debug("XmppClient_OnRosterEnd");

            this.presenceManager               = new PresenceManager(this.xmppClient);
            this.presenceManager.OnSubscribe  += PresenceManager_OnSubscribe;
            this.presenceManager.OnSubscribed += PresenceManager_OnSubscribed;

            this.rosterManager = new RosterManager(this.xmppClient);

            this.mucManager           = new MucManager(this.xmppClient);
            this.mucManager.OnInvite += MucManager_OnInvite;

            this.pubsubManager          = new PubSubManager(this.xmppClient);
            this.pubsubManager.OnEvent += PubsubManager_OnEvent;
            this.pubsubManager.Subscribe(_pubsubServer, "urn:xmpp:openpgp:0", this._jid);

            this.discoManager = new DiscoManager(this.xmppClient);

            this.openPGP = new OpenPGP(this, this._jid);

            if (this.OnConnected != null)
            {
                this.OnConnected(this, e);
            }
        }
Example #6
0
 public RibbonForm()
 {
     InitializeComponent();
     panelControl.Visible  = false;
     progressPanel.Visible = false;
     _connection           = new XmppClientConnection {
         SocketConnectionType = SocketConnectionType.Direct
     };
     _connection.OnReadXml     += _connection_OnReadXml;
     _connection.OnWriteXml    += _connection_OnWriteXml;
     _connection.OnRosterStart += _connection_OnRosterStart;
     _connection.OnRosterEnd   += _connection_OnRosterEnd;
     _connection.OnRosterItem  += _connection_OnRosterItem;
     _connection.OnLogin       += _connection_OnLogin;
     _connection.OnClose       += _connection_OnClose;
     _connection.OnError       += _connection_OnError;
     _connection.OnPresence    += _connection_OnPresence;
     _connection.OnMessage     += _connection_OnMessage;
     _connection.OnIq          += _connection_OnIq;
     _connection.OnAuthError   += _connection_OnAuthError;
     _connection.OnSocketError += _connection_OnSocketError;
     _connection.OnStreamError += _connection_OnStreamError;
     _discoManager              = new DiscoManager(_connection);
     _rosterManager             = new RosterManager(_connection);
     _formDebug = new XtraFormDebug();
 }
Example #7
0
 private void InitializeJabberClient()
 {
     try {
         _jabberClient                      = new JabberClient();
         _jabberClient.OnMessage           += JabberClientOnMessage;
         _jabberClient.OnDisconnect        += JabberClientOnDisconnect;
         _jabberClient.OnError             += JabberClientOnError;
         _jabberClient.OnAuthError         += JabberClientOnAuthError;
         _jabberClient.OnPresence          += OnPresence;
         _jabberClient.AutoStartCompression = true;
         _jabberClient.AutoStartTLS         = false;
         _jabberClient.AutoStartCompression = true;
         _jabberClient.PlaintextAuth        = true;
         _jabberClient.RequiresSASL         = true;
         _jabberClient.LocalCertificate     = null;
         _jabberClient.AutoPresence         = true;
         _jabberClient.AutoRoster           = true;
         _jabberClient.AutoReconnect        = -1f;
         var manager = new RosterManager {
             Stream        = _jabberClient,
             AutoSubscribe = true,
             AutoAllow     = AutoSubscriptionHanding.AllowAll
         };
         manager.OnRosterBegin        += RosterManagerOnRosterBegin;
         manager.OnRosterEnd          += RosterManagerOnRosterEnd;
         manager.OnRosterItem         += RosterManagerOnRosterItem;
         _jabberClient.OnAuthenticate += JabberClientOnAuthenticate;
     }
     catch (Exception exception) {
         _log.Error(exception);
     }
 }
Example #8
0
        /// <summary>Signin button</summary>
        private void btnSignin_Click(object sender, EventArgs e)
        {
            panelCredentials.Enabled = false;

            JID jid = new JID(txtUserName.Text);

            if (String.IsNullOrEmpty(jid.User))
            {
                jabberClient.User   = txtUserName.Text;
                jabberClient.Server = cbServer.Text.Equals(DEFAULT_SERVER) ? "gmail.com" : cbServer.Text;
            }
            else
            {
                jabberClient.User   = jid.User;
                jabberClient.Server = jid.Server;
            }
            jabberClient.NetworkHost  = cbServer.Text;
            jabberClient.Password     = txtPassword.Text;
            jabberClient.AutoRoster   = true;
            jabberClient.AutoStartTLS = true;
            jabberClient.AutoPresence = true;
            jabberClient.AutoLogin    = true;
            jabberClient.Resource     = "realjabber";
            //jabberClient.PlaintextAuth = true;
            jabberClient.OnAuthenticate       += new bedrock.ObjectHandler(jabberClient_OnAuthenticate);
            jabberClient.OnInvalidCertificate += new System.Net.Security.RemoteCertificateValidationCallback(jabberClient_OnInvalidCertificate);
            jabberClient.AddNamespace("rtt", RealTimeTextUtil.RealTimeText.NAMESPACE);
            jabberClient.OnIQ += new IQHandler(jabberClient_OnIQ);

            rosterMgr                   = new RosterManager();
            rosterMgr.Stream            = jabberClient;
            rosterMgr.AutoSubscribe     = true;
            rosterMgr.AutoAllow         = jabber.client.AutoSubscriptionHanding.AllowAll;
            rosterMgr.OnRosterBegin    += new bedrock.ObjectHandler(RosterMgr_OnRosterBegin);
            rosterMgr.OnRosterEnd      += new bedrock.ObjectHandler(RosterMgr_OnRosterEnd);
            rosterMgr.OnRosterItem     += new RosterItemHandler(RosterMgr_OnRosterItem);
            rosterMgr.OnSubscription   += new SubscriptionHandler(rosterMgr_OnSubscription);
            rosterMgr.OnUnsubscription += new UnsubscriptionHandler(rosterMgr_OnUnsubscription);

            discoMgr        = new DiscoManager();
            discoMgr.Stream = jabberClient;

            capsMgr = new CapsManager();
            capsMgr.DiscoManager = discoMgr;
            capsMgr.AddFeature(RealTimeTextUtil.RealTimeText.NAMESPACE);
            capsMgr.Node   = RealTimeTextUtil.RealTimeText.NAMESPACE;
            capsMgr.Stream = jabberClient;

            presenceMgr             = new PresenceManager();
            presenceMgr.Stream      = jabberClient;
            presenceMgr.CapsManager = capsMgr;

            rosterTree.RosterManager   = rosterMgr;
            rosterTree.PresenceManager = presenceMgr;
            rosterTree.DoubleClick    += new EventHandler(rosterTree_DoubleClick);

            lblUser.Text = jabberClient.User;
            jabberClient.Connect();
        }
Example #9
0
        /// <summary>Call after display of buddy list finished</summary>
        void RosterMgr_OnRosterEnd(object sender)
        {
            RosterManager rm1 = (RosterManager)sender;

            done.Set();
            rosterTree.EndUpdate();
            jabberClient.Presence(jabber.protocol.client.PresenceType.available, txtStatus.Text, null, 0);
            lblPresence.Text = "Available";
            rosterTree.ExpandAll();
        }
Example #10
0
 private void deleteToolStripMenuItem_Click(object sender, System.EventArgs e)
 {
     if (listContacts.SelectedItems.Count > 0)
     {
         var item = listContacts.SelectedItems[0];
         var rm   = new RosterManager(xmppClient);
         Jid jid  = item.Name;
         rm.Remove(jid);
     }
 }
Example #11
0
 public XmppClient(JID jid, string password, bool autoPresence = true)
     : base(Namespaces.JabberClient, jid, password)
 {
     SignedIn += (sender, args) =>
     {
         if (autoPresence)
         {
             Send(new XMPPPresence());
         }
     };
     BookmarkManager = new BookmarksManager(this, autoPresence);
     RosterManager   = new RosterManager(this, autoPresence);
 }
Example #12
0
        public void Connect(string user, string password)
        {
            Disconnect();
            _jc = new JabberClient();

            _jc.AutoReconnect = _reconnect;
            _user             = new JID(user + "@" + _serverName);
            _jc.User          = _user.User;
            _jc.Server        = _user.Server;
            _jc.NetworkHost   = _networkHost;
            _jc.Port          = _port;
            _jc.Resource      = _resource;
            _jc.Password      = password;
            _jc.AutoStartTLS  = _TLS;
            _jc.AutoPresence  = _initialPresence;
            _jc.AutoRoster    = _autoRoster;
            _jc.AutoLogin     = _loging;

            if (!string.IsNullOrEmpty(_certificateFile))
            {
                _jc.SetCertificateFile(_certificateFile, _certificatePass);
                Console.WriteLine(_jc.LocalCertificate.ToString(true));
            }

            if (!string.IsNullOrEmpty(_boshURL))
            {
                _jc[Options.POLL_URL]        = _boshURL;
                _jc[Options.CONNECTION_TYPE] = ConnectionType.HTTP_Binding;
            }

            if (_register)
            {
                _jc.AutoLogin = false;
                _register     = false;
            }

            _conference        = new ConferenceManager();
            _conference.Stream = _jc;

            _roster               = new RosterManager();
            _roster.AutoAllow     = jabber.client.AutoSubscriptionHanding.AllowIfSubscribed;
            _roster.AutoSubscribe = true;
            _roster.Stream        = _jc;

            _disco        = new DiscoManager();
            _disco.Stream = _jc;

            Subscribe();

            _jc.Connect();
        }
    /// <summary>
    /// Initialize world entity managers.
    /// </summary>
    protected void InitializeWorldEntityManagers()
    {
        SaveGame save = null;

        if (SaveGameManager.SaveGameExists)
        {
            save = SaveGameManager.LoadGame();
        }

        heroManager      = HeroManager.Load(save);
        abilityManager   = new AbilityManager(save);
        rosterManager    = new RosterManager(save);
        inventoryManager = new InventoryManager(save);
    }
Example #14
0
        public ClientConnection(INotificationQueue notificationQueue, Client client)
        {
            _client            = client;
            _notificationQueue = notificationQueue;

            _rosterManager = new RosterManager(_connection);

            SubscribeToEvents();

            SetAuthorizationProvider();
            SetRosterObsererver();
            SetPresenceObserver();

            HandleClientChanges();
        }
        /// <summary>
        /// This class should be created and passed into Application.Run( ... )
        /// </summary>
        /// <param name="options"> </param>
        public GwupeClientAppContext(List <GwupeOption> options)
        {
            CurrentAppContext = this;
            Options           = options;
            XmlConfigurator.Configure(Assembly.GetExecutingAssembly().GetManifestResourceStream("Gwupe.Agent.log4net.xml"));
            StartupVersion = Regex.Replace(FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion, "\\.[0-9]+$", "");
            Logger.Info("Gwupe" + Program.BuildMarker + ".Agent Starting up [" + StartupVersion + "]");
#if DEBUG
            foreach (var manifestResourceName in Assembly.GetExecutingAssembly().GetManifestResourceNames())
            {
                Logger.Debug("Embedded Resource : " + manifestResourceName);
            }
#endif
            GwupeServiceProxy   = new GwupeServiceProxy();
            ConnectionManager   = new ConnectionManager();
            LoginManager        = new LoginManager();
            P2PManager          = new P2PManager();
            RosterManager       = new RosterManager();
            EngagementManager   = new EngagementManager();
            NotificationManager = new NotificationManager();
            SearchManager       = new SearchManager();
            CurrentUserManager  = new CurrentUserManager();
            TeamManager         = new TeamManager();
            SettingsManager     = new SettingsManager();
            UIManager           = new UIManager();
            _requestManager     = new RequestManager();
            ScheduleManager     = new ScheduleManager();
            ScheduleManager.AddTask(new CheckUpgradeTask(this)
            {
                PeriodSeconds = 120
            });
            ScheduleManager.AddTask(new CheckServiceTask(this)
            {
                PeriodSeconds = 120
            });
            ScheduleManager.AddTask(new DetectIdleTask(this));
            RepeaterManager     = new RepeaterManager();
            RelationshipManager = new RelationshipManager();
            PartyManager        = new PartyManager();
            SetupChangeLog();
            // Start all the Active Managers
            UIManager.Start();
            ScheduleManager.Start();
            ConnectionManager.Start();
            LoginManager.Start();
            // Set correct last version
            Reg.LastVersion = StartupVersion;
        }
Example #16
0
        private void addToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            var input = new FrmAddUser(_dictContactGroups, true, xmppClient);

            if (input.ShowDialog() == DialogResult.OK)
            {
                _dictContactGroups = input.DictContactGroups;
                var rm  = new RosterManager(xmppClient);
                Jid jid = input.Address;
                rm.Add(jid, input.Name, input.Group);

                var    pm     = new PresenceManager(xmppClient);
                string reason = input.Message;
                pm.Subscribe(jid, reason, input.Name);
            }
        }
Example #17
0
    // Add contact to contact list
    void AddNewContact()
    {
        var rm  = new RosterManager(xmppClient);
        var pm  = new PresenceManager(xmppClient);
        Jid jid = ReceiverName.text;

        if (string.IsNullOrEmpty(NickName.text))
        {
            rm.Add(jid, ReceiverName.text);
        }
        else
        {
            rm.Add(jid, NickName.text);
        }
        pm.Subscribe(jid);
    }
Example #18
0
        public void Remove(string jid)
        {
            RosterManager rm = new RosterManager(this.xmppClient);

            rm.Remove(jid);
            return;

            /*
             * pubsubManager.Unsubscribe("", "urn:xmpp:openpgp:0", jid, delegate {
             * presenceManager.Unsubscribe(jid);
             *
             * RosterManager rm = new RosterManager(this.xmppClient);
             * rm.Remove(jid);
             * });
             */
        }
Example #19
0
 private void editToolStripMenuItem_Click(object sender, System.EventArgs e)
 {
     if (listContacts.SelectedItems.Count > 0)
     {
         var item  = listContacts.SelectedItems[0];
         var input = new FrmAddUser(_dictContactGroups, false, xmppClient);
         input.Name    = item.Text;
         input.Address = item.Name;
         input.Group   = item.Group.Header;
         if (input.ShowDialog() == DialogResult.OK)
         {
             var rm  = new RosterManager(xmppClient);
             Jid jid = input.Address;
             rm.Update(jid, input.Name, input.Group);
         }
     }
 }
        public void TestNumeric()
        {
            RosterManager rm = new RosterManager();

            RosterIQ riq = new RosterIQ(doc);

            riq.Type = IQType.set;
            Roster r = riq.Instruction;
            Item   i = r.AddItem();

            i.JID          = new JID("support", "conference.192.168.32.109", null);
            i.Nickname     = "FOO";
            i.Subscription = Subscription.both;

            rm.AddRoster(riq);
            Assert.AreEqual(Subscription.both, rm["[email protected]"].Subscription);
            Assert.AreEqual("FOO", rm["[email protected]"].Nickname);
        }
Example #21
0
        public static XmppClient InitXmppClient(string userName, string passWord, string domain, string server)
        {
            StaticClass2.xmppClient          = new XmppClient(userName, domain, passWord);
            StaticClass2.xmppClient.Hostname = server;

            //StaticClass.xmppClient.Open();

            StaticClass2.pm = new PresenceManager(xmppClient);
            StaticClass2.rm = new RosterManager(xmppClient);

            StaticClass2.muc = new MucManager(xmppClient);

            StaticClass2.fm = new FileTransferManager();
            //StaticClass.fm.OnProgress += Fm_OnProgress;
            //StaticClass.fm.OnEnd += Fm_OnEnd;

            return(StaticClass2.xmppClient);
        }
Example #22
0
        static XmppGlobal()
        {
            jabber_client = new JabberClient();

            roster_manager        = new RosterManager();
            roster_manager.Stream = jabber_client;

            presence_manager        = new PresenceManager();
            presence_manager.Stream = jabber_client;

            iq_tracker = new IQTracker(jabber_client);

            connection  = new Connection();
            debug       = new Debug();
            disco       = new Disco();
            presence    = new Presence();
            roster      = new Roster();
            queries     = new Queries();
            query_cache = new QueryCache();
            messaging   = new Messaging();
        }
Example #23
0
        internal static void ChatClientConnect(object sender)
        {
            Groups.Add(new Group("Online"));

            //Get all groups
            RosterManager manager       = sender as RosterManager;
            string        ParseString   = manager.ToString();
            List <string> StringHackOne = new List <string>(ParseString.Split(new string[] { "@pvp.net=" }, StringSplitOptions.None));

            StringHackOne.RemoveAt(0);
            foreach (string StringHack in StringHackOne)
            {
                string[] StringHackTwo = StringHack.Split(',');
                string   Parse         = StringHackTwo[0];
                using (XmlReader reader = XmlReader.Create(new StringReader(Parse)))
                {
                    while (reader.Read())
                    {
                        if (reader.IsStartElement())
                        {
                            switch (reader.Name)
                            {
                            case "group":
                                reader.Read();
                                string Group = reader.Value;
                                if (Group != "**Default" && Groups.Find(e => e.GroupName == Group) == null)
                                {
                                    Groups.Add(new Group(Group));
                                }
                                break;
                            }
                        }
                    }
                }
            }

            Groups.Add(new Group("Offline", false));
            SetChatHover();
        }
Example #24
0
        public RiotChat()
        {
            xmpp = new XmppClientConnection {
                Server                   = "pvp.net",
                Port                     = 5223,
                ConnectServer            = Session.Region.ChatServer,
                AutoResolveConnectServer = false,
                Resource                 = "xiff",
                UseSSL                   = true,
                KeepAliveInterval        = 10,
                KeepAlive                = true,
                UseCompression           = true,
                AutoPresence             = true,
                Status                   = new LeagueStatus(StatusMessage, Status).ToXML(),
                Show                     = ShowType.chat,
                Priority                 = 0
            };
            xmpp.OnMessage   += Xmpp_OnMessage;
            xmpp.OnAuthError += (o, e) => Session.Log(e);
            xmpp.OnError     += (o, e) => Session.Log(e);
            xmpp.OnLogin     += o => Session.Log("Connected to chat server");
            xmpp.Open(Session.Current.Account.LoginSession.AccountSummary.Username, "AIR_" + Session.Current.Account.LoginSession.Password);

            presence = new PresenceManager(xmpp);
            roster   = new RosterManager(xmpp);
            lobby    = new MucManager(xmpp);

            xmpp.OnRosterEnd  += o => connected = true;
            xmpp.OnRosterItem += Xmpp_OnRosterItem;
            xmpp.OnPresence   += Xmpp_OnPresence;

            timer = new Timer(1000)
            {
                AutoReset = true
            };
            timer.Elapsed += UpdateProc;
            timer.Start();
        }
Example #25
0
        private void xmppClient_OnPresence(object sender, PresenceEventArgs e)
        {
            DisplayEvent(string.Format("OnPresence\t{0}", e.Presence.From));

            if (e.Presence.Type == PresenceType.Subscribe)
            {
                //presenceManager.ApproveSubscriptionRequest(e.Presence.From);
                var item = listContacts.Items[e.Presence.From.Bare] as RosterListViewItem;
                if (item != null)
                {
                    var pm = new PresenceManager(xmppClient);
                    pm.ApproveSubscriptionRequest(e.Presence.From);
                }
                else
                {
                    var input = new FrmAddUser(_dictContactGroups, true, xmppClient);
                    input.Address = e.Presence.From;
                    if (input.ShowDialog() == DialogResult.OK)
                    {
                        _dictContactGroups = input.DictContactGroups;
                        var rm = new RosterManager(xmppClient);
                        Jid jid = input.Address;
                        rm.Add(jid, input.Name, input.Group);

                        var pm = new PresenceManager(xmppClient);
                        pm.ApproveSubscriptionRequest(e.Presence.From);
                        //string reason = input.Message;
                        //pm.Subscribe(jid, reason, input.Name);
                    }
                }
            }
            else if (e.Presence.Type == PresenceType.Subscribed)
            {
                var pm = new PresenceManager(xmppClient);
                pm.ApproveSubscriptionRequest(e.Presence.From);
            }
            else if (e.Presence.Type == PresenceType.Unsubscribe)
            {
                var pm = new PresenceManager(xmppClient);
                pm.ApproveSubscriptionRequest(e.Presence.From);
                var rm = new RosterManager(xmppClient);
                Jid jid = e.Presence.From;
                rm.Remove(jid);
            }
            else if (e.Presence.Type == PresenceType.Unsubscribed)
            {
                var pm = new PresenceManager(xmppClient);
                pm.ApproveSubscriptionRequest(e.Presence.From);
                var rm = new RosterManager(xmppClient);
                Jid jid = e.Presence.From;
                rm.Remove(jid);
            }
            else
            {
                var item = listContacts.Items[e.Presence.From.Bare] as RosterListViewItem;
                if (item != null)
                {
                    item.ImageIndex = Util.GetRosterImageIndex(e.Presence);
                    string resource = e.Presence.From.Resource;
                    if (e.Presence.Type != PresenceType.Unavailable)
                    {
                        if (!item.Resources.Contains(resource))
                            item.Resources.Add(resource);
                    }
                    else
                    {
                        if (item.Resources.Contains(resource))
                            item.Resources.Remove(resource);
                    }
                }
            }
        }
Example #26
0
 public Contacts(XmppClientConnection connection)
 {
     _presence = new PresenceManager(connection);
     _roster   = new RosterManager(connection);
 }
Example #27
0
        public void Execute(List <Logic.Configuration.Plugin> plugins)
        {
            try
            {
                this.Plugins = plugins;
                var account = plugins.First().JabberAccount;

                this.AppMan = new ApplicationManager(plugins);

                this.BotClient = new JabberClient();

                this.BotClient.User     = account.User;
                this.BotClient.Server   = account.Server;
                this.BotClient.Password = account.Password;

                this.BotClient.AutoPresence  = true;
                this.BotClient.AutoRoster    = true;
                this.BotClient.AutoReconnect = 10;

                // listen for errors.  Always do this!
                this.BotClient.OnError += new bedrock.ExceptionHandler(BotClient_OnError);

                this.BotClient.OnAuthenticate += new bedrock.ObjectHandler(BotClient_OnAuthenticate);

                this.BotClient.OnMessage  += new MessageHandler(BotClient_OnMessage);
                this.BotClient.OnIQ       += new IQHandler(BotClient_OnIQ);
                this.BotClient.OnPresence += new PresenceHandler(BotClient_OnPresence);
                this.BotClient.OnReadText += new bedrock.TextHandler(BotClient_OnReadText);

                RosterManager rosterManager = new RosterManager();
                rosterManager.Client    = this.BotClient;
                rosterManager.AutoAllow = AutoSubscriptionHanding.AllowAll;

                if (VERBOSE)
                {
                    this.BotClient.OnWriteText += new bedrock.TextHandler(BotClient_OnWriteText);
                }

                this.BotClient.Connect();

                Thread.Sleep(2000);

                try
                {
                    this.BotClient.GetAgents();
                }
                catch (NullReferenceException ex)
                {
                    EventLog.WriteEntry("JabberInterface", ex.Message);
                }

                while (true)
                {
                    Thread.Sleep(60000);
                }
            }
            catch (ThreadAbortException)
            {
                this.Close();
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("JabberInterface", ex.Message);
                this.Close();
            }
        }
Example #28
0
        public Account(AccountInfo info)
        {
            if (String.IsNullOrEmpty(info.User))
            {
                throw new ArgumentNullException("user");
            }
            if (String.IsNullOrEmpty(info.Domain))
            {
                throw new ArgumentNullException("domain");
            }
            if (String.IsNullOrEmpty(info.Resource))
            {
                throw new ArgumentNullException("resource");
            }

            m_Info = info;

            m_UserPresenceCache = new Dictionary <JID, Presence>();

            m_Client = new JabberClient();
            m_Client.AutoPresence          = false;
            m_Client.AutoRoster            = true;
            m_Client.AutoStartTLS          = true;
            m_Client.OnConnect            += HandleOnConnect;
            m_Client.OnAuthenticate       += HandleOnAuthenticate;
            m_Client.OnDisconnect         += HandleOnDisconnect;
            m_Client.OnError              += HandleOnError;
            m_Client.OnPresence           += HandleOnPresence;
            m_Client.OnInvalidCertificate += delegate { return(true); };            // XXX:
            m_Client.OnBeforePresenceOut  += HandleOnBeforePresenceOut;
            m_Client.OnStreamInit         += HandleOnStreamInit;

            m_Roster              = new RosterManager();
            m_Roster.OnRosterEnd += HandleOnRosterEnd;
            m_Roster.Stream       = m_Client;

            m_CapsManager        = new CapsManager();
            m_CapsManager.Stream = m_Client;
            m_CapsManager.Node   = "http://www.synapse.im/";

            m_PubSubManager        = new PubSubManager();
            m_PubSubManager.Stream = m_Client;

            m_DiscoManager        = new DiscoManager();
            m_DiscoManager.Stream = m_Client;

            m_ConferenceManager           = new ConferenceManager();
            m_ConferenceManager.Stream    = m_Client;
            m_ConferenceManager.OnInvite += HandleOnInvite;

            m_BookmarkManager                   = new BookmarkManager();
            m_BookmarkManager.Stream            = m_Client;
            m_BookmarkManager.ConferenceManager = m_ConferenceManager;

            m_PresenceManager        = new PresenceManager();
            m_PresenceManager.Stream = m_Client;

            m_AvatarManager = new AvatarManager(this);

            m_IQTracker = new IQTracker(m_Client);

            // XXX: Don't hard-code this.
            m_CapsManager.AddIdentity("Synapse 0.1", "client", "pc", "en_US");

            // Create builtin features
            // XXX: This should be an extension point as well.
            AddFeature(new PersonalEventing(this));
            AddFeature(new Microblogging(this));
            AddFeature(new UserMood(this));
            AddFeature(new UserTune(this));
            AddFeature(new UserAvatars(this));
            AddFeature(new ChatStates(this));
            AddFeature(new UserWebIdentities(this));

            if (ServiceManager.Contains <NetworkService>())
            {
                ServiceManager.Get <NetworkService>().StateChange += HandleNetworkStateChanged;
            }
        }
Example #29
0
 void Awake()
 {
     Instance = this;
 }
Example #30
0
 private void editToolStripMenuItem_Click(object sender, System.EventArgs e)
 {
     if (listContacts.SelectedItems.Count > 0)
     {
         var item = listContacts.SelectedItems[0];
         var input = new FrmAddUser(_dictContactGroups, false, xmppClient);
         input.Name = item.Text;
         input.Address = item.Name;
         input.Group = item.Group.Header;
         if (input.ShowDialog() == DialogResult.OK)
         {
             var rm = new RosterManager(xmppClient);
             Jid jid = input.Address;
             rm.Update(jid, input.Name, input.Group);
         }
     }
 }
Example #31
0
 private void deleteToolStripMenuItem_Click(object sender, System.EventArgs e)
 {
     if (listContacts.SelectedItems.Count > 0)
     {
         var item = listContacts.SelectedItems[0];
         var rm = new RosterManager(xmppClient);
         Jid jid = item.Name;
         rm.Remove(jid);
     }
 }
Example #32
0
        private void addToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            var input = new FrmAddUser(_dictContactGroups, true, xmppClient);
            if (input.ShowDialog() == DialogResult.OK)
            {
                _dictContactGroups = input.DictContactGroups;
                var rm = new RosterManager(xmppClient);
                Jid jid = input.Address;
                rm.Add(jid, input.Name, input.Group);

                var pm = new PresenceManager(xmppClient);
                string reason = input.Message;
                pm.Subscribe(jid, reason, input.Name);
            }
        }
        [Test] public void Test_Create()
        {
            RosterManager rm = new RosterManager();

            Assert.AreEqual("jabber.client.RosterManager", rm.GetType().FullName);
        }
Example #34
0
 public RosterController(RosterManager rosterManager)
 {
     RosterManager = rosterManager;
 }