Index: xmlrpc.php
===================================================================
--- xmlrpc.php	(revision 6333)
+++ xmlrpc.php	(working copy)
@@ -172,6 +172,49 @@
 		}
 	}
 
+	function get_custom_fields($post_id) {
+		$post_id = (int) $post_id;
+
+		$custom_fields = array();
+
+		foreach ( (array) has_meta($post_id) as $meta ) {
+			// Don't expose protected fields.
+			if ( strpos($meta['meta_key'], '_wp_') === 0 ) {
+				continue;
+			}
+
+			$custom_fields[] = array(
+				"id"	=> $meta['meta_id'],
+				"key"	=> $meta['meta_key'],
+				"value"	=> $meta['meta_value']
+			);
+		}
+
+		return $custom_fields;
+	}
+
+	function add_custom_fields($post_id, $fields) {
+		$post_id = (int) $post_id;
+
+		foreach ( (array) $fields as $meta ) {
+			if ( isset($meta['id']) ) {
+				$meta['id'] = (int) $meta['id'];
+
+				if ( isset($meta['key']) ) {
+					update_meta($meta['id'], $meta['key'], $meta['value']);
+				}
+				else {
+					delete_meta($meta['id']);
+				}
+			}
+			else {
+				$_POST['metakeyinput']	= $meta['key'];
+				$_POST['metavalue']		= $meta['value'];
+				add_meta($post_id);
+			}
+		}
+	}
+
 	/**
 	 * WordPress XML-RPC API
 	 * wp_getPage
@@ -243,7 +286,8 @@
 				"wp_page_order"			=> $page->menu_order,
 				"wp_author_id"			=> $author->ID,
 				"wp_author_display_name"	=> $author->display_name,
-				"date_created_gmt"		=> new IXR_Date($page_date_gmt)
+				"date_created_gmt"		=> new IXR_Date($page_date_gmt),
+				"custom_fields"			=> $this->get_custom_fields($page_id)
 			);
 
 			return($page_struct);
@@ -1098,6 +1142,10 @@
 	    return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
 	  }
 
+	  if ( isset($content_struct['custom_fields']) ) {
+	    $this->add_custom_fields($post_ID, $content_struct['custom_fields']);
+	  }
+	
 	  $this->attach_uploads( $post_ID, $post_content );
 
 	  logIO('O', "Posted ! ID: $post_ID");
@@ -1318,6 +1366,11 @@
 	  if (!$result) {
 	    return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.'));
 	  }
+
+	  if ( isset($content_struct['custom_fields']) ) {
+	    $this->add_custom_fields($post_ID, $content_struct['custom_fields']);
+	  }
+
 	  $this->attach_uploads( $ID, $post_content );
 
 	  logIO('O',"(MW) Edited ! ID: $post_ID");
@@ -1394,7 +1447,8 @@
           'wp_password' => $postdata['post_password'],
           'wp_author_id' => $author->ID,
           'wp_author_display_name'	=> $author->display_name,
-          'date_created_gmt' => new IXR_Date($post_date_gmt)
+          'date_created_gmt' => new IXR_Date($post_date_gmt),
+		  'custom_fields' => $this->get_custom_fields($post_ID)
 	    );
 
 	    return $resp;
@@ -1476,7 +1530,8 @@
 				'wp_password' => $entry['post_password'],
 				'wp_author_id' => $author->ID,
 				'wp_author_display_name' => $author->display_name,
-				'date_created_gmt' => new IXR_Date($post_date_gmt)
+				'date_created_gmt' => new IXR_Date($post_date_gmt),
+				'custom_fields' => $this->get_custom_fields($entry['ID'])
 			);
 
 		}

