PageRenderTime 26ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/lllogchat.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 121 lines | 53 code | 15 blank | 53 comment | 0 complexity | c78f90cdeb91c48d0748789985ba5f8b MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lllogchat.h
  3. * @brief LLFloaterChat class definition
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLLOGCHAT_H
  27. #define LL_LLLOGCHAT_H
  28. class LLChat;
  29. class LLLogChat
  30. {
  31. public:
  32. // status values for callback function
  33. enum ELogLineType {
  34. LOG_EMPTY,
  35. LOG_LINE,
  36. LOG_LLSD,
  37. LOG_END
  38. };
  39. static std::string timestamp(bool withdate = false);
  40. static std::string makeLogFileName(std::string(filename));
  41. /**
  42. *Add functions to get old and non date stamped file names when needed
  43. */
  44. static std::string oldLogFileName(std::string(filename));
  45. static void saveHistory(const std::string& filename,
  46. const std::string& from,
  47. const LLUUID& from_id,
  48. const std::string& line);
  49. /** @deprecated @see loadAllHistory() */
  50. static void loadHistory(const std::string& filename,
  51. void (*callback)(ELogLineType, const LLSD&, void*),
  52. void* userdata);
  53. static void loadAllHistory(const std::string& file_name, std::list<LLSD>& messages);
  54. private:
  55. static std::string cleanFileName(std::string filename);
  56. };
  57. /**
  58. * Formatter for the plain text chat log files
  59. */
  60. class LLChatLogFormatter
  61. {
  62. public:
  63. LLChatLogFormatter(const LLSD& im) : mIM(im) {}
  64. virtual ~LLChatLogFormatter() {};
  65. friend std::ostream& operator<<(std::ostream& str, const LLChatLogFormatter& formatter)
  66. {
  67. formatter.format(formatter.mIM, str);
  68. return str;
  69. }
  70. protected:
  71. /**
  72. * Format an instant message to a stream
  73. * Timestamps and sender names are required
  74. * New lines of multilined messages are prepended with a space
  75. */
  76. void format(const LLSD& im, std::ostream& ostr) const;
  77. LLSD mIM;
  78. };
  79. /**
  80. * Parser for the plain text chat log files
  81. */
  82. class LLChatLogParser
  83. {
  84. public:
  85. /**
  86. * Parse a line from the plain text chat log file
  87. * General plain text log format is like: "[timestamp] [name]: [message]"
  88. * [timestamp] and [name] are optional
  89. * Examples of plain text chat log lines:
  90. * "[2009/11/20 2:53] Igor ProductEngine: howdy"
  91. * "Igor ProductEngine: howdy"
  92. * "Dserduk ProductEngine is Online"
  93. *
  94. * @return false if failed to parse mandatory data - message text
  95. */
  96. static bool parse(std::string& raw, LLSD& im);
  97. protected:
  98. LLChatLogParser();
  99. virtual ~LLChatLogParser() {};
  100. };
  101. // LLSD map lookup constants
  102. extern const std::string IM_TIME; //("time");
  103. extern const std::string IM_TEXT; //("message");
  104. extern const std::string IM_FROM; //("from");
  105. extern const std::string IM_FROM_ID; //("from_id");
  106. #endif