private void handle_metaWeblog_editPost(System.Net.HttpListenerContext context, MP.XmlRpc.MethodCall methodcall) { this.WriteLogMethodName(); var postid = (MP.XmlRpc.StringValue)methodcall.Parameters[0]; var username = (MP.XmlRpc.StringValue)methodcall.Parameters[1]; var password = (MP.XmlRpc.StringValue)methodcall.Parameters[2]; var struct_ = (MP.XmlRpc.Struct)methodcall.Parameters[3]; var publish = (MP.XmlRpc.BooleanValue)methodcall.Parameters[4]; this.AuthenicateUser(username.String, password.String); this.WriteLog("PostId = {0}", postid.String); this.WriteLog("Username = {0}", username.String); this.WriteLog("Publish = {0}", publish.Boolean); // Post was found var post_title = struct_.Get <MP.XmlRpc.StringValue>("title", null); var post_description = struct_.Get <MP.XmlRpc.StringValue>("description", null); var post_categories = struct_.Get <MP.XmlRpc.Array>("categories", null); var cats = GetCategoriesFromArray(post_categories); this.PostList.Edit(postid.String, null, post_title.String, post_description.String, cats, publish.Boolean); var method_response = new MP.XmlRpc.MethodResponse(); method_response.Parameters.Add(true); // this is supposed to always return true WriteResponseString(context, method_response.CreateDocument().ToString(), 200, "text/xml"); }
private void handle_metaWeblog_deletePost(System.Net.HttpListenerContext context, MP.XmlRpc.MethodCall methodcall) { this.WriteLogMethodName(); var appkey = (MP.XmlRpc.StringValue)methodcall.Parameters[0]; var postid = (MP.XmlRpc.StringValue)methodcall.Parameters[1]; var username = (MP.XmlRpc.StringValue)methodcall.Parameters[2]; var password = (MP.XmlRpc.StringValue)methodcall.Parameters[3]; this.WriteLog("AppKey = {0}", postid.String); this.WriteLog("PostId = {0}", postid.String); this.WriteLog("Username = {0}", username.String); var post = this.PostList.TryGetPostById(postid.String); if (post == null) { this.WriteLog("No such Post with ID {0}", postid.String); // Post was not found respond_error_invalid_postid_parameter(context, 404); return; } // Post was found this.WriteLog("Found Post with ID {0}", postid.String); this.PostList.Delete(post.Value); var method_response = new MP.XmlRpc.MethodResponse(); method_response.Parameters.Add(true); // this is supposed to always return true WriteResponseString(context, method_response.CreateDocument().ToString(), 200, "text/xml"); }
private void handle_metaWeblog_newPost(System.Net.HttpListenerContext context, MP.XmlRpc.MethodCall methodcall) { this.WriteLogMethodName(); var blogid = (MP.XmlRpc.StringValue)methodcall.Parameters[0]; var username = (MP.XmlRpc.StringValue)methodcall.Parameters[1]; var password = (MP.XmlRpc.StringValue)methodcall.Parameters[2]; this.WriteLog("BlogId = {0}", blogid.String); this.WriteLog("Username = {0}", username.String); this.AuthenicateUser(username.String, password.String); var struct_ = (MP.XmlRpc.Struct)methodcall.Parameters[3]; var publish = (MP.XmlRpc.BooleanValue)methodcall.Parameters[4]; var post_title = struct_.Get <MP.XmlRpc.StringValue>("title").String; var post_description = struct_.Get <MP.XmlRpc.StringValue>("description"); var post_categories = struct_.Get <MP.XmlRpc.Array>("categories", null); var cats = GetCategoriesFromArray(post_categories); this.WriteLog(" Categories {0}", string.Join(",", cats)); var new_post = this.PostList.Add(null, post_title, post_description.String, cats, publish.Boolean); var method_response = new MP.XmlRpc.MethodResponse(); method_response.Parameters.Add(new_post.PostId); this.WriteLog("New Post Created with ID = {0}", new_post.PostId); WriteResponseString(context, method_response.CreateDocument().ToString(), 200, "text/xml"); }
private void respond_post(System.Net.HttpListenerContext context, PostInfoRecord post) { this.WriteLogMethodName(); var method_response = new MP.XmlRpc.MethodResponse(); var struct_ = post.ToPostInfo().ToStruct(); method_response.Parameters.Add(struct_); WriteResponseString(context, method_response.CreateDocument().ToString(), 200, ContentType_TextXml); }
public MP.XmlRpc.MethodResponse BuildStructArrayResponse(IEnumerable <MP.XmlRpc.Struct> structs) { var method_response = new MP.XmlRpc.MethodResponse(); var arr = new MP.XmlRpc.Array(); foreach (var struct_ in structs) { arr.Add(struct_); } method_response.Parameters.Add(arr); return(method_response); }
private void handle_metaWeblog_newMediaObject(System.Net.HttpListenerContext context, MP.XmlRpc.MethodCall methodcall) { this.WriteLogMethodName(); var blogid = (MP.XmlRpc.StringValue)methodcall.Parameters[0]; var username = (MP.XmlRpc.StringValue)methodcall.Parameters[1]; var password = (MP.XmlRpc.StringValue)methodcall.Parameters[2]; this.AuthenicateUser(username.String, password.String); this.WriteLog("BlogId = {0}", blogid.String); this.WriteLog("Username = {0}", username.String); var struct_ = (MP.XmlRpc.Struct)methodcall.Parameters[3]; var name = struct_.Get <MP.XmlRpc.StringValue>("name"); var type = struct_.Get <MP.XmlRpc.StringValue>("type"); var bits = struct_.Get <MP.XmlRpc.Base64Data>("bits"); this.WriteLog("Name = {0}", name.String); this.WriteLog("Type = {0}", type.String); this.WriteLog("Bits = {0} Bytes Characters", bits.Bytes); var mo = this.MediaObjectList.StoreNewObject(blogid.String, username.String, name.String, type.String, Convert.ToBase64String(bits.Bytes)); var s_ = new MP.XmlRpc.Struct(); s_["url"] = new MP.XmlRpc.StringValue(this.ServerUrlPrimary + mo.Url.Substring(1)); var method_response = new MP.XmlRpc.MethodResponse(); method_response.Parameters.Add(s_); string response_body = method_response.CreateDocument().ToString(); this.WriteLog(response_body); WriteResponseString(context, response_body, 200, "text/xml"); }
private void handle_metaWeblog_editPost(System.Net.HttpListenerContext context, MP.XmlRpc.MethodCall methodcall) { this.WriteLogMethodName(); var postid = (MP.XmlRpc.StringValue)methodcall.Parameters[0]; var username = (MP.XmlRpc.StringValue)methodcall.Parameters[1]; var password = (MP.XmlRpc.StringValue)methodcall.Parameters[2]; var struct_ = (MP.XmlRpc.Struct)methodcall.Parameters[3]; var publish = (MP.XmlRpc.BooleanValue)methodcall.Parameters[4]; this.AuthenicateUser(username.String,password.String); this.WriteLog("PostId = {0}", postid.String); this.WriteLog("Username = {0}", username.String); this.WriteLog("Publish = {0}", publish.Boolean); // Post was found var post_title = struct_.Get<MP.XmlRpc.StringValue>("title", null); var post_description = struct_.Get<MP.XmlRpc.StringValue>("description", null); var post_categories = struct_.Get<MP.XmlRpc.Array>("categories", null); var cats = GetCategoriesFromArray(post_categories); this.PostList.Edit(postid.String, null, post_title.String, post_description.String, cats, publish.Boolean); var method_response = new MP.XmlRpc.MethodResponse(); method_response.Parameters.Add(true); // this is supposed to always return true WriteResponseString(context, method_response.CreateDocument().ToString(), 200, "text/xml"); }
private void handle_metaWeblog_newPost(System.Net.HttpListenerContext context, MP.XmlRpc.MethodCall methodcall) { this.WriteLogMethodName(); var blogid = (MP.XmlRpc.StringValue)methodcall.Parameters[0]; var username = (MP.XmlRpc.StringValue)methodcall.Parameters[1]; var password = (MP.XmlRpc.StringValue)methodcall.Parameters[2]; this.WriteLog("BlogId = {0}", blogid.String); this.WriteLog("Username = {0}", username.String); this.AuthenicateUser(username.String, password.String); var struct_ = (MP.XmlRpc.Struct)methodcall.Parameters[3]; var publish = (MP.XmlRpc.BooleanValue)methodcall.Parameters[4]; var post_title = struct_.Get<MP.XmlRpc.StringValue>("title").String; var post_description = struct_.Get<MP.XmlRpc.StringValue>("description"); var post_categories = struct_.Get<MP.XmlRpc.Array>("categories", null); var cats = GetCategoriesFromArray(post_categories); this.WriteLog(" Categories {0}", string.Join(",", cats)); var new_post = this.PostList.Add(null, post_title, post_description.String, cats, publish.Boolean); var method_response = new MP.XmlRpc.MethodResponse(); method_response.Parameters.Add(new_post.PostId); this.WriteLog("New Post Created with ID = {0}", new_post.PostId); WriteResponseString(context, method_response.CreateDocument().ToString(), 200, "text/xml"); }
private void handle_metaWeblog_newMediaObject(System.Net.HttpListenerContext context, MP.XmlRpc.MethodCall methodcall) { this.WriteLogMethodName(); var blogid = (MP.XmlRpc.StringValue)methodcall.Parameters[0]; var username = (MP.XmlRpc.StringValue)methodcall.Parameters[1]; var password = (MP.XmlRpc.StringValue)methodcall.Parameters[2]; this.AuthenicateUser(username.String, password.String); this.WriteLog("BlogId = {0}", blogid.String); this.WriteLog("Username = {0}", username.String); var struct_ = (MP.XmlRpc.Struct)methodcall.Parameters[3]; var name = struct_.Get<MP.XmlRpc.StringValue>("name"); var type = struct_.Get<MP.XmlRpc.StringValue>("type"); var bits = struct_.Get<MP.XmlRpc.Base64Data>("bits"); this.WriteLog("Name = {0}", name.String); this.WriteLog("Type = {0}", type.String); this.WriteLog("Bits = {0} Bytes Characters", bits.Bytes); var mo = this.MediaObjectList.StoreNewObject(blogid.String, username.String, name.String, type.String, Convert.ToBase64String(bits.Bytes)); var s_ = new MP.XmlRpc.Struct(); s_["url"] = new MP.XmlRpc.StringValue(this.ServerUrlPrimary + mo.Url.Substring(1)); var method_response = new MP.XmlRpc.MethodResponse(); method_response.Parameters.Add(s_); string response_body = method_response.CreateDocument().ToString(); this.WriteLog(response_body); WriteResponseString(context, response_body, 200, "text/xml"); }
public MP.XmlRpc.MethodResponse BuildStructArrayResponse(IEnumerable<MP.XmlRpc.Struct> structs) { var method_response = new MP.XmlRpc.MethodResponse(); var arr = new MP.XmlRpc.Array(); foreach (var struct_ in structs) { arr.Add(struct_); } method_response.Parameters.Add(arr); return method_response; }