aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lllogchat.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/lllogchat.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/lllogchat.cpp')
-rw-r--r--linden/indra/newview/lllogchat.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/linden/indra/newview/lllogchat.cpp b/linden/indra/newview/lllogchat.cpp
index 38c4869..030b357 100644
--- a/linden/indra/newview/lllogchat.cpp
+++ b/linden/indra/newview/lllogchat.cpp
@@ -38,16 +38,29 @@
38const S32 LOG_RECALL_SIZE = 2048; 38const S32 LOG_RECALL_SIZE = 2048;
39 39
40//static 40//static
41LLString LLLogChat::makeLogFileName(LLString filename) 41std::string LLLogChat::makeLogFileName(std::string filename)
42{ 42{
43 filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename.c_str()); 43 filename = cleanFileName(filename);
44 filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename);
44 filename += ".txt"; 45 filename += ".txt";
45 return filename; 46 return filename;
46} 47}
47 48
48LLString LLLogChat::timestamp(bool withdate) 49std::string LLLogChat::cleanFileName(std::string filename)
49{ 50{
50 U32 utc_time; 51 std::string invalidChars = "\"\'\\/?*:<>|";
52 S32 position = filename.find_first_of(invalidChars);
53 while (position != filename.npos)
54 {
55 filename[position] = '_';
56 position = filename.find_first_of(invalidChars, position);
57 }
58 return filename;
59}
60
61std::string LLLogChat::timestamp(bool withdate)
62{
63 time_t utc_time;
51 utc_time = time_corrected(); 64 utc_time = time_corrected();
52 65
53 // There's only one internal tm buffer. 66 // There's only one internal tm buffer.
@@ -57,7 +70,7 @@ LLString LLLogChat::timestamp(bool withdate)
57 // it's daylight savings time there. 70 // it's daylight savings time there.
58 timep = utc_to_pacific_time(utc_time, gPacificDaylightTime); 71 timep = utc_to_pacific_time(utc_time, gPacificDaylightTime);
59 72
60 LLString text; 73 std::string text;
61 if (withdate) 74 if (withdate)
62 text = llformat("[%d/%02d/%02d %d:%02d] ", (timep->tm_year-100)+2000, timep->tm_mon+1, timep->tm_mday, timep->tm_hour, timep->tm_min); 75 text = llformat("[%d/%02d/%02d %d:%02d] ", (timep->tm_year-100)+2000, timep->tm_mon+1, timep->tm_mday, timep->tm_hour, timep->tm_min);
63 else 76 else
@@ -68,7 +81,7 @@ LLString LLLogChat::timestamp(bool withdate)
68 81
69 82
70//static 83//static
71void LLLogChat::saveHistory(LLString filename, LLString line) 84void LLLogChat::saveHistory(std::string filename, std::string line)
72{ 85{
73 if(!filename.size()) 86 if(!filename.size())
74 { 87 {
@@ -76,7 +89,7 @@ void LLLogChat::saveHistory(LLString filename, LLString line)
76 return; 89 return;
77 } 90 }
78 91
79 LLFILE* fp = LLFile::fopen(LLLogChat::makeLogFileName(filename).c_str(), "a"); /*Flawfinder: ignore*/ 92 LLFILE* fp = LLFile::fopen(LLLogChat::makeLogFileName(filename), "a"); /*Flawfinder: ignore*/
80 if (!fp) 93 if (!fp)
81 { 94 {
82 llinfos << "Couldn't open chat history log!" << llendl; 95 llinfos << "Couldn't open chat history log!" << llendl;
@@ -89,19 +102,19 @@ void LLLogChat::saveHistory(LLString filename, LLString line)
89 } 102 }
90} 103}
91 104
92void LLLogChat::loadHistory(LLString filename , void (*callback)(ELogLineType,LLString,void*), void* userdata) 105void LLLogChat::loadHistory(std::string filename , void (*callback)(ELogLineType,std::string,void*), void* userdata)
93{ 106{
94 if(!filename.size()) 107 if(!filename.size())
95 { 108 {
96 llerrs << "Filename is Empty!" << llendl; 109 llerrs << "Filename is Empty!" << llendl;
97 } 110 }
98 111
99 LLFILE* fptr = LLFile::fopen(makeLogFileName(filename).c_str(), "r"); /*Flawfinder: ignore*/ 112 LLFILE* fptr = LLFile::fopen(makeLogFileName(filename), "r"); /*Flawfinder: ignore*/
100 if (!fptr) 113 if (!fptr)
101 { 114 {
102 //LLUIString message = LLFloaterChat::getInstance()->getUIString("IM_logging_string"); 115 //LLUIString message = LLFloaterChat::getInstance()->getUIString("IM_logging_string");
103 //callback(LOG_EMPTY,"IM_logging_string",userdata); 116 //callback(LOG_EMPTY,"IM_logging_string",userdata);
104 callback(LOG_EMPTY,"",userdata); 117 callback(LOG_EMPTY,LLStringUtil::null,userdata);
105 return; //No previous conversation with this name. 118 return; //No previous conversation with this name.
106 } 119 }
107 else 120 else
@@ -128,14 +141,14 @@ void LLLogChat::loadHistory(LLString filename , void (*callback)(ELogLineType,LL
128 141
129 if (!firstline) 142 if (!firstline)
130 { 143 {
131 callback(LOG_LINE,buffer,userdata); 144 callback(LOG_LINE,std::string(buffer),userdata);
132 } 145 }
133 else 146 else
134 { 147 {
135 firstline = FALSE; 148 firstline = FALSE;
136 } 149 }
137 } 150 }
138 callback(LOG_END,"",userdata); 151 callback(LOG_END,LLStringUtil::null,userdata);
139 152
140 fclose(fptr); 153 fclose(fptr);
141 } 154 }