|
@@ -31,57 +31,68 @@ std::string Decode(const std::string& data)
|
|
|
|
|
|
|
|
void message::processMessage(const std::string& message)
|
|
void message::processMessage(const std::string& message)
|
|
|
{
|
|
{
|
|
|
- message::state::type state = message::state::header;
|
|
|
|
|
- std::string line;
|
|
|
|
|
- std::istringstream stream(message);
|
|
|
|
|
- while (std::getline(stream, line, '\r'))
|
|
|
|
|
|
|
+ try
|
|
|
{
|
|
{
|
|
|
- boost::erase_all(line, "\n");
|
|
|
|
|
- switch (state)
|
|
|
|
|
|
|
+ std::cout << "message::processMessage enter" << std::endl;
|
|
|
|
|
+ message::state::type state = message::state::header;
|
|
|
|
|
+ std::string line;
|
|
|
|
|
+ std::istringstream stream(message);
|
|
|
|
|
+ while (std::getline(stream, line, '\r'))
|
|
|
{
|
|
{
|
|
|
- case state::header:
|
|
|
|
|
- state = processHeaderLine(line);
|
|
|
|
|
- break;
|
|
|
|
|
- case state::data:
|
|
|
|
|
- state = processDataLine(line);
|
|
|
|
|
- break;
|
|
|
|
|
- case state::mimeBoundary:
|
|
|
|
|
- state = processMimeBoundary(line);
|
|
|
|
|
- break;
|
|
|
|
|
- case state::image:
|
|
|
|
|
- state = processImage(line);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ boost::erase_all(line, "\n");
|
|
|
|
|
+ switch (state)
|
|
|
|
|
+ {
|
|
|
|
|
+ case state::header:
|
|
|
|
|
+ state = processHeaderLine(line);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case state::data:
|
|
|
|
|
+ state = processDataLine(line);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case state::mimeBoundary:
|
|
|
|
|
+ state = processMimeBoundary(line);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case state::image:
|
|
|
|
|
+ state = processImage(line);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- if (boost::algorithm::contains(m_contentEncoding, "base64"))
|
|
|
|
|
- {
|
|
|
|
|
- std::string decoded = Decode(m_subject);
|
|
|
|
|
- if (decoded.size() > 0)
|
|
|
|
|
- m_subject = decoded;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (boost::algorithm::contains(m_contentEncoding, "base64"))
|
|
|
|
|
+ {
|
|
|
|
|
+ std::string decoded = Decode(m_subject);
|
|
|
|
|
+ if (decoded.size() > 0)
|
|
|
|
|
+ m_subject = decoded;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- outputImage image(m_images);
|
|
|
|
|
|
|
+ outputImage image(m_images);
|
|
|
|
|
|
|
|
- boost::filesystem::path path(m_context.path);
|
|
|
|
|
- path = boost::filesystem::canonical(path);
|
|
|
|
|
- path /= m_address;
|
|
|
|
|
|
|
+ boost::filesystem::path path(m_context.path);
|
|
|
|
|
+ path = boost::filesystem::canonical(path);
|
|
|
|
|
+ path /= m_address;
|
|
|
|
|
|
|
|
- if (!boost::filesystem::exists(path))
|
|
|
|
|
- boost::filesystem::create_directory(path);
|
|
|
|
|
|
|
+ if (!boost::filesystem::exists(path))
|
|
|
|
|
+ boost::filesystem::create_directory(path);
|
|
|
|
|
|
|
|
- std::string fileName(getTimeString());
|
|
|
|
|
- fileName.append(".jpg");
|
|
|
|
|
- path /= fileName;
|
|
|
|
|
|
|
+ std::string fileName(getTimeString());
|
|
|
|
|
+ fileName.append(".jpg");
|
|
|
|
|
+ path /= fileName;
|
|
|
|
|
|
|
|
- image.save(path.string());
|
|
|
|
|
|
|
+ image.save(path.string());
|
|
|
|
|
|
|
|
- if (!m_context.url.empty())
|
|
|
|
|
|
|
+ if (!m_context.url.empty())
|
|
|
|
|
+ {
|
|
|
|
|
+ std::stringstream url;
|
|
|
|
|
+ url << m_context.url << "?ip=" << m_address << "&file=" << fileName;
|
|
|
|
|
+ m_context.client.GetUrlContents(url.str());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (std::exception& e)
|
|
|
{
|
|
{
|
|
|
- std::stringstream url;
|
|
|
|
|
- url << m_context.url << "?ip=" << m_address << "&file=" << fileName;
|
|
|
|
|
- m_context.client.GetUrlContents(url.str());
|
|
|
|
|
|
|
+ std::cout << "Exception: " << e.what() << std::endl;
|
|
|
|
|
+ std::cerr << "Exception: " << e.what() << std::endl;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ std::cout << "message::processMessage exit" << std::endl;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
message::state::type message::processHeaderLine(const std::string& line)
|
|
message::state::type message::processHeaderLine(const std::string& line)
|