Пример #1
0
        public MessageSender()
        {
            try
            {
                _messenger = new DotMSN.Messenger();
            }
            catch
            {
                throw new ApplicationException("Unable to connect. Your Internet connection might be down");
            }

            _messenger.ContactOnline += new Messenger.ContactOnlineHandler(ContactOnline);
            // notify us when synchronization is completed
            _messenger.SynchronizationCompleted += new Messenger.SynchronizationCompletedHandler(OnSynchronizationCompleted);
            _messenger.ConversationCreated += new Messenger.ConversationCreatedHandler(ConversationCreated);

            if (ConfigurationManager.AppSettings["UseSingleMSNConversation"] != null &&
                ConfigurationManager.AppSettings["UseSingleMSNConversation"].ToUpper() == "TRUE")
            {
                _useSingleConversation = true;
            }
        }
Пример #2
0
        private void LogginMsn(string name, string password)
        {
            menuItemLoggOfMSN.Enabled = true;
            msnMessenger = new Messenger();
            try
            {
                msnMessenger.ConnectionFailure += new DotMSN.Messenger.ConnectionFailureHandler(msnMessenger_ConnectionFailure);
                msnMessenger.MailboxStatus += new DotMSN.Messenger.MailboxStatusHandler(msnMessenger_MailboxStatus);
                msnMessenger.ErrorReceived += new DotMSN.Messenger.ErrorReceivedHandler(msnMessenger_ErrorReceived);
                msnMessenger.ListReceived += new DotMSN.Messenger.ListReceivedHandler(msnMessenger_ListReceived);
                // Event när contact har lagts till..
                msnMessenger.ContactAdded += new DotMSN.Messenger.ContactAddedHandler(msnMessenger_ContactAdded);
                // setup the callbacks
                // we log when someone goes online
                msnMessenger.ContactOnline += new Messenger.ContactOnlineHandler(ContactOnline);

                msnMessenger.ContactOffline += new DotMSN.Messenger.ContactOfflineHandler(ContactOffline);

                // we want to do something when we have a conversation
                msnMessenger.ConversationCreated += new DotMSN.Messenger.ConversationCreatedHandler(msnMessenger_ConversationCreated);

                // notify us when synchronization is completed
                msnMessenger.SynchronizationCompleted += new Messenger.SynchronizationCompletedHandler(OnSynchronizationCompleted);

                DotMSN.Owner owner = new DotMSN.Owner(logginDialog.MsnName, logginDialog.MsnPassword);

                owner.ScreenNameChanged += new DotMSN.Contact.ScreenNameChangedHandler(Owner_ScreenNameChanged);
                owner.StatusChanged		+= new DotMSN.Contact.StatusChangedHandler(Owner_StatusChanged);

                DotMSN.Connection connection = new DotMSN.Connection("64.4.13.58", 1863);

                // everything is setup, now connect to the msnMessenger service
                msnMessenger.Connect(connection, owner);

                msnMessenger.InitialStatus = MSNStatus.Online;

                //Log.Text += "Connected!\r\n";

                // synchronize the whole list.
                // remember you can only do this once per session!
                // after synchronizing the initial status will be set.
                msnMessenger.SynchronizeList();

                /* uncomment this when you want to automatically add
                      people who have added you to their contactlist on your own
                      contactlist. (remember the pop-up dialog in MSN Messenger client when someone adds you, this is the 'automatic' method)
                */	foreach(Contact contact in
                        msnMessenger.GetListEnumerator(MSNList.ReverseList))
                    {
                        msnMessenger.AddContact(contact.Mail);
                    }

            }
            catch(MSNException)
            {
                MessageBox.Show(this, "Problem vid MSN inloggingen!", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Loggout(Protokoll.ALL);
                // in case of an error, report this to the user (or developer)
                //MessageBox.Show(this, "Connecting failed: " + e.ToString());
            }
        }
Пример #3
0
        private void Loggin()
        {
            logginDialog = new LogginDialog();

            if(logginDialog.ShowDialog(this) == DialogResult.OK)
            {
                loggingInDGP = logginDialog.DgpLoggin;
                loggingInMSN = logginDialog.MsnLoggin;
                loggingInChat	 = logginDialog.ChatLoggin;

                this.ShowLoggingInLayout();
                //this.Invoke(new ShowLoggingInLayoutDelegate(this.ShowLoggingInLayout), null );

                if(loggingInDGP)
                {
                    dgpMessenger = new DGPMessenger();
                    loggingInDGP = true;
                    this.LogginDgp(logginDialog.DgpName, logginDialog.DgpPassword);
                    //this.Invoke(new LogginDelegate(LogginDgp), new object [] {logginDialog.DgpName, logginDialog.DgpPassword});
                }
                if(loggingInMSN)
                {
                    msnMessenger = new Messenger();
                    loggingInMSN = true;
                    this.LogginMsn(logginDialog.MsnName, logginDialog.MsnPassword);
                    //this.Invoke(new LogginDelegate(LogginMsn), new object [] {logginDialog.MsnName, logginDialog.MsnPassword});
                }
                if(loggingInChat)
                {
                    chatMessenger = new DGPMessenger();
                    loggingInChat = true;
                    //this.Invoke(new LogginChatDelegate(LogginChat), new object [] {logginDialog.ChatName, "", logginDialog.ChatServer});
                    this.LogginChat(logginDialog.ChatName, "", logginDialog.ChatServer, 1080);
                }
            }
            logginDialog = null;
        }