Index: protocols/rpc/rpc.c
===================================================================
--- protocols/rpc/rpc.c	(revision f3af614c28f7eefb0cba6a41c74339a92ed96f5f)
+++ protocols/rpc/rpc.c	(revision c5a7b8d43cb3d5f0c32af83f9f51eb3a5398fdae)
@@ -14,7 +14,19 @@
 
 struct rpc_plugin {
+	/* Socket address of the RPC server. */
 	struct sockaddr *addr;
 	socklen_t addrlen;
+	/* Full copy of the "settings" section of the init message. This info
+	 * can only be applied later on, when an account is created (but well
+	 * before logging in). */
 	JSON_Value *settings;
+	/* Supported away states returned by the away_states() function. Since
+	 * RPC servers can't do return values, just get this info at init time.
+	 * This means the list of possible away states is static from init time
+	 * which hopefully won't be a problem. If NULL, the away_states function
+	 * will not be set on this protocol. */
+	GList *away_states;
+	/* Account flags. See account.h. Plugin lib should provide constants. */
+	int account_flags;
 };
 
@@ -170,4 +182,6 @@
 		 * passed to the module immediately. TODO. */
 	}
+
+	acc->flags |= pd->account_flags;
 }
 
@@ -185,4 +199,6 @@
 	if (connect(rd->fd, pd->addr, pd->addrlen) == -1) {
 		closesocket(rd->fd);
+		imcb_error(ic, "RPC server unreachable");
+		imc_logout(ic, TRUE);
 		return;
 	}
@@ -385,4 +401,9 @@
 	json_array_append_string(params, topic);
 	rpc_send(gc->ic, rpc);
+}
+
+static GList *rpc_away_states(struct im_connection *ic) {
+	struct rpc_plugin *pd = ic->acc->prpl->data;
+	return pd->away_states;
 }
 
@@ -787,5 +808,27 @@
 
 	struct prpl *ret = g_new0(struct prpl, 1);
-	
+	struct rpc_plugin *proto_data = g_new0(struct rpc_plugin, 1);
+	proto_data->addr = g_memdup(address, addrlen);
+	proto_data->addrlen = addrlen;
+	ret->name = g_strdup(json_object_get_string(isup, "name"));
+	ret->data = proto_data;
+
+	proto_data->account_flags = json_object_get_number(isup, "account_flags");
+
+	/* Keep a full copy of the settings list, we can only use it when we
+	 * have an account to work on. */
+	JSON_Value *settings = json_object_get_value(isup, "settings");
+	if (json_type(settings) == JSONObject)
+		proto_data->settings = json_value_deep_copy(settings);
+
+	JSON_Array *aways_a = json_object_get_array(isup, "away_state_list");
+	for (i = 0; i < json_array_get_count(aways_a); ++i) {
+		JSON_Value *state = json_array_get_value(aways_a, i);
+		if (json_type(state) == JSONString)
+			proto_data->away_states =
+				g_list_append(proto_data->away_states,
+					      g_strdup(json_string(state)));
+	}
+
 	JSON_Array *methods_a = json_object_get_array(isup, "method_list");
 	GHashTable *methods = g_hash_table_new(g_str_hash, g_str_equal);
@@ -814,4 +857,6 @@
 	RPC_ADD_FUNC(chat_join);
 	RPC_ADD_FUNC(chat_topic);
+	if (proto_data->away_states)
+		ret->away_states = rpc_away_states;
 	
 	g_hash_table_destroy(methods);
@@ -820,16 +865,4 @@
 	ret->handle_cmp = g_ascii_strcasecmp;
 	
-	struct rpc_plugin *proto_data = g_new0(struct rpc_plugin, 1);
-	proto_data->addr = g_memdup(address, addrlen);
-	proto_data->addrlen = addrlen;
-	ret->name = g_strdup(json_object_get_string(isup, "name"));
-	ret->data = proto_data;
-
-	/* Keep a full copy of the settings list, we can only use it when we
-	 * have an account to work on. */
-	JSON_Value *settings = json_object_get_value(isup, "settings");
-	if (json_type(settings) == JSONObject)
-		proto_data->settings = json_value_deep_copy(settings);
-
 	register_protocol(ret);
 }
@@ -859,5 +892,8 @@
 		rpc_initmodule_sock((struct sockaddr*) &su, sizeof(su));
 		g_free(fn);
-	}
-}
-
+		/* Idea: Also support textfiles containing a host:port tuple to
+		 * connect to. Not that remote RPC'ing would be a great idea,
+		 * but maybe some jsonrpc libs don't support Unix domain sockets. */
+	}
+}
+
Index: python/implugin.py
===================================================================
--- python/implugin.py	(revision f3af614c28f7eefb0cba6a41c74339a92ed96f5f)
+++ python/implugin.py	(revision c5a7b8d43cb3d5f0c32af83f9f51eb3a5398fdae)
@@ -35,5 +35,13 @@
 
 class BitlBeeIMPlugin(BaseHandler):
+	# Protocol name to be used in the BitlBee CLI, etc.
 	NAME = "rpc-test"
+
+	# See account.h (TODO: Add constants.)
+	ACCOUNT_FLAGS = 3
+	
+	# Supported away states. If your protocol supports a specific set of
+	# away states, put them in a list in this variable.
+	AWAY_STATES = ["Away", "Busy"] #None
 	
 	# Filled in during initialisation:
@@ -43,4 +51,6 @@
 	# Full version string
 	bitlbee_version_str = None
+	# Will become an RpcForwarder object to call into BitlBee
+	bee = None
 	
 	@classmethod
@@ -62,4 +72,6 @@
 			"name": self.NAME,
 			"method_list": list(set(dir(self)) & set(SUPPORTED_FUNCTIONS)),
+			"account_flags": self.ACCOUNT_FLAGS,
+			"away_state_list": self.AWAY_STATES,
 			"settings": {
 				"oauth": {
@@ -89,4 +101,7 @@
 		print self.bee.set_setstr("test", handle)
 		print self.bee.set_reset("test")
+	
+	def set_away(self, state, message):
+		print "You're a slacker: %s (%r)" % (state, message)
 
 def RunPlugin(plugin, debug=True):
