コード例 #1
0
ファイル: MainForm.cs プロジェクト: liweizl/GGTalk-1
        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();
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: xydoublez/GGTalk-V5.5
        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();
            }
        }
コード例 #3
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);
                }
            }
        }