Exemplo n.º 1
0
        void do_globalUserCache_GroupInfoChanged(GGGroup group, GroupChangedType type, string userID)
        {
            this.groupListBox.GroupInfoChanged(group, type, userID);

            if (type == GroupChangedType.GroupDeleted)
            {
                GroupChatForm form = this.groupChatFormManager.GetForm(group.ID);
                if (form != null)
                {
                    form.Close();
                }

                if (userID != null) //为null 表示更改了自己的部门资料
                {
                    MessageBoxEx.Show(string.Format("群{0}({1})已经被解散。", group.ID, group.Name));
                }
                return;
            }

            GroupChatForm form2 = this.groupChatFormManager.GetForm(group.ID);

            if (form2 != null)
            {
                form2.OnGroupInfoChanged(type, userID);
            }
        }
Exemplo n.º 2
0
        public GroupChatForm GetGroupChatForm(string groupID)
        {
            GroupChatForm form = this.groupChatFormManager.GetForm(groupID);

            if (form == null)
            {
                form = new GroupChatForm(this.rapidPassiveEngine, groupID, this.globalUserCache, this);
                form.LastWordChanged += new CbGeneric <bool, string, LastWordsRecord>(form_LastWordChanged);
                this.groupChatFormManager.Add(form);
                form.Show();
                UnhandleGroupMessageBox cache = this.notifyIcon.PickoutGroupMessageCache(groupID);
                if (cache != null)
                {
                    form.HandleReceivedMessage(cache.MessageList);
                }
            }
            else
            {
                if (form.WindowState == FormWindowState.Minimized)
                {
                    form.WindowState = FormWindowState.Normal;
                }
                form.Focus();
            }
            return(form);
        }
Exemplo n.º 3
0
        void groupListBox_DismissGroupClicked(IGroup group)
        {
            try
            {
                if (group.CreatorID != this.globalUserCache.CurrentUser.UserID)
                {
                    MessageBoxEx.Show("只有群的创始人才能解散群。");
                    return;
                }

                if (!ESBasic.Helpers.WindowsHelper.ShowQuery(string.Format("您确定要解散群{0}({1})吗?", group.ID, group.Name)))
                {
                    return;
                }

                this.rapidPassiveEngine.CustomizeOutter.SendCertainly(null, InformationTypes.DeleteGroup, System.Text.Encoding.UTF8.GetBytes(group.ID));
                this.groupListBox.RemoveGroup(group.ID);
                this.recentListBox1.RemoveUnit(group);
                GroupChatForm form = this.groupChatFormManager.GetForm(group.ID);
                if (form != null)
                {
                    form.Close();
                }
                this.globalUserCache.RemoveGroup(group.ID);
                this.globalUserCache.CurrentUser.QuitGroup(group.ID);
                MessageBoxEx.Show(string.Format("您已经解散群{0}({1})。", group.ID, group.Name));
            }
            catch (Exception ee)
            {
                MessageBoxEx.Show("请求超时!" + ee.Message, GlobalResourceManager.SoftwareName);
            }
        }
Exemplo n.º 4
0
 void groupListBox_GroupDoubleClicked(IGroup group)
 {
     try
     {
         GroupChatForm form = this.GetGroupChatForm(group.ID);
         form.Show();
         form.Focus();
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.Message);
     }
 }
Exemplo n.º 5
0
        private void ToJoinGroup()
        {
            JoinGroupForm form = new JoinGroupForm(this.rapidPassiveEngine, this);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.globalUserCache.CurrentUser.JoinGroup(form.GroupID);
                GGGroup group = this.globalUserCache.GetGroup(form.GroupID);
                this.groupListBox.AddGroup(group);
                GroupChatForm groupChatForm = this.GetGroupChatForm(group.ID);
                groupChatForm.AppendSysMessage("您已经成功加入群,可以开始聊天了...");
                groupChatForm.Show();
                groupChatForm.Focus();
            }
        }
Exemplo n.º 6
0
        private void 创建群ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (this.globalUserCache.CurrentUser.UserStatus == UserStatus.OffLine)
            {
                return;
            }

            CreateGroupForm form = new CreateGroupForm(this.rapidPassiveEngine);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                GGGroup group = form.Group;
                this.globalUserCache.CurrentUser.JoinGroup(group.ID);
                this.globalUserCache.OnCreateGroup(group);
                this.groupListBox.AddGroup(group);

                GroupChatForm groupChatForm = this.GetGroupChatForm(group.ID);
                groupChatForm.AppendSysMessage("您已经成功创建群...");
                groupChatForm.Show();
                groupChatForm.Focus();
            }
        }
