示例#1
0
文件: client.cpp 项目: j0wl/licq
void Client::broadcastPhotoHash(const boost::optional<std::string>& hash)
{
  TRACE();

  if (hash)
  {
    if (hash->empty())
    {
      // Bug in gloox: if the hash is empty then VCardUpdate will not generate
      // a empty photo tag as it should.
      gloox::VCardUpdate card("dummy");

      gloox::Tag* tag = card.tag();
      tag->removeChild("photo");
      new gloox::Tag(tag, "photo");

      myClient.addPresenceExtension(new gloox::VCardUpdate(tag));
      delete tag;
    }
    else
      myClient.addPresenceExtension(new gloox::VCardUpdate(*hash));
  }
  else
  {
    myClient.addPresenceExtension(new gloox::VCardUpdate);
  }

  myClient.setPresence();
}
示例#2
0
 Connection(std::string const& connection_str,boost::optional<std::string> const& password)
     : cursorId(0),
       closed_(false),
       pending_(false)
 {
     std::string connect_with_pass = connection_str;
     if (password && !password->empty())
     {
         connect_with_pass += " password="******"postgis_connection: postgresql connection create - " << this;
     if (PQstatus(conn_) != CONNECTION_OK)
     {
         std::string err_msg = "Postgis Plugin: ";
         err_msg += status();
         err_msg += "\nConnection string: '";
         err_msg += connection_str;
         err_msg += "'\n";
         MAPNIK_LOG_DEBUG(postgis) << "postgis_connection: creation failed, closing connection - " << this;
         close();
         throw mapnik::datasource_exception(err_msg);
     }
     PGresult *result = PQexec(conn_, "SET DEFAULT_TRANSACTION_READ_ONLY = TRUE;");
     bool ok = (result && (PQresultStatus(result) == PGRES_COMMAND_OK));
     if ( result ) PQclear(result);
     if ( ! ok ) {
         std::string err_msg = "Postgis Plugin: ";
         err_msg += status();
         err_msg += "\nConnection string: '";
         err_msg += connection_str;
         err_msg += "'\n";
         throw mapnik::datasource_exception(err_msg);
     }
 }
    inline std::string connection_string() const {
        std::string rs = *host_;

        if (port_ && !port_->empty())
            rs += ":" + *port_;

        return rs;
    }
示例#4
0
 VrpnBasedConnection::VrpnBasedConnection(
     boost::optional<std::string const &> iface, boost::optional<int> port) {
     int myPort = port.get_value_or(0);
     if (iface && !(iface->empty())) {
         m_initConnection(iface->c_str(), myPort);
     } else {
         m_initConnection(nullptr, myPort);
     }
 }