1 /********************************************************************** 2 * 3 * FreeDoko a Doppelkopf-Game 4 * 5 * Copyright (C) 2001 – 2018 by Diether Knof and Borg Enders 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 2 of 10 * the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * You can find this license in the file 'gpl.txt'. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA 22 * 23 * Contact: 24 * Diether Knof dknof@posteo.de 25 * 26 **********************************************************************/ 27 28 #include "constants.h" 29 30 #ifdef USE_UI_TEXT 31 32 #include "bug_report.h" 33 34 #include "../../os/bug_report.h" 35 #include "../../misc/translations.h" 36 #include "../../utils/string.h" 37 38 namespace UI_TEXT_NS { 39 40 /** 41 ** 42 ** constructor 43 ** 44 ** @param ui pointer to the ui 45 ** 46 ** 47 ** 48 ** 49 **/ BugReport(UI_Text * const ui)50 UI_Text::BugReport::BugReport(UI_Text* const ui) : 51 ui(ui) 52 { } 53 54 /** 55 ** 56 ** destructor 57 ** 58 ** 59 ** 60 ** 61 ** 62 **/ ~BugReport()63 UI_Text::BugReport::~BugReport() 64 { } 65 66 /** 67 ** 68 ** interprets the line read by the ui 69 ** 70 ** 71 ** @return whether the line was interpreted 72 ** 73 ** 74 ** 75 **/ 76 bool interpret_line()77 UI_Text::BugReport::interpret_line() 78 { 79 // whether the line has been interpreted 80 bool interpreted = false; 81 82 if (this->ui->iskeyword("bug report")) { 83 this->create(); 84 interpreted = true; 85 } // if (this->ui->iskeyword("help")) 86 87 return interpreted; 88 } // bool UI_Text::BugReport::interpret_line() 89 90 /** 91 ** 92 ** create a bug report 93 ** 94 ** 95 ** @return the file in which the bug report is written 96 ** 97 ** 98 ** 99 **/ 100 string create()101 UI_Text::BugReport::create() 102 { 103 this->ui->ostr() << ::translation("Creating bug-report.") << '\n' 104 << ::translation("Please type your message.") << '\n'; 105 106 string line; // the read line 107 string message; // the message 108 while (this->ui->istr().good()) { 109 std::getline(this->ui->istr(), line); 110 if (line == ".") 111 break; 112 113 message += line; 114 message += "\n"; 115 } // while (this->ui->istr().good()) 116 117 string const filename = ::bug_report->report(message); 118 119 this->ui->ostr() << ::translation("The bug report is written into the file '%sfile%'.", filename.c_str()) 120 << '\n'; 121 122 return filename; 123 } // string UI_Text::BugReport::create() 124 125 } // namespace UI_TEXT_NS 126 127 #endif // #ifdef USE_UI_TEXT 128