Exemplo n.º 7
0
        public void HandleInformation(string sourceUserID, int informationType, byte[] info)
        {
            if (!this.initialized)
            {
                return;
            }

            #region 需要twinkle的消息
            if (informationType == InformationTypes.Chat || informationType == InformationTypes.OfflineMessage || informationType == InformationTypes.OfflineFileResultNotify ||
                informationType == InformationTypes.Vibration || informationType == InformationTypes.VideoRequest || informationType == InformationTypes.AgreeVideo ||
                informationType == InformationTypes.RejectVideo || informationType == InformationTypes.HungUpVideo || informationType == InformationTypes.DiskRequest ||
                informationType == InformationTypes.AgreeDisk || informationType == InformationTypes.RejectDisk || informationType == InformationTypes.RemoteHelpRequest ||
                informationType == InformationTypes.AgreeRemoteHelp || informationType == InformationTypes.RejectRemoteHelp || informationType == InformationTypes.CloseRemoteHelp ||
                informationType == InformationTypes.TerminateRemoteHelp ||
                informationType == InformationTypes.AudioRequest || informationType == InformationTypes.RejectAudio || informationType == InformationTypes.AgreeAudio ||
                informationType == InformationTypes.HungupAudio ||
                informationType == InformationTypes.FriendAddedNotify)
            {
                if (informationType == InformationTypes.FriendAddedNotify)
                {
                    GGUser owner = CompactPropertySerializer.Default.Deserialize <GGUser>(info, 0); // 0922
                    this.globalUserCache.CurrentUser.AddFriend(owner.ID, this.globalUserCache.CurrentUser.DefaultFriendCatalog);
                    this.globalUserCache.OnFriendAdded(owner);                                      //自然会添加 好友条目
                    sourceUserID = owner.UserID;
                }

                object tag = null;
                if (informationType == InformationTypes.OfflineMessage)
                {
                    byte[]         bChatBoxContent = null;
                    OfflineMessage msg             = CompactPropertySerializer.Default.Deserialize <OfflineMessage>(info, 0);
                    if (msg.InformationType == InformationTypes.Chat) //目前只处理离线的聊天消息
                    {
                        sourceUserID    = msg.SourceUserID;
                        bChatBoxContent = msg.Information;
                        byte[] decrypted = bChatBoxContent;
                        if (GlobalResourceManager.Des3Encryption != null)
                        {
                            decrypted = GlobalResourceManager.Des3Encryption.Decrypt(bChatBoxContent);
                        }

                        ChatMessageRecord record = new ChatMessageRecord(sourceUserID, this.rapidPassiveEngine.CurrentUserID, decrypted, false, false);
                        GlobalResourceManager.ChatMessageRecordPersister.InsertChatMessageRecord(record);
                        ChatBoxContent content = CompactPropertySerializer.Default.Deserialize <ChatBoxContent>(decrypted, 0);
                        tag = new Parameter <ChatBoxContent, DateTime>(content, msg.Time);
                    }
                }

                if (informationType == InformationTypes.OfflineFileResultNotify)
                {
                    OfflineFileResultNotifyContract contract = CompactPropertySerializer.Default.Deserialize <OfflineFileResultNotifyContract>(info, 0);
                    sourceUserID = contract.AccepterID;
                }

                GGUser user = this.globalUserCache.GetUser(sourceUserID);
                this.notifyIcon.PushFriendMessage(sourceUserID, informationType, info, tag);
                return;
            }
            #endregion

            if (this.InvokeRequired)
            {
                this.BeginInvoke(new CbGeneric <string, int, byte[]>(this.HandleInformation), sourceUserID, informationType, info);
            }
            else
            {
                try
                {
                    if (informationType == InformationTypes.InputingNotify)
                    {
                        ChatForm form = this.chatFormManager.GetForm(sourceUserID);
                        if (form != null)
                        {
                            form.OnInptingNotify();
                        }
                        return;
                    }

                    if (informationType == InformationTypes.FriendRemovedNotify)
                    {
                        string friendID = System.Text.Encoding.UTF8.GetString(info);
                        this.globalUserCache.RemovedFriend(friendID);
                        return;
                    }

                    if (informationType == InformationTypes.UserInforChanged)
                    {
                        GGUser user = ESPlus.Serialization.CompactPropertySerializer.Default.Deserialize <GGUser>(info, 0);
                        this.globalUserCache.AddOrUpdateUser(user);
                        return;
                    }


                    if (informationType == InformationTypes.UpdateGroupInfo)
                    {
                        GGGroup group = ESPlus.Serialization.CompactPropertySerializer.Default.Deserialize <GGGroup>(info, 0);
                        this.globalUserCache.UpdateGroup(group);


                        return;
                    }
                    if (informationType == InformationTypes.UserStatusChanged)
                    {
                        UserStatusChangedContract contract = ESPlus.Serialization.CompactPropertySerializer.Default.Deserialize <UserStatusChangedContract>(info, 0);
                        this.globalUserCache.ChangeUserStatus(contract.UserID, (UserStatus)contract.NewStatus);
                    }

                    if (informationType == InformationTypes.SystemNotify4AllOnline)
                    {
                        SystemNotifyContract contract = CompactPropertySerializer.Default.Deserialize <SystemNotifyContract>(info, 0);
                        SystemNotifyForm     form     = new SystemNotifyForm(contract.Title, contract.Content);
                        form.Show();
                        return;
                    }

                    if (informationType == InformationTypes.SystemNotify4Group)
                    {
                        SystemNotifyContract contract = CompactPropertySerializer.Default.Deserialize <SystemNotifyContract>(info, 0);
                        SystemNotifyForm     form     = new SystemNotifyForm(contract.Title, contract.Content);
                        form.Show();
                        return;
                    }

                    if (informationType == InformationTypes.RemoveMember)
                    {
                        //GGUser user = ESPlus.Serialization.CompactPropertySerializer.Default.Deserialize<GGUser>(info, 0);
                        //this.globalUserCache.AddOrUpdateUser(user);
                        string groupID = System.Text.Encoding.UTF8.GetString(info).Split('|')[0];
                        string UserID  = System.Text.Encoding.UTF8.GetString(info).Split('|')[1];
                        this.groupListBox.RemoveGroup(groupID);
                        this.recentListBox1.RemoveUnit(this.globalUserCache.GetGroup(groupID));
                        GroupChatForm form = this.groupChatFormManager.GetForm(groupID);
                        if (form != null)
                        {
                            form.Close();
                        }


                        IGroup group = this.globalUserCache.GetGroup(groupID);
                        group.NoSpeakList.Remove(UserID);

                        this.globalUserCache.RemoveGroup(groupID);
                        this.globalUserCache.CurrentUser.QuitGroup(groupID);

                        MessageBoxEx.Show(string.Format("您已经被踢出群{0}({1})。", group.ID, group.Name));

                        return;
                    }


                    if (informationType == InformationTypes.AddMember)
                    {
                        string groupID = System.Text.Encoding.UTF8.GetString(info).Split('|')[0];
                        string UserID  = System.Text.Encoding.UTF8.GetString(info).Split('|')[1];


                        this.globalUserCache.CurrentUser.JoinGroup(groupID);
                        GGGroup group = this.globalUserCache.GetGroup(groupID);
                        group.NoSpeakList.Remove(UserID);

                        this.groupListBox.AddGroup(group);

                        GroupChatForm groupChatForm = this.GetGroupChatForm(group.ID);
                        groupChatForm.AppendSysMessage("您已经成功加入群,可以开始聊天了...");
                        groupChatForm.Show();
                        groupChatForm.Focus();

                        return;
                    }


                    //if (informationType == InformationTypes.AddManager)
                    //{

                    //    string groupID = System.Text.Encoding.UTF8.GetString(info).Split('|')[0];
                    //    string UserID = System.Text.Encoding.UTF8.GetString(info).Split('|')[1];
                    //    GGGroup group = this.globalUserCache.GetGroup(groupID);
                    //    group.AddManager(UserID);

                    //    GroupChatForm groupChatForm = this.GetGroupChatForm(group.ID);
                    //    groupChatForm.AppendSysMessage("您已经成功加入群,可以开始聊天了...");
                    //    groupChatForm.Show();
                    //    groupChatForm.Focus();

                    //    return;
                    //}
                }
                catch (Exception ee)
                {
                    GlobalResourceManager.Logger.Log(ee, "MainForm.HandleInformation", ESBasic.Loggers.ErrorLevel.Standard);
                    MessageBox.Show(ee.Message);
                }
            }
        }