1 /* 2 * Copyright © 2010 Mank <mank@besthub.eu> 3 * Copyright © 2010 Eugene Petrov <dhamp@ya.ru> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * In addition, as a special exception, compiling, linking, and/or 20 * using OpenSSL with this program is allowed. 21 */ 22 23 #pragma once 24 25 #include <dcpp/stdinc.h> 26 #include "bookentry.hh" 27 #include "treeview.hh" 28 #include "wulformanager.hh" 29 30 31 class cmddebug: 32 public BookEntry, 33 private dcpp::DebugManagerListener, public dcpp::Thread 34 { 35 public: 36 cmddebug(); 37 virtual ~cmddebug(); 38 virtual void show(); 39 40 private: 41 void add_gui(std::string file); 42 void init(); 43 void addCmd(const std::string& cmd,const std::string& ip); 44 45 dcpp::CriticalSection cs; 46 dcpp::Semaphore s; 47 std::deque<std::string> cmdList; run()48 virtual int run() { 49 setThreadPriority(dcpp::Thread::LOW); 50 std::string x; 51 52 while(true) { 53 s.wait(); 54 55 { 56 dcpp::Lock l(cs); 57 58 if(cmdList.empty()) continue; 59 60 x = cmdList.front(); 61 cmdList.pop_front(); 62 63 } 64 typedef Func1<cmddebug,std::string> F1; 65 F1 *func = new F1(this, &cmddebug::add_gui, x); 66 WulforManager::get()->dispatchGuiFunc(func); 67 } 68 69 return 0; 70 } 71 72 void on(dcpp::DebugManagerListener::DebugDetection, const std::string& com) noexcept; 73 void on(dcpp::DebugManagerListener::DebugCommand, const std::string& mess, int typedir, const std::string& ip) noexcept; 74 75 static void onScroll_gui(GtkAdjustment *adjustment, gpointer data); 76 static void onResize_gui(GtkAdjustment *adjustment, gpointer data); 77 78 GtkTextBuffer *buffer; 79 static const int maxLines = 1000; 80 GtkTextIter iter; 81 bool scrollToBottom; 82 GtkTextMark *cmdMark; 83 84 }; 85