/// <summary>
 /// 登陆成功后触发此操作
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnLogin(object sender, LoginEventArgs e)
 {
     if (e.Succeeded)
     {
         try
         {
             this.buddyManager.Refresh();
             this.InitAfterFirstLogin();
             buddyList = BuddyListBuilder.Instance.Build(false);
             this.BindContactList();
             this.BindSelf();
             ContactSortManager.RequestSorting(true);
             //DelayTask.DelayRun(0x7d0, delegate(DelayTask task, object obj)
             //{
             //    EmoticonShow.Init();
             //});
             //if (this._desktopBuddyCollection == null)
             //{
             //    this._desktopBuddyCollection = Util_UserSettings_DesktopBuddy.DesktopBuddyCollection;
             //    foreach (DesktopBuddyInfo info in this._desktopBuddyCollection)
             //    {
             //        System.Windows.Point point = new System.Windows.Point((double)info.Left, (double)info.Top);
             //        Buddy buddy = BuddyListBuilder.Instance.FindOrCreateBuddy(info.Uin, false, false);
             //        if (buddy != null)
             //        {
             //            Util_Buddy.OpenContactSessionWindow(buddy, new Util_Buddy.BuddySessionParameter { ContactSessionWindowStatus = Util_Buddy.ContactSessionWindowStatus.Avatar, WindowPosition = point, OpenFromDesktopBuddy = false });
             //        }
             //    }
             //}
         }
         catch (Exception)
         {
         }
     }
 }
Example #2
0
 /// <summary>
 /// Initializes the values of BuddyList control's properties.
 /// </summary>
 /// <param name="customBuddyList">
 /// The custom BuddyList control.
 /// </param>
 /// <param name="mode">
 /// The mode of this BuddyList.
 /// </param>
 /// <param name="buddyList">
 /// The buddy List.
 /// </param>
 private void InitializeBuddyList([NotNull] BuddyList customBuddyList, int mode, List <dynamic> buddyList)
 {
     customBuddyList.FriendsList   = buddyList;
     customBuddyList.CurrentUserID = this.PageContext.PageUserID;
     customBuddyList.Mode          = mode;
     customBuddyList.Container     = this;
 }
Example #3
0
 /// <summary>
 /// Initializes the values of BuddyList control's properties.
 /// </summary>
 /// <param name="customBuddyList">
 /// The custom BuddyList control.
 /// </param>
 /// <param name="mode">
 /// The mode of this BuddyList.
 /// </param>
 /// <param name="buddyListDataTable">
 /// The buddy List Data Table.
 /// </param>
 private void InitializeBuddyList([NotNull] BuddyList customBuddyList, int mode, DataTable buddyListDataTable)
 {
     customBuddyList.FriendsTable  = buddyListDataTable;
     customBuddyList.CurrentUserID = this.PageContext.PageUserID;
     customBuddyList.Mode          = mode;
     customBuddyList.Container     = this;
 }
 /// <summary>
 /// 绑定联系人列表到“联系人”面板
 /// </summary>
 /// <param name="buddyList"></param>
 public void BindContactList(BuddyList buddyList)
 {
     Binding binding = new Binding
     {
         Source = buddyList
     };
     this.buddyTree.SetBinding(ItemsControl.ItemsSourceProperty, binding);
 }
Example #5
0
        /// <summary>
        /// 绑定联系人列表到“联系人”面板
        /// </summary>
        /// <param name="buddyList"></param>
        public void BindContactList(BuddyList buddyList)
        {
            Binding binding = new Binding
            {
                Source = buddyList
            };

            this.buddyTree.SetBinding(ItemsControl.ItemsSourceProperty, binding);
        }
