public static bool reDownloadVoiceInfo(ChatMsg msg) { MsgTrans voiceinfo = new MsgTrans { nTransType = 4, nStatus = 0, strToUserName = AccountMgr.getCurAccount().strUsrName, strFromUserName = msg.strTalker }; string strMsg = msg.strMsg; if (ContactMgr.getUserType(msg.strTalker) == ContactMgr.UserType.UserTypeChatRoom) { strMsg = strMsg.Substring(strMsg.IndexOf('\n') + 1); } if (!parseVoiceMsgXML(strMsg, voiceinfo)) { Log.d("DownloadVoiceService", "parseVoiceMsgXML failed"); return(false); } voiceinfo.nMsgSvrID = msg.nMsgSvrID; if (AccountMgr.getCurAccount().strUsrName == voiceinfo.strFromUserName) { Log.d("DownloadVoiceService", "the mVoiceinfo.strFromUserName is yourself"); return(false); } if (DownloadVoiceContextMgr.getInstance().GetBySvrID(msg.nMsgSvrID) == null) { DownloadVoiceContext context = new DownloadVoiceContext(msg.nMsgSvrID, msg.strTalker) { mStatus = 0 }; context.Enqueue(voiceinfo); DownloadVoiceContextMgr.getInstance().putToTail(context); //DownloadVoiceStorage.updateDownloadVoiceContext(voiceinfo); doSceneBegin(); } return(true); }
public static bool downloadVoiceInfo(AddMsg cmdAM) { MsgTrans voiceinfo = new MsgTrans { nTransType = 4, nStatus = 0, strToUserName = cmdAM.ToUserName.String, strFromUserName = cmdAM.FromUserName.String }; string xmlStr = cmdAM.Content.String; if (ContactMgr.getUserType(cmdAM.FromUserName.String) == ContactMgr.UserType.UserTypeChatRoom) { xmlStr = xmlStr.Substring(xmlStr.IndexOf('\n') + 1); } if (!parseVoiceMsgXML(xmlStr, voiceinfo)) { Log.d("DownloadVoiceService", "parseVoiceMsgXML failed"); return(false); } voiceinfo.nMsgSvrID = cmdAM.MsgId; if (AccountMgr.getCurAccount().strUsrName == voiceinfo.strFromUserName) { Log.d("DownloadVoiceService", "the mVoiceinfo.strFromUserName is yourself"); return(false); } if (isCancelVoiceMsg(xmlStr)) { Log.d("DownloadVoiceService", "the msg has been canceled"); //StorageMgr.chatMsg.delMsg(ChatMsgHelper.getTalker(voiceinfo.strToUserName, voiceinfo.strFromUserName), voiceinfo.nMsgSvrID); voiceinfo.nStatus = 5; //DownloadVoiceStorage.updateDownloadVoiceContext(voiceinfo); DownloadVoiceContext context = DownloadVoiceContextMgr.getInstance().GetBySvrID(cmdAM.MsgId); if (context != null) { context.mStatus = 5; } return(false); } if ((cmdAM.ImgBuf != null) && (cmdAM.ImgBuf.Buffer.Length != 0)) { return(saveShortVoiceInfo(voiceinfo, cmdAM.ImgBuf.Buffer.ToByteArray())); } DownloadVoiceContext bySvrID = DownloadVoiceContextMgr.getInstance().GetBySvrID(cmdAM.MsgId); if (bySvrID == null) { bySvrID = new DownloadVoiceContext(cmdAM.MsgId, ChatMsgHelper.getTalker(cmdAM.ToUserName.String, cmdAM.FromUserName.String)) { mStatus = 0 }; bySvrID.Enqueue(voiceinfo); DownloadVoiceContextMgr.getInstance().putToTail(bySvrID); } else { bySvrID.Enqueue(voiceinfo); } //DownloadVoiceStorage.updateDownloadVoiceContext(voiceinfo); doSceneBegin(); return(true); }