Logo Search packages:      
Sourcecode: vdr-plugin-fritzbox version File versions  Download package

std::string cOertlichesFonbuch::ResolveToName ( std::string &  number ) [virtual]

Resolves the given number to the corresponding name.

Parameters:
numberthe number to resolve
Returns:
the resolved name or the number, if unsuccesful

Reimplemented from cFonbuch.

Definition at line 38 of file oertlichesfonbuch.c.

                                                            {

      std::string msg;
      std::string name;
      try {
            dsyslog("oertlichesfonbuch.c: sending reverse lookup request to www.dasoertliche.de");
            std::string host = "www.dasoertliche.de";
            cHttpClient tc(host, PORT_WWW);
            tc << "GET /?form_name=detail&lastFormName=search_inv&ph=" << number << "&recFrom=1&hitno=99&zvo_ok=1&page=TREFFERLISTE&context=TREFFERLISTE&action=TEILNEHMER&detvert_ok=1 HTTP/1.1\nHost: www.dasoertliche.de\nAccept-Charset: ISO-8859-1\n\n\0";
            do {
                  tc >> msg;
                  usleep(100000);
            } while (msg.find(std::string("</html>")) == std::string::npos);

      } catch (cTcpException te) {
            dsyslog("oertlichesfonbuch.c: Exception - %s", te.what());
            return number;
      }
      // parse answer
      size_t start = msg.find("<div class=\"detail_top\">");
      if (start == std::string::npos)
            return number;
      // add the length of search pattern
      start += 24;
      size_t stop  = msg.find("<", start);
      name = msg.substr(start, stop - start);
#if VDRVERSNUM >= 10503
            // convert the string from latin1 to current system character table
            cCharSetConv *conv = new cCharSetConv("ISO-8859-1", cCharSetConv::SystemCharacterTable());
            const char *s_converted = conv->Convert(name.c_str());
            name = s_converted;
            delete (conv);
#endif
      return name;
}

Generated by  Doxygen 1.6.0   Back to index