Changeset

218:39af184385cd

plugins.version: Use get_child_text() and fix traceback on empty iq-result reply.
author Kim Alvefur <zash@zash.se>
date Thu, 22 Sep 2011 19:52:06 +0200
parents 217:60db4e738910
children 219:ce8ed17710cb
files plugins/version.lua
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/version.lua	Thu Sep 08 18:04:49 2011 +0200
+++ b/plugins/version.lua	Thu Sep 22 19:52:06 2011 +0200
@@ -30,15 +30,15 @@
 		stream:send_iq(verse.iq({ type = "get", to = target_jid })
 			:tag("query", { xmlns = xmlns_version }), 
 			function (reply)
-				local query = reply:get_child("query", xmlns_version);
 				if reply.attr.type == "result" then
-					local name = query:get_child("name");
-					local version = query:get_child("version");
-					local os = query:get_child("os");
+					local query = reply:get_child("query", xmlns_version);
+					local name = query and query:get_child_text("name");
+					local version = query and query:get_child_text("version");
+					local os = query and query:get_child_text("os");
 					callback({
-						name = name and name:get_text() or nil;
-						version = version and version:get_text() or nil;
-						platform = os and os:get_text() or nil;
+						name = name;
+						version = version;
+						platform = os;
 						});
 				else
 					local type, condition, text = reply:get_error();