/// <summary> /// Constructs an instance of ManagerResponse based on a map of attributes. /// </summary> /// <param name="attributes">the attributes and their values. The keys of this map must be all lower case.</param> /// <returns>the response with the given attributes.</returns> internal static ManagerResponse BuildResponse(Dictionary <string, string> attributes) { ManagerResponse response; string responseType = ((string)attributes["response"]).ToLower(Helper.CultureInfo); // Determine type if (responseType == "error") { response = new ManagerError(); } else if (attributes.ContainsKey("challenge")) { response = new ChallengeResponse(); } else if (attributes.ContainsKey("mailbox") && attributes.ContainsKey("waiting")) { response = new MailboxStatusResponse(); } else if (attributes.ContainsKey("mailbox") && attributes.ContainsKey("newmessages") && attributes.ContainsKey("oldmessages")) { response = new MailboxCountResponse(); } else if (attributes.ContainsKey("exten") && attributes.ContainsKey("context") && attributes.ContainsKey("hint") && attributes.ContainsKey("status")) { response = new ExtensionStateResponse(); } else { response = new ManagerResponse(); } Helper.SetAttributes(response, attributes); return(response); }
private bool getMWI(string dn) { log.Debug("Retreiving mwi status for " + dn); MailboxStatusAction msa = new MailboxStatusAction(dn); MailboxStatusResponse msr = (MailboxStatusResponse)manager.SendAction(msa, 10000); log.Debug("Mwi status for " + dn + ": " + msr.ToString()); return(msr.Waiting); }