soc.2009.transport: 018f3033: Move setRequestFields to dataforms.cpp

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Sat Jun 27 05:20:21 EDT 2009


-----------------------------------------------------------------
Revision: 018f30333ae2dfb4dc75448acedfa7d7c3f7fb97
Ancestor: 439c2999d42e9695d8108ece3deb877c7b002e26
Author: hanzz at soc.pidgin.im
Date: 2009-06-27T09:10:56
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/018f30333ae2dfb4dc75448acedfa7d7c3f7fb97

Modified files:
        adhocrepeater.cpp dataforms.cpp dataforms.h

ChangeLog: 

Move setRequestFields to dataforms.cpp

-------------- next part --------------
============================================================
--- adhocrepeater.cpp	1e09f7b61c354ee0178bce0954e221dce561fe0d
+++ adhocrepeater.cpp	4c1bf33c12b6fe3f9d16c7eb8f9ec68e2d71027c
@@ -176,42 +176,7 @@ bool AdhocRepeater::handleIq(const IQ &s
 	Tag *x = tag->findChildWithAttrib("xmlns","jabber:x:data");
 	if (x) {
 		if (m_type == PURPLE_REQUEST_FIELDS) {
-			for(std::list<Tag*>::const_iterator it = x->children().begin(); it != x->children().end(); ++it){
-				std::string key = (*it)->findAttribute("var");
-				if (key.empty()) continue;
-				
-				PurpleRequestField * fld = purple_request_fields_get_field(m_fields, key.c_str());
-				if (!fld) continue;
-				PurpleRequestFieldType type;
-				type = purple_request_field_get_type(fld);
-				
-				Tag *v =(*it)->findChild("value");
-				if (!v) continue;
-				
-				std::string val = v->cdata();
-				if (val.empty() && type != PURPLE_REQUEST_FIELD_STRING)
-					continue;
-				
-				if (type == PURPLE_REQUEST_FIELD_STRING) {
-					purple_request_field_string_set_value(fld, (val.empty() ? NULL : val.c_str()));
-				}
-				else if (type == PURPLE_REQUEST_FIELD_INTEGER) {
-					purple_request_field_int_set_value(fld, atoi(val.c_str()));
-				}
-				else if (type == PURPLE_REQUEST_FIELD_BOOLEAN) {
-					purple_request_field_bool_set_value(fld, atoi(val.c_str()));
-				}
-				else if (type == PURPLE_REQUEST_FIELD_CHOICE) {
-					purple_request_field_choice_set_value(fld, atoi(val.c_str()));
-				}
-				else if (type == PURPLE_REQUEST_FIELD_LIST) {
-					for(std::list<Tag*>::const_iterator it2 = (*it)->children().begin(); it2 != (*it)->children().end(); ++it2) {
-						val = (*it2)->cdata();
-						if (!val.empty())
-							purple_request_field_list_add_selected(fld, val.c_str());
-					}
-				}
-			}
+			setRequestFields(m_fields, x);
 			((PurpleRequestFieldsCb) m_ok_cb) (m_requestData, m_fields);
 		}
 		else {
============================================================
--- dataforms.cpp	98948695c73052911a683ccb62ab2d3eaa4bb8ab
+++ dataforms.cpp	c11ef9207e0badf3d0f4b0dd55b64d994956810c
@@ -216,3 +216,42 @@ Tag * xdataFromRequestFields(const std::
 	
 	return xdata;
 }
+
+void setRequestFields(PurpleRequestFields *m_fields, Tag *x) {
+	for(std::list<Tag*>::const_iterator it = x->children().begin(); it != x->children().end(); ++it) {
+		std::string key = (*it)->findAttribute("var");
+		if (key.empty()) continue;
+		
+		PurpleRequestField * fld = purple_request_fields_get_field(m_fields, key.c_str());
+		if (!fld) continue;
+		PurpleRequestFieldType type;
+		type = purple_request_field_get_type(fld);
+		
+		Tag *v =(*it)->findChild("value");
+		if (!v) continue;
+		
+		std::string val = v->cdata();
+		if (val.empty() && type != PURPLE_REQUEST_FIELD_STRING)
+			continue;
+		
+		if (type == PURPLE_REQUEST_FIELD_STRING) {
+			purple_request_field_string_set_value(fld, (val.empty() ? NULL : val.c_str()));
+		}
+		else if (type == PURPLE_REQUEST_FIELD_INTEGER) {
+			purple_request_field_int_set_value(fld, atoi(val.c_str()));
+		}
+		else if (type == PURPLE_REQUEST_FIELD_BOOLEAN) {
+			purple_request_field_bool_set_value(fld, atoi(val.c_str()));
+		}
+		else if (type == PURPLE_REQUEST_FIELD_CHOICE) {
+			purple_request_field_choice_set_value(fld, atoi(val.c_str()));
+		}
+		else if (type == PURPLE_REQUEST_FIELD_LIST) {
+			for(std::list<Tag*>::const_iterator it2 = (*it)->children().begin(); it2 != (*it)->children().end(); ++it2) {
+				val = (*it2)->cdata();
+				if (!val.empty())
+					purple_request_field_list_add_selected(fld, val.c_str());
+			}
+		}
+	}
+}
============================================================
--- dataforms.h	2bd839419e22d1d1585d0b774b309c29ed6850e0
+++ dataforms.h	dde67c09a2f380d9e4fe36a110a8de5ff9e8f3e9
@@ -30,5 +30,6 @@ Tag * xdataFromRequestFields(const std::
 Tag * xdataFromRequestInput(const std::string &title, const std::string &primaryString, const std::string &value, gboolean multiline);
 Tag * xdataFromRequestAction(const std::string &title, const std::string &primaryString, size_t action_count, va_list acts);
 Tag * xdataFromRequestFields(const std::string &title, const std::string &primaryString, PurpleRequestFields *fields);
+void setRequestFields(PurpleRequestFields *m_fields, Tag *x);
 
 #endif


More information about the Commits mailing list