Example #6
0
        /// <summary>
        /// Removes the passed in user from the users buddy list.
        /// If the user is not in the buddy list, an ArgumentException is thrown.
        /// </summary>
        /// <param name="buddy">The buddy to remove.</param>
        /// <exception cref="ArgumentException">Thrown when buddy not in the buddy list</exception>
        public virtual void RemoveBuddy(User buddy)
        {
            CosmoMongerDbDataContext db = CosmoManager.GetDbContext();
            BuddyList buddyToRemove     = (from bl in this.BuddyLists where bl.FriendId == buddy.UserId select bl).SingleOrDefault();

            if (buddyToRemove == null)
            {
                throw new ArgumentException("User is not in the buddy list", "buddy");
            }

            db.BuddyLists.DeleteOnSubmit(buddyToRemove);
            db.SaveChanges();
        }
Example #7
0
        private void AddContact(XmlNode contact)
        {
            string protocol = null;
            string owner    = null;
            string buddy    = null;
            string alias    = null;

            // For each and every meta-contact, there can be multiple
            // buddy information entries if we have a contact added on
            // multiple protocols. Loop through them.

            foreach (XmlNode plugin_node in contact.SelectNodes("plugin-data"))
            {
                // Determine the protocol
                XmlAttribute plugin_id_attr = plugin_node.Attributes ["plugin-id"];
                protocol = plugin_id_attr.Value.Substring(0, plugin_id_attr.Value.Length - 8).ToLower();

                // Fetch all the buddy properties
                foreach (XmlNode plugin_data_node in plugin_node.SelectNodes("plugin-data-field"))
                {
                    switch (plugin_data_node.Attributes ["key"].Value)
                    {
                    case "contactId":
                        buddy = plugin_data_node.InnerText;
                        break;

                    case "accountId":
                        owner = plugin_data_node.InnerText;
                        break;

                    case "displayName":
                        alias = plugin_data_node.InnerText;
                        break;
                    }
                }

                string buddy_name = Format(buddy);

                // Replace any earlier buddies with the same screenname
                // FIXME: Not safe since we can have the same screenname on different accounts.
                if (BuddyList.ContainsKey(buddy_name))
                {
                    BuddyList.Remove(buddy_name);
                }

                ImBuddy im_buddy = new ImBuddy(protocol, owner, buddy_name, alias, null, null);

                BuddyList.Add(buddy_name, im_buddy);
            }
        }
        private static BuddyList ConvertFriendListItem(FriendInfo[] friendsList)
        {
            BuddyList buddylistreturn = new BuddyList();

            foreach (BuddyList.BuddyInfo buddyitem in from finfo in friendsList where finfo.TheirFlags != -1 select new BuddyList.BuddyInfo(finfo.Friend)
            {
                BuddyID = finfo.Friend,
                BuddyRightsHave = finfo.TheirFlags,
                BuddyRightsGiven = finfo.MyFlags
            })
            {
                buddylistreturn.AddNewBuddy(buddyitem);
            }
            return(buddylistreturn);
        }
Example #9
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            AddProjectItem item = ProjectCombo.SelectedItem as AddProjectItem;

            if (item == null)
            {
                return;
            }

            People = item.TrustType ? TrustTree.GetSelectedIDs() : BuddyList.GetSelectedIDs();

            if (People.Count > 0)
            {
                Person = People[0];
            }

            DialogResult = DialogResult.OK;

            Close();
        }
Example #10
0
        public void BuddyList()
        {
            // Arrange
            Mock <User> userMock = new Mock <User>();

            BuddyList[] list = new BuddyList[0];
            userMock.Expect(u => u.GetBuddyList())
            .Returns(list)
            .Verifiable();
            Mock <GameManager>  managerMock = new Mock <GameManager>(userMock.Object);
            BuddyListController controller  = new BuddyListController(managerMock.Object);

            // Act
            ActionResult result = controller.BuddyList();

            // Assert
            Assert.That(result, Is.TypeOf(typeof(ViewResult)), "Should return a view");
            Assert.That(controller.ModelState.IsValid, "No errors should be returned");
            ViewResult viewResult = (ViewResult)result;

            Assert.That(viewResult.ViewData["BuddyList"], Is.EqualTo(list), "ViewData should have buddy list");
            managerMock.Verify();
        }
