From 06772a369f2beef80bb291ded30cbe125a24af56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Fri, 26 Oct 2018 04:07:01 +0200 Subject: Fix structure of directories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- CHANGELOG | 69 +++++ CMakeLists.txt | 10 + Doxyfile | 266 +++++++++++++++++ Makefile.am | 3 + Makefile.am.in | 3 + doc/.gitignore | 0 doc/CMakeLists.txt | 1 + doc/COPYING-DOCS | 397 +++++++++++++++++++++++++ doc/Makefile.am | 1 + doc/en/CMakeLists.txt | 1 + doc/en/Makefile.am | 2 + doc/en/index.docbook | 115 +++++++ doc/man/CMakeLists.txt | 5 + doc/man/Makefile.am | 3 + doc/man/knetstats.1 | 53 ++++ doc/man/manpage.xml | 142 +++++++++ icons/CMakeLists.txt | 3 + icons/Makefile.am | 1 + icons/hi16-app-knetstats.png | Bin 0 -> 1919 bytes icons/hi32-app-knetstats.png | Bin 0 -> 2286 bytes icons/hi48-app-knetstats.png | Bin 0 -> 12237 bytes knetstats.desktop | 32 ++ src/.svnignore | 2 - src/CHANGELOG | 69 ----- src/CMakeLists.txt | 39 ++- src/COPYING-DOCS | 397 ------------------------- src/Doxyfile | 266 ----------------- src/Makefile.am | 23 +- src/chart.cpp | 65 ++++ src/chart.h | 43 +++ src/configure.cpp | 161 ++++++++++ src/configure.h | 66 ++++ src/configurebase.ui | 677 ++++++++++++++++++++++++++++++++++++++++++ src/doc/CMakeLists.txt | 1 - src/doc/Makefile.am | 1 - src/doc/en/CMakeLists.txt | 1 - src/doc/en/Makefile.am | 2 - src/doc/en/index.docbook | 115 ------- src/doc/man/CMakeLists.txt | 5 - src/doc/man/Makefile.am | 4 - src/doc/man/knetstats.1 | 53 ---- src/doc/man/manpage.xml | 142 --------- src/hi16-app-knetstats.png | Bin 1919 -> 0 bytes src/hi32-app-knetstats.png | Bin 2286 -> 0 bytes src/hi48-app-knetstats.png | Bin 12237 -> 0 bytes src/interface.cpp | 57 ++++ src/interface.h | 51 ++++ src/knetstats.cpp | 191 ++++++++++++ src/knetstats.desktop | 32 -- src/knetstats.h | 94 ++++++ src/knetstatsview.cpp | 402 +++++++++++++++++++++++++ src/knetstatsview.h | 260 ++++++++++++++++ src/main.cpp | 66 ++++ src/pics/CMakeLists.txt | 6 + src/pics/Makefile.am | 5 + src/pics/icon_pci.png | Bin 0 -> 704 bytes src/pics/theme0_both.png | Bin 0 -> 1406 bytes src/pics/theme0_error.png | Bin 0 -> 1510 bytes src/pics/theme0_none.png | Bin 0 -> 1403 bytes src/pics/theme0_rx.png | Bin 0 -> 1411 bytes src/pics/theme0_tx.png | Bin 0 -> 1405 bytes src/pics/theme1_both.png | Bin 0 -> 1219 bytes src/pics/theme1_error.png | Bin 0 -> 483 bytes src/pics/theme1_none.png | Bin 0 -> 482 bytes src/pics/theme1_rx.png | Bin 0 -> 881 bytes src/pics/theme1_tx.png | Bin 0 -> 927 bytes src/pics/theme2_both.png | Bin 0 -> 1384 bytes src/pics/theme2_error.png | Bin 0 -> 709 bytes src/pics/theme2_none.png | Bin 0 -> 835 bytes src/pics/theme2_rx.png | Bin 0 -> 1121 bytes src/pics/theme2_tx.png | Bin 0 -> 1115 bytes src/pics/theme3_both.png | Bin 0 -> 870 bytes src/pics/theme3_error.png | Bin 0 -> 342 bytes src/pics/theme3_none.png | Bin 0 -> 339 bytes src/pics/theme3_rx.png | Bin 0 -> 615 bytes src/pics/theme3_tx.png | Bin 0 -> 787 bytes src/pics/theme4_both.png | Bin 0 -> 1034 bytes src/pics/theme4_error.png | Bin 0 -> 1245 bytes src/pics/theme4_none.png | Bin 0 -> 1000 bytes src/pics/theme4_rx.png | Bin 0 -> 1025 bytes src/pics/theme4_tx.png | Bin 0 -> 1025 bytes src/src/CMakeLists.txt | 38 --- src/src/Makefile.am | 22 -- src/src/chart.cpp | 65 ---- src/src/chart.h | 43 --- src/src/configure.cpp | 161 ---------- src/src/configure.h | 66 ---- src/src/configurebase.ui | 677 ------------------------------------------ src/src/interface.cpp | 57 ---- src/src/interface.h | 51 ---- src/src/knetstats.cpp | 191 ------------ src/src/knetstats.h | 94 ------ src/src/knetstatsview.cpp | 402 ------------------------- src/src/knetstatsview.h | 260 ---------------- src/src/main.cpp | 66 ---- src/src/pics/CMakeLists.txt | 6 - src/src/pics/Makefile.am | 5 - src/src/pics/icon_pci.png | Bin 704 -> 0 bytes src/src/pics/theme0_both.png | Bin 1406 -> 0 bytes src/src/pics/theme0_error.png | Bin 1510 -> 0 bytes src/src/pics/theme0_none.png | Bin 1403 -> 0 bytes src/src/pics/theme0_rx.png | Bin 1411 -> 0 bytes src/src/pics/theme0_tx.png | Bin 1405 -> 0 bytes src/src/pics/theme1_both.png | Bin 1219 -> 0 bytes src/src/pics/theme1_error.png | Bin 483 -> 0 bytes src/src/pics/theme1_none.png | Bin 482 -> 0 bytes src/src/pics/theme1_rx.png | Bin 881 -> 0 bytes src/src/pics/theme1_tx.png | Bin 927 -> 0 bytes src/src/pics/theme2_both.png | Bin 1384 -> 0 bytes src/src/pics/theme2_error.png | Bin 709 -> 0 bytes src/src/pics/theme2_none.png | Bin 835 -> 0 bytes src/src/pics/theme2_rx.png | Bin 1121 -> 0 bytes src/src/pics/theme2_tx.png | Bin 1115 -> 0 bytes src/src/pics/theme3_both.png | Bin 870 -> 0 bytes src/src/pics/theme3_error.png | Bin 342 -> 0 bytes src/src/pics/theme3_none.png | Bin 339 -> 0 bytes src/src/pics/theme3_rx.png | Bin 615 -> 0 bytes src/src/pics/theme3_tx.png | Bin 787 -> 0 bytes src/src/pics/theme4_both.png | Bin 1034 -> 0 bytes src/src/pics/theme4_error.png | Bin 1245 -> 0 bytes src/src/pics/theme4_none.png | Bin 1000 -> 0 bytes src/src/pics/theme4_rx.png | Bin 1025 -> 0 bytes src/src/pics/theme4_tx.png | Bin 1025 -> 0 bytes src/src/statistics.cpp | 79 ----- src/src/statistics.h | 79 ----- src/src/statisticsbase.ui | 478 ----------------------------- src/statistics.cpp | 79 +++++ src/statistics.h | 79 +++++ src/statisticsbase.ui | 478 +++++++++++++++++++++++++++++ subdirs | 2 + 130 files changed, 3940 insertions(+), 3941 deletions(-) create mode 100644 CHANGELOG create mode 100644 Doxyfile delete mode 100644 doc/.gitignore create mode 100644 doc/CMakeLists.txt create mode 100644 doc/COPYING-DOCS create mode 100644 doc/Makefile.am create mode 100644 doc/en/CMakeLists.txt create mode 100644 doc/en/Makefile.am create mode 100644 doc/en/index.docbook create mode 100644 doc/man/CMakeLists.txt create mode 100644 doc/man/Makefile.am create mode 100644 doc/man/knetstats.1 create mode 100644 doc/man/manpage.xml create mode 100644 icons/CMakeLists.txt create mode 100644 icons/Makefile.am create mode 100644 icons/hi16-app-knetstats.png create mode 100644 icons/hi32-app-knetstats.png create mode 100644 icons/hi48-app-knetstats.png create mode 100644 knetstats.desktop delete mode 100644 src/.svnignore delete mode 100644 src/CHANGELOG delete mode 100644 src/COPYING-DOCS delete mode 100644 src/Doxyfile create mode 100644 src/chart.cpp create mode 100644 src/chart.h create mode 100644 src/configure.cpp create mode 100644 src/configure.h create mode 100644 src/configurebase.ui delete mode 100644 src/doc/CMakeLists.txt delete mode 100644 src/doc/Makefile.am delete mode 100644 src/doc/en/CMakeLists.txt delete mode 100644 src/doc/en/Makefile.am delete mode 100644 src/doc/en/index.docbook delete mode 100644 src/doc/man/CMakeLists.txt delete mode 100644 src/doc/man/Makefile.am delete mode 100644 src/doc/man/knetstats.1 delete mode 100644 src/doc/man/manpage.xml delete mode 100644 src/hi16-app-knetstats.png delete mode 100644 src/hi32-app-knetstats.png delete mode 100644 src/hi48-app-knetstats.png create mode 100644 src/interface.cpp create mode 100644 src/interface.h create mode 100644 src/knetstats.cpp delete mode 100644 src/knetstats.desktop create mode 100644 src/knetstats.h create mode 100644 src/knetstatsview.cpp create mode 100644 src/knetstatsview.h create mode 100644 src/main.cpp create mode 100644 src/pics/CMakeLists.txt create mode 100644 src/pics/Makefile.am create mode 100644 src/pics/icon_pci.png create mode 100644 src/pics/theme0_both.png create mode 100644 src/pics/theme0_error.png create mode 100644 src/pics/theme0_none.png create mode 100644 src/pics/theme0_rx.png create mode 100644 src/pics/theme0_tx.png create mode 100644 src/pics/theme1_both.png create mode 100644 src/pics/theme1_error.png create mode 100644 src/pics/theme1_none.png create mode 100644 src/pics/theme1_rx.png create mode 100644 src/pics/theme1_tx.png create mode 100644 src/pics/theme2_both.png create mode 100644 src/pics/theme2_error.png create mode 100644 src/pics/theme2_none.png create mode 100644 src/pics/theme2_rx.png create mode 100644 src/pics/theme2_tx.png create mode 100644 src/pics/theme3_both.png create mode 100644 src/pics/theme3_error.png create mode 100644 src/pics/theme3_none.png create mode 100644 src/pics/theme3_rx.png create mode 100644 src/pics/theme3_tx.png create mode 100644 src/pics/theme4_both.png create mode 100644 src/pics/theme4_error.png create mode 100644 src/pics/theme4_none.png create mode 100644 src/pics/theme4_rx.png create mode 100644 src/pics/theme4_tx.png delete mode 100644 src/src/CMakeLists.txt delete mode 100644 src/src/Makefile.am delete mode 100644 src/src/chart.cpp delete mode 100644 src/src/chart.h delete mode 100644 src/src/configure.cpp delete mode 100644 src/src/configure.h delete mode 100644 src/src/configurebase.ui delete mode 100644 src/src/interface.cpp delete mode 100644 src/src/interface.h delete mode 100644 src/src/knetstats.cpp delete mode 100644 src/src/knetstats.h delete mode 100644 src/src/knetstatsview.cpp delete mode 100644 src/src/knetstatsview.h delete mode 100644 src/src/main.cpp delete mode 100644 src/src/pics/CMakeLists.txt delete mode 100644 src/src/pics/Makefile.am delete mode 100644 src/src/pics/icon_pci.png delete mode 100644 src/src/pics/theme0_both.png delete mode 100644 src/src/pics/theme0_error.png delete mode 100644 src/src/pics/theme0_none.png delete mode 100644 src/src/pics/theme0_rx.png delete mode 100644 src/src/pics/theme0_tx.png delete mode 100644 src/src/pics/theme1_both.png delete mode 100644 src/src/pics/theme1_error.png delete mode 100644 src/src/pics/theme1_none.png delete mode 100644 src/src/pics/theme1_rx.png delete mode 100644 src/src/pics/theme1_tx.png delete mode 100644 src/src/pics/theme2_both.png delete mode 100644 src/src/pics/theme2_error.png delete mode 100644 src/src/pics/theme2_none.png delete mode 100644 src/src/pics/theme2_rx.png delete mode 100644 src/src/pics/theme2_tx.png delete mode 100644 src/src/pics/theme3_both.png delete mode 100644 src/src/pics/theme3_error.png delete mode 100644 src/src/pics/theme3_none.png delete mode 100644 src/src/pics/theme3_rx.png delete mode 100644 src/src/pics/theme3_tx.png delete mode 100644 src/src/pics/theme4_both.png delete mode 100644 src/src/pics/theme4_error.png delete mode 100644 src/src/pics/theme4_none.png delete mode 100644 src/src/pics/theme4_rx.png delete mode 100644 src/src/pics/theme4_tx.png delete mode 100644 src/src/statistics.cpp delete mode 100644 src/src/statistics.h delete mode 100644 src/src/statisticsbase.ui create mode 100644 src/statistics.cpp create mode 100644 src/statistics.h create mode 100644 src/statisticsbase.ui diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..d5f0e02 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,69 @@ +v1.6.1 + +- Fixed crash when discovering a new interface. + +v1.6.0.1 + +- Disable the -ansi flag to avoid compile problems. + +v1.6 + +- More user-friendly, try to detect some things and start without importune the user with configuration dialogs. + +v1.5 + +- Added "Chart view". +- New Statistics dialog (show IP address, MAC address, etc). +- Using bksys as building tool. +- Carrier on/off detection. +- Reading interface date from /sys/class/net/INTERFACE/statistics instead of parse /proc/dev/net. +- New translation to romanian + +Note to BSD users: This version is not compatible with BSD, it uses some linux-only stuff. A BSD-compatible version is plained in a near future. + +v1.3.1 + +- Minor fix for Mandriva Linux (former Mandrake Linux). Env is now set for uic during build. + +v1.3 + +- New configuration dialog. +- Support to multiple interfaces. +- Is possible change the colors in the text mode view. +- Is possible change the icon theme of in icon mode. +- Added smooth speed meter. + +v1.2.1 + +- Added Russian translation (Edward Romantsov). +- Added Polish translation (Wiktor Wandachowicz). + +v1.2 + +- Now using SCons as building and install tool, so you will need to have Python installed in your distro to run SCons scripts and compile/install KNetStats. +- Added Brazilian portuguese translation (me). +- Added Kirghiz translation (Ilyas Bakirov). +- Added Italian translation (Roberto Leandrini). +- Added Spanish translation (Carlos Ortiz). +- Added Deutsch translation (Henrik Gebauer). +- Bug Fix: When network interface in changed, the Statistics window caption is changed too. +- Bug Fix: Statistics window now correctly format Download/Upload Speed. +- Bug Fix: When start KNetstats with a unavaliable interface, now upload speed is equals to 0pkts/s (not -2pkts/s) +- Bug Fix: When knetstats starts and statistics windows is hidden it is not updated. + +v1.1.2 + +- Build system now uses tde-config instead $TDEDIR env. variable. This will solve problems when compiling KNetstats on some distros (Suse 9.1, Fedora). + +v1.1.1 + +- Clicking on trayicon show/hide statistics window (suggestion by Fredy Yanardi). +- All dialogs now show the KNetStats icon on windows decoration. +- It's possible to change the font used in textmode (suggestion by Vik). + + +v1.1 + +- Bug Fix: Not saving UpdateInterval when the network interface is not changed. +- Litle optimizations +- Support to IconMode (Activity Led's) or TextMode (showing rx/tx transfer rate) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 00718bc..938bb69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,9 +68,19 @@ set( CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined" ) ##### directories add_subdirectory( src ) +add_subdirectory( icons ) +tde_conditional_add_subdirectory( BUILD_DOC doc ) tde_conditional_add_subdirectory( BUILD_TRANSLATIONS translations ) ##### write configure files configure_file( config.h.cmake config.h @ONLY ) + + +##### other data + +install( + FILES ${PROJECT_NAME}.desktop + DESTINATION ${XDG_APPS_INSTALL_DIR} +) diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..d7efd44 --- /dev/null +++ b/Doxyfile @@ -0,0 +1,266 @@ +# Doxyfile 1.3.7-KDevelop + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = knetstats.tdevelop +PROJECT_NUMBER = 0.1 +OUTPUT_DIRECTORY = +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = /home/hugo/ +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = /home/hugo/src/knetstats +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.C \ + *.CC \ + *.C++ \ + *.II \ + *.I++ \ + *.H \ + *.HH \ + *.H++ \ + *.CS \ + *.PHP \ + *.PHP3 \ + *.M \ + *.MM \ + *.C \ + *.H \ + *.tlh \ + *.diff \ + *.patch \ + *.moc \ + *.xpm \ + *.dox +RECURSIVE = yes +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = yes +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = knetstats.tag +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 1000 +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/Makefile.am b/Makefile.am index 2369f25..0aa05e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,4 +2,7 @@ AUTOMAKE_OPTIONS = foreign 1.6.1 include admin/deps.am include admin/Doxyfile.am + +xdg_apps_DATA = knetstats.desktop + SUBDIRS=$(TOPSUBDIRS) diff --git a/Makefile.am.in b/Makefile.am.in index e46b27c..628b551 100644 --- a/Makefile.am.in +++ b/Makefile.am.in @@ -2,3 +2,6 @@ AUTOMAKE_OPTIONS = foreign 1.6.1 include admin/deps.am include admin/Doxyfile.am + +xdg_apps_DATA = knetstats.desktop + diff --git a/doc/.gitignore b/doc/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 0000000..6d0aa9f --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1 @@ +tde_auto_add_subdirectories( ) diff --git a/doc/COPYING-DOCS b/doc/COPYING-DOCS new file mode 100644 index 0000000..4a0fe1c --- /dev/null +++ b/doc/COPYING-DOCS @@ -0,0 +1,397 @@ + GNU Free Documentation License + Version 1.2, November 2002 + + + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + +0. PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document "free" in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + + +1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The "Document", below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as "you". You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A "Modified Version" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall subject +(or to related matters) and contains nothing that could fall directly +within that overall subject. (Thus, if the Document is in part a +textbook of mathematics, a Secondary Section may not explain any +mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML, PostScript or PDF designed for human modification. Examples of +transparent image formats include PNG, XCF and JPG. Opaque formats +include proprietary formats that can be read and edited only by +proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML, PostScript or PDF produced by some word +processors for output purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +A section "Entitled XYZ" means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as "Acknowledgements", +"Dedications", "Endorsements", or "History".) To "Preserve the Title" +of such a section when you modify the Document means that it remains a +section "Entitled XYZ" according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + + +2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + + +3. COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + + +4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +A. Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. +B. List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has fewer than five), + unless they release you from this requirement. +C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. +D. Preserve all the copyright notices of the Document. +E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. +F. Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. +G. Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. +H. Include an unaltered copy of this License. +I. Preserve the section Entitled "History", Preserve its Title, and add + to it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section Entitled "History" in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. +J. Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the "History" section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. +K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section all + the substance and tone of each of the contributor acknowledgements + and/or dedications given therein. +L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. +M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. +N. Do not retitle any existing section to be Entitled "Endorsements" + or to conflict in title with any Invariant Section. +O. Preserve any Warranty Disclaimers. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties--for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + + +5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled "History" +in the various original documents, forming one section Entitled +"History"; likewise combine any sections Entitled "Acknowledgements", +and any sections Entitled "Dedications". You must delete all sections +Entitled "Endorsements". + + +6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + + +7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an "aggregate" if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + + +8. TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled "Acknowledgements", +"Dedications", or "History", the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + + +9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document except +as expressly provided for under this License. Any other attempt to +copy, modify, sublicense or distribute the Document is void, and will +automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + + +10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. + + +ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (c) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..8bd0272 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = en man diff --git a/doc/en/CMakeLists.txt b/doc/en/CMakeLists.txt new file mode 100644 index 0000000..ba3ef3e --- /dev/null +++ b/doc/en/CMakeLists.txt @@ -0,0 +1 @@ +tde_create_handbook( DESTINATION ${PROJECT_NAME} ) diff --git a/doc/en/Makefile.am b/doc/en/Makefile.am new file mode 100644 index 0000000..8f050ec --- /dev/null +++ b/doc/en/Makefile.am @@ -0,0 +1,2 @@ +KDE_LANG = en +KDE_DOCS = knetstats diff --git a/doc/en/index.docbook b/doc/en/index.docbook new file mode 100644 index 0000000..55b829b --- /dev/null +++ b/doc/en/index.docbook @@ -0,0 +1,115 @@ + +KNetStats"> + + + + +]> + + + + +The &knetstats; Handbook + + + +Hugo Parente Lima + + + +
hugo_pl@users.sourceforge.net
+
+
+
+ + + + +2004-2005 +Hugo Parente Lima + + + +&FDLNotice; + + + +2005-11-14 +1.1 + + + + + +&knetstats; Is a simple KDE network monitor that show rx/tx LEDs of any network interface on a system tray icon. + + + + + + +KDE +knetstats +network +monitor +leds + + +
+ + + + +Using &knetstats; + +Choose a interface and see the leds :-). + + + + + + + + +Credits and License + + +&knetstats; + +Hugo Parente Lima - original author. +Thomas Windheuser - SCons help, Debian packages, etc. +KNemo - Icon themes +Ilyas Bakirov, Roberto Leandrini, Carlos Ortiz, Henrik Gebauer, Edward Romantsov, Wiktor Wandachowicz, Guillaume Savaton, Petar Toushkov, Liu Di - KNetStats translation to other languages + +You can find more info on KNetStats website. + + + +&underFDL; +&underGPL; + + + +&documentation.index; +
diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt new file mode 100644 index 0000000..8512250 --- /dev/null +++ b/doc/man/CMakeLists.txt @@ -0,0 +1,5 @@ +INSTALL( + FILES ${PROJECT_NAME}.1 + DESTINATION ${MAN_INSTALL_DIR}/man1 + COMPONENT doc +) diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am new file mode 100644 index 0000000..5894f60 --- /dev/null +++ b/doc/man/Makefile.am @@ -0,0 +1,3 @@ +man_MANS = knetstats.1 + +EXTRA_DIST = $(man_MANS) diff --git a/doc/man/knetstats.1 b/doc/man/knetstats.1 new file mode 100644 index 0000000..7197c48 --- /dev/null +++ b/doc/man/knetstats.1 @@ -0,0 +1,53 @@ +'\" -*- coding: us-ascii -*- +.if \n(.g .ds T< \\FC +.if \n(.g .ds T> \\F[\n[.fam]] +.de URL +\\$2 \(la\\$1\(ra\\$3 +.. +.if \n(.g .mso www.tmac +.TH knetstats 1 "16 Oct 2005" "" "" +.SH NAME +knetstats \- A system tray icon, which indicates network activity +.SH SYNOPSIS +'nh +.fi +.ad l +\fBknetstats\fR \kx +.if (\nx>(\n(.l/2)) .nr x (\n(.l/5) +'in \n(.iu+\nxu +[\fB--help \fIPrint options to console.\fB\fR] +'in \n(.iu-\nxu +.ad b +'hy +.SH DESCRIPTION +This manual page documents briefly the +\fBknetstats\fR +commands. +.PP +This manual page was written for the Debian distribution. +Instead, it has documentation in the GNU +Info format; see below. +.PP +\fBknetstats\fR is a program that provides a system tray icon. This icon provides two +LED's, which begin to blink if there is network traffic. +.SH OPTIONS +These programs follow the usual GNU command line syntax, +with long options starting with two dashes (`-'). A summary of +options is included below. For a complete description, see the +Info files. +.TP +\*(T<\fB\-h\fR\*(T> \*(T<\fB\-\-help\fR\*(T> +Show summary of options. +.TP +\*(T<\fB\-v\fR\*(T> \*(T<\fB\-\-version\fR\*(T> +Show version of program. +.SH "SEE ALSO" +.SH AUTHOR +This manual page was written by windheus <\*(T> for +the Debian system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GNU General Public License, Version 2 any +later version published by the Free Software Foundation. +.PP +On Debian systems, the complete text of the GNU General Public +License can be found in /usr/share/common-licenses/GPL. diff --git a/doc/man/manpage.xml b/doc/man/manpage.xml new file mode 100644 index 0000000..52d305e --- /dev/null +++ b/doc/man/manpage.xml @@ -0,0 +1,142 @@ + +.
will be generated. You may view the +manual page with: nroff -man .
| less'. A +typical entry in a Makefile or Makefile.am is: + +DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/\ +manpages/docbook.xsl +XP=xsltproc -''-nonet + +manpage.1: manpage.dbk + $(XP) $(DB2MAN) $< + +The xsltproc binary is found in the xsltproc package. The +XSL files are in docbook-xsl. Please remember that if you +create the nroff version in one of the debian/rules file +targets (such as build), you will need to include xsltproc +and docbook-xsl in your Build-Depends control field. + +--> + + + Thomas"> + Windheuser"> + + 16 Oct 2005"> + + 1"> + thomas@0x5c.net"> + + knetstats"> + + + Debian"> + GNU"> + GPL"> +]> + + + +
+ &dhemail; +
+ + &dhfirstname; + &dhsurname; + + + 2005 + &dhusername; + + &dhdate; +
+ + &dhucpackage; + + &dhsection; + + + &dhpackage; + + A system tray icon, which indicates network activity + + + + &dhpackage; + + + + + + + DESCRIPTION + + This manual page documents briefly the + &dhpackage; + commands. + + This manual page was written for the &debian; distribution. + Instead, it has documentation in the &gnu; + Info format; see below. + + &dhpackage; is a program that provides a system tray icon. This icon provides two + LED's, which begin to blink if there is network traffic. + + + + OPTIONS + + These programs follow the usual &gnu; command line syntax, + with long options starting with two dashes (`-'). A summary of + options is included below. For a complete description, see the + Info files. + + + + + + + + Show summary of options. + + + + + + + + Show version of program. + + + + + + SEE ALSO + + + + AUTHOR + + This manual page was written by &dhusername; &dhemail; for + the &debian; system (but may be used by others). Permission is + granted to copy, distribute and/or modify this document under + the terms of the &gnu; General Public License, Version 2 any + later version published by the Free Software Foundation. + + + On Debian systems, the complete text of the GNU General Public + License can be found in /usr/share/common-licenses/GPL. + + + +
+ diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt new file mode 100644 index 0000000..33ca26f --- /dev/null +++ b/icons/CMakeLists.txt @@ -0,0 +1,3 @@ +##### icons + +tde_install_icons( ${PROJECT_NAME} ) diff --git a/icons/Makefile.am b/icons/Makefile.am new file mode 100644 index 0000000..9860d39 --- /dev/null +++ b/icons/Makefile.am @@ -0,0 +1 @@ +KDE_ICON = knetstats diff --git a/icons/hi16-app-knetstats.png b/icons/hi16-app-knetstats.png new file mode 100644 index 0000000..cd48fb7 Binary files /dev/null and b/icons/hi16-app-knetstats.png differ diff --git a/icons/hi32-app-knetstats.png b/icons/hi32-app-knetstats.png new file mode 100644 index 0000000..96e06d5 Binary files /dev/null and b/icons/hi32-app-knetstats.png differ diff --git a/icons/hi48-app-knetstats.png b/icons/hi48-app-knetstats.png new file mode 100644 index 0000000..fdf0d47 Binary files /dev/null and b/icons/hi48-app-knetstats.png differ diff --git a/knetstats.desktop b/knetstats.desktop new file mode 100644 index 0000000..d77f9c2 --- /dev/null +++ b/knetstats.desktop @@ -0,0 +1,32 @@ +[Desktop Entry] +Name=KNetStats +Name[pa]=ਕੇ-ਨੈੱਟ-ਹਾਲਤ +GenericName=Network Monitor +GenericName[bg]=Наблюдение на мрежа +GenericName[cs]=Síťový monitor +GenericName[da]=Netværksovervåger +GenericName[de]=Netzwerkmonitor +GenericName[el]=Επόπτης δικτύου +GenericName[es]=Monitor de red +GenericName[et]=Võrgumonitor +GenericName[fr]=Surveillance réseau +GenericName[ga]=Monatóir líonra +GenericName[gl]=Monitor da rede +GenericName[it]=Monitor di rete +GenericName[ja]=ネットワークモニター +GenericName[ka]=ქსელის მეთვალყურე +GenericName[nl]=Netwerkmonitor +GenericName[pa]=ਨੈੱਟਵਰਕ ਨਿਗਰਾਨ +GenericName[pt]=Monitor da rede +GenericName[pt_BR]=Monitor de rede +GenericName[sk]=Monitor siete +GenericName[sv]=Nätverksövervakare +GenericName[tr]=Ağ izleyici +GenericName[uk]=Монітор мережі +Exec=knetstats +Icon=knetstats +Terminal=false +Type=Application +Categories=Qt;TDE;Network; +X-TDE-StartupNotify=true +X-DocPath=knetstats/index.html diff --git a/src/.svnignore b/src/.svnignore deleted file mode 100644 index 896d115..0000000 --- a/src/.svnignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -*Makefile.in diff --git a/src/CHANGELOG b/src/CHANGELOG deleted file mode 100644 index d5f0e02..0000000 --- a/src/CHANGELOG +++ /dev/null @@ -1,69 +0,0 @@ -v1.6.1 - -- Fixed crash when discovering a new interface. - -v1.6.0.1 - -- Disable the -ansi flag to avoid compile problems. - -v1.6 - -- More user-friendly, try to detect some things and start without importune the user with configuration dialogs. - -v1.5 - -- Added "Chart view". -- New Statistics dialog (show IP address, MAC address, etc). -- Using bksys as building tool. -- Carrier on/off detection. -- Reading interface date from /sys/class/net/INTERFACE/statistics instead of parse /proc/dev/net. -- New translation to romanian - -Note to BSD users: This version is not compatible with BSD, it uses some linux-only stuff. A BSD-compatible version is plained in a near future. - -v1.3.1 - -- Minor fix for Mandriva Linux (former Mandrake Linux). Env is now set for uic during build. - -v1.3 - -- New configuration dialog. -- Support to multiple interfaces. -- Is possible change the colors in the text mode view. -- Is possible change the icon theme of in icon mode. -- Added smooth speed meter. - -v1.2.1 - -- Added Russian translation (Edward Romantsov). -- Added Polish translation (Wiktor Wandachowicz). - -v1.2 - -- Now using SCons as building and install tool, so you will need to have Python installed in your distro to run SCons scripts and compile/install KNetStats. -- Added Brazilian portuguese translation (me). -- Added Kirghiz translation (Ilyas Bakirov). -- Added Italian translation (Roberto Leandrini). -- Added Spanish translation (Carlos Ortiz). -- Added Deutsch translation (Henrik Gebauer). -- Bug Fix: When network interface in changed, the Statistics window caption is changed too. -- Bug Fix: Statistics window now correctly format Download/Upload Speed. -- Bug Fix: When start KNetstats with a unavaliable interface, now upload speed is equals to 0pkts/s (not -2pkts/s) -- Bug Fix: When knetstats starts and statistics windows is hidden it is not updated. - -v1.1.2 - -- Build system now uses tde-config instead $TDEDIR env. variable. This will solve problems when compiling KNetstats on some distros (Suse 9.1, Fedora). - -v1.1.1 - -- Clicking on trayicon show/hide statistics window (suggestion by Fredy Yanardi). -- All dialogs now show the KNetStats icon on windows decoration. -- It's possible to change the font used in textmode (suggestion by Vik). - - -v1.1 - -- Bug Fix: Not saving UpdateInterval when the network interface is not changed. -- Litle optimizations -- Support to IconMode (Activity Led's) or TextMode (showing rx/tx transfer rate) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 93766be..4b74eac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,15 +1,38 @@ -add_subdirectory( src ) -tde_conditional_add_subdirectory( BUILD_DOC doc ) +add_subdirectory( pics ) +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) -##### icons +link_directories( + ${TQT_LIBRARY_DIRS} + ${TDE_LIB_DIR} +) -tde_install_icons( ${PROJECT_NAME} ) +##### knetstats (executable) -##### other data +tde_add_executable( ${PROJECT_NAME} AUTOMOC -install( - FILES ${PROJECT_NAME}.desktop - DESTINATION ${XDG_APPS_INSTALL_DIR} + SOURCES + configurebase.ui + configure.cpp + statisticsbase.ui + main.cpp + knetstats.cpp + knetstatsview.cpp + statistics.cpp + chart.cpp + interface.cpp + LINK + tdecore-shared + tdeui-shared + tdeio-shared + tdeui-shared + + DESTINATION ${BIN_INSTALL_DIR} ) diff --git a/src/COPYING-DOCS b/src/COPYING-DOCS deleted file mode 100644 index 4a0fe1c..0000000 --- a/src/COPYING-DOCS +++ /dev/null @@ -1,397 +0,0 @@ - GNU Free Documentation License - Version 1.2, November 2002 - - - Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - -0. PREAMBLE - -The purpose of this License is to make a manual, textbook, or other -functional and useful document "free" in the sense of freedom: to -assure everyone the effective freedom to copy and redistribute it, -with or without modifying it, either commercially or noncommercially. -Secondarily, this License preserves for the author and publisher a way -to get credit for their work, while not being considered responsible -for modifications made by others. - -This License is a kind of "copyleft", which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - - -1. APPLICABILITY AND DEFINITIONS - -This License applies to any manual or other work, in any medium, that -contains a notice placed by the copyright holder saying it can be -distributed under the terms of this License. Such a notice grants a -world-wide, royalty-free license, unlimited in duration, to use that -work under the conditions stated herein. The "Document", below, -refers to any such manual or work. Any member of the public is a -licensee, and is addressed as "you". You accept the license if you -copy, modify or distribute the work in a way requiring permission -under copyright law. - -A "Modified Version" of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A "Secondary Section" is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (Thus, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The "Invariant Sections" are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. If a -section does not fit the above definition of Secondary then it is not -allowed to be designated as Invariant. The Document may contain zero -Invariant Sections. If the Document does not identify any Invariant -Sections then there are none. - -The "Cover Texts" are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. A Front-Cover Text may -be at most 5 words, and a Back-Cover Text may be at most 25 words. - -A "Transparent" copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, that is suitable for revising the document -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup, or absence of markup, has been arranged to thwart -or discourage subsequent modification by readers is not Transparent. -An image format is not Transparent if used for any substantial amount -of text. A copy that is not "Transparent" is called "Opaque". - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML, PostScript or PDF designed for human modification. Examples of -transparent image formats include PNG, XCF and JPG. Opaque formats -include proprietary formats that can be read and edited only by -proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML, PostScript or PDF produced by some word -processors for output purposes only. - -The "Title Page" means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, "Title Page" means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. - -A section "Entitled XYZ" means a named subunit of the Document whose -title either is precisely XYZ or contains XYZ in parentheses following -text that translates XYZ in another language. (Here XYZ stands for a -specific section name mentioned below, such as "Acknowledgements", -"Dedications", "Endorsements", or "History".) To "Preserve the Title" -of such a section when you modify the Document means that it remains a -section "Entitled XYZ" according to this definition. - -The Document may include Warranty Disclaimers next to the notice which -states that this License applies to the Document. These Warranty -Disclaimers are considered to be included by reference in this -License, but only as regards disclaiming warranties: any other -implication that these Warranty Disclaimers may have is void and has -no effect on the meaning of this License. - - -2. VERBATIM COPYING - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section 3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. - - -3. COPYING IN QUANTITY - -If you publish printed copies (or copies in media that commonly have -printed covers) of the Document, numbering more than 100, and the -Document's license notice requires Cover Texts, you must enclose the -copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a computer-network location from which the general network-using -public has access to download using public-standard network protocols -a complete Transparent copy of the Document, free of added material. -If you use the latter option, you must take reasonably prudent steps, -when you begin distribution of Opaque copies in quantity, to ensure -that this Transparent copy will remain thus accessible at the stated -location until at least one year after the last time you distribute an -Opaque copy (directly or through your agents or retailers) of that -edition to the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. - - -4. MODIFICATIONS - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission. -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has fewer than five), - unless they release you from this requirement. -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher. -D. Preserve all the copyright notices of the Document. -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below. -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice. -H. Include an unaltered copy of this License. -I. Preserve the section Entitled "History", Preserve its Title, and add - to it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section Entitled "History" in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence. -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the "History" section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission. -K. For any section Entitled "Acknowledgements" or "Dedications", - Preserve the Title of the section, and preserve in the section all - the substance and tone of each of the contributor acknowledgements - and/or dedications given therein. -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles. -M. Delete any section Entitled "Endorsements". Such a section - may not be included in the Modified Version. -N. Do not retitle any existing section to be Entitled "Endorsements" - or to conflict in title with any Invariant Section. -O. Preserve any Warranty Disclaimers. - -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section Entitled "Endorsements", provided it contains -nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. - - -5. COMBINING DOCUMENTS - -You may combine the Document with other documents released under this -License, under the terms defined in section 4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice, and that you preserve all their Warranty Disclaimers. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections Entitled "History" -in the various original documents, forming one section Entitled -"History"; likewise combine any sections Entitled "Acknowledgements", -and any sections Entitled "Dedications". You must delete all sections -Entitled "Endorsements". - - -6. COLLECTIONS OF DOCUMENTS - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. - - -7. AGGREGATION WITH INDEPENDENT WORKS - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, is called an "aggregate" if the copyright -resulting from the compilation is not used to limit the legal rights -of the compilation's users beyond what the individual works permit. -When the Document is included in an aggregate, this License does not -apply to the other works in the aggregate which are not themselves -derivative works of the Document. - -If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one half of -the entire aggregate, the Document's Cover Texts may be placed on -covers that bracket the Document within the aggregate, or the -electronic equivalent of covers if the Document is in electronic form. -Otherwise they must appear on printed covers that bracket the whole -aggregate. - - -8. TRANSLATION - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section 4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License, and all the license notices in the -Document, and any Warranty Disclaimers, provided that you also include -the original English version of this License and the original versions -of those notices and disclaimers. In case of a disagreement between -the translation and the original version of this License or a notice -or disclaimer, the original version will prevail. - -If a section in the Document is Entitled "Acknowledgements", -"Dedications", or "History", the requirement (section 4) to Preserve -its Title (section 1) will typically require changing the actual -title. - - -9. TERMINATION - -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document is void, and will -automatically terminate your rights under this License. However, -parties who have received copies, or rights, from you under this -License will not have their licenses terminated so long as such -parties remain in full compliance. - - -10. FUTURE REVISIONS OF THIS LICENSE - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. See -http://www.gnu.org/copyleft/. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License "or any later version" applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. - - -ADDENDUM: How to use this License for your documents - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and -license notices just after the title page: - - Copyright (c) YEAR YOUR NAME. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.2 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled "GNU - Free Documentation License". - -If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, -replace the "with...Texts." line with this: - - with the Invariant Sections being LIST THEIR TITLES, with the - Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. - -If you have Invariant Sections without Cover Texts, or some other -combination of the three, merge those two alternatives to suit the -situation. - -If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, -to permit their use in free software. diff --git a/src/Doxyfile b/src/Doxyfile deleted file mode 100644 index d7efd44..0000000 --- a/src/Doxyfile +++ /dev/null @@ -1,266 +0,0 @@ -# Doxyfile 1.3.7-KDevelop - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = knetstats.tdevelop -PROJECT_NUMBER = 0.1 -OUTPUT_DIRECTORY = -CREATE_SUBDIRS = NO -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = NO -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = YES -STRIP_FROM_PATH = /home/hugo/ -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 8 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -SUBGROUPING = YES -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = NO -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = NO -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = YES -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_BY_SCOPE_NAME = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = YES -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = /home/hugo/src/knetstats -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ - *.inc \ - *.m \ - *.mm \ - *.C \ - *.CC \ - *.C++ \ - *.II \ - *.I++ \ - *.H \ - *.HH \ - *.H++ \ - *.CS \ - *.PHP \ - *.PHP3 \ - *.M \ - *.MM \ - *.C \ - *.H \ - *.tlh \ - *.diff \ - *.patch \ - *.moc \ - *.xpm \ - *.dox -RECURSIVE = yes -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = * -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -VERBATIM_HEADERS = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = YES -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = yes -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -XML_PROGRAMLISTING = YES -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = knetstats.tag -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = NO -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -UML_LOOK = NO -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DOT_IMAGE_FORMAT = png -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 1000 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO diff --git a/src/Makefile.am b/src/Makefile.am index 66b3066..2875827 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,22 @@ -SUBDIRS = src doc +INCLUDES = $(all_includes) -xdg_apps_DATA = knetstats.desktop +SUBDIRS = pics + +bin_PROGRAMS = knetstats + +knetstats_SOURCES = configurebase.ui configure.cpp statisticsbase.ui main.cpp \ + knetstats.cpp knetstatsview.cpp statistics.cpp chart.cpp interface.cpp +knetstats_LDADD = $(LIB_TDEUI) +knetstats_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +METASOURCES = configure.moc knetstats.moc knetstatsview.moc statistics.moc + +# these are the headers for your project +noinst_HEADERS = chart.h configure.h knetstats.h knetstatsview.h statistics.h \ + interface.h + +messages: rc.cpp + $(EXTRACTRC) *.ui >> rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/knetstats.pot + +KDE_OPTIONS = nofinal -KDE_ICON = knetstats diff --git a/src/chart.cpp b/src/chart.cpp new file mode 100644 index 0000000..8af9d1e --- /dev/null +++ b/src/chart.cpp @@ -0,0 +1,65 @@ +/*************************************************************************** +* Copyright (C) 2005 by Hugo Parente Lima * +* hugo_pl@users.sourceforge.net * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +***************************************************************************/ + +#include "chart.h" +#include +#include + +Chart::Chart(TQWidget* parent, const double* uploadBuffer, const double* downloadBuffer, int bufferSize, const int* ptr, const double* maxspeed) : TQWidget(parent), mUplBuffer(uploadBuffer), mDldBuffer(downloadBuffer), mBufferSize(bufferSize), mPtr(ptr), mMaxSpeed(maxspeed) { + setWFlags(TQt::WNoAutoErase); + setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding); +} + +void Chart::paintEvent(TQPaintEvent*) { + TQPainter paint(this); + paint.setBackgroundColor(TQt::black); + paint.setBackgroundMode(Qt::OpaqueMode); + TQBrush brush(TQColor(0x33, 0x33, 0x33), CrossPattern); + paint.fillRect(0, 0, width(), height(), brush); + + const double step = width()/double(mBufferSize); + const int HEIGHT = height() - 1; + + int x; + int lastX = x = width(); + int lastRxY = HEIGHT - int(HEIGHT * (mDldBuffer[*mPtr]/(*mMaxSpeed))); + int lastTxY = HEIGHT - int(HEIGHT * (mUplBuffer[*mPtr]/(*mMaxSpeed))); + + int count = 0; + for (int i = *mPtr; count < mBufferSize; i--) { + if (i < 0) + i = mBufferSize-1; + int rxY = HEIGHT - int(HEIGHT * (mDldBuffer[i]/(*mMaxSpeed))); + int txY = HEIGHT - int(HEIGHT * (mUplBuffer[i]/(*mMaxSpeed))); + paint.setPen(TQt::green); + paint.drawLine(lastX, lastRxY, x, rxY); + paint.setPen(TQt::red); + paint.drawLine(lastX, lastTxY, x, txY); + //tqDebug("%d => %d", i, int(mSpeedHistoryRx[i])); + lastX = x; + lastRxY = rxY; + lastTxY = txY; + + count++; + x = width() - int(step*(count+1)); + + } +} + diff --git a/src/chart.h b/src/chart.h new file mode 100644 index 0000000..8bd8be8 --- /dev/null +++ b/src/chart.h @@ -0,0 +1,43 @@ +/*************************************************************************** +* Copyright (C) 2005 by Hugo Parente Lima * +* hugo_pl@users.sourceforge.net * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +***************************************************************************/ + +#ifndef CHART_H +#define CHART_H + +#include + +class TQPaintEvent; + +class Chart : public TQWidget { +public: + Chart(TQWidget* parent, const double* uploadBuffer, const double* downloadBuffer, int bufferSize, const int* ptr, const double* maxspeed); + TQSize sizeHint() { return TQSize(200, 100); } +protected: + void paintEvent( TQPaintEvent* ev ); + +private: + const double* mUplBuffer; + const double* mDldBuffer; + const int mBufferSize; + const int* mPtr; + const double* mMaxSpeed; +}; + +#endif diff --git a/src/configure.cpp b/src/configure.cpp new file mode 100644 index 0000000..f3ffcff --- /dev/null +++ b/src/configure.cpp @@ -0,0 +1,161 @@ +/*************************************************************************** + * Copyright (C) 2004 by Hugo Parente Lima * + * hugo_pl@users.sourceforge.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "configure.h" +#include "knetstats.h" + +// TQt includes +#include +#include +#include +#include +#include +#include +// Kde includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +Configure::Configure(KNetStats* parent, const InterfaceMap& ifs) : ConfigureBase(parent) { + // Load configuration + TDEIconLoader* loader = kapp->iconLoader(); + + TQPixmap iconPCI = loader->loadIcon("icon_pci.png", TDEIcon::Small, 16); + + // Clone the configuration. + for (InterfaceMap::ConstIterator it = ifs.begin(); it != ifs.end(); ++it) { + mInterfaces->insertItem(iconPCI, it.key()); + mConfig[it.key()] = it.data()->options(); + +// parent->readInterfaceOptions(*it, &mConfig[*it]); + } + + mInterfaces->setCurrentItem(0); + changeInterface(mInterfaces->selectedItem()); + + connect(mInterfaces, TQT_SIGNAL(selectionChanged(TQListBoxItem*)), this, TQT_SLOT(changeInterface(TQListBoxItem*))); + connect(mTheme, TQT_SIGNAL(activated(int)), this, TQT_SLOT(changeTheme(int))); + //connect(mInterfaces, TQT_SIGNAL(contextMenuRequested(TQListBoxItem*, const TQPoint&)), this, TQT_SLOT(showInterfaceContextMenu(TQListBoxItem*, const TQPoint&))); +} + +void Configure::changeInterface(TQListBoxItem* item) { + TQString interface = item->text(); + + if (!mCurrentItem.isEmpty()) + { + // Salvas as modificações passadas + KNetStatsView::Options& oldview = mConfig[mCurrentItem]; + // general options + oldview.mMonitoring = mMonitoring->isChecked(); + oldview.mUpdateInterval = mUpdateInterval->value(); + oldview.mViewMode = (KNetStatsView::Mode) mViewMode->currentItem(); + // txt view options + oldview.mTxtUplColor = mTxtUplColor->color(); + oldview.mTxtDldColor = mTxtDldColor->color(); + oldview.mTxtFont = mTxtFont->font(); + // icon view + oldview.mTheme = mTheme->currentItem(); + // chart view + oldview.mChartUplColor = mChartUplColor->color(); + oldview.mChartDldColor = mChartDldColor->color(); + oldview.mChartBgColor = mChartBgColor->color(); + oldview.mChartTransparentBackground = mChartTransparentBackground->isChecked(); + } + + if (interface == mCurrentItem) + return; + // Carrega as opt. da nova interface + KNetStatsView::Options& view = mConfig[interface]; + // general + mMonitoring->setChecked(view.mMonitoring); + mUpdateInterval->setValue(view.mUpdateInterval); + mViewMode->setCurrentItem(view.mViewMode); + mWdgStack->raiseWidget(view.mViewMode); + // txt options + mTxtUplColor->setColor(view.mTxtUplColor); + mTxtDldColor->setColor(view.mTxtDldColor); + mTxtFont->setFont( view.mTxtFont ); + // icon options + mTheme->setCurrentItem(view.mTheme); + changeTheme(view.mTheme); + // chart options + mChartUplColor->setColor(view.mChartUplColor); + mChartDldColor->setColor(view.mChartDldColor); + mChartBgColor->setColor(view.mChartBgColor); + mChartTransparentBackground->setChecked(view.mChartTransparentBackground); + + mCurrentItem = interface; +} + +bool Configure::canSaveConfig() +{ + // update the options + changeInterface(mInterfaces->item( mInterfaces->currentItem() )); + + bool ok = false; + for(OptionsMap::ConstIterator i = mConfig.begin(); i != mConfig.end(); ++i) + if (i.data().mMonitoring) { + ok = true; + break; + } + + if (!ok) + KMessageBox::error(this, i18n("You need to select at least one interface to monitor.")); + return ok; +} + +void Configure::changeTheme(int theme) +{ + TDEIconLoader* loader = kapp->iconLoader(); + mIconError->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_error.png", + TDEIcon::Panel, ICONSIZE)); + mIconNone->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_none.png", + TDEIcon::Panel, ICONSIZE)); + mIconTx->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_tx.png", + TDEIcon::Panel, ICONSIZE)); + mIconRx->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_rx.png", + TDEIcon::Panel, ICONSIZE)); + mIconBoth->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_both.png", + TDEIcon::Panel, ICONSIZE)); +} +/* +void Configure::showInterfaceContextMenu(TQListBoxItem* item, const TQPoint& point) { + if (!item && mConfig.size() == 1) + return; + TQPixmap icon = kapp->iconLoader()->loadIcon("edit-delete", TDEIcon::Small, 16); + TQPopupMenu* menu = new TQPopupMenu(this); + menu->insertItem(icon, i18n("Renomve Interface"), this, TQT_SLOT(removeInterface())); + menu->exec(point); +} + +void Configure::removeInterface() { + mConfig.erase(mInterfaces->currentText()); + mInterfaces->removeItem(mInterfaces->currentItem()); +} +*/ +#include "configure.moc" diff --git a/src/configure.h b/src/configure.h new file mode 100644 index 0000000..f214555 --- /dev/null +++ b/src/configure.h @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2004 by Hugo Parente Lima * + * hugo_pl@users.sourceforge.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef CONFIGURE_H +#define CONFIGURE_H + +#include "configurebase.h" +#include "interface.h" +#include +#include +#include +#include +#include +#include + +static const int ICONSIZE = 22; + +class KNetStats; +class TQListBoxItem; + + +typedef TQMap OptionsMap; + + +/** +* Configure dialog +*/ +class Configure : public ConfigureBase +{ + Q_OBJECT + +public: + Configure(KNetStats* parent, const InterfaceMap& ifs); + + const OptionsMap& currentConfig() const { return mConfig; } + bool canSaveConfig(); + const OptionsMap& options() const { return mConfig; } +private: + TQString mCurrentItem; + OptionsMap mConfig; + +protected slots: + void changeInterface(TQListBoxItem* item); + void changeTheme(int theme); + //void showInterfaceContextMenu(TQListBoxItem* item, const TQPoint& point); + //void removeInterface(); +}; + +#endif diff --git a/src/configurebase.ui b/src/configurebase.ui new file mode 100644 index 0000000..7619924 --- /dev/null +++ b/src/configurebase.ui @@ -0,0 +1,677 @@ + +ConfigureBase + + + ConfigureBase + + + + 0 + 0 + 355 + 307 + + + + + 4 + 4 + 0 + 0 + + + + Configure KNetStats + + + + unnamed + + + Minimum + + + + layout7 + + + + unnamed + + + + mSpacer + + + Horizontal + + + Expanding + + + + 120 + 20 + + + + + + mOk + + + Ok + + + true + + + + + mApply + + + Apply + + + + + mCancel + + + Cancel + + + + + + + mInterfaces + + + + 5 + 7 + 0 + 0 + + + + + + mAppearanceGroup + + + + 5 + 7 + 0 + 0 + + + + Appearance + + + + unnamed + + + + mWdgStack + + + + mIconPage + + + 0 + + + + unnamed + + + 0 + + + + layout5 + + + + unnamed + + + + mLabel4 + + + Theme: + + + + + + Classic + + + + + Modem + + + + + Network + + + + + Wireless + + + + + Kppp + + + + mTheme + + + + + spacer2 + + + Horizontal + + + Expanding + + + + 21 + 20 + + + + + + + + layout7_2 + + + + unnamed + + + + mIconError + + + + 0 + 0 + 0 + 0 + + + + + 22 + 22 + + + + true + + + + + spacer3 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + mIconNone + + + + 0 + 0 + 0 + 0 + + + + + 22 + 22 + + + + true + + + + + spacer4 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + mIconTx + + + + 0 + 0 + 0 + 0 + + + + + 22 + 22 + + + + true + + + + + spacer5 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + mIconRx + + + + 0 + 0 + 0 + 0 + + + + + 22 + 22 + + + + true + + + + + spacer6 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + mIconBoth + + + + 0 + 0 + 0 + 0 + + + + + 22 + 22 + + + + true + + + + + + + spacer11 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + mTextPage + + + 1 + + + + unnamed + + + 0 + + + + mTxtUplColor + + + + + + + + mLabel5 + + + Download color: + + + + + mTxtDldColor + + + + + + + + mTxtFont + + + + 5 + 0 + 0 + 0 + + + + + + mLabel6 + + + Upload color: + + + + + + + mBarsPage + + + 2 + + + + unnamed + + + 0 + + + + mChartBgLabel + + + Background: + + + + + mChartUplColor + + + + + + + + mLabel7 + + + Upload color: + + + + + mLabel8 + + + Download color: + + + + + mChartDldColor + + + + + + + + mChartBgColor + + + + + + + + mChartTransparentBackground + + + Transparent background + + + + + + + + + + mConfigurationGroup + + + + 5 + 7 + 0 + 0 + + + + Configuration + + + + unnamed + + + + + Icon + + + + + Text + + + + + Chart + + + + mViewMode + + + + + mLabel3 + + + View mode: + + + + + mLabel2 + + + Update interval: + + + WordBreak|AlignVCenter + + + + + mUpdateInterval + + + 300 + + + 100 + + + 2000 + + + ms + + + + + mMonitoring + + + To monitor this interface + + + + + + + + + mViewMode + activated(int) + mWdgStack + raiseWidget(int) + + + mChartTransparentBackground + toggled(bool) + mChartBgColor + setDisabled(bool) + + + mChartTransparentBackground + toggled(bool) + mChartBgLabel + setDisabled(bool) + + + + mOk + mApply + mCancel + mInterfaces + mMonitoring + mUpdateInterval + mViewMode + mTheme + mTxtUplColor + mTxtDldColor + mTxtFont + mChartUplColor + mChartDldColor + mChartBgColor + mChartTransparentBackground + + + + kcolorbutton.h + kcombobox.h + knuminput.h + kpushbutton.h + tdefontrequester.h + + diff --git a/src/doc/CMakeLists.txt b/src/doc/CMakeLists.txt deleted file mode 100644 index 6d0aa9f..0000000 --- a/src/doc/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -tde_auto_add_subdirectories( ) diff --git a/src/doc/Makefile.am b/src/doc/Makefile.am deleted file mode 100644 index 81fee21..0000000 --- a/src/doc/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = en diff --git a/src/doc/en/CMakeLists.txt b/src/doc/en/CMakeLists.txt deleted file mode 100644 index ba3ef3e..0000000 --- a/src/doc/en/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -tde_create_handbook( DESTINATION ${PROJECT_NAME} ) diff --git a/src/doc/en/Makefile.am b/src/doc/en/Makefile.am deleted file mode 100644 index 8f050ec..0000000 --- a/src/doc/en/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -KDE_LANG = en -KDE_DOCS = knetstats diff --git a/src/doc/en/index.docbook b/src/doc/en/index.docbook deleted file mode 100644 index 55b829b..0000000 --- a/src/doc/en/index.docbook +++ /dev/null @@ -1,115 +0,0 @@ - -KNetStats"> - - - - -]> - - - - -The &knetstats; Handbook - - - -Hugo Parente Lima - - - -
hugo_pl@users.sourceforge.net
-
-
-
- - - - -2004-2005 -Hugo Parente Lima - - - -&FDLNotice; - - - -2005-11-14 -1.1 - - - - - -&knetstats; Is a simple KDE network monitor that show rx/tx LEDs of any network interface on a system tray icon. - - - - - - -KDE -knetstats -network -monitor -leds - - -
- - - - -Using &knetstats; - -Choose a interface and see the leds :-). - - - - - - - - -Credits and License - - -&knetstats; - -Hugo Parente Lima - original author. -Thomas Windheuser - SCons help, Debian packages, etc. -KNemo - Icon themes -Ilyas Bakirov, Roberto Leandrini, Carlos Ortiz, Henrik Gebauer, Edward Romantsov, Wiktor Wandachowicz, Guillaume Savaton, Petar Toushkov, Liu Di - KNetStats translation to other languages - -You can find more info on KNetStats website. - - - -&underFDL; -&underGPL; - - - -&documentation.index; -
diff --git a/src/doc/man/CMakeLists.txt b/src/doc/man/CMakeLists.txt deleted file mode 100644 index 8512250..0000000 --- a/src/doc/man/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -INSTALL( - FILES ${PROJECT_NAME}.1 - DESTINATION ${MAN_INSTALL_DIR}/man1 - COMPONENT doc -) diff --git a/src/doc/man/Makefile.am b/src/doc/man/Makefile.am deleted file mode 100644 index 514c585..0000000 --- a/src/doc/man/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -man_MANS = manpage.xml - -EXTRA_DIST = $(man_MANS) - diff --git a/src/doc/man/knetstats.1 b/src/doc/man/knetstats.1 deleted file mode 100644 index 7197c48..0000000 --- a/src/doc/man/knetstats.1 +++ /dev/null @@ -1,53 +0,0 @@ -'\" -*- coding: us-ascii -*- -.if \n(.g .ds T< \\FC -.if \n(.g .ds T> \\F[\n[.fam]] -.de URL -\\$2 \(la\\$1\(ra\\$3 -.. -.if \n(.g .mso www.tmac -.TH knetstats 1 "16 Oct 2005" "" "" -.SH NAME -knetstats \- A system tray icon, which indicates network activity -.SH SYNOPSIS -'nh -.fi -.ad l -\fBknetstats\fR \kx -.if (\nx>(\n(.l/2)) .nr x (\n(.l/5) -'in \n(.iu+\nxu -[\fB--help \fIPrint options to console.\fB\fR] -'in \n(.iu-\nxu -.ad b -'hy -.SH DESCRIPTION -This manual page documents briefly the -\fBknetstats\fR -commands. -.PP -This manual page was written for the Debian distribution. -Instead, it has documentation in the GNU -Info format; see below. -.PP -\fBknetstats\fR is a program that provides a system tray icon. This icon provides two -LED's, which begin to blink if there is network traffic. -.SH OPTIONS -These programs follow the usual GNU command line syntax, -with long options starting with two dashes (`-'). A summary of -options is included below. For a complete description, see the -Info files. -.TP -\*(T<\fB\-h\fR\*(T> \*(T<\fB\-\-help\fR\*(T> -Show summary of options. -.TP -\*(T<\fB\-v\fR\*(T> \*(T<\fB\-\-version\fR\*(T> -Show version of program. -.SH "SEE ALSO" -.SH AUTHOR -This manual page was written by windheus <\*(T> for -the Debian system (but may be used by others). Permission is -granted to copy, distribute and/or modify this document under -the terms of the GNU General Public License, Version 2 any -later version published by the Free Software Foundation. -.PP -On Debian systems, the complete text of the GNU General Public -License can be found in /usr/share/common-licenses/GPL. diff --git a/src/doc/man/manpage.xml b/src/doc/man/manpage.xml deleted file mode 100644 index 52d305e..0000000 --- a/src/doc/man/manpage.xml +++ /dev/null @@ -1,142 +0,0 @@ - -.
will be generated. You may view the -manual page with: nroff -man .
| less'. A -typical entry in a Makefile or Makefile.am is: - -DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/\ -manpages/docbook.xsl -XP=xsltproc -''-nonet - -manpage.1: manpage.dbk - $(XP) $(DB2MAN) $< - -The xsltproc binary is found in the xsltproc package. The -XSL files are in docbook-xsl. Please remember that if you -create the nroff version in one of the debian/rules file -targets (such as build), you will need to include xsltproc -and docbook-xsl in your Build-Depends control field. - ---> - - - Thomas"> - Windheuser"> - - 16 Oct 2005"> - - 1"> - thomas@0x5c.net"> - - knetstats"> - - - Debian"> - GNU"> - GPL"> -]> - - - -
- &dhemail; -
- - &dhfirstname; - &dhsurname; - - - 2005 - &dhusername; - - &dhdate; -
- - &dhucpackage; - - &dhsection; - - - &dhpackage; - - A system tray icon, which indicates network activity - - - - &dhpackage; - - - - - - - DESCRIPTION - - This manual page documents briefly the - &dhpackage; - commands. - - This manual page was written for the &debian; distribution. - Instead, it has documentation in the &gnu; - Info format; see below. - - &dhpackage; is a program that provides a system tray icon. This icon provides two - LED's, which begin to blink if there is network traffic. - - - - OPTIONS - - These programs follow the usual &gnu; command line syntax, - with long options starting with two dashes (`-'). A summary of - options is included below. For a complete description, see the - Info files. - - - - - - - - Show summary of options. - - - - - - - - Show version of program. - - - - - - SEE ALSO - - - - AUTHOR - - This manual page was written by &dhusername; &dhemail; for - the &debian; system (but may be used by others). Permission is - granted to copy, distribute and/or modify this document under - the terms of the &gnu; General Public License, Version 2 any - later version published by the Free Software Foundation. - - - On Debian systems, the complete text of the GNU General Public - License can be found in /usr/share/common-licenses/GPL. - - - -
- diff --git a/src/hi16-app-knetstats.png b/src/hi16-app-knetstats.png deleted file mode 100644 index cd48fb7..0000000 Binary files a/src/hi16-app-knetstats.png and /dev/null differ diff --git a/src/hi32-app-knetstats.png b/src/hi32-app-knetstats.png deleted file mode 100644 index 96e06d5..0000000 Binary files a/src/hi32-app-knetstats.png and /dev/null differ diff --git a/src/hi48-app-knetstats.png b/src/hi48-app-knetstats.png deleted file mode 100644 index fdf0d47..0000000 Binary files a/src/hi48-app-knetstats.png and /dev/null differ diff --git a/src/interface.cpp b/src/interface.cpp new file mode 100644 index 0000000..1ac98a8 --- /dev/null +++ b/src/interface.cpp @@ -0,0 +1,57 @@ +// +// C++ Implementation: interface +// +// Description: +// +// +// Author: Hugo Parente Lima , (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "interface.h" +#include +#include +#include + +Interface::Interface(KNetStats* parent, const TQString& name) : mName(name), mView(0), mParent(parent) { + update(); +} + +void Interface::update() { + bool defaultVisibility = !(mName == "lo" || mName == "sit0"); + + TDEConfig* cfg = kapp->config(); + TDEConfigGroupSaver groupSaver(cfg, mName); + bool visible = cfg->readBoolEntry("Monitoring", defaultVisibility); + if (!visible) + setVisible(false); + else if (visible && !mView) + setVisible(true); + else if (visible && mView) + mView->updateViewOptions(); +} + +void Interface::setVisible(bool visible) { + if (!visible) { + delete mView; + mView = 0; + } else if (visible && !mView) + mView = new KNetStatsView(mParent, mName); +} + +KNetStatsView::Options Interface::options() { + if (mView) + return mView->options(); + else { + KNetStatsView::Options opt; + KNetStatsView::readOptions(mName, &opt, false); + return opt; + } +} + +void Interface::say(const TQString& message) { + if (mView) + mView->say(message); +} + diff --git a/src/interface.h b/src/interface.h new file mode 100644 index 0000000..66bffc8 --- /dev/null +++ b/src/interface.h @@ -0,0 +1,51 @@ +// +// C++ Interface: interface +// +// Description: +// +// +// Author: Hugo Parente Lima , (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef INTERFACE_H +#define INTERFACE_H + +#include +#include "knetstatsview.h" +class KNetStats; + +class Interface { + TQString mName; + KNetStatsView* mView; + KNetStats* mParent; + + Interface(const Interface&); +public: + /** + * Constructs a new interface. + * \param parent parent of the view of this interface. + * \param name name of this interface (not the TQObject name!!) + */ + Interface(KNetStats* parent, const TQString& name); + + /** + * Set this interface visible to the user via a KNetStatsView. + */ + void setVisible(bool visible); + bool isVisible() { return mView; } + + void update(); + + void say(const TQString& message); + + KNetStatsView::Options options(); +}; + +#include +typedef TQMap InterfaceMap; + + +#endif diff --git a/src/knetstats.cpp b/src/knetstats.cpp new file mode 100644 index 0000000..bfbb1b2 --- /dev/null +++ b/src/knetstats.cpp @@ -0,0 +1,191 @@ +/*************************************************************************** + * Copyright (C) 2004 by Hugo Parente Lima * + * hugo_pl@users.sourceforge.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "knetstats.h" +#include "knetstatsview.h" +#include "configure.h" +#include "interface.h" + +// TQt includes +#include +#include +#include +// KDE includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +KNetStats::KNetStats() : TQWidget(0, "knetstats"), mConfigure(0), mBoot(true) { + setupUi(); + int count; + detectNewInterfaces(&count); + if (!count && numInterfaces()) // caos!!! All interfaces are invisible! turn all visible... + for(InterfaceMap::Iterator i = mInterfaces.begin(); i != mInterfaces.end(); ++i) + i.data()->setVisible(true); + + + mBoot = false; + TQTimer* timer = new TQTimer(this); + connect(timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(detectNewInterfaces())); + timer->start(IF_DETECTION_INTERVAL); +} + +KNetStats::~KNetStats() { + for (InterfaceMap::Iterator it = mInterfaces.begin(); it != mInterfaces.end(); ++it) + delete it.data(); +} + + +void KNetStats::setupUi() { + setIcon(kapp->icon()); + // Cria o contextMenu + mActionCollection = new TDEActionCollection(this); + mContextMenu = new TDEPopupMenu(this); + mContextMenu->insertTitle( kapp->miniIcon(), kapp->caption() ); + TDEAction* configure = KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT(configure()), mActionCollection, "configure"); + configure->plug(mContextMenu); + mContextMenu->insertSeparator(); + KHelpMenu* helpmenu = new KHelpMenu(this, TQString(), false); + mContextMenu->insertItem( i18n("&Help"), helpmenu->menu() ); + + mContextMenu->insertSeparator(); + TDEAction* quitAction = KStdAction::quit(TQT_TQOBJECT(kapp), TQT_SLOT(quit()), mActionCollection); + quitAction->plug(mContextMenu); + + connect(helpmenu, TQT_SIGNAL(showAboutApplication()), this, TQT_SLOT(about())); +} + +TQStringList KNetStats::scanInterfaces() { + TQDir dir("/sys/class/net"); + if (!dir.exists()) { + KMessageBox::error(0, i18n("You need kernel 2.6.x with support to the /sys filesystem.")); + return TQStringList(); + } else { + TQStringList list = dir.entryList(TQDir::Dirs); + list.pop_front(); // removes "." and ".." entries + list.pop_front(); + return list; + } +} + +bool KNetStats::configure() { + if (mConfigure) + mConfigure->show(); + else { +/* if (!mInterfaces.size()) { + KMessageBox::error(this, i18n("You don't have any network interface.\nKNetStats will quit now.")); + return false; + }*/ + + mConfigure = new Configure(this, mInterfaces); + connect(mConfigure->mOk, TQT_SIGNAL(clicked()), this, TQT_SLOT(configOk())); + connect(mConfigure->mApply, TQT_SIGNAL(clicked()), this, TQT_SLOT(configApply())); + connect(mConfigure->mCancel, TQT_SIGNAL(clicked()), this, TQT_SLOT(configCancel())); + mConfigure->show(); + } + return true; +} + +void KNetStats::configOk() { + if (mConfigure->canSaveConfig()) { + saveConfig( mConfigure->options() ); + delete mConfigure; + mConfigure = 0; + } +} + +void KNetStats::configApply() { + if (mConfigure->canSaveConfig()) + saveConfig( mConfigure->options() ); +} + +void KNetStats::configCancel() { + delete mConfigure; + mConfigure = 0; +} + +void KNetStats::saveConfig(const OptionsMap& options) { + TDEConfig* cfg = kapp->config(); + + for(OptionsMap::ConstIterator i = options.begin(); i != options.end(); ++i) { + TDEConfigGroupSaver groupSaver(cfg, i.key()); + const KNetStatsView::Options& opt = i.data(); + // general + cfg->writeEntry("UpdateInterval", opt.mUpdateInterval); + cfg->writeEntry("ViewMode", opt.mViewMode); + cfg->writeEntry("Monitoring", opt.mMonitoring); + // txt view + cfg->writeEntry("TxtFont", opt.mTxtFont); + cfg->writeEntry("TxtUplColor", opt.mTxtUplColor); + cfg->writeEntry("TxtDldColor", opt.mTxtDldColor); + // IconView + cfg->writeEntry("Theme", opt.mTheme); + // Graphic view + cfg->writeEntry("ChartUplColor", opt.mChartUplColor); + cfg->writeEntry("ChartDldColor", opt.mChartDldColor); + cfg->writeEntry("ChartBgColor", opt.mChartBgColor); + cfg->writeEntry("ChartUseTransparentBackground", opt.mChartTransparentBackground); + } + + for (InterfaceMap::ConstIterator i = mInterfaces.begin(); i != mInterfaces.end(); ++i) + i.data()->update(); +} + +void KNetStats::about() { + TDEAboutApplication dlg(this); + dlg.exec(); +} + + +void KNetStats::detectNewInterfaces(int* count_ptr) { + int count = 0; + const TQStringList& interfaces = KNetStats::scanInterfaces(); + TQStringList::ConstIterator i = interfaces.begin(); + for(; i != interfaces.end(); ++i) { + InterfaceMap::Iterator elem = mInterfaces.find(*i); + if (elem == mInterfaces.end()) + if (createInterface(*i)) + count++; + } + if (count && count_ptr) + *count_ptr = count; +} + +bool KNetStats::createInterface(const TQString& name) { + // Cria a interface e adiciona em mInterfaces. + Interface* interface = new Interface(this, name); + mInterfaces.insert(name, interface); + if (!mBoot) + interface->say(i18n("New interface detected: %1").arg(name)); + return interface->isVisible(); +} + +#include "knetstats.moc" diff --git a/src/knetstats.desktop b/src/knetstats.desktop deleted file mode 100644 index d77f9c2..0000000 --- a/src/knetstats.desktop +++ /dev/null @@ -1,32 +0,0 @@ -[Desktop Entry] -Name=KNetStats -Name[pa]=ਕੇ-ਨੈੱਟ-ਹਾਲਤ -GenericName=Network Monitor -GenericName[bg]=Наблюдение на мрежа -GenericName[cs]=Síťový monitor -GenericName[da]=Netværksovervåger -GenericName[de]=Netzwerkmonitor -GenericName[el]=Επόπτης δικτύου -GenericName[es]=Monitor de red -GenericName[et]=Võrgumonitor -GenericName[fr]=Surveillance réseau -GenericName[ga]=Monatóir líonra -GenericName[gl]=Monitor da rede -GenericName[it]=Monitor di rete -GenericName[ja]=ネットワークモニター -GenericName[ka]=ქსელის მეთვალყურე -GenericName[nl]=Netwerkmonitor -GenericName[pa]=ਨੈੱਟਵਰਕ ਨਿਗਰਾਨ -GenericName[pt]=Monitor da rede -GenericName[pt_BR]=Monitor de rede -GenericName[sk]=Monitor siete -GenericName[sv]=Nätverksövervakare -GenericName[tr]=Ağ izleyici -GenericName[uk]=Монітор мережі -Exec=knetstats -Icon=knetstats -Terminal=false -Type=Application -Categories=Qt;TDE;Network; -X-TDE-StartupNotify=true -X-DocPath=knetstats/index.html diff --git a/src/knetstats.h b/src/knetstats.h new file mode 100644 index 0000000..e5042da --- /dev/null +++ b/src/knetstats.h @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2004 by Hugo Parente Lima * + * hugo_pl@users.sourceforge.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef KNETSTATS_H +#define KNETSTATS_H + +#include +#include +#include +#include "configure.h" + +class KNetStatsView; +class TDEConfig; +class TDEPopupMenu; +class TDEActionCollection; + +class Interface; + + +class KNetStats : public TQWidget +{ + Q_OBJECT + + + enum { + IF_DETECTION_INTERVAL = 5000 + }; + +public: + /// Constructor + KNetStats(); + ~KNetStats(); + + TDEPopupMenu* const contextMenu() const { return mContextMenu; } + /** + * \brief Search for network interfaces parsing /proc/net/dev + * \return A StringList with the network interface names + */ + static TQStringList scanInterfaces(); + int numInterfaces() const { return mInterfaces.size(); } + + +public slots: + /// Display configure the dialog box + bool configure(); + /// Configure dialog OK button + void configOk(); + /// Configure dialog Apply button + void configApply(); + /// Configure dialog Cancel button + void configCancel(); + + /// Diaplay the about box + void about(); + /** + * Search for new interfaces + * \param count_ptr Interface count, store the number of new visible interfaces found. + */ + void detectNewInterfaces(int* count_ptr = 0); +private: + TDEPopupMenu* mContextMenu; // help menu usado por todos os tray icons + Configure* mConfigure; + TDEActionCollection* mActionCollection; + bool mBoot; + InterfaceMap mInterfaces; + + + void readOptions(); + void saveConfig(const OptionsMap& options); + void clearOptions(OptionsMap* options); + void setupUi(); + // Creates a new interface, returns true or false if the new interface is visible or not. + bool createInterface(const TQString& interface); + +}; + +#endif diff --git a/src/knetstatsview.cpp b/src/knetstatsview.cpp new file mode 100644 index 0000000..72af3b4 --- /dev/null +++ b/src/knetstatsview.cpp @@ -0,0 +1,402 @@ +/*************************************************************************** + * Copyright (C) 2004-2005 by Hugo Parente Lima * + * hugo_pl@users.sourceforge.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#include "knetstatsview.h" +#include "knetstats.h" + +// KDE headers +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +// TQt headers +#include +#include +#include +#include +#include +#include +#include +#include + +// C headers +#include +#include + +// Linux headers +extern "C" { +#include +#include +#include +#include +} + +#include "configure.h" +#include "statistics.h" + +extern const char* programName; + +KNetStatsView::KNetStatsView(KNetStats* parent, const TQString& interface) +: KSystemTray(parent, 0), mSysDevPath("/sys/class/net/"+interface+"/"), mInterface(interface) { + mFdSock = 0; + mFirstUpdate = true; + mMaxSpeedAge = 0; + mMaxSpeed = 0.0; + mBRx = mBTx = mPRx = mPTx = 0; + mConnected = mCarrier = true; + mTotalBytesRx = mTotalBytesTx = mTotalPktRx = mTotalPktTx = 0; + mSpeedBufferPtr = mSpeedHistoryPtr = 0; + mStatistics = 0; + + readOptions(interface, &mOptions, true); + resetBuffers(); + openFdSocket(); + memset(&mDevInfo, 0, sizeof(mDevInfo)); + strcpy(mDevInfo.ifr_name, mInterface.latin1()); + + setTextFormat(TQt::PlainText); + mContextMenu = parent->contextMenu(); + show(); + + // Timer + mTimer = new TQTimer(this, "timer"); + connect(mTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(updateStats(void))); + + TQToolTip::add(this, i18n("Monitoring %1").arg(mInterface)); + setup(); + mStatistics = new Statistics(this); +} + +KNetStatsView::~KNetStatsView() { + if (mFdSock != -1) + shutdown(mFdSock, SHUT_RDWR); + +} + +void KNetStatsView::setup() { + if (mOptions.mViewMode == Text) + setFont(mOptions.mTxtFont); + else if (mOptions.mViewMode == Icon) { + // Load Icons + TDEIconLoader* loader = kapp->iconLoader(); + mIconError = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_error.png", + TDEIcon::Panel, ICONSIZE); + mIconNone = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_none.png", + TDEIcon::Panel, ICONSIZE); + mIconTx = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_tx.png", + TDEIcon::Panel, ICONSIZE); + mIconRx =loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_rx.png", + TDEIcon::Panel, ICONSIZE); + mIconBoth = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_both.png", + TDEIcon::Panel, ICONSIZE); + mCurrentIcon = &mIconNone; + } + mTimer->start(mOptions.mUpdateInterval); + updateStats(); + TQWidget::update(); + mFirstUpdate = false; +} + +void KNetStatsView::say(const TQString& message) { + KPassivePopup::message(programName, message, kapp->miniIcon(), this); +} + +void KNetStatsView::updateViewOptions() { + readOptions(mInterface, &mOptions); + setup(); +} + +void KNetStatsView::updateStats() { + FILE* flags_fp = fopen((mSysDevPath+"flags").latin1(), "r"); + bool currentStatus; + if (!flags_fp) + currentStatus = false; + else { + int flags; + fscanf(flags_fp, "%Xu", &flags); + fclose(flags_fp); + currentStatus = IFF_UP & flags; + } + + if (!currentStatus && mConnected) { // interface down... + mConnected = false; + resetBuffers(); + TQWidget::update(); + say(i18n("%1 is inactive").arg(mInterface)); + } else if (currentStatus && !mConnected) { + mConnected = true; + say(i18n("%1 is active").arg(mInterface)); + } + + // kernel < 2.6.9 (I think) does not have carrier info, considering carrier ever on. + FILE* carrier_fp = fopen((mSysDevPath+"carrier").latin1(), "r"); + char carrierFlag = '1'; + if (carrier_fp) { + carrierFlag = fgetc(carrier_fp); + fclose(carrier_fp); + } + + if (!mConnected) + return; + if (carrierFlag == '0') { // carrier down + if (mCarrier) { + mCarrier = false; + TQWidget::update(); + say(i18n("%1 is disconnected").arg(mInterface)); + } + return; + } else if (!mCarrier) { // carrier up + mCarrier = true; + say(i18n("%1 is connected").arg(mInterface)); + } + + unsigned int brx = readInterfaceNumValue("rx_bytes"); + unsigned int btx = readInterfaceNumValue("tx_bytes"); + unsigned int prx = readInterfaceNumValue("rx_packets"); + unsigned int ptx = readInterfaceNumValue("tx_packets"); + + + if (!mFirstUpdate) { // a primeira velocidade sempre eh absurda, para evitar isso temos o mFirstUpdate + if (++mSpeedBufferPtr >= SPEED_BUFFER_SIZE) + mSpeedBufferPtr = 0; + + // Calcula as velocidades + mSpeedBufferTx[mSpeedBufferPtr] = ((btx - mBTx)*(1000.0f/mOptions.mUpdateInterval)); + mSpeedBufferRx[mSpeedBufferPtr] = ((brx - mBRx)*(1000.0f/mOptions.mUpdateInterval)); + mSpeedBufferPTx[mSpeedBufferPtr] = ((ptx - mPTx)*(1000.0f/mOptions.mUpdateInterval)); + mSpeedBufferPRx[mSpeedBufferPtr] = ((prx - mPRx)*(1000.0f/mOptions.mUpdateInterval)); + + if (++mSpeedHistoryPtr >= HISTORY_SIZE) + mSpeedHistoryPtr = 0; + mSpeedHistoryRx[mSpeedHistoryPtr] = calcSpeed(mSpeedBufferRx); + mSpeedHistoryTx[mSpeedHistoryPtr] = calcSpeed(mSpeedBufferTx); + + mMaxSpeedAge--; + + if (mSpeedHistoryTx[mSpeedHistoryPtr] > mMaxSpeed) { + mMaxSpeed = mSpeedHistoryTx[mSpeedHistoryPtr]; + mMaxSpeedAge = HISTORY_SIZE; + } + if (mSpeedHistoryRx[mSpeedHistoryPtr] > mMaxSpeed) { + mMaxSpeed = mSpeedHistoryRx[mSpeedHistoryPtr]; + mMaxSpeedAge = HISTORY_SIZE; + } + if (mMaxSpeedAge < 1) + calcMaxSpeed(); + } + + if (mOptions.mViewMode == Icon) { + TQPixmap* newIcon; + if (brx == mBRx) { + if (btx == mBTx ) + newIcon = &mIconNone; + else + newIcon = &mIconTx; + } else { + if (btx == mBTx ) + newIcon = &mIconRx; + else + newIcon = &mIconBoth; + } + + if (newIcon != mCurrentIcon) { + mCurrentIcon = newIcon; + TQWidget::update(); + } + } else if (mOptions.mViewMode == Graphic || (btx != mBTx && brx != mBRx)) + TQWidget::update(); + + // Update stats + mTotalBytesRx += brx - mBRx; + mTotalBytesTx += btx - mBTx; + mTotalPktRx += prx - mPRx; + mTotalPktTx += ptx - mPTx; + + mBRx = brx; + mBTx = btx; + mPRx = prx; + mPTx = ptx; +} + +unsigned long KNetStatsView::readInterfaceNumValue(const char* name) { + // stdio functions appear to be more fast than TQFile? + FILE* fp = fopen((mSysDevPath+"statistics/"+name).latin1(), "r"); + long retval; + fscanf(fp, "%lu", &retval); + fclose(fp); + return retval; +} + +TQString KNetStatsView::readInterfaceStringValue(const char* name, int maxlength) { + TQFile macFile(mSysDevPath+name); + macFile.open(IO_ReadOnly); + TQString value; + macFile.readLine(value, maxlength); + return value; +} + +void KNetStatsView::resetBuffers() { + memset(mSpeedHistoryRx, 0, sizeof(double)*HISTORY_SIZE); + memset(mSpeedHistoryTx, 0, sizeof(double)*HISTORY_SIZE); + memset(mSpeedBufferRx, 0, sizeof(double)*SPEED_BUFFER_SIZE); + memset(mSpeedBufferTx, 0, sizeof(double)*SPEED_BUFFER_SIZE); + memset(mSpeedBufferPRx, 0, sizeof(double)*SPEED_BUFFER_SIZE); + memset(mSpeedBufferPTx, 0, sizeof(double)*SPEED_BUFFER_SIZE); +} + +void KNetStatsView::paintEvent( TQPaintEvent* ) { + TQPainter paint(this); + switch(mOptions.mViewMode) { + case Icon: + if (!mCarrier || !mConnected) + mCurrentIcon = &mIconError; + paint.drawPixmap(0, 0, *mCurrentIcon); + break; + case Text: + drawText(paint); + break; + case Graphic: + drawGraphic(paint); + break; + } +} + +void KNetStatsView::drawText(TQPainter& paint) { + if (!mCarrier || !mConnected) { + paint.drawText(rect(), TQt::AlignCenter, "?"); + } else { + paint.setFont( mOptions.mTxtFont ); + paint.setPen( mOptions.mTxtUplColor ); + paint.drawText( rect(), TQt::AlignTop, Statistics::byteFormat(byteSpeedTx(), "KB", "MB")); + paint.setPen( mOptions.mTxtDldColor ); + paint.drawText( rect(), TQt::AlignBottom, Statistics::byteFormat(byteSpeedRx(), "KB", "MB")); + } +} + +void KNetStatsView::drawGraphic(TQPainter& paint) { + if (!mCarrier || !mConnected) { + paint.drawText(rect(), TQt::AlignCenter, "X"); + return; + } + + TQSize size = this->size(); + + if (!mOptions.mChartTransparentBackground) + paint.fillRect(0, 0, size.width(), size.height(), mOptions.mChartBgColor); + + const int HEIGHT = size.height()-1; + + // tqDebug("MaxSpeed: %d, age: %d", int(mMaxSpeed), mMaxSpeedAge); + int lastX; + int lastRxY = HEIGHT - int(HEIGHT * (mSpeedHistoryRx[mSpeedHistoryPtr]/mMaxSpeed)); + int lastTxY = HEIGHT - int(HEIGHT * (mSpeedHistoryTx[mSpeedHistoryPtr]/mMaxSpeed)); + int x = lastX = size.width(); + int count = 0; + for (int i = mSpeedHistoryPtr; count < width(); i--) { + if (i < 0) + i = HISTORY_SIZE-1; + + int rxY = HEIGHT - int(HEIGHT * (mSpeedHistoryRx[i]/mMaxSpeed)); + int txY = HEIGHT - int(HEIGHT * (mSpeedHistoryTx[i]/mMaxSpeed)); + paint.setPen(mOptions.mChartDldColor); + paint.drawLine(lastX, lastRxY, x, rxY); + paint.setPen(mOptions.mChartUplColor); + paint.drawLine(lastX, lastTxY, x, txY); + //tqDebug("%d => %d", i, int(mSpeedHistoryRx[i])); + lastX = x; + lastRxY = rxY; + lastTxY = txY; + + count++; + x = width()-int(count+1); + } +} + +void KNetStatsView::mousePressEvent(TQMouseEvent* ev) { + if (ev->button() == Qt::RightButton ) + mContextMenu->exec(TQCursor::pos()); + else if (ev->button() == Qt::LeftButton) + if (mStatistics->isShown()) + mStatistics->accept(); + else + mStatistics->show(); +} + +bool KNetStatsView::openFdSocket() { + if (mFdSock > 0) + return true; + if ((mFdSock = socket(AF_INET, SOCK_DGRAM, 0)) > 0) + return true; + return false; +} + +TQString KNetStatsView::getIp() { + if (mFdSock == -1 && !openFdSocket()) + return ""; + + ioctl(mFdSock, SIOCGIFADDR, &mDevInfo); + sockaddr_in sin = ((sockaddr_in&)mDevInfo.ifr_addr); + return inet_ntoa(sin.sin_addr); +} + +TQString KNetStatsView::getNetmask() { + if (mFdSock == -1 && !openFdSocket()) + return ""; + ioctl(mFdSock, SIOCGIFNETMASK, &mDevInfo); + sockaddr_in mask = ((sockaddr_in&)mDevInfo.ifr_netmask); + return inet_ntoa(mask.sin_addr); +} + +void KNetStatsView::readOptions( const TQString& name, KNetStatsView::Options* opts, bool defaultVisibility ) { + TDEConfig* cfg = kapp->config(); + TDEConfigGroupSaver groupSaver(cfg, name); + + // general + opts->mUpdateInterval = cfg->readNumEntry("UpdateInterval", 300); + opts->mViewMode = (Mode)cfg->readNumEntry("ViewMode", 0); + opts->mMonitoring = cfg->readBoolEntry("Monitoring", defaultVisibility); + // txt view + opts->mTxtFont = cfg->readFontEntry("TxtFont"); + opts->mTxtUplColor = cfg->readColorEntry("TxtUplColor", &TQt::red); + opts->mTxtDldColor = cfg->readColorEntry("TxtDldColor", &TQt::green); + // IconView + int defaultTheme = 0; + if (name.startsWith("wlan")) + defaultTheme = 3; // three... is a magic number... a magic number.... + opts->mTheme = cfg->readNumEntry("Theme", defaultTheme); + // Graphic + opts->mChartUplColor = cfg->readColorEntry("ChartUplColor", &TQt::red); + opts->mChartDldColor = cfg->readColorEntry("ChartDldColor", &TQt::blue); + opts->mChartBgColor = cfg->readColorEntry("ChartBgColor", &TQt::white); + opts->mChartTransparentBackground = cfg->readBoolEntry("ChartUseTransparentBackground", true); +} + + +#include "knetstatsview.moc" diff --git a/src/knetstatsview.h b/src/knetstatsview.h new file mode 100644 index 0000000..e8cc0b8 --- /dev/null +++ b/src/knetstatsview.h @@ -0,0 +1,260 @@ +/*************************************************************************** +* (c) 2015 Timothy Pearson * +* Copyright (C) 2004-2005 by Hugo Parente Lima * +* hugo_pl@users.sourceforge.net * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +***************************************************************************/ + +#ifndef KNETSTATSVIEW_H +#define KNETSTATSVIEW_H + +#include +#include +#include +#include + +#include +#include + +class TQTimer; +class TQMouseEvent; +class TQPainter; +class TQPaintEvent; +class Statistics; +class KNetStats; + +/** +* Main class +*/ +class KNetStatsView : public KSystemTray +{ + Q_OBJECT + + + enum { + HISTORY_SIZE = 50, // Speed history buffer size + SPEED_BUFFER_SIZE = 10 // Speed normalization buffer size + }; + +public: + /** + * KNetstats view mode on system tray. + */ + enum Mode { + Icon, Text, Graphic + }; + + /** + * Visualization options. + */ + struct Options { + // general + int mUpdateInterval; + Mode mViewMode; + bool mMonitoring; + // txt view + TQFont mTxtFont; + TQColor mTxtUplColor; + TQColor mTxtDldColor; + // icon view + int mTheme; + // chart view + TQColor mChartUplColor; + TQColor mChartDldColor; + TQColor mChartBgColor; + bool mChartTransparentBackground; + }; + + KNetStatsView(KNetStats* parent, const TQString& interface); + ~KNetStatsView(); + + void say(const TQString& message); + void updateViewOptions(); + // read a value from /sys/class/net/interface/name + unsigned long readInterfaceNumValue(const char* name); + // read a value from /sys/class/net/interface/name + TQString readInterfaceStringValue(const char* name, int maxlength); + TQString getIp(); + TQString getNetmask(); + + const double* speedHistoryRx() const { return mSpeedHistoryRx; } + const double* speedHistoryTx() const { return mSpeedHistoryTx; } + const int historyBufferSize() const { return HISTORY_SIZE; } + const int* historyPointer() const { return &mSpeedHistoryPtr; } + const double* maxSpeed() const { return &mMaxSpeed; } + + /// Return a copy of the current view options. + Options options() const { return mOptions; } + /// read the interface view options + static void readOptions( const TQString& name, Options* opts, bool defaultVisibility = false ); + + /// The current monitored network interface + inline const TQString& interface() const; + /// The current Update Interval in miliseconds + inline int updateInterval() const; + /// We are in textmode? + inline Mode viewMode() const; + + /// Total of bytes receiveds + inline unsigned long totalBytesRx() const; + /// Total of bytes transmitted + inline unsigned long totalBytesTx() const; + /// Total of packets receiveds + inline unsigned long totalPktRx() const; + /// Total of packets transmitted + inline unsigned long totalPktTx() const; + /// RX Speed in bytes per second + inline double byteSpeedRx() const; + /// TX Speed in bytes per second + inline double byteSpeedTx() const; + /// RX Speed in packets per second + inline double pktSpeedRx() const; + /// TX Speed in packets per second + inline double pktSpeedTx() const; + +protected: + void mousePressEvent( TQMouseEvent* ev ); + void paintEvent( TQPaintEvent* ev ); + +private: + + int mFdSock; // Kernel-knetstats socket + struct ifreq mDevInfo; // info struct about our interface + + + TQString mSysDevPath; // Path to the device. + bool mCarrier; // Interface carrier is on? + bool mConnected; // Interface exists? + + TDEPopupMenu* mContextMenu; // Global ContextMenu + Statistics* mStatistics; // Statistics window + TQString mInterface; // Current interface + Options mOptions; // View options + + // Icons + TQPixmap mIconError, mIconNone, mIconTx, mIconRx, mIconBoth; + TQPixmap* mCurrentIcon; // Current state + TQTimer* mTimer; // Timer + + // Rx e Tx to bytes and packets + unsigned long mBRx, mBTx, mPRx, mPTx; + // Statistics + unsigned long mTotalBytesRx, mTotalBytesTx, mTotalPktRx, mTotalPktTx; + // Speed buffers + double mSpeedBufferRx[SPEED_BUFFER_SIZE], mSpeedBufferTx[SPEED_BUFFER_SIZE]; + double mSpeedBufferPRx[SPEED_BUFFER_SIZE], mSpeedBufferPTx[SPEED_BUFFER_SIZE]; + // pointer to current speed buffer position + int mSpeedBufferPtr; + + bool mFirstUpdate; + + // History buffer TODO: Make it configurable! + double mSpeedHistoryRx[HISTORY_SIZE]; + double mSpeedHistoryTx[HISTORY_SIZE]; + int mSpeedHistoryPtr; + double mMaxSpeed; + int mMaxSpeedAge; + + + // setup the view. + void setup(); + void drawText(TQPainter& paint); + void drawGraphic(TQPainter& paint); + // Reset speed and history buffers + void resetBuffers(); + // calc tha max. speed stored in the history buffer + inline void calcMaxSpeed(); + // calc the speed using a speed buffer + inline double calcSpeed(const double* buffer) const; + + bool openFdSocket(); + +private slots: + // Called by the timer to update statistics + void updateStats(); + +}; + +void KNetStatsView::calcMaxSpeed() { + double max = 0.0; + int ptr = mSpeedHistoryPtr; + for (int i = 0; i < HISTORY_SIZE; ++i) { + if (mSpeedHistoryRx[i] > max) { + max = mSpeedHistoryRx[i]; + ptr = i; + } + if (mSpeedHistoryTx[i] > max) { + max = mSpeedHistoryTx[i]; + ptr = i; + } + } + mMaxSpeed = max; + mMaxSpeedAge = (mSpeedHistoryPtr > ptr) ? (mSpeedHistoryPtr - ptr) : (mSpeedHistoryPtr + HISTORY_SIZE - ptr); +} + +double KNetStatsView::calcSpeed(const double* buffer) const { + double total = 0.0; + for (int i = 0; i < SPEED_BUFFER_SIZE; ++i) + total += buffer[i]; + return total/SPEED_BUFFER_SIZE; +} + +const TQString& KNetStatsView::interface() const { + return mInterface; +} + +int KNetStatsView::updateInterval() const { + return mOptions.mUpdateInterval; +} + +KNetStatsView::Mode KNetStatsView::viewMode() const { + return mOptions.mViewMode; +} + +unsigned long KNetStatsView::totalBytesRx() const { + return mTotalBytesRx; +} + +unsigned long KNetStatsView::totalBytesTx() const { + return mTotalBytesTx; +} + +unsigned long KNetStatsView::totalPktRx() const { + return mTotalPktRx; +} + +unsigned long KNetStatsView::totalPktTx() const { + return mTotalPktTx; +} + +double KNetStatsView::byteSpeedRx() const { + return mSpeedHistoryRx[mSpeedHistoryPtr]; +} + +double KNetStatsView::byteSpeedTx() const { + return mSpeedHistoryTx[mSpeedHistoryPtr]; +} + +double KNetStatsView::pktSpeedRx() const { + return calcSpeed(mSpeedBufferPRx); +} + +double KNetStatsView::pktSpeedTx() const { + return calcSpeed(mSpeedBufferPTx); +} + +#endif diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..b35cf41 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2004-2006 by Hugo Parente Lima * + * hugo_pl@users.sourceforge.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "knetstats.h" + +const char* programName = I18N_NOOP( "KNetStats" ); + +int main( int argc, char** argv ) +{ + TDEAboutData aboutData( "knetstats", programName, + "v1.6.1", // version + I18N_NOOP( "A network device monitor." ), // description + TDEAboutData::License_GPL, // license + "(C) 2004-2005 Hugo Parente Lima", // copyright + 0, + "http://knetstats.sourceforge.net", // homepage + "hugo_pl@users.sourceforge.net"); // bug email address + aboutData.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS"), I18N_NOOP("_: EMAIL OF TRANSLATORS")); + aboutData.addAuthor( "Hugo Parente Lima", 0, "hugo_pl@users.sourceforge.net" ); + + // Credits + aboutData.addCredit( "Thomas Windheuser", I18N_NOOP("SCons help, Debian packages, etc."), 0); + aboutData.addCredit( "KNemo", I18N_NOOP("Icon themes"), 0, + "http://kde-apps.org/content/show.php?content=12956" ); + // translators + aboutData.addCredit( "Ilyas Bakirov, Roberto Leandrini, Carlos Ortiz, Henrik Gebauer, Edward Romantsov, Wiktor Wandachowicz, Guillaume Savaton, Petar Toushkov, Liu Di", I18N_NOOP("KNetStats translation to other languages"), 0); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + TDEApplication::disableAutoDcopRegistration(); + + TDEApplication app; + KNetStats knetstats; + if (!knetstats.numInterfaces()) { + KMessageBox::error(0, i18n("You don't have any network interface.\nKNetStats will quit now.")); + return 1; + } + return app.exec(); +} + diff --git a/src/pics/CMakeLists.txt b/src/pics/CMakeLists.txt new file mode 100644 index 0000000..e7d1781 --- /dev/null +++ b/src/pics/CMakeLists.txt @@ -0,0 +1,6 @@ +file( GLOB _pics RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.png ) + +install( + FILES ${_pics} + DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME}/pics +) diff --git a/src/pics/Makefile.am b/src/pics/Makefile.am new file mode 100644 index 0000000..fab68d0 --- /dev/null +++ b/src/pics/Makefile.am @@ -0,0 +1,5 @@ +knetstats_DATA = theme0_none.png theme1_error.png theme2_both.png theme2_tx.png theme3_rx.png theme4_none.png \ + icon_pci.png theme0_rx.png theme1_none.png theme2_error.png theme3_both.png theme3_tx.png theme4_rx.png \ + theme0_both.png theme0_tx.png theme1_rx.png theme2_none.png theme3_error.png theme4_both.png theme4_tx.png \ + theme0_error.png theme1_both.png theme1_tx.png theme2_rx.png theme3_none.png theme4_error.png +knetstatsdir = $(kde_datadir)/knetstats/pics diff --git a/src/pics/icon_pci.png b/src/pics/icon_pci.png new file mode 100644 index 0000000..f7a607e Binary files /dev/null and b/src/pics/icon_pci.png differ diff --git a/src/pics/theme0_both.png b/src/pics/theme0_both.png new file mode 100644 index 0000000..0950f8b Binary files /dev/null and b/src/pics/theme0_both.png differ diff --git a/src/pics/theme0_error.png b/src/pics/theme0_error.png new file mode 100644 index 0000000..b618a9a Binary files /dev/null and b/src/pics/theme0_error.png differ diff --git a/src/pics/theme0_none.png b/src/pics/theme0_none.png new file mode 100644 index 0000000..b953009 Binary files /dev/null and b/src/pics/theme0_none.png differ diff --git a/src/pics/theme0_rx.png b/src/pics/theme0_rx.png new file mode 100644 index 0000000..e902270 Binary files /dev/null and b/src/pics/theme0_rx.png differ diff --git a/src/pics/theme0_tx.png b/src/pics/theme0_tx.png new file mode 100644 index 0000000..d3ad8be Binary files /dev/null and b/src/pics/theme0_tx.png differ diff --git a/src/pics/theme1_both.png b/src/pics/theme1_both.png new file mode 100644 index 0000000..851c1cb Binary files /dev/null and b/src/pics/theme1_both.png differ diff --git a/src/pics/theme1_error.png b/src/pics/theme1_error.png new file mode 100644 index 0000000..4b121a2 Binary files /dev/null and b/src/pics/theme1_error.png differ diff --git a/src/pics/theme1_none.png b/src/pics/theme1_none.png new file mode 100644 index 0000000..57f0142 Binary files /dev/null and b/src/pics/theme1_none.png differ diff --git a/src/pics/theme1_rx.png b/src/pics/theme1_rx.png new file mode 100644 index 0000000..0a38fa3 Binary files /dev/null and b/src/pics/theme1_rx.png differ diff --git a/src/pics/theme1_tx.png b/src/pics/theme1_tx.png new file mode 100644 index 0000000..9708c27 Binary files /dev/null and b/src/pics/theme1_tx.png differ diff --git a/src/pics/theme2_both.png b/src/pics/theme2_both.png new file mode 100644 index 0000000..0ce25c8 Binary files /dev/null and b/src/pics/theme2_both.png differ diff --git a/src/pics/theme2_error.png b/src/pics/theme2_error.png new file mode 100644 index 0000000..4418e97 Binary files /dev/null and b/src/pics/theme2_error.png differ diff --git a/src/pics/theme2_none.png b/src/pics/theme2_none.png new file mode 100644 index 0000000..a686cba Binary files /dev/null and b/src/pics/theme2_none.png differ diff --git a/src/pics/theme2_rx.png b/src/pics/theme2_rx.png new file mode 100644 index 0000000..8d992d9 Binary files /dev/null and b/src/pics/theme2_rx.png differ diff --git a/src/pics/theme2_tx.png b/src/pics/theme2_tx.png new file mode 100644 index 0000000..d176fac Binary files /dev/null and b/src/pics/theme2_tx.png differ diff --git a/src/pics/theme3_both.png b/src/pics/theme3_both.png new file mode 100644 index 0000000..8670266 Binary files /dev/null and b/src/pics/theme3_both.png differ diff --git a/src/pics/theme3_error.png b/src/pics/theme3_error.png new file mode 100644 index 0000000..ee08863 Binary files /dev/null and b/src/pics/theme3_error.png differ diff --git a/src/pics/theme3_none.png b/src/pics/theme3_none.png new file mode 100644 index 0000000..4fbdbe5 Binary files /dev/null and b/src/pics/theme3_none.png differ diff --git a/src/pics/theme3_rx.png b/src/pics/theme3_rx.png new file mode 100644 index 0000000..c0a6daf Binary files /dev/null and b/src/pics/theme3_rx.png differ diff --git a/src/pics/theme3_tx.png b/src/pics/theme3_tx.png new file mode 100644 index 0000000..bf1c21e Binary files /dev/null and b/src/pics/theme3_tx.png differ diff --git a/src/pics/theme4_both.png b/src/pics/theme4_both.png new file mode 100644 index 0000000..d237404 Binary files /dev/null and b/src/pics/theme4_both.png differ diff --git a/src/pics/theme4_error.png b/src/pics/theme4_error.png new file mode 100644 index 0000000..b14a709 Binary files /dev/null and b/src/pics/theme4_error.png differ diff --git a/src/pics/theme4_none.png b/src/pics/theme4_none.png new file mode 100644 index 0000000..02c7131 Binary files /dev/null and b/src/pics/theme4_none.png differ diff --git a/src/pics/theme4_rx.png b/src/pics/theme4_rx.png new file mode 100644 index 0000000..d77b01d Binary files /dev/null and b/src/pics/theme4_rx.png differ diff --git a/src/pics/theme4_tx.png b/src/pics/theme4_tx.png new file mode 100644 index 0000000..86591c6 Binary files /dev/null and b/src/pics/theme4_tx.png differ diff --git a/src/src/CMakeLists.txt b/src/src/CMakeLists.txt deleted file mode 100644 index 4b74eac..0000000 --- a/src/src/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -add_subdirectory( pics ) - -include_directories( - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${TDE_INCLUDE_DIR} - ${TQT_INCLUDE_DIRS} -) - -link_directories( - ${TQT_LIBRARY_DIRS} - ${TDE_LIB_DIR} -) - - -##### knetstats (executable) - -tde_add_executable( ${PROJECT_NAME} AUTOMOC - - SOURCES - configurebase.ui - configure.cpp - statisticsbase.ui - main.cpp - knetstats.cpp - knetstatsview.cpp - statistics.cpp - chart.cpp - interface.cpp - LINK - tdecore-shared - tdeui-shared - tdeio-shared - tdeui-shared - - DESTINATION ${BIN_INSTALL_DIR} -) diff --git a/src/src/Makefile.am b/src/src/Makefile.am deleted file mode 100644 index 2875827..0000000 --- a/src/src/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -INCLUDES = $(all_includes) - -SUBDIRS = pics - -bin_PROGRAMS = knetstats - -knetstats_SOURCES = configurebase.ui configure.cpp statisticsbase.ui main.cpp \ - knetstats.cpp knetstatsview.cpp statistics.cpp chart.cpp interface.cpp -knetstats_LDADD = $(LIB_TDEUI) -knetstats_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor -METASOURCES = configure.moc knetstats.moc knetstatsview.moc statistics.moc - -# these are the headers for your project -noinst_HEADERS = chart.h configure.h knetstats.h knetstatsview.h statistics.h \ - interface.h - -messages: rc.cpp - $(EXTRACTRC) *.ui >> rc.cpp - $(XGETTEXT) *.cpp -o $(podir)/knetstats.pot - -KDE_OPTIONS = nofinal - diff --git a/src/src/chart.cpp b/src/src/chart.cpp deleted file mode 100644 index 8af9d1e..0000000 --- a/src/src/chart.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2005 by Hugo Parente Lima * -* hugo_pl@users.sourceforge.net * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -***************************************************************************/ - -#include "chart.h" -#include -#include - -Chart::Chart(TQWidget* parent, const double* uploadBuffer, const double* downloadBuffer, int bufferSize, const int* ptr, const double* maxspeed) : TQWidget(parent), mUplBuffer(uploadBuffer), mDldBuffer(downloadBuffer), mBufferSize(bufferSize), mPtr(ptr), mMaxSpeed(maxspeed) { - setWFlags(TQt::WNoAutoErase); - setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding); -} - -void Chart::paintEvent(TQPaintEvent*) { - TQPainter paint(this); - paint.setBackgroundColor(TQt::black); - paint.setBackgroundMode(Qt::OpaqueMode); - TQBrush brush(TQColor(0x33, 0x33, 0x33), CrossPattern); - paint.fillRect(0, 0, width(), height(), brush); - - const double step = width()/double(mBufferSize); - const int HEIGHT = height() - 1; - - int x; - int lastX = x = width(); - int lastRxY = HEIGHT - int(HEIGHT * (mDldBuffer[*mPtr]/(*mMaxSpeed))); - int lastTxY = HEIGHT - int(HEIGHT * (mUplBuffer[*mPtr]/(*mMaxSpeed))); - - int count = 0; - for (int i = *mPtr; count < mBufferSize; i--) { - if (i < 0) - i = mBufferSize-1; - int rxY = HEIGHT - int(HEIGHT * (mDldBuffer[i]/(*mMaxSpeed))); - int txY = HEIGHT - int(HEIGHT * (mUplBuffer[i]/(*mMaxSpeed))); - paint.setPen(TQt::green); - paint.drawLine(lastX, lastRxY, x, rxY); - paint.setPen(TQt::red); - paint.drawLine(lastX, lastTxY, x, txY); - //tqDebug("%d => %d", i, int(mSpeedHistoryRx[i])); - lastX = x; - lastRxY = rxY; - lastTxY = txY; - - count++; - x = width() - int(step*(count+1)); - - } -} - diff --git a/src/src/chart.h b/src/src/chart.h deleted file mode 100644 index 8bd8be8..0000000 --- a/src/src/chart.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2005 by Hugo Parente Lima * -* hugo_pl@users.sourceforge.net * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -***************************************************************************/ - -#ifndef CHART_H -#define CHART_H - -#include - -class TQPaintEvent; - -class Chart : public TQWidget { -public: - Chart(TQWidget* parent, const double* uploadBuffer, const double* downloadBuffer, int bufferSize, const int* ptr, const double* maxspeed); - TQSize sizeHint() { return TQSize(200, 100); } -protected: - void paintEvent( TQPaintEvent* ev ); - -private: - const double* mUplBuffer; - const double* mDldBuffer; - const int mBufferSize; - const int* mPtr; - const double* mMaxSpeed; -}; - -#endif diff --git a/src/src/configure.cpp b/src/src/configure.cpp deleted file mode 100644 index f3ffcff..0000000 --- a/src/src/configure.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Hugo Parente Lima * - * hugo_pl@users.sourceforge.net * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "configure.h" -#include "knetstats.h" - -// TQt includes -#include -#include -#include -#include -#include -#include -// Kde includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -Configure::Configure(KNetStats* parent, const InterfaceMap& ifs) : ConfigureBase(parent) { - // Load configuration - TDEIconLoader* loader = kapp->iconLoader(); - - TQPixmap iconPCI = loader->loadIcon("icon_pci.png", TDEIcon::Small, 16); - - // Clone the configuration. - for (InterfaceMap::ConstIterator it = ifs.begin(); it != ifs.end(); ++it) { - mInterfaces->insertItem(iconPCI, it.key()); - mConfig[it.key()] = it.data()->options(); - -// parent->readInterfaceOptions(*it, &mConfig[*it]); - } - - mInterfaces->setCurrentItem(0); - changeInterface(mInterfaces->selectedItem()); - - connect(mInterfaces, TQT_SIGNAL(selectionChanged(TQListBoxItem*)), this, TQT_SLOT(changeInterface(TQListBoxItem*))); - connect(mTheme, TQT_SIGNAL(activated(int)), this, TQT_SLOT(changeTheme(int))); - //connect(mInterfaces, TQT_SIGNAL(contextMenuRequested(TQListBoxItem*, const TQPoint&)), this, TQT_SLOT(showInterfaceContextMenu(TQListBoxItem*, const TQPoint&))); -} - -void Configure::changeInterface(TQListBoxItem* item) { - TQString interface = item->text(); - - if (!mCurrentItem.isEmpty()) - { - // Salvas as modificações passadas - KNetStatsView::Options& oldview = mConfig[mCurrentItem]; - // general options - oldview.mMonitoring = mMonitoring->isChecked(); - oldview.mUpdateInterval = mUpdateInterval->value(); - oldview.mViewMode = (KNetStatsView::Mode) mViewMode->currentItem(); - // txt view options - oldview.mTxtUplColor = mTxtUplColor->color(); - oldview.mTxtDldColor = mTxtDldColor->color(); - oldview.mTxtFont = mTxtFont->font(); - // icon view - oldview.mTheme = mTheme->currentItem(); - // chart view - oldview.mChartUplColor = mChartUplColor->color(); - oldview.mChartDldColor = mChartDldColor->color(); - oldview.mChartBgColor = mChartBgColor->color(); - oldview.mChartTransparentBackground = mChartTransparentBackground->isChecked(); - } - - if (interface == mCurrentItem) - return; - // Carrega as opt. da nova interface - KNetStatsView::Options& view = mConfig[interface]; - // general - mMonitoring->setChecked(view.mMonitoring); - mUpdateInterval->setValue(view.mUpdateInterval); - mViewMode->setCurrentItem(view.mViewMode); - mWdgStack->raiseWidget(view.mViewMode); - // txt options - mTxtUplColor->setColor(view.mTxtUplColor); - mTxtDldColor->setColor(view.mTxtDldColor); - mTxtFont->setFont( view.mTxtFont ); - // icon options - mTheme->setCurrentItem(view.mTheme); - changeTheme(view.mTheme); - // chart options - mChartUplColor->setColor(view.mChartUplColor); - mChartDldColor->setColor(view.mChartDldColor); - mChartBgColor->setColor(view.mChartBgColor); - mChartTransparentBackground->setChecked(view.mChartTransparentBackground); - - mCurrentItem = interface; -} - -bool Configure::canSaveConfig() -{ - // update the options - changeInterface(mInterfaces->item( mInterfaces->currentItem() )); - - bool ok = false; - for(OptionsMap::ConstIterator i = mConfig.begin(); i != mConfig.end(); ++i) - if (i.data().mMonitoring) { - ok = true; - break; - } - - if (!ok) - KMessageBox::error(this, i18n("You need to select at least one interface to monitor.")); - return ok; -} - -void Configure::changeTheme(int theme) -{ - TDEIconLoader* loader = kapp->iconLoader(); - mIconError->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_error.png", - TDEIcon::Panel, ICONSIZE)); - mIconNone->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_none.png", - TDEIcon::Panel, ICONSIZE)); - mIconTx->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_tx.png", - TDEIcon::Panel, ICONSIZE)); - mIconRx->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_rx.png", - TDEIcon::Panel, ICONSIZE)); - mIconBoth->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_both.png", - TDEIcon::Panel, ICONSIZE)); -} -/* -void Configure::showInterfaceContextMenu(TQListBoxItem* item, const TQPoint& point) { - if (!item && mConfig.size() == 1) - return; - TQPixmap icon = kapp->iconLoader()->loadIcon("edit-delete", TDEIcon::Small, 16); - TQPopupMenu* menu = new TQPopupMenu(this); - menu->insertItem(icon, i18n("Renomve Interface"), this, TQT_SLOT(removeInterface())); - menu->exec(point); -} - -void Configure::removeInterface() { - mConfig.erase(mInterfaces->currentText()); - mInterfaces->removeItem(mInterfaces->currentItem()); -} -*/ -#include "configure.moc" diff --git a/src/src/configure.h b/src/src/configure.h deleted file mode 100644 index f214555..0000000 --- a/src/src/configure.h +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Hugo Parente Lima * - * hugo_pl@users.sourceforge.net * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef CONFIGURE_H -#define CONFIGURE_H - -#include "configurebase.h" -#include "interface.h" -#include -#include -#include -#include -#include -#include - -static const int ICONSIZE = 22; - -class KNetStats; -class TQListBoxItem; - - -typedef TQMap OptionsMap; - - -/** -* Configure dialog -*/ -class Configure : public ConfigureBase -{ - Q_OBJECT - -public: - Configure(KNetStats* parent, const InterfaceMap& ifs); - - const OptionsMap& currentConfig() const { return mConfig; } - bool canSaveConfig(); - const OptionsMap& options() const { return mConfig; } -private: - TQString mCurrentItem; - OptionsMap mConfig; - -protected slots: - void changeInterface(TQListBoxItem* item); - void changeTheme(int theme); - //void showInterfaceContextMenu(TQListBoxItem* item, const TQPoint& point); - //void removeInterface(); -}; - -#endif diff --git a/src/src/configurebase.ui b/src/src/configurebase.ui deleted file mode 100644 index 7619924..0000000 --- a/src/src/configurebase.ui +++ /dev/null @@ -1,677 +0,0 @@ - -ConfigureBase - - - ConfigureBase - - - - 0 - 0 - 355 - 307 - - - - - 4 - 4 - 0 - 0 - - - - Configure KNetStats - - - - unnamed - - - Minimum - - - - layout7 - - - - unnamed - - - - mSpacer - - - Horizontal - - - Expanding - - - - 120 - 20 - - - - - - mOk - - - Ok - - - true - - - - - mApply - - - Apply - - - - - mCancel - - - Cancel - - - - - - - mInterfaces - - - - 5 - 7 - 0 - 0 - - - - - - mAppearanceGroup - - - - 5 - 7 - 0 - 0 - - - - Appearance - - - - unnamed - - - - mWdgStack - - - - mIconPage - - - 0 - - - - unnamed - - - 0 - - - - layout5 - - - - unnamed - - - - mLabel4 - - - Theme: - - - - - - Classic - - - - - Modem - - - - - Network - - - - - Wireless - - - - - Kppp - - - - mTheme - - - - - spacer2 - - - Horizontal - - - Expanding - - - - 21 - 20 - - - - - - - - layout7_2 - - - - unnamed - - - - mIconError - - - - 0 - 0 - 0 - 0 - - - - - 22 - 22 - - - - true - - - - - spacer3 - - - Horizontal - - - Expanding - - - - 20 - 20 - - - - - - mIconNone - - - - 0 - 0 - 0 - 0 - - - - - 22 - 22 - - - - true - - - - - spacer4 - - - Horizontal - - - Expanding - - - - 20 - 20 - - - - - - mIconTx - - - - 0 - 0 - 0 - 0 - - - - - 22 - 22 - - - - true - - - - - spacer5 - - - Horizontal - - - Expanding - - - - 20 - 20 - - - - - - mIconRx - - - - 0 - 0 - 0 - 0 - - - - - 22 - 22 - - - - true - - - - - spacer6 - - - Horizontal - - - Expanding - - - - 20 - 20 - - - - - - mIconBoth - - - - 0 - 0 - 0 - 0 - - - - - 22 - 22 - - - - true - - - - - - - spacer11 - - - Vertical - - - Expanding - - - - 20 - 20 - - - - - - - - mTextPage - - - 1 - - - - unnamed - - - 0 - - - - mTxtUplColor - - - - - - - - mLabel5 - - - Download color: - - - - - mTxtDldColor - - - - - - - - mTxtFont - - - - 5 - 0 - 0 - 0 - - - - - - mLabel6 - - - Upload color: - - - - - - - mBarsPage - - - 2 - - - - unnamed - - - 0 - - - - mChartBgLabel - - - Background: - - - - - mChartUplColor - - - - - - - - mLabel7 - - - Upload color: - - - - - mLabel8 - - - Download color: - - - - - mChartDldColor - - - - - - - - mChartBgColor - - - - - - - - mChartTransparentBackground - - - Transparent background - - - - - - - - - - mConfigurationGroup - - - - 5 - 7 - 0 - 0 - - - - Configuration - - - - unnamed - - - - - Icon - - - - - Text - - - - - Chart - - - - mViewMode - - - - - mLabel3 - - - View mode: - - - - - mLabel2 - - - Update interval: - - - WordBreak|AlignVCenter - - - - - mUpdateInterval - - - 300 - - - 100 - - - 2000 - - - ms - - - - - mMonitoring - - - To monitor this interface - - - - - - - - - mViewMode - activated(int) - mWdgStack - raiseWidget(int) - - - mChartTransparentBackground - toggled(bool) - mChartBgColor - setDisabled(bool) - - - mChartTransparentBackground - toggled(bool) - mChartBgLabel - setDisabled(bool) - - - - mOk - mApply - mCancel - mInterfaces - mMonitoring - mUpdateInterval - mViewMode - mTheme - mTxtUplColor - mTxtDldColor - mTxtFont - mChartUplColor - mChartDldColor - mChartBgColor - mChartTransparentBackground - - - - kcolorbutton.h - kcombobox.h - knuminput.h - kpushbutton.h - tdefontrequester.h - - diff --git a/src/src/interface.cpp b/src/src/interface.cpp deleted file mode 100644 index 1ac98a8..0000000 --- a/src/src/interface.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -// C++ Implementation: interface -// -// Description: -// -// -// Author: Hugo Parente Lima , (C) 2006 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#include "interface.h" -#include -#include -#include - -Interface::Interface(KNetStats* parent, const TQString& name) : mName(name), mView(0), mParent(parent) { - update(); -} - -void Interface::update() { - bool defaultVisibility = !(mName == "lo" || mName == "sit0"); - - TDEConfig* cfg = kapp->config(); - TDEConfigGroupSaver groupSaver(cfg, mName); - bool visible = cfg->readBoolEntry("Monitoring", defaultVisibility); - if (!visible) - setVisible(false); - else if (visible && !mView) - setVisible(true); - else if (visible && mView) - mView->updateViewOptions(); -} - -void Interface::setVisible(bool visible) { - if (!visible) { - delete mView; - mView = 0; - } else if (visible && !mView) - mView = new KNetStatsView(mParent, mName); -} - -KNetStatsView::Options Interface::options() { - if (mView) - return mView->options(); - else { - KNetStatsView::Options opt; - KNetStatsView::readOptions(mName, &opt, false); - return opt; - } -} - -void Interface::say(const TQString& message) { - if (mView) - mView->say(message); -} - diff --git a/src/src/interface.h b/src/src/interface.h deleted file mode 100644 index 66bffc8..0000000 --- a/src/src/interface.h +++ /dev/null @@ -1,51 +0,0 @@ -// -// C++ Interface: interface -// -// Description: -// -// -// Author: Hugo Parente Lima , (C) 2006 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -#ifndef INTERFACE_H -#define INTERFACE_H - -#include -#include "knetstatsview.h" -class KNetStats; - -class Interface { - TQString mName; - KNetStatsView* mView; - KNetStats* mParent; - - Interface(const Interface&); -public: - /** - * Constructs a new interface. - * \param parent parent of the view of this interface. - * \param name name of this interface (not the TQObject name!!) - */ - Interface(KNetStats* parent, const TQString& name); - - /** - * Set this interface visible to the user via a KNetStatsView. - */ - void setVisible(bool visible); - bool isVisible() { return mView; } - - void update(); - - void say(const TQString& message); - - KNetStatsView::Options options(); -}; - -#include -typedef TQMap InterfaceMap; - - -#endif diff --git a/src/src/knetstats.cpp b/src/src/knetstats.cpp deleted file mode 100644 index bfbb1b2..0000000 --- a/src/src/knetstats.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Hugo Parente Lima * - * hugo_pl@users.sourceforge.net * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "knetstats.h" -#include "knetstatsview.h" -#include "configure.h" -#include "interface.h" - -// TQt includes -#include -#include -#include -// KDE includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -KNetStats::KNetStats() : TQWidget(0, "knetstats"), mConfigure(0), mBoot(true) { - setupUi(); - int count; - detectNewInterfaces(&count); - if (!count && numInterfaces()) // caos!!! All interfaces are invisible! turn all visible... - for(InterfaceMap::Iterator i = mInterfaces.begin(); i != mInterfaces.end(); ++i) - i.data()->setVisible(true); - - - mBoot = false; - TQTimer* timer = new TQTimer(this); - connect(timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(detectNewInterfaces())); - timer->start(IF_DETECTION_INTERVAL); -} - -KNetStats::~KNetStats() { - for (InterfaceMap::Iterator it = mInterfaces.begin(); it != mInterfaces.end(); ++it) - delete it.data(); -} - - -void KNetStats::setupUi() { - setIcon(kapp->icon()); - // Cria o contextMenu - mActionCollection = new TDEActionCollection(this); - mContextMenu = new TDEPopupMenu(this); - mContextMenu->insertTitle( kapp->miniIcon(), kapp->caption() ); - TDEAction* configure = KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT(configure()), mActionCollection, "configure"); - configure->plug(mContextMenu); - mContextMenu->insertSeparator(); - KHelpMenu* helpmenu = new KHelpMenu(this, TQString(), false); - mContextMenu->insertItem( i18n("&Help"), helpmenu->menu() ); - - mContextMenu->insertSeparator(); - TDEAction* quitAction = KStdAction::quit(TQT_TQOBJECT(kapp), TQT_SLOT(quit()), mActionCollection); - quitAction->plug(mContextMenu); - - connect(helpmenu, TQT_SIGNAL(showAboutApplication()), this, TQT_SLOT(about())); -} - -TQStringList KNetStats::scanInterfaces() { - TQDir dir("/sys/class/net"); - if (!dir.exists()) { - KMessageBox::error(0, i18n("You need kernel 2.6.x with support to the /sys filesystem.")); - return TQStringList(); - } else { - TQStringList list = dir.entryList(TQDir::Dirs); - list.pop_front(); // removes "." and ".." entries - list.pop_front(); - return list; - } -} - -bool KNetStats::configure() { - if (mConfigure) - mConfigure->show(); - else { -/* if (!mInterfaces.size()) { - KMessageBox::error(this, i18n("You don't have any network interface.\nKNetStats will quit now.")); - return false; - }*/ - - mConfigure = new Configure(this, mInterfaces); - connect(mConfigure->mOk, TQT_SIGNAL(clicked()), this, TQT_SLOT(configOk())); - connect(mConfigure->mApply, TQT_SIGNAL(clicked()), this, TQT_SLOT(configApply())); - connect(mConfigure->mCancel, TQT_SIGNAL(clicked()), this, TQT_SLOT(configCancel())); - mConfigure->show(); - } - return true; -} - -void KNetStats::configOk() { - if (mConfigure->canSaveConfig()) { - saveConfig( mConfigure->options() ); - delete mConfigure; - mConfigure = 0; - } -} - -void KNetStats::configApply() { - if (mConfigure->canSaveConfig()) - saveConfig( mConfigure->options() ); -} - -void KNetStats::configCancel() { - delete mConfigure; - mConfigure = 0; -} - -void KNetStats::saveConfig(const OptionsMap& options) { - TDEConfig* cfg = kapp->config(); - - for(OptionsMap::ConstIterator i = options.begin(); i != options.end(); ++i) { - TDEConfigGroupSaver groupSaver(cfg, i.key()); - const KNetStatsView::Options& opt = i.data(); - // general - cfg->writeEntry("UpdateInterval", opt.mUpdateInterval); - cfg->writeEntry("ViewMode", opt.mViewMode); - cfg->writeEntry("Monitoring", opt.mMonitoring); - // txt view - cfg->writeEntry("TxtFont", opt.mTxtFont); - cfg->writeEntry("TxtUplColor", opt.mTxtUplColor); - cfg->writeEntry("TxtDldColor", opt.mTxtDldColor); - // IconView - cfg->writeEntry("Theme", opt.mTheme); - // Graphic view - cfg->writeEntry("ChartUplColor", opt.mChartUplColor); - cfg->writeEntry("ChartDldColor", opt.mChartDldColor); - cfg->writeEntry("ChartBgColor", opt.mChartBgColor); - cfg->writeEntry("ChartUseTransparentBackground", opt.mChartTransparentBackground); - } - - for (InterfaceMap::ConstIterator i = mInterfaces.begin(); i != mInterfaces.end(); ++i) - i.data()->update(); -} - -void KNetStats::about() { - TDEAboutApplication dlg(this); - dlg.exec(); -} - - -void KNetStats::detectNewInterfaces(int* count_ptr) { - int count = 0; - const TQStringList& interfaces = KNetStats::scanInterfaces(); - TQStringList::ConstIterator i = interfaces.begin(); - for(; i != interfaces.end(); ++i) { - InterfaceMap::Iterator elem = mInterfaces.find(*i); - if (elem == mInterfaces.end()) - if (createInterface(*i)) - count++; - } - if (count && count_ptr) - *count_ptr = count; -} - -bool KNetStats::createInterface(const TQString& name) { - // Cria a interface e adiciona em mInterfaces. - Interface* interface = new Interface(this, name); - mInterfaces.insert(name, interface); - if (!mBoot) - interface->say(i18n("New interface detected: %1").arg(name)); - return interface->isVisible(); -} - -#include "knetstats.moc" diff --git a/src/src/knetstats.h b/src/src/knetstats.h deleted file mode 100644 index e5042da..0000000 --- a/src/src/knetstats.h +++ /dev/null @@ -1,94 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Hugo Parente Lima * - * hugo_pl@users.sourceforge.net * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef KNETSTATS_H -#define KNETSTATS_H - -#include -#include -#include -#include "configure.h" - -class KNetStatsView; -class TDEConfig; -class TDEPopupMenu; -class TDEActionCollection; - -class Interface; - - -class KNetStats : public TQWidget -{ - Q_OBJECT - - - enum { - IF_DETECTION_INTERVAL = 5000 - }; - -public: - /// Constructor - KNetStats(); - ~KNetStats(); - - TDEPopupMenu* const contextMenu() const { return mContextMenu; } - /** - * \brief Search for network interfaces parsing /proc/net/dev - * \return A StringList with the network interface names - */ - static TQStringList scanInterfaces(); - int numInterfaces() const { return mInterfaces.size(); } - - -public slots: - /// Display configure the dialog box - bool configure(); - /// Configure dialog OK button - void configOk(); - /// Configure dialog Apply button - void configApply(); - /// Configure dialog Cancel button - void configCancel(); - - /// Diaplay the about box - void about(); - /** - * Search for new interfaces - * \param count_ptr Interface count, store the number of new visible interfaces found. - */ - void detectNewInterfaces(int* count_ptr = 0); -private: - TDEPopupMenu* mContextMenu; // help menu usado por todos os tray icons - Configure* mConfigure; - TDEActionCollection* mActionCollection; - bool mBoot; - InterfaceMap mInterfaces; - - - void readOptions(); - void saveConfig(const OptionsMap& options); - void clearOptions(OptionsMap* options); - void setupUi(); - // Creates a new interface, returns true or false if the new interface is visible or not. - bool createInterface(const TQString& interface); - -}; - -#endif diff --git a/src/src/knetstatsview.cpp b/src/src/knetstatsview.cpp deleted file mode 100644 index 72af3b4..0000000 --- a/src/src/knetstatsview.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004-2005 by Hugo Parente Lima * - * hugo_pl@users.sourceforge.net * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#include "knetstatsview.h" -#include "knetstats.h" - -// KDE headers -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -// TQt headers -#include -#include -#include -#include -#include -#include -#include -#include - -// C headers -#include -#include - -// Linux headers -extern "C" { -#include -#include -#include -#include -} - -#include "configure.h" -#include "statistics.h" - -extern const char* programName; - -KNetStatsView::KNetStatsView(KNetStats* parent, const TQString& interface) -: KSystemTray(parent, 0), mSysDevPath("/sys/class/net/"+interface+"/"), mInterface(interface) { - mFdSock = 0; - mFirstUpdate = true; - mMaxSpeedAge = 0; - mMaxSpeed = 0.0; - mBRx = mBTx = mPRx = mPTx = 0; - mConnected = mCarrier = true; - mTotalBytesRx = mTotalBytesTx = mTotalPktRx = mTotalPktTx = 0; - mSpeedBufferPtr = mSpeedHistoryPtr = 0; - mStatistics = 0; - - readOptions(interface, &mOptions, true); - resetBuffers(); - openFdSocket(); - memset(&mDevInfo, 0, sizeof(mDevInfo)); - strcpy(mDevInfo.ifr_name, mInterface.latin1()); - - setTextFormat(TQt::PlainText); - mContextMenu = parent->contextMenu(); - show(); - - // Timer - mTimer = new TQTimer(this, "timer"); - connect(mTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(updateStats(void))); - - TQToolTip::add(this, i18n("Monitoring %1").arg(mInterface)); - setup(); - mStatistics = new Statistics(this); -} - -KNetStatsView::~KNetStatsView() { - if (mFdSock != -1) - shutdown(mFdSock, SHUT_RDWR); - -} - -void KNetStatsView::setup() { - if (mOptions.mViewMode == Text) - setFont(mOptions.mTxtFont); - else if (mOptions.mViewMode == Icon) { - // Load Icons - TDEIconLoader* loader = kapp->iconLoader(); - mIconError = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_error.png", - TDEIcon::Panel, ICONSIZE); - mIconNone = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_none.png", - TDEIcon::Panel, ICONSIZE); - mIconTx = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_tx.png", - TDEIcon::Panel, ICONSIZE); - mIconRx =loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_rx.png", - TDEIcon::Panel, ICONSIZE); - mIconBoth = loader->loadIcon("theme"+TQString::number(mOptions.mTheme)+"_both.png", - TDEIcon::Panel, ICONSIZE); - mCurrentIcon = &mIconNone; - } - mTimer->start(mOptions.mUpdateInterval); - updateStats(); - TQWidget::update(); - mFirstUpdate = false; -} - -void KNetStatsView::say(const TQString& message) { - KPassivePopup::message(programName, message, kapp->miniIcon(), this); -} - -void KNetStatsView::updateViewOptions() { - readOptions(mInterface, &mOptions); - setup(); -} - -void KNetStatsView::updateStats() { - FILE* flags_fp = fopen((mSysDevPath+"flags").latin1(), "r"); - bool currentStatus; - if (!flags_fp) - currentStatus = false; - else { - int flags; - fscanf(flags_fp, "%Xu", &flags); - fclose(flags_fp); - currentStatus = IFF_UP & flags; - } - - if (!currentStatus && mConnected) { // interface down... - mConnected = false; - resetBuffers(); - TQWidget::update(); - say(i18n("%1 is inactive").arg(mInterface)); - } else if (currentStatus && !mConnected) { - mConnected = true; - say(i18n("%1 is active").arg(mInterface)); - } - - // kernel < 2.6.9 (I think) does not have carrier info, considering carrier ever on. - FILE* carrier_fp = fopen((mSysDevPath+"carrier").latin1(), "r"); - char carrierFlag = '1'; - if (carrier_fp) { - carrierFlag = fgetc(carrier_fp); - fclose(carrier_fp); - } - - if (!mConnected) - return; - if (carrierFlag == '0') { // carrier down - if (mCarrier) { - mCarrier = false; - TQWidget::update(); - say(i18n("%1 is disconnected").arg(mInterface)); - } - return; - } else if (!mCarrier) { // carrier up - mCarrier = true; - say(i18n("%1 is connected").arg(mInterface)); - } - - unsigned int brx = readInterfaceNumValue("rx_bytes"); - unsigned int btx = readInterfaceNumValue("tx_bytes"); - unsigned int prx = readInterfaceNumValue("rx_packets"); - unsigned int ptx = readInterfaceNumValue("tx_packets"); - - - if (!mFirstUpdate) { // a primeira velocidade sempre eh absurda, para evitar isso temos o mFirstUpdate - if (++mSpeedBufferPtr >= SPEED_BUFFER_SIZE) - mSpeedBufferPtr = 0; - - // Calcula as velocidades - mSpeedBufferTx[mSpeedBufferPtr] = ((btx - mBTx)*(1000.0f/mOptions.mUpdateInterval)); - mSpeedBufferRx[mSpeedBufferPtr] = ((brx - mBRx)*(1000.0f/mOptions.mUpdateInterval)); - mSpeedBufferPTx[mSpeedBufferPtr] = ((ptx - mPTx)*(1000.0f/mOptions.mUpdateInterval)); - mSpeedBufferPRx[mSpeedBufferPtr] = ((prx - mPRx)*(1000.0f/mOptions.mUpdateInterval)); - - if (++mSpeedHistoryPtr >= HISTORY_SIZE) - mSpeedHistoryPtr = 0; - mSpeedHistoryRx[mSpeedHistoryPtr] = calcSpeed(mSpeedBufferRx); - mSpeedHistoryTx[mSpeedHistoryPtr] = calcSpeed(mSpeedBufferTx); - - mMaxSpeedAge--; - - if (mSpeedHistoryTx[mSpeedHistoryPtr] > mMaxSpeed) { - mMaxSpeed = mSpeedHistoryTx[mSpeedHistoryPtr]; - mMaxSpeedAge = HISTORY_SIZE; - } - if (mSpeedHistoryRx[mSpeedHistoryPtr] > mMaxSpeed) { - mMaxSpeed = mSpeedHistoryRx[mSpeedHistoryPtr]; - mMaxSpeedAge = HISTORY_SIZE; - } - if (mMaxSpeedAge < 1) - calcMaxSpeed(); - } - - if (mOptions.mViewMode == Icon) { - TQPixmap* newIcon; - if (brx == mBRx) { - if (btx == mBTx ) - newIcon = &mIconNone; - else - newIcon = &mIconTx; - } else { - if (btx == mBTx ) - newIcon = &mIconRx; - else - newIcon = &mIconBoth; - } - - if (newIcon != mCurrentIcon) { - mCurrentIcon = newIcon; - TQWidget::update(); - } - } else if (mOptions.mViewMode == Graphic || (btx != mBTx && brx != mBRx)) - TQWidget::update(); - - // Update stats - mTotalBytesRx += brx - mBRx; - mTotalBytesTx += btx - mBTx; - mTotalPktRx += prx - mPRx; - mTotalPktTx += ptx - mPTx; - - mBRx = brx; - mBTx = btx; - mPRx = prx; - mPTx = ptx; -} - -unsigned long KNetStatsView::readInterfaceNumValue(const char* name) { - // stdio functions appear to be more fast than TQFile? - FILE* fp = fopen((mSysDevPath+"statistics/"+name).latin1(), "r"); - long retval; - fscanf(fp, "%lu", &retval); - fclose(fp); - return retval; -} - -TQString KNetStatsView::readInterfaceStringValue(const char* name, int maxlength) { - TQFile macFile(mSysDevPath+name); - macFile.open(IO_ReadOnly); - TQString value; - macFile.readLine(value, maxlength); - return value; -} - -void KNetStatsView::resetBuffers() { - memset(mSpeedHistoryRx, 0, sizeof(double)*HISTORY_SIZE); - memset(mSpeedHistoryTx, 0, sizeof(double)*HISTORY_SIZE); - memset(mSpeedBufferRx, 0, sizeof(double)*SPEED_BUFFER_SIZE); - memset(mSpeedBufferTx, 0, sizeof(double)*SPEED_BUFFER_SIZE); - memset(mSpeedBufferPRx, 0, sizeof(double)*SPEED_BUFFER_SIZE); - memset(mSpeedBufferPTx, 0, sizeof(double)*SPEED_BUFFER_SIZE); -} - -void KNetStatsView::paintEvent( TQPaintEvent* ) { - TQPainter paint(this); - switch(mOptions.mViewMode) { - case Icon: - if (!mCarrier || !mConnected) - mCurrentIcon = &mIconError; - paint.drawPixmap(0, 0, *mCurrentIcon); - break; - case Text: - drawText(paint); - break; - case Graphic: - drawGraphic(paint); - break; - } -} - -void KNetStatsView::drawText(TQPainter& paint) { - if (!mCarrier || !mConnected) { - paint.drawText(rect(), TQt::AlignCenter, "?"); - } else { - paint.setFont( mOptions.mTxtFont ); - paint.setPen( mOptions.mTxtUplColor ); - paint.drawText( rect(), TQt::AlignTop, Statistics::byteFormat(byteSpeedTx(), "KB", "MB")); - paint.setPen( mOptions.mTxtDldColor ); - paint.drawText( rect(), TQt::AlignBottom, Statistics::byteFormat(byteSpeedRx(), "KB", "MB")); - } -} - -void KNetStatsView::drawGraphic(TQPainter& paint) { - if (!mCarrier || !mConnected) { - paint.drawText(rect(), TQt::AlignCenter, "X"); - return; - } - - TQSize size = this->size(); - - if (!mOptions.mChartTransparentBackground) - paint.fillRect(0, 0, size.width(), size.height(), mOptions.mChartBgColor); - - const int HEIGHT = size.height()-1; - - // tqDebug("MaxSpeed: %d, age: %d", int(mMaxSpeed), mMaxSpeedAge); - int lastX; - int lastRxY = HEIGHT - int(HEIGHT * (mSpeedHistoryRx[mSpeedHistoryPtr]/mMaxSpeed)); - int lastTxY = HEIGHT - int(HEIGHT * (mSpeedHistoryTx[mSpeedHistoryPtr]/mMaxSpeed)); - int x = lastX = size.width(); - int count = 0; - for (int i = mSpeedHistoryPtr; count < width(); i--) { - if (i < 0) - i = HISTORY_SIZE-1; - - int rxY = HEIGHT - int(HEIGHT * (mSpeedHistoryRx[i]/mMaxSpeed)); - int txY = HEIGHT - int(HEIGHT * (mSpeedHistoryTx[i]/mMaxSpeed)); - paint.setPen(mOptions.mChartDldColor); - paint.drawLine(lastX, lastRxY, x, rxY); - paint.setPen(mOptions.mChartUplColor); - paint.drawLine(lastX, lastTxY, x, txY); - //tqDebug("%d => %d", i, int(mSpeedHistoryRx[i])); - lastX = x; - lastRxY = rxY; - lastTxY = txY; - - count++; - x = width()-int(count+1); - } -} - -void KNetStatsView::mousePressEvent(TQMouseEvent* ev) { - if (ev->button() == Qt::RightButton ) - mContextMenu->exec(TQCursor::pos()); - else if (ev->button() == Qt::LeftButton) - if (mStatistics->isShown()) - mStatistics->accept(); - else - mStatistics->show(); -} - -bool KNetStatsView::openFdSocket() { - if (mFdSock > 0) - return true; - if ((mFdSock = socket(AF_INET, SOCK_DGRAM, 0)) > 0) - return true; - return false; -} - -TQString KNetStatsView::getIp() { - if (mFdSock == -1 && !openFdSocket()) - return ""; - - ioctl(mFdSock, SIOCGIFADDR, &mDevInfo); - sockaddr_in sin = ((sockaddr_in&)mDevInfo.ifr_addr); - return inet_ntoa(sin.sin_addr); -} - -TQString KNetStatsView::getNetmask() { - if (mFdSock == -1 && !openFdSocket()) - return ""; - ioctl(mFdSock, SIOCGIFNETMASK, &mDevInfo); - sockaddr_in mask = ((sockaddr_in&)mDevInfo.ifr_netmask); - return inet_ntoa(mask.sin_addr); -} - -void KNetStatsView::readOptions( const TQString& name, KNetStatsView::Options* opts, bool defaultVisibility ) { - TDEConfig* cfg = kapp->config(); - TDEConfigGroupSaver groupSaver(cfg, name); - - // general - opts->mUpdateInterval = cfg->readNumEntry("UpdateInterval", 300); - opts->mViewMode = (Mode)cfg->readNumEntry("ViewMode", 0); - opts->mMonitoring = cfg->readBoolEntry("Monitoring", defaultVisibility); - // txt view - opts->mTxtFont = cfg->readFontEntry("TxtFont"); - opts->mTxtUplColor = cfg->readColorEntry("TxtUplColor", &TQt::red); - opts->mTxtDldColor = cfg->readColorEntry("TxtDldColor", &TQt::green); - // IconView - int defaultTheme = 0; - if (name.startsWith("wlan")) - defaultTheme = 3; // three... is a magic number... a magic number.... - opts->mTheme = cfg->readNumEntry("Theme", defaultTheme); - // Graphic - opts->mChartUplColor = cfg->readColorEntry("ChartUplColor", &TQt::red); - opts->mChartDldColor = cfg->readColorEntry("ChartDldColor", &TQt::blue); - opts->mChartBgColor = cfg->readColorEntry("ChartBgColor", &TQt::white); - opts->mChartTransparentBackground = cfg->readBoolEntry("ChartUseTransparentBackground", true); -} - - -#include "knetstatsview.moc" diff --git a/src/src/knetstatsview.h b/src/src/knetstatsview.h deleted file mode 100644 index e8cc0b8..0000000 --- a/src/src/knetstatsview.h +++ /dev/null @@ -1,260 +0,0 @@ -/*************************************************************************** -* (c) 2015 Timothy Pearson * -* Copyright (C) 2004-2005 by Hugo Parente Lima * -* hugo_pl@users.sourceforge.net * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -***************************************************************************/ - -#ifndef KNETSTATSVIEW_H -#define KNETSTATSVIEW_H - -#include -#include -#include -#include - -#include -#include - -class TQTimer; -class TQMouseEvent; -class TQPainter; -class TQPaintEvent; -class Statistics; -class KNetStats; - -/** -* Main class -*/ -class KNetStatsView : public KSystemTray -{ - Q_OBJECT - - - enum { - HISTORY_SIZE = 50, // Speed history buffer size - SPEED_BUFFER_SIZE = 10 // Speed normalization buffer size - }; - -public: - /** - * KNetstats view mode on system tray. - */ - enum Mode { - Icon, Text, Graphic - }; - - /** - * Visualization options. - */ - struct Options { - // general - int mUpdateInterval; - Mode mViewMode; - bool mMonitoring; - // txt view - TQFont mTxtFont; - TQColor mTxtUplColor; - TQColor mTxtDldColor; - // icon view - int mTheme; - // chart view - TQColor mChartUplColor; - TQColor mChartDldColor; - TQColor mChartBgColor; - bool mChartTransparentBackground; - }; - - KNetStatsView(KNetStats* parent, const TQString& interface); - ~KNetStatsView(); - - void say(const TQString& message); - void updateViewOptions(); - // read a value from /sys/class/net/interface/name - unsigned long readInterfaceNumValue(const char* name); - // read a value from /sys/class/net/interface/name - TQString readInterfaceStringValue(const char* name, int maxlength); - TQString getIp(); - TQString getNetmask(); - - const double* speedHistoryRx() const { return mSpeedHistoryRx; } - const double* speedHistoryTx() const { return mSpeedHistoryTx; } - const int historyBufferSize() const { return HISTORY_SIZE; } - const int* historyPointer() const { return &mSpeedHistoryPtr; } - const double* maxSpeed() const { return &mMaxSpeed; } - - /// Return a copy of the current view options. - Options options() const { return mOptions; } - /// read the interface view options - static void readOptions( const TQString& name, Options* opts, bool defaultVisibility = false ); - - /// The current monitored network interface - inline const TQString& interface() const; - /// The current Update Interval in miliseconds - inline int updateInterval() const; - /// We are in textmode? - inline Mode viewMode() const; - - /// Total of bytes receiveds - inline unsigned long totalBytesRx() const; - /// Total of bytes transmitted - inline unsigned long totalBytesTx() const; - /// Total of packets receiveds - inline unsigned long totalPktRx() const; - /// Total of packets transmitted - inline unsigned long totalPktTx() const; - /// RX Speed in bytes per second - inline double byteSpeedRx() const; - /// TX Speed in bytes per second - inline double byteSpeedTx() const; - /// RX Speed in packets per second - inline double pktSpeedRx() const; - /// TX Speed in packets per second - inline double pktSpeedTx() const; - -protected: - void mousePressEvent( TQMouseEvent* ev ); - void paintEvent( TQPaintEvent* ev ); - -private: - - int mFdSock; // Kernel-knetstats socket - struct ifreq mDevInfo; // info struct about our interface - - - TQString mSysDevPath; // Path to the device. - bool mCarrier; // Interface carrier is on? - bool mConnected; // Interface exists? - - TDEPopupMenu* mContextMenu; // Global ContextMenu - Statistics* mStatistics; // Statistics window - TQString mInterface; // Current interface - Options mOptions; // View options - - // Icons - TQPixmap mIconError, mIconNone, mIconTx, mIconRx, mIconBoth; - TQPixmap* mCurrentIcon; // Current state - TQTimer* mTimer; // Timer - - // Rx e Tx to bytes and packets - unsigned long mBRx, mBTx, mPRx, mPTx; - // Statistics - unsigned long mTotalBytesRx, mTotalBytesTx, mTotalPktRx, mTotalPktTx; - // Speed buffers - double mSpeedBufferRx[SPEED_BUFFER_SIZE], mSpeedBufferTx[SPEED_BUFFER_SIZE]; - double mSpeedBufferPRx[SPEED_BUFFER_SIZE], mSpeedBufferPTx[SPEED_BUFFER_SIZE]; - // pointer to current speed buffer position - int mSpeedBufferPtr; - - bool mFirstUpdate; - - // History buffer TODO: Make it configurable! - double mSpeedHistoryRx[HISTORY_SIZE]; - double mSpeedHistoryTx[HISTORY_SIZE]; - int mSpeedHistoryPtr; - double mMaxSpeed; - int mMaxSpeedAge; - - - // setup the view. - void setup(); - void drawText(TQPainter& paint); - void drawGraphic(TQPainter& paint); - // Reset speed and history buffers - void resetBuffers(); - // calc tha max. speed stored in the history buffer - inline void calcMaxSpeed(); - // calc the speed using a speed buffer - inline double calcSpeed(const double* buffer) const; - - bool openFdSocket(); - -private slots: - // Called by the timer to update statistics - void updateStats(); - -}; - -void KNetStatsView::calcMaxSpeed() { - double max = 0.0; - int ptr = mSpeedHistoryPtr; - for (int i = 0; i < HISTORY_SIZE; ++i) { - if (mSpeedHistoryRx[i] > max) { - max = mSpeedHistoryRx[i]; - ptr = i; - } - if (mSpeedHistoryTx[i] > max) { - max = mSpeedHistoryTx[i]; - ptr = i; - } - } - mMaxSpeed = max; - mMaxSpeedAge = (mSpeedHistoryPtr > ptr) ? (mSpeedHistoryPtr - ptr) : (mSpeedHistoryPtr + HISTORY_SIZE - ptr); -} - -double KNetStatsView::calcSpeed(const double* buffer) const { - double total = 0.0; - for (int i = 0; i < SPEED_BUFFER_SIZE; ++i) - total += buffer[i]; - return total/SPEED_BUFFER_SIZE; -} - -const TQString& KNetStatsView::interface() const { - return mInterface; -} - -int KNetStatsView::updateInterval() const { - return mOptions.mUpdateInterval; -} - -KNetStatsView::Mode KNetStatsView::viewMode() const { - return mOptions.mViewMode; -} - -unsigned long KNetStatsView::totalBytesRx() const { - return mTotalBytesRx; -} - -unsigned long KNetStatsView::totalBytesTx() const { - return mTotalBytesTx; -} - -unsigned long KNetStatsView::totalPktRx() const { - return mTotalPktRx; -} - -unsigned long KNetStatsView::totalPktTx() const { - return mTotalPktTx; -} - -double KNetStatsView::byteSpeedRx() const { - return mSpeedHistoryRx[mSpeedHistoryPtr]; -} - -double KNetStatsView::byteSpeedTx() const { - return mSpeedHistoryTx[mSpeedHistoryPtr]; -} - -double KNetStatsView::pktSpeedRx() const { - return calcSpeed(mSpeedBufferPRx); -} - -double KNetStatsView::pktSpeedTx() const { - return calcSpeed(mSpeedBufferPTx); -} - -#endif diff --git a/src/src/main.cpp b/src/src/main.cpp deleted file mode 100644 index b35cf41..0000000 --- a/src/src/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004-2006 by Hugo Parente Lima * - * hugo_pl@users.sourceforge.net * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include "knetstats.h" - -const char* programName = I18N_NOOP( "KNetStats" ); - -int main( int argc, char** argv ) -{ - TDEAboutData aboutData( "knetstats", programName, - "v1.6.1", // version - I18N_NOOP( "A network device monitor." ), // description - TDEAboutData::License_GPL, // license - "(C) 2004-2005 Hugo Parente Lima", // copyright - 0, - "http://knetstats.sourceforge.net", // homepage - "hugo_pl@users.sourceforge.net"); // bug email address - aboutData.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS"), I18N_NOOP("_: EMAIL OF TRANSLATORS")); - aboutData.addAuthor( "Hugo Parente Lima", 0, "hugo_pl@users.sourceforge.net" ); - - // Credits - aboutData.addCredit( "Thomas Windheuser", I18N_NOOP("SCons help, Debian packages, etc."), 0); - aboutData.addCredit( "KNemo", I18N_NOOP("Icon themes"), 0, - "http://kde-apps.org/content/show.php?content=12956" ); - // translators - aboutData.addCredit( "Ilyas Bakirov, Roberto Leandrini, Carlos Ortiz, Henrik Gebauer, Edward Romantsov, Wiktor Wandachowicz, Guillaume Savaton, Petar Toushkov, Liu Di", I18N_NOOP("KNetStats translation to other languages"), 0); - - TDECmdLineArgs::init( argc, argv, &aboutData ); - TDEApplication::disableAutoDcopRegistration(); - - TDEApplication app; - KNetStats knetstats; - if (!knetstats.numInterfaces()) { - KMessageBox::error(0, i18n("You don't have any network interface.\nKNetStats will quit now.")); - return 1; - } - return app.exec(); -} - diff --git a/src/src/pics/CMakeLists.txt b/src/src/pics/CMakeLists.txt deleted file mode 100644 index e7d1781..0000000 --- a/src/src/pics/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -file( GLOB _pics RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.png ) - -install( - FILES ${_pics} - DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME}/pics -) diff --git a/src/src/pics/Makefile.am b/src/src/pics/Makefile.am deleted file mode 100644 index fab68d0..0000000 --- a/src/src/pics/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -knetstats_DATA = theme0_none.png theme1_error.png theme2_both.png theme2_tx.png theme3_rx.png theme4_none.png \ - icon_pci.png theme0_rx.png theme1_none.png theme2_error.png theme3_both.png theme3_tx.png theme4_rx.png \ - theme0_both.png theme0_tx.png theme1_rx.png theme2_none.png theme3_error.png theme4_both.png theme4_tx.png \ - theme0_error.png theme1_both.png theme1_tx.png theme2_rx.png theme3_none.png theme4_error.png -knetstatsdir = $(kde_datadir)/knetstats/pics diff --git a/src/src/pics/icon_pci.png b/src/src/pics/icon_pci.png deleted file mode 100644 index f7a607e..0000000 Binary files a/src/src/pics/icon_pci.png and /dev/null differ diff --git a/src/src/pics/theme0_both.png b/src/src/pics/theme0_both.png deleted file mode 100644 index 0950f8b..0000000 Binary files a/src/src/pics/theme0_both.png and /dev/null differ diff --git a/src/src/pics/theme0_error.png b/src/src/pics/theme0_error.png deleted file mode 100644 index b618a9a..0000000 Binary files a/src/src/pics/theme0_error.png and /dev/null differ diff --git a/src/src/pics/theme0_none.png b/src/src/pics/theme0_none.png deleted file mode 100644 index b953009..0000000 Binary files a/src/src/pics/theme0_none.png and /dev/null differ diff --git a/src/src/pics/theme0_rx.png b/src/src/pics/theme0_rx.png deleted file mode 100644 index e902270..0000000 Binary files a/src/src/pics/theme0_rx.png and /dev/null differ diff --git a/src/src/pics/theme0_tx.png b/src/src/pics/theme0_tx.png deleted file mode 100644 index d3ad8be..0000000 Binary files a/src/src/pics/theme0_tx.png and /dev/null differ diff --git a/src/src/pics/theme1_both.png b/src/src/pics/theme1_both.png deleted file mode 100644 index 851c1cb..0000000 Binary files a/src/src/pics/theme1_both.png and /dev/null differ diff --git a/src/src/pics/theme1_error.png b/src/src/pics/theme1_error.png deleted file mode 100644 index 4b121a2..0000000 Binary files a/src/src/pics/theme1_error.png and /dev/null differ diff --git a/src/src/pics/theme1_none.png b/src/src/pics/theme1_none.png deleted file mode 100644 index 57f0142..0000000 Binary files a/src/src/pics/theme1_none.png and /dev/null differ diff --git a/src/src/pics/theme1_rx.png b/src/src/pics/theme1_rx.png deleted file mode 100644 index 0a38fa3..0000000 Binary files a/src/src/pics/theme1_rx.png and /dev/null differ diff --git a/src/src/pics/theme1_tx.png b/src/src/pics/theme1_tx.png deleted file mode 100644 index 9708c27..0000000 Binary files a/src/src/pics/theme1_tx.png and /dev/null differ diff --git a/src/src/pics/theme2_both.png b/src/src/pics/theme2_both.png deleted file mode 100644 index 0ce25c8..0000000 Binary files a/src/src/pics/theme2_both.png and /dev/null differ diff --git a/src/src/pics/theme2_error.png b/src/src/pics/theme2_error.png deleted file mode 100644 index 4418e97..0000000 Binary files a/src/src/pics/theme2_error.png and /dev/null differ diff --git a/src/src/pics/theme2_none.png b/src/src/pics/theme2_none.png deleted file mode 100644 index a686cba..0000000 Binary files a/src/src/pics/theme2_none.png and /dev/null differ diff --git a/src/src/pics/theme2_rx.png b/src/src/pics/theme2_rx.png deleted file mode 100644 index 8d992d9..0000000 Binary files a/src/src/pics/theme2_rx.png and /dev/null differ diff --git a/src/src/pics/theme2_tx.png b/src/src/pics/theme2_tx.png deleted file mode 100644 index d176fac..0000000 Binary files a/src/src/pics/theme2_tx.png and /dev/null differ diff --git a/src/src/pics/theme3_both.png b/src/src/pics/theme3_both.png deleted file mode 100644 index 8670266..0000000 Binary files a/src/src/pics/theme3_both.png and /dev/null differ diff --git a/src/src/pics/theme3_error.png b/src/src/pics/theme3_error.png deleted file mode 100644 index ee08863..0000000 Binary files a/src/src/pics/theme3_error.png and /dev/null differ diff --git a/src/src/pics/theme3_none.png b/src/src/pics/theme3_none.png deleted file mode 100644 index 4fbdbe5..0000000 Binary files a/src/src/pics/theme3_none.png and /dev/null differ diff --git a/src/src/pics/theme3_rx.png b/src/src/pics/theme3_rx.png deleted file mode 100644 index c0a6daf..0000000 Binary files a/src/src/pics/theme3_rx.png and /dev/null differ diff --git a/src/src/pics/theme3_tx.png b/src/src/pics/theme3_tx.png deleted file mode 100644 index bf1c21e..0000000 Binary files a/src/src/pics/theme3_tx.png and /dev/null differ diff --git a/src/src/pics/theme4_both.png b/src/src/pics/theme4_both.png deleted file mode 100644 index d237404..0000000 Binary files a/src/src/pics/theme4_both.png and /dev/null differ diff --git a/src/src/pics/theme4_error.png b/src/src/pics/theme4_error.png deleted file mode 100644 index b14a709..0000000 Binary files a/src/src/pics/theme4_error.png and /dev/null differ diff --git a/src/src/pics/theme4_none.png b/src/src/pics/theme4_none.png deleted file mode 100644 index 02c7131..0000000 Binary files a/src/src/pics/theme4_none.png and /dev/null differ diff --git a/src/src/pics/theme4_rx.png b/src/src/pics/theme4_rx.png deleted file mode 100644 index d77b01d..0000000 Binary files a/src/src/pics/theme4_rx.png and /dev/null differ diff --git a/src/src/pics/theme4_tx.png b/src/src/pics/theme4_tx.png deleted file mode 100644 index 86591c6..0000000 Binary files a/src/src/pics/theme4_tx.png and /dev/null differ diff --git a/src/src/statistics.cpp b/src/src/statistics.cpp deleted file mode 100644 index 6097be1..0000000 --- a/src/src/statistics.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2004 by Hugo Parente Lima * -* hugo_pl@users.sourceforge.net * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -***************************************************************************/ -#include "statistics.h" -#include "chart.h" -#include "knetstatsview.h" - -#include -#include -#include -#include -#include - - - -Statistics::Statistics( KNetStatsView* parent, const char *name ) -: StatisticsBase( parent, name ), mInterface(parent->interface()), mParent(parent) { - setCaption( i18n( "Details of %1" ).arg( mInterface ) ); - - TQBoxLayout* l = new TQHBoxLayout( mChart ); - l->setAutoAdd( true ); - Chart* chart = new Chart(mChart, parent->speedHistoryTx(), parent->speedHistoryRx(), parent->historyBufferSize(), parent->historyPointer(), parent->maxSpeed()); - mMAC->setText(mParent->readInterfaceStringValue("address", 18)); - mIP->setAlignment(TQt::AlignRight); - mMAC->setAlignment(TQt::AlignRight); - mNetmask->setAlignment(TQt::AlignRight); - update(); - - mTimer = new TQTimer( this ); - connect( mTimer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( update() ) ); - connect( mTimer, TQT_SIGNAL( timeout() ), chart, TQT_SLOT( update() ) ); -} - -void Statistics::update() { - mMaxSpeed->setText(byteFormat( *mParent->maxSpeed() )+"/s"); - mBRx->setText( byteFormat( mParent->totalBytesRx() ) ); - mBTx->setText( byteFormat( mParent->totalBytesTx() ) ); - mByteSpeedRx->setText( byteFormat( mParent->byteSpeedRx() )+"/s" ); - mByteSpeedTx->setText( byteFormat( mParent->byteSpeedTx() )+"/s" ); - - mPRx->setText( TQString::number( mParent->totalPktRx() ) ); - mPTx->setText( TQString::number( mParent->totalPktTx() ) ); - mPktSpeedRx->setText( TQString::number( mParent->pktSpeedRx(), 'f', 1 )+"pkts/s" ); - mPktSpeedTx->setText( TQString::number( mParent->pktSpeedTx(), 'f', 1 )+"pkts/s" ); -} - -void Statistics::show() { - // Update details... - mMTU->setText(mParent->readInterfaceStringValue("mtu", 6)); - mIP->setText( mParent->getIp() ); - mNetmask->setText( mParent->getNetmask() ); - - mTimer->start( mParent->updateInterval() ); - StatisticsBase::show(); -} - -void Statistics::accept() { - mTimer->stop(); - StatisticsBase::accept(); -} - - -#include "statistics.moc" diff --git a/src/src/statistics.h b/src/src/statistics.h deleted file mode 100644 index a979961..0000000 --- a/src/src/statistics.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************** -* (c) 2015 Timothy Pearson * -* Copyright (C) 2004 by Hugo Parente Lima * -* hugo_pl@users.sourceforge.net * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -***************************************************************************/ -#ifndef STATISTICS_H -#define STATISTICS_H - -#include "statisticsbase.h" -#include - -class KNetStatsView; - -class Statistics : public StatisticsBase -{ - Q_OBJECT - - -public: - Statistics(KNetStatsView* parent = 0, const char *name = 0); - - /** - * Formats a numberic byte representation - * \param num The numeric representation - * \param decimal Decimal digits - * \param ksuffix Suffix for kilobytes - * \param msuffix Suffix for megabytes - * \param gsuffix Suffix for gigabytes - * \param tsuffix Suffix for terabytes - */ - static inline TQString byteFormat(double num, const char* ksuffix = " KB", const char* msuffix = " MB", const char* gsuffix = " GB", const char* tsuffix = " TB"); - - void show(); -private: - TQTimer* mTimer; - const TQString& mInterface; - KNetStatsView* mParent; -public slots: - void accept(); - -private slots: - void update(); -}; - -TQString Statistics::byteFormat(double num, const char* ksuffix, const char* msuffix, const char* gsuffix, const char* tsuffix) { - const double ONE_KB = 1024.0; - const double ONE_MB = ONE_KB*ONE_KB; - const double ONE_GB = ONE_KB*ONE_KB*ONE_KB; - const double ONE_TB = ONE_KB*ONE_KB*ONE_KB*ONE_KB; - if ( num >= ONE_TB ) { // TB - return TQString::number(num/(ONE_TB), 'f', 1) + tsuffix; - } - else if ( num >= ONE_GB ) { // GB - return TQString::number(num/(ONE_GB), 'f', 1) + gsuffix; - } - else if ( num >= ONE_MB ) { // MB - return TQString::number(num/(ONE_MB), 'f', 1) + msuffix; - } - else { // KB - return TQString::number(num/(ONE_KB), 'f', 1) + ksuffix; - } -} - -#endif diff --git a/src/src/statisticsbase.ui b/src/src/statisticsbase.ui deleted file mode 100644 index c10548e..0000000 --- a/src/src/statisticsbase.ui +++ /dev/null @@ -1,478 +0,0 @@ - -StatisticsBase - - - StatisticsBase - - - - 0 - 0 - 261 - 303 - - - - - 5 - 5 - 0 - 0 - - - - KNetStats - - - - unnamed - - - Minimum - - - - layout3 - - - - unnamed - - - - mChart - - - - 7 - 5 - 0 - 0 - - - - Panel - - - Sunken - - - - - spacer4_2 - - - Vertical - - - Expanding - - - - 20 - 41 - - - - - - mMaxSpeed - - - - 7 - - - - ? KB/s - - - AlignVCenter|AlignRight - - - - - textLabel2_3 - - - - 7 - - - - 0 KB/s - - - AlignVCenter|AlignRight - - - - - - - tabWidget2 - - - - 7 - 4 - 0 - 0 - - - - - tab - - - &Statistics - - - - unnamed - - - - mLabel5 - - - Upload speed: - - - - - mLabel1 - - - Received: - - - - - mLabel6 - - - Download speed: - - - - - mLabel2 - - - Transmited: - - - - - spacer2_2 - - - Horizontal - - - Expanding - - - - 71 - 20 - - - - - - mPktSpeedRx - - - AlignVCenter|AlignRight - - - - - textLabel1 - - - Bytes - - - - - mPRx - - - AlignVCenter|AlignRight - - - - - mByteSpeedTx - - - AlignVCenter|AlignRight - - - - - mBTx - - - AlignVCenter|AlignRight - - - - - mPTx - - - AlignVCenter|AlignRight - - - - - mPktSpeedTx - - - AlignVCenter|AlignRight - - - - - mBRx - - - AlignVCenter|AlignRight - - - - - mByteSpeedRx - - - AlignVCenter|AlignRight - - - - - textLabel2 - - - Packets - - - - - - - tab - - - Deta&ils - - - - unnamed - - - - textLabel1_2 - - - IP: - - - - - textLabel2_2 - - - Netmask: - - - - - textLabel3 - - - MAC: - - - - - textLabel7 - - - MTU: - - - - - spacer4 - - - Vertical - - - Expanding - - - - 200 - 21 - - - - - - spacer5 - - - Horizontal - - - Expanding - - - - 51 - 80 - - - - - - mIP - - - - 5 - 7 - 0 - 0 - - - - NoWrap - - - - - mNetmask - - - - 5 - 7 - 0 - 0 - - - - NoWrap - - - - - mMAC - - - - 5 - 7 - 0 - 0 - - - - 1 - - - - - - NoWrap - - - - - mMTU - - - 1 - - - - - - AlignVCenter - - - - - - - - layout2 - - - - unnamed - - - - spacer2 - - - Horizontal - - - Expanding - - - - 91 - 20 - - - - - - mOk - - - - 1 - 4 - 0 - 0 - - - - O&k - - - true - - - - - - - - - mOk - clicked() - StatisticsBase - accept() - - - - tabWidget2 - mOk - - - - kactivelabel.h - kpushbutton.h - - diff --git a/src/statistics.cpp b/src/statistics.cpp new file mode 100644 index 0000000..6097be1 --- /dev/null +++ b/src/statistics.cpp @@ -0,0 +1,79 @@ +/*************************************************************************** +* Copyright (C) 2004 by Hugo Parente Lima * +* hugo_pl@users.sourceforge.net * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +***************************************************************************/ +#include "statistics.h" +#include "chart.h" +#include "knetstatsview.h" + +#include +#include +#include +#include +#include + + + +Statistics::Statistics( KNetStatsView* parent, const char *name ) +: StatisticsBase( parent, name ), mInterface(parent->interface()), mParent(parent) { + setCaption( i18n( "Details of %1" ).arg( mInterface ) ); + + TQBoxLayout* l = new TQHBoxLayout( mChart ); + l->setAutoAdd( true ); + Chart* chart = new Chart(mChart, parent->speedHistoryTx(), parent->speedHistoryRx(), parent->historyBufferSize(), parent->historyPointer(), parent->maxSpeed()); + mMAC->setText(mParent->readInterfaceStringValue("address", 18)); + mIP->setAlignment(TQt::AlignRight); + mMAC->setAlignment(TQt::AlignRight); + mNetmask->setAlignment(TQt::AlignRight); + update(); + + mTimer = new TQTimer( this ); + connect( mTimer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( update() ) ); + connect( mTimer, TQT_SIGNAL( timeout() ), chart, TQT_SLOT( update() ) ); +} + +void Statistics::update() { + mMaxSpeed->setText(byteFormat( *mParent->maxSpeed() )+"/s"); + mBRx->setText( byteFormat( mParent->totalBytesRx() ) ); + mBTx->setText( byteFormat( mParent->totalBytesTx() ) ); + mByteSpeedRx->setText( byteFormat( mParent->byteSpeedRx() )+"/s" ); + mByteSpeedTx->setText( byteFormat( mParent->byteSpeedTx() )+"/s" ); + + mPRx->setText( TQString::number( mParent->totalPktRx() ) ); + mPTx->setText( TQString::number( mParent->totalPktTx() ) ); + mPktSpeedRx->setText( TQString::number( mParent->pktSpeedRx(), 'f', 1 )+"pkts/s" ); + mPktSpeedTx->setText( TQString::number( mParent->pktSpeedTx(), 'f', 1 )+"pkts/s" ); +} + +void Statistics::show() { + // Update details... + mMTU->setText(mParent->readInterfaceStringValue("mtu", 6)); + mIP->setText( mParent->getIp() ); + mNetmask->setText( mParent->getNetmask() ); + + mTimer->start( mParent->updateInterval() ); + StatisticsBase::show(); +} + +void Statistics::accept() { + mTimer->stop(); + StatisticsBase::accept(); +} + + +#include "statistics.moc" diff --git a/src/statistics.h b/src/statistics.h new file mode 100644 index 0000000..a979961 --- /dev/null +++ b/src/statistics.h @@ -0,0 +1,79 @@ +/*************************************************************************** +* (c) 2015 Timothy Pearson * +* Copyright (C) 2004 by Hugo Parente Lima * +* hugo_pl@users.sourceforge.net * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +***************************************************************************/ +#ifndef STATISTICS_H +#define STATISTICS_H + +#include "statisticsbase.h" +#include + +class KNetStatsView; + +class Statistics : public StatisticsBase +{ + Q_OBJECT + + +public: + Statistics(KNetStatsView* parent = 0, const char *name = 0); + + /** + * Formats a numberic byte representation + * \param num The numeric representation + * \param decimal Decimal digits + * \param ksuffix Suffix for kilobytes + * \param msuffix Suffix for megabytes + * \param gsuffix Suffix for gigabytes + * \param tsuffix Suffix for terabytes + */ + static inline TQString byteFormat(double num, const char* ksuffix = " KB", const char* msuffix = " MB", const char* gsuffix = " GB", const char* tsuffix = " TB"); + + void show(); +private: + TQTimer* mTimer; + const TQString& mInterface; + KNetStatsView* mParent; +public slots: + void accept(); + +private slots: + void update(); +}; + +TQString Statistics::byteFormat(double num, const char* ksuffix, const char* msuffix, const char* gsuffix, const char* tsuffix) { + const double ONE_KB = 1024.0; + const double ONE_MB = ONE_KB*ONE_KB; + const double ONE_GB = ONE_KB*ONE_KB*ONE_KB; + const double ONE_TB = ONE_KB*ONE_KB*ONE_KB*ONE_KB; + if ( num >= ONE_TB ) { // TB + return TQString::number(num/(ONE_TB), 'f', 1) + tsuffix; + } + else if ( num >= ONE_GB ) { // GB + return TQString::number(num/(ONE_GB), 'f', 1) + gsuffix; + } + else if ( num >= ONE_MB ) { // MB + return TQString::number(num/(ONE_MB), 'f', 1) + msuffix; + } + else { // KB + return TQString::number(num/(ONE_KB), 'f', 1) + ksuffix; + } +} + +#endif diff --git a/src/statisticsbase.ui b/src/statisticsbase.ui new file mode 100644 index 0000000..c10548e --- /dev/null +++ b/src/statisticsbase.ui @@ -0,0 +1,478 @@ + +StatisticsBase + + + StatisticsBase + + + + 0 + 0 + 261 + 303 + + + + + 5 + 5 + 0 + 0 + + + + KNetStats + + + + unnamed + + + Minimum + + + + layout3 + + + + unnamed + + + + mChart + + + + 7 + 5 + 0 + 0 + + + + Panel + + + Sunken + + + + + spacer4_2 + + + Vertical + + + Expanding + + + + 20 + 41 + + + + + + mMaxSpeed + + + + 7 + + + + ? KB/s + + + AlignVCenter|AlignRight + + + + + textLabel2_3 + + + + 7 + + + + 0 KB/s + + + AlignVCenter|AlignRight + + + + + + + tabWidget2 + + + + 7 + 4 + 0 + 0 + + + + + tab + + + &Statistics + + + + unnamed + + + + mLabel5 + + + Upload speed: + + + + + mLabel1 + + + Received: + + + + + mLabel6 + + + Download speed: + + + + + mLabel2 + + + Transmited: + + + + + spacer2_2 + + + Horizontal + + + Expanding + + + + 71 + 20 + + + + + + mPktSpeedRx + + + AlignVCenter|AlignRight + + + + + textLabel1 + + + Bytes + + + + + mPRx + + + AlignVCenter|AlignRight + + + + + mByteSpeedTx + + + AlignVCenter|AlignRight + + + + + mBTx + + + AlignVCenter|AlignRight + + + + + mPTx + + + AlignVCenter|AlignRight + + + + + mPktSpeedTx + + + AlignVCenter|AlignRight + + + + + mBRx + + + AlignVCenter|AlignRight + + + + + mByteSpeedRx + + + AlignVCenter|AlignRight + + + + + textLabel2 + + + Packets + + + + + + + tab + + + Deta&ils + + + + unnamed + + + + textLabel1_2 + + + IP: + + + + + textLabel2_2 + + + Netmask: + + + + + textLabel3 + + + MAC: + + + + + textLabel7 + + + MTU: + + + + + spacer4 + + + Vertical + + + Expanding + + + + 200 + 21 + + + + + + spacer5 + + + Horizontal + + + Expanding + + + + 51 + 80 + + + + + + mIP + + + + 5 + 7 + 0 + 0 + + + + NoWrap + + + + + mNetmask + + + + 5 + 7 + 0 + 0 + + + + NoWrap + + + + + mMAC + + + + 5 + 7 + 0 + 0 + + + + 1 + + + + + + NoWrap + + + + + mMTU + + + 1 + + + + + + AlignVCenter + + + + + + + + layout2 + + + + unnamed + + + + spacer2 + + + Horizontal + + + Expanding + + + + 91 + 20 + + + + + + mOk + + + + 1 + 4 + 0 + 0 + + + + O&k + + + true + + + + + + + + + mOk + clicked() + StatisticsBase + accept() + + + + tabWidget2 + mOk + + + + kactivelabel.h + kpushbutton.h + + diff --git a/subdirs b/subdirs index 34efd98..7f26902 100644 --- a/subdirs +++ b/subdirs @@ -1,2 +1,4 @@ src +icons +doc translations -- cgit v1.2.3