]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Client/src/principal.cpp
Mini bugfix.
[z.facultad/75.42/plaqui.git] / Client / src / principal.cpp
index 89caf8233ccf2161847e4119c618a0354b10b35d..0a48c30eb76b52508728721e6cf94a7609fd68af 100644 (file)
@@ -53,7 +53,7 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &
        rev = rev.substr(6, rev.length() - 8);
        std::string s = "PlaQui Client versión " VERSION " (revisión ";
        s += rev + ")"; 
        rev = rev.substr(6, rev.length() - 8);
        std::string s = "PlaQui Client versión " VERSION " (revisión ";
        s += rev + ")"; 
-       lbl_plaqui_version->set_text(Glib::locale_to_utf8(s));
+       lbl_plaqui_version->set_text(Glib::convert(s, "UTF-8", "ISO-8859-1"));
 
        rg->get_widget("anim_frames", anim);
        anim->set(anim_frames[current_frame]);
 
        rg->get_widget("anim_frames", anim);
        anim->set(anim_frames[current_frame]);
@@ -378,7 +378,14 @@ void Principal::on_conexion_ok(const std::string &body)
                load_xml_dispatch();
        } else {
                Glib::ustring s;
                load_xml_dispatch();
        } else {
                Glib::ustring s;
-               s = "<IN>\n"+Glib::locale_to_utf8(body)+"\n</IN>\n";
+               try {
+                       // El mensaje deberia convertirse a UTF antes de
+                       // mandarlo para evitar problemas.
+                       s = "<IN>\n"+Glib::locale_to_utf8(body)+"\n</IN>\n";
+               }
+               catch (...) {
+                       s = "NO SE PUDO CONVERTIR MENSAJE A UTF8";
+               }
                txt_view->get_buffer()->insert(txt_view->get_buffer()->begin(),s);
        }
 }
                txt_view->get_buffer()->insert(txt_view->get_buffer()->begin(),s);
        }
 }
@@ -484,6 +491,7 @@ void Principal::loadNot(xmlNodePtr nodo)
                                y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
                        } else if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
                                linea.dst = (char *)XML_GET_CONTENT(nodo->children);
                                y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
                        } else if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
                                linea.dst = (char *)XML_GET_CONTENT(nodo->children);
+                               linea.is_tank = false;
                                p->out_lines.push_back(linea);
                        } else if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) {
                                linea.dst = (char *)XML_GET_CONTENT(nodo->children);
                                p->out_lines.push_back(linea);
                        } else if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) {
                                linea.dst = (char *)XML_GET_CONTENT(nodo->children);
@@ -529,6 +537,7 @@ void Principal::loadOr(xmlNodePtr nodo)
                                y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
                        } else if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
                                linea.dst = (char *)XML_GET_CONTENT(nodo->children);
                                y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
                        } else if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
                                linea.dst = (char *)XML_GET_CONTENT(nodo->children);
+                               linea.is_tank = false;
                                p->out_lines.push_back(linea);
                        } else if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) {
                                linea.dst = (char *)XML_GET_CONTENT(nodo->children);
                                p->out_lines.push_back(linea);
                        } else if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) {
                                linea.dst = (char *)XML_GET_CONTENT(nodo->children);
@@ -802,10 +811,18 @@ void Principal::loadDrain(xmlNodePtr nodo)
        mapItems[name] = b;
 }
 
        mapItems[name] = b;
 }
 
-void Principal::read_status_xml(const std::string &frame)
+void Principal::read_status_xml(const std::string &_frame)
 {
        std::string item_name;
 {
        std::string item_name;
+       std::string frame = _frame;
        xmlDocPtr document;
        xmlDocPtr document;
+
+       // Cambio las , por . para evitar problemas de convercion 
+       for(int i=0; i<frame.size(); i++) {
+               if (frame[i] == ',') {
+                       frame[i] = '.';
+               }
+       }
        document = xmlParseMemory(frame.c_str(),frame.size());
        if (document == NULL) {
                txt_view->get_buffer()->insert(txt_view->get_buffer()->begin(), "ERROR : No se pudo leer el último frame!\n");
        document = xmlParseMemory(frame.c_str(),frame.size());
        if (document == NULL) {
                txt_view->get_buffer()->insert(txt_view->get_buffer()->begin(), "ERROR : No se pudo leer el último frame!\n");
@@ -854,7 +871,7 @@ void Principal::read_status_xml(const std::string &frame)
                                                        else if (xmlStrcmp(nodo_tmp->name, BAD_CAST"litros")==0)
                                                                lit= atof( (char *)XML_GET_CONTENT(nodo_tmp->children) );
                                                        else if (xmlStrcmp(nodo_tmp->name, BAD_CAST"salida")==0) {
                                                        else if (xmlStrcmp(nodo_tmp->name, BAD_CAST"litros")==0)
                                                                lit= atof( (char *)XML_GET_CONTENT(nodo_tmp->children) );
                                                        else if (xmlStrcmp(nodo_tmp->name, BAD_CAST"salida")==0) {
-                                                               if (xmlStrcmp(xmlGetProp(items, BAD_CAST"id"), BAD_CAST"inferior")==0) {
+                                                               if (xmlStrcmp(xmlGetProp(nodo_tmp, BAD_CAST"id"), BAD_CAST"inferior")==0) {
                                                                        b_inf = get_bool_from_xml(nodo_tmp->children);
                                                                } else {
                                                                        b_sup = get_bool_from_xml(nodo_tmp->children);
                                                                        b_inf = get_bool_from_xml(nodo_tmp->children);
                                                                } else {
                                                                        b_sup = get_bool_from_xml(nodo_tmp->children);
@@ -905,16 +922,21 @@ Gdk::Color Principal::get_rgb_from_xml(xmlNodePtr nodo)
 float Principal::get_float_from_xml(xmlNodePtr nodo)
 {
        float tmp = -1;
 float Principal::get_float_from_xml(xmlNodePtr nodo)
 {
        float tmp = -1;
+       std::string s;
        while (nodo != NULL) {
                if (nodo->type == XML_ELEMENT_NODE) {
                        if (xmlStrcmp(nodo->name, BAD_CAST"actual_flow")==0) {
        while (nodo != NULL) {
                if (nodo->type == XML_ELEMENT_NODE) {
                        if (xmlStrcmp(nodo->name, BAD_CAST"actual_flow")==0) {
-                               tmp = atof( (char *)XML_GET_CONTENT(nodo->children) );
+                               s = (char *)XML_GET_CONTENT(nodo->children);
                                break;
                        }
                }
                nodo = nodo->next;
        }
                                break;
                        }
                }
                nodo = nodo->next;
        }
+       std::stringstream ss;
+       ss << s;
+       ss >> tmp;
        if (tmp == INFINITO) tmp = 0;
        if (tmp == INFINITO) tmp = 0;
+
        return tmp;
 }
 
        return tmp;
 }