Example #11
0
        public AddUsersDialog(CoreUI ui, uint project)
            : base(ui.Core)
        {
            InitializeComponent();

            UI        = ui;
            Core      = ui.Core;
            ProjectID = project;

            // load up trust
            if (Core.Trust != null)
            {
                LoadTrustTree();
            }

            // load up buddies - last option
            BuddyList.FirstLineBlank = false;
            BuddyList.Init(ui, Core.Buddies, null, false);
            ProjectCombo.Items.Add(new AddProjectItem("Buddies"));


            if (Core.Trust != null)
            {
                foreach (AddProjectItem item in ProjectCombo.Items)
                {
                    if (item.ID == ProjectID)
                    {
                        ProjectCombo.SelectedItem = item;
                        break; // break before buddies is selected
                    }
                }
            }
            else
            {
                ProjectCombo.SelectedIndex = 0; // buddy list
            }
        }
Example #12
0
        /// <summary>
        /// Adds the passed in user to the users buddy list.
        /// If the user is already in the list an ArgumentException is thrown.
        /// </summary>
        /// <param name="buddy">The buddy to add.</param>
        /// <exception cref="ArgumentException">Thrown when buddy is already in the buddy list</exception>
        public virtual void AddBuddy(User buddy)
        {
            CosmoMongerDbDataContext db = CosmoManager.GetDbContext();

            if (buddy == this)
            {
                throw new ArgumentException("Cannot add self to buddy list", "buddy");
            }

            bool matchingBuddy = (from bl in this.BuddyLists where bl.FriendId == buddy.UserId select bl).Any();

            if (matchingBuddy)
            {
                throw new ArgumentException("User is already in the buddy list", "buddy");
            }

            BuddyList buddyEntry = new BuddyList();

            buddyEntry.User     = this;
            buddyEntry.FriendId = buddy.UserId;
            db.BuddyLists.InsertOnSubmit(buddyEntry);

            db.SaveChanges();
        }
Example #13
0
        public IMForm(CoreUI ui)
            : base(ui.Core)
        {
            InitializeComponent();

            UI   = ui;
            Core = ui.Core;

            GuiUtils.SetupToolstrip(TopStrip, new OpusColorTable());
            GuiUtils.FixMonoDropDownOpening(OptionsButton, OptionsButton_DropDownOpening);

            UI.ShowView += ShowExternal;

            Text = "IM - " + Core.GetName(Core.UserID);

            BuddyList.Init(UI, Core.Buddies, SelectionInfo, true);

            IM = UI.GetService(ServiceIDs.IM) as IMUI;

            SelectionInfo.Init(UI);

            SelectionInfo.ShowNetwork();

            if (GuiUtils.IsRunningOnMono())
            {
                AddButton.Text    = "Add";
                SharedButton.Text = "Files";
            }

            Rectangle screen = Screen.GetWorkingArea(this);

            Location = new Point(screen.Width - Width, screen.Height / 2 - Height / 2);


            ShowExternal(new Info.InfoView(Core, false, true));
        }
Example #14
0
 /// <summary>
 /// 登陆成功后触发此操作
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnLogin(object sender, LoginEventArgs e)
 {
     if (e.Succeeded)
     {
         try
         {
             this.buddyManager.Refresh();
             this.InitAfterFirstLogin();
             buddyList = BuddyListBuilder.Instance.Build(false);
             this.BindContactList();
             this.BindSelf();
             ContactSortManager.RequestSorting(true);
             //DelayTask.DelayRun(0x7d0, delegate(DelayTask task, object obj)
             //{
             //    EmoticonShow.Init();
             //});
             //if (this._desktopBuddyCollection == null)
             //{
             //    this._desktopBuddyCollection = Util_UserSettings_DesktopBuddy.DesktopBuddyCollection;
             //    foreach (DesktopBuddyInfo info in this._desktopBuddyCollection)
             //    {
             //        System.Windows.Point point = new System.Windows.Point((double)info.Left, (double)info.Top);
             //        Buddy buddy = BuddyListBuilder.Instance.FindOrCreateBuddy(info.Uin, false, false);
             //        if (buddy != null)
             //        {
             //            Util_Buddy.OpenContactSessionWindow(buddy, new Util_Buddy.BuddySessionParameter { ContactSessionWindowStatus = Util_Buddy.ContactSessionWindowStatus.Avatar, WindowPosition = point, OpenFromDesktopBuddy = false });
             //        }
             //    }
             //}
         }
         catch (Exception)
         {
         }
     }
 }
Example #15
0
 /// <summary>
 /// Initializes the values of BuddyList control's properties.
 /// </summary>
 /// <param name="customBuddyList">
 /// The custom BuddyList control.
 /// </param>
 /// <param name="mode">
 /// The mode of this BuddyList.
 /// </param>
 private void InitializeBuddyList([NotNull] BuddyList customBuddyList, int mode)
 {
     customBuddyList.CurrentUserID = this.PageContext.PageUserID;
     customBuddyList.Mode          = mode;
     customBuddyList.Container     = this;
 }
Example #16
0
 private static void XmppClientOnPresence(object sender, Presence presence)
 {
     BuddyList.SetBuddyPresence(presence);
 }
Example #17
0
 private static BuddyList ConvertFriendListItem(FriendInfo[] friendsList)
 {
     BuddyList buddylistreturn = new BuddyList();
     foreach (BuddyList.BuddyInfo buddyitem in from finfo in friendsList
                                               where finfo.TheirFlags != -1
                                               select new BuddyList.BuddyInfo(finfo.Friend)
                                                          {
                                                              BuddyID = finfo.Friend,
                                                              BuddyRightsHave = finfo.TheirFlags,
                                                              BuddyRightsGiven = finfo.MyFlags
                                                          })
     {
         buddylistreturn.AddNewBuddy(buddyitem);
     }
     return buddylistreturn;
 }
Example #18
0
 private static void XmppClientOnRosterItem(object sender, RosterItem item)
 {
     BuddyList.AddBuddyIfNotExists(item);
 }
Example #19
0
        private void AddBuddy(XmlNode node, string group_alias)
        {
            string protocol     = null;
            string owner        = null;
            string buddy        = null;
            string alias        = null;
            string iconlocation = null;
            string iconchecksum = null;

            foreach (XmlAttribute attr in node.Attributes)
            {
                switch (attr.Name)
                {
                case "account":
                    owner = attr.Value;
                    break;

                case "proto":
                    protocol = attr.Value;
                    break;
                }
            }

            foreach (XmlNode attr in node.ChildNodes)
            {
                switch (attr.LocalName)
                {
                case "name":
                    buddy = attr.InnerText;
                    break;

                case "alias":
                    alias = attr.InnerText;
                    break;

                case "setting":
                    foreach (XmlAttribute subattr in attr.Attributes)
                    {
                        if (subattr.Name == "name" && subattr.Value == "buddy_icon")
                        {
                            iconlocation = Path.Combine(icons_dir, attr.InnerText);
                        }
                        else if (subattr.Name == "name" && subattr.Value == "icon_checksum")
                        {
                            iconchecksum = attr.InnerText;
                        }
                    }
                    break;
                }
            }

            if (!String.IsNullOrEmpty(group_alias))
            {
                alias = group_alias;
            }

            if (BuddyList.ContainsKey(Format(buddy)))
            {
                ImBuddy old = Search(buddy);

                if (String.IsNullOrEmpty(old.Alias) && !String.IsNullOrEmpty(alias))
                {
                    old.Alias = alias;
                }

                if (String.IsNullOrEmpty(old.BuddyIconLocation) && !String.IsNullOrEmpty(iconlocation))
                {
                    old.BuddyIconLocation = iconlocation;
                    old.BuddyIconChecksum = iconchecksum;
                }
            }
            else
            {
                ImBuddy im_buddy = new ImBuddy(protocol, owner, Format(buddy), alias, iconlocation, iconchecksum);
                BuddyList.Add(Format(buddy), im_buddy);
            }
        }