RutilTv0.18/0000755000175000017500000000000011054676161012341 5ustar romainromainRutilTv0.18/AUTHORS0000644000175000017500000000103510707371533013407 0ustar romainromainRomain BONDUE Many thanks to the people who contributed : Neil Armstrong Nicolas Favre-Félix Szymon Dziok Vincent Stehlé Kirk Williams Alessandro Grechi - AleXit Cesare Tirabassi Misha Aizatulin Ben Hutchings Thanks to Anders Carlsson for the eggtrayicon library. Thanks to my brother, Cyril BONDUE , for all RutilT's artworks and for hosting the webpage (http://cbbk.free.fr/bonrom). And thanks to all people who sent feedbacks, bug reports and/or helped testing. RutilTv0.18/rutilt_helper.10000644000175000017500000000150311054622203015270 0ustar romainromain.TH RUTILT_HELPER "1" "August 2008" "RutilT v0.18" "User Commands" .SH NAME RutilT Helper \- execute RutilT internal commands as root. .SH SYNOPSIS .B rutilt_helper .SH DESCRIPTION .PP rutilt_helper is an external program used by RutilT to get root privileges. It is not designed to be used on its own. .TP .SH AUTHOR Written by Romain BONDUE. See the AUTHORS file or the about dialog for all contributors. .SH "REPORTING BUGS" Report bugs to , on the rt2x00 mailing lists or on the forum . .SH COPYRIGHT Copyright \(co 2005-2008 Romain BONDUE .br This is free software. You may redistribute copies of it under the terms of the GNU General Public License . There is NO WARRANTY, to the extent permitted by law. .SH "SEE ALSO" \fBrutilt\fR(1) RutilTv0.18/Makefile0000644000175000017500000004273710722772626014022 0ustar romainromain# Copyright (c) 2005 Romain BONDUE # This file is part of RutilT. # # RutilT 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. # # RutilT 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 RutilT; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # # The file is generated by configure.sh and mostly contains installation # settings : include Makefile_cst # Concatenate PREFIX to DESTDIR if defined, and enable silent overwriting. ifdef DESTDIR PREFIX := $(DESTDIR)/$(PREFIX) CHECK_OVERWRITE := false else CHECK_OVERWRITE := true endif # # # Useful macros : INCLUDE := include/ LIB := lib SRC := $(LIB)/src/ PRIVATE := $(INCLUDE)/private/ ART := art/ # COMPILER = @echo " Compiling $@"; g++ $< -c $(CFLAGS) -o $@ \ -I$(KERNEL_SOURCES_PATH) -I$(INCLUDE) COMPILER_WITH_GTK = $(COMPILER) `pkg-config gtk+-2.0 --cflags` LINKER = @echo " Linking $@"; g++ $(CFLAGS) -o $@ # # # Headers dependencies : STATICSETTINGS_H := $(INCLUDE)/StaticSettings.h ERRORSCODE_H := $(INCLUDE)/ErrorsCode.h EXCEPTIONS_H := $(INCLUDE)/Exceptions.h $(PRIVATE)/Exceptions.hxx CLIOPT_H := $(INCLUDE)/CLIOpt.h $(PRIVATE)/CLIOpt.hxx $(EXCEPTIONS_H) SYSTEMTOOLS_H := $(INCLUDE)/SystemTools.h $(PRIVATE)/SystemTools.hxx \ $(EXCEPTIONS_H) SU_H := $(INCLUDE)/Su.h $(PRIVATE)/Su.hxx $(EXCEPTIONS_H) $(SYSTEMTOOLS_H) MSG_H := $(INCLUDE)/Msg.h $(PRIVATE)/Msg.hxx SUWPROTOCOLCODES_H := $(INCLUDE)/SuWProtocolCodes.h SUWPROTOCOL_H := $(INCLUDE)/SuWProtocol.h $(PRIVATE)/SuWProtocol.hxx $(MSG_H) \ $(EXCEPTIONS_H) $(SU_H) $(PARAMETERS_H) PARAMETERS_H := $(INCLUDE)/Parameters.h $(PRIVATE)/Parameters.hxx \ $(EXCEPTIONS_H) IDRIVER_H := $(INCLUDE)/IDriver.h $(PARAMETERS_H) $(EXCEPTIONS_H) MODULE_H := $(INCLUDE)/Module.h $(EXCEPTIONS_H) $(PARAMETERS_H) WE17DRIVER_H := $(INCLUDE)/WE17Driver.h $(PRIVATE)/WE17Driver.hxx $(IDRIVER_H) \ $(SYSTEMTOOLS_H) CLINKSTATUSTAB_H := $(INCLUDE)/CLinkStatusTab.h $(PRIVATE)/CLinkStatusTab.hxx \ $(EXCEPTIONS_H) CSELECTABLEROWLIST_H := $(INCLUDE)/CSelectableRowList.h \ $(PRIVATE)/CSelectableRowList.hxx CSITESURVEYTAB_H := $(INCLUDE)/CSiteSurveyTab.h $(PRIVATE)/CSiteSurveyTab.hxx \ $(CSELECTABLEROWLIST_H) CPROFILETAB_H := $(INCLUDE)/CProfileTab.h $(PRIVATE)/CProfileTab.hxx \ $(CSELECTABLEROWLIST_H) XMLPARSER_H := $(INCLUDE)/XMLParser.h $(PRIVATE)/XMLParser.hxx $(EXCEPTIONS_H) USERDATA_H := $(INCLUDE)/UserData.h $(PRIVATE)/UserData.hxx $(PARAMETERS_H) \ $(EXCEPTIONS_H) $(XMLPARSER_H) NETTOOLS_H := $(INCLUDE)/NetTools.h $(PRIVATE)/NetTools.hxx $(EXCEPTIONS_H) EGGTRAYICON_H := $(INCLUDE)/eggtrayicon.h TRAYICON_H := $(INCLUDE)/TrayIcon.h $(PRIVATE)/TrayIcon.hxx IFACEROOT_H := $(INCLUDE)/IfaceRoot.h $(NETTOOLS_H) $(SU_H) PREFSPAGE_H := $(INCLUDE)/PrefsPage.h $(PRIVATE)/PrefsPage.hxx GTKGUI_H := $(INCLUDE)/GtkGUI.h $(PRIVATE)/GtkGUI.hxx $(MODULE_H) \ $(EXCEPTIONS_H) $(CLINKSTATUSTAB_H) $(CSITESURVEYTAB_H) $(CLIOPT_H)\ $(CPROFILETAB_H) $(CSTATSPAGE_H) $(TRAYICON_H) $(PREFSPAGE_H) CWE17MODULE_H := $(INCLUDE)/CWE17Module.h $(PRIVATE)/CWE17Module.hxx \ $(MODULE_H) $(USERDATA_H) $(PROFILEEDITOR_H) $(WE17DRIVER_H) RTDRIVERS_H := $(INCLUDE)/RTDrivers.h $(PRIVATE)/RTDrivers.hxx $(WE17DRIVER_H) RTMODULES_H := $(INCLUDE)/RTModules.h $(PRIVATE)/RTModules.hxx $(MODULE_H) \ $(USERDATA_H) $(CWE17MODULE_H) $(ERRORSCODE_H) $(WWIDGETS_H) \ $(PROFILEEDITOR_H) $(RTDRIVERS_H) IFACEPROTOCOLCODES_H := $(INCLUDE)/IfaceProtocolCodes.h IMSGHANDLER_H := $(INCLUDE)/IMsgHandler.h $(MSG_H) CWIRELESSMSGHANDLER_H := $(INCLUDE)/CWirelessMsgHandler.h $(EXCEPTIONS_H) \ $(PRIVATE)/CWirelessMsgHandler.hxx $(IMSGHANDLER_H) \ $(IDRIVER_H) MSGHANDLERFACTORY_H := $(INCLUDE)/MsgHandlerFactory.h $(EXCEPTIONS_H) WE17DRIVERROOT_H := $(INCLUDE)/WE17DriverRoot.h $(PRIVATE)/WE17DriverRoot.hxx \ $(WE17DRIVER_H) RTDRIVERSROOT_H := $(INCLUDE)/RTDriversRoot.h $(PRIVATE)/RTDriversRoot.hxx \ $(RTDRIVERS_H) $(SUWPROTOCOL_H) RTSUWPROTOCOLCODES_H := $(INCLUDE)/RTSuWProtocolCodes.h $(SUWPROTOCOLCODES_H) RTWMSGHANDLERS_H := $(INCLUDE)/RTWMsgHandlers.h $(PRIVATE)/RTWMsgHandlers.hxx \ $(CWIRELESSMSGHANDLER_H) WWIDGETS_H := $(INCLUDE)/WWidgets.h $(PRIVATE)/WWidgets.hxx $(PARAMETERS_H) \ $(USERDATA_H) PROFILEEDITOR_H := $(INCLUDE)/ProfileEditor.h $(PRIVATE)/ProfileEditor.hxx CSTATSPAGE_H := $(INCLUDE)/CStatsPage.h $(PRIVATE)/CStatsPage.hxx IFACEMSGHANDLER_H := $(INCLUDE)/IfaceMsgHandler.h $(NETTOOLS_H) $(MSG_H) \ $(IMSGHANDLER_H) $(EXCEPTIONS_H) OPTIONSFILE_H := $(INCLUDE)/OptionsFile.h $(PRIVATE)/OptionsFile.hxx \ $(EXCEPTIONS_H) $(XMLPARSER_H) # # # Objects dependencies : OBJECTS := $(LIB)/WE17Driver.o $(LIB)/RTDrivers.o $(LIB)/RutilT.o \ $(LIB)/Parameters.o $(LIB)/CWE17Module.o $(LIB)/RTModules.o \ $(LIB)/UserData.o $(LIB)/Module.o $(LIB)/Su.o $(LIB)/SystemTools.o \ $(LIB)/GtkGUI.o $(LIB)/CLinkStatusTab.o $(LIB)/CSelectableRowList.o \ $(LIB)/CSiteSurveyTab.o $(LIB)/CProfileTab.o $(LIB)/SuWProtocol.o \ $(LIB)/WE17DriverRoot.o $(LIB)/RTDriversRoot.o $(LIB)/WWidgets.o \ $(LIB)/ProfileEditor.o $(LIB)/CStatsPage.o $(LIB)/NetTools.o \ $(LIB)/IfaceRoot.o $(LIB)/eggtrayicon.o $(LIB)/TrayIcon.o \ $(LIB)/PrefsPage.o $(LIB)/OptionsFile.o $(LIB)/XMLParser.o \ $(LIB)/CLIOpt.o # HELPER_OBJECTS := $(LIB)/Helper.o $(LIB)/SystemTools.o $(LIB)/Parameters.o \ $(LIB)/CWirelessMsgHandler.o $(LIB)/WE17Driver.o \ $(LIB)/MsgHandlerFactory.o $(LIB)/RTWMsgHandlers.o \ $(LIB)/RTDrivers.o $(LIB)/NetTools.o $(LIB)/IfaceMsgHandler.o # # # By default, compile rutilt and its helper. default_target : $(BUILD) # # # Linking : $(RUTILT_NAME) : $(OBJECTS) $(LINKER) $(OBJECTS) `pkg-config gtk+-2.0 --libs` # $(HELPER_NAME) : $(HELPER_OBJECTS) $(LINKER) $(HELPER_OBJECTS) -lcrypt # # # Compilation : $(LIB)/WE17Driver.o : $(SRC)/WE17Driver.cxx $(WE17DRIVER_H) $(ERRORSCODE_H) $(COMPILER) # $(LIB)/RutilT.o : $(SRC)/RutilT.cxx $(GTKGUI_H) $(ERRORSCODE_H) $(CLIOPT_H) \ $(EXCEPTIONS_H) $(MODULE_H) $(NETTOOLS_H) $(USERDATA_H) \ $(IDRIVER_H) $(STATICSETTINGS_H) $(COMPILER_WITH_GTK) # $(LIB)/Parameters.o : $(SRC)/Parameters.cxx $(PARAMETERS_H) $(COMPILER) # $(LIB)/UserData.o : $(SRC)/UserData.cxx $(USERDATA_H) $(ERRORSCODE_H) \ $(STATICSETTINGS_H) $(COMPILER_WITH_GTK) # $(LIB)/CWE17Module.o : $(SRC)/CWE17Module.cxx $(CWE17MODULE_H) $(WWIDGETS_H) \ $(WE17DRIVERROOT_H) $(COMPILER_WITH_GTK) # $(LIB)/RTModules.o : $(SRC)/RTModules.cxx $(RTMODULES_H) $(GTKGUI_H) \ $(RTDRIVERSROOT_H) $(COMPILER_WITH_GTK) # $(LIB)/RTDrivers.o : $(SRC)/RTDrivers.cxx $(RTDRIVERS_H) $(ERRORSCODE_H) $(COMPILER) # $(LIB)/Module.o : $(SRC)/Module.cxx $(MODULE_H) $(PARAMETERS_H) $(RTMODULES_H) \ $(CWE17MODULE_H) $(ERRORSCODE_H) $(SYSTEMTOOLS_H) $(COMPILER_WITH_GTK) # $(LIB)/Su.o : $(SRC)/Su.cxx $(SU_H) $(MSG_H) $(ERRORSCODE_H) $(STATICSETTINGS_H) $(COMPILER) # $(LIB)/SystemTools.o : $(SRC)/SystemTools.cxx $(SYSTEMTOOLS_H) $(COMPILER) # $(LIB)/GtkGUI.o : $(SRC)/GtkGUI.cxx $(GTKGUI_H) $(PARAMETERS_H) $(MODULE_H) \ $(IDRIVER) $(ERRORSCODE_H) $(SU_H) $(USERDATA_H) \ $(NETTOOLS_H) $(WWIDGETS_H) $(IFACEROOT_H) $(OPTIONSFILE_H) \ $(STATICSETTINGS_H) $(COMPILER_WITH_GTK) # $(LIB)/CLinkStatusTab.o : $(SRC)/CLinkStatusTab.cxx $(CLINKSTATUSTAB_H) $(COMPILER_WITH_GTK) # $(LIB)/CSelectableRowList.o : $(SRC)/CSelectableRowList.cxx $(CGTKGUI_H) \ $(CSELECTABLEROWLIST_H) $(COMPILER_WITH_GTK) # $(LIB)/CSiteSurveyTab.o : $(SRC)/CSiteSurveyTab.cxx $(CSITESURVEYTAB_H) \ $(GTKGUI_H) $(PARAMETERS_H) $(COMPILER_WITH_GTK) # $(LIB)/CProfileTab.o : $(SRC)/CProfileTab.cxx $(CPROFILETAB_H) $(GTKGUI_H) \ $(PARAMETERS_H) $(COMPILER_WITH_GTK) # $(LIB)/SuWProtocol.o : $(SRC)/SuWProtocol.cxx $(SUWPROTOCOL_H) \ $(ERRORSCODE_H) $(SUWPROTOCOLCODES_H) $(COMPILER) # $(LIB)/WE17DriverRoot.o : $(SRC)/WE17DriverRoot.cxx $(WE17DRIVERROOT_H) \ $(SUWPROTOCOLCODES_H) $(COMPILER) # $(LIB)/RTDriversRoot.o : $(SRC)/RTDriversRoot.cxx $(RTDRIVERSROOT_H) \ $(RTSUWPROTOCOLCODES_H) $(COMPILER) # $(LIB)/Helper.o : $(SRC)/Helper.cxx $(SYSTEMTOOLS_H) $(MSG_H) $(ERRORSCODE_H) \ $(EXCEPTIONS_H) $(IMSGHANDLER_H) $(MSGHANDLERFACTORY_H) \ $(STATICSETTINGS_H) $(COMPILER) # $(LIB)/CWirelessMsgHandler.o : $(SRC)/CWirelessMsgHandler.cxx $(WE17DRIVER_H) \ $(CWIRELESSMSGHANDLER_H) $(SUWPROTOCOLCODES_H) $(COMPILER) # $(LIB)/MsgHandlerFactory.o : $(SRC)/MsgHandlerFactory.cxx $(ERRORSCODE_H) \ $(MSGHANDLERFACTORY_H) $(CWIRELESSMSGHANDLER_H) \ $(SUWPROTOCOLCODES_H) $(RTSUWPROTOCOLCODES_H) \ $(RTWMSGHANDLERS_H) $(IFACEPROTOCOLCODES_H) \ $(IFACEMSGHANDLER_H) $(COMPILER) # $(LIB)/RTWMsgHandlers.o : $(SRC)/RTWMsgHandlers.cxx $(RTWMSGHANDLERS_H) \ $(RTDRIVERS_H) $(RTSUWPROTOCOLCODES_H) $(ERRORSCODE_H) $(COMPILER) # $(LIB)/WWidgets.o : $(SRC)/WWidgets.cxx $(WWIDGETS_H) $(COMPILER_WITH_GTK) # $(LIB)/ProfileEditor.o : $(SRC)/ProfileEditor.cxx $(PROFILEEDITOR_H) \ $(USERDATA_H) $(GTKGUI_H) $(WWIDGETS_H) $(COMPILER_WITH_GTK) # $(LIB)/CStatsPage.o : $(SRC)/CStatsPage.cxx $(CSTATSPAGE_H) $(COMPILER_WITH_GTK) # $(LIB)/NetTools.o : $(SRC)/NetTools.cxx $(NETTOOLS_H) $(ERRORSCODE_H) \ $(SYSTEMTOOLS_H) $(STATICSETTINGS_H) $(COMPILER) # $(LIB)/IfaceMsgHandler.o : $(SRC)/IfaceMsgHandler.cxx $(IFACEMSGHANDLER_H) \ $(IFACEPROTOCOLCODES_H) $(ERRORSCODE_H) $(COMPILER) # $(LIB)/IfaceRoot.o : $(SRC)/IfaceRoot.cxx $(IFACEROOT_H) $(MSG_H) \ $(IFACEPROTOCOLCODES_H) $(ERRORSCODE_H) $(COMPILER) # $(LIB)/CLIOpt.o : $(SRC)/CLIOpt.cxx $(CLIOPT_H) $(ERRORSCODE_H) $(COMPILER) # # Better use gcc instead of g++ for this. $(LIB)/eggtrayicon.o : $(SRC)/eggtrayicon.c $(EGGTRAYICON_H) @echo " Compiling $@"; gcc $< -c $(CFLAGS) `pkg-config gtk+-2.0 \ --cflags` -o $@ -I$(INCLUDE) # $(LIB)/TrayIcon.o : $(SRC)/TrayIcon.cxx $(TRAYICON_H) $(EGGTRAYICON_H) $(COMPILER_WITH_GTK) # $(LIB)/PrefsPage.o : $(SRC)/PrefsPage.cxx $(PREFSPAGE_H) $(STATICSETTINGS_H) $(COMPILER_WITH_GTK) # $(LIB)/XMLParser.o : $(SRC)/XMLParser.cxx $(XMLPARSER_H) $(ERRORSCODE_H) $(COMPILER_WITH_GTK) # $(LIB)/OptionsFile.o : $(SRC)/OptionsFile.cxx $(OPTIONSFILE_H) $(USERDATA_H) \ $(ERRORSCODE_H) $(STATICSETTINGS_H) $(COMPILER_WITH_GTK) # # # Miscellaneous : # FIXME .phony or something... clean : rm -f $(RUTILT_NAME); rm -f $(HELPER_NAME); rm -f $(LIB)/*.o # install : @if [ -e $(RUTILT_NAME) ]; then \ echo "Installing $(RUTILT_NAME) in $(RUTILT_PREFIX)"; \ install -d $(RUTILT_PREFIX); \ install $(RUTILT_NAME) $(RUTILT_PREFIX); \ if [ `echo $(BUILD) | grep -c helper` -gt 0 ]; then \ echo "Installing $(HELPER_NAME) in $(HELPER_PREFIX)"; \ install -d $(HELPER_PREFIX); \ install -m $(HELPER_MODE) -o root $(HELPER_NAME) $(HELPER_PREFIX); \ chmod $(HELPER_MODE) $(HELPER_PREFIX)/$(HELPER_NAME); \ fi; \ echo "Installing $(IP_SCRIPT_NAME) in $(IP_SCRIPT_PREFIX)"; \ if $(CHECK_OVERWRITE) && [ -e $(IP_SCRIPT_PREFIX)/$(IP_SCRIPT_NAME) ]; then \ echo -n "Overwrite previous $(IP_SCRIPT_NAME)? "; \ read answer; \ if [ -z $$answer ]; then \ answer=N; \ fi; \ if [ $$answer = 'y' ] || [ $$answer = 'yes' ] || [ $$answer = 'Y' ]; then \ echo "Overwritting previous $(IP_SCRIPT_NAME)..."; \ install $(IP_SCRIPT_NAME) $(IP_SCRIPT_PREFIX); \ fi; \ else \ install -d $(IP_SCRIPT_PREFIX); \ install $(IP_SCRIPT_NAME) $(IP_SCRIPT_PREFIX); \ fi; \ if [ $(HELPER_MODE) -eq 755 ]; then \ echo "Installing $(HELPER_LAUNCHER_NAME) in $(HELPER_LAUNCHER_PREFIX)"; \ if $(CHECK_OVERWRITE) && [ -e $(HELPER_LAUNCHER_PREFIX)/$(HELPER_LAUNCHER_NAME) ]; then \ echo -n "Overwrite previous $(HELPER_LAUNCHER_NAME)? "; \ read answer; \ if [ -z $$answer ]; then \ answer=N; \ fi; \ if [ $$answer = 'y' ] || [ $$answer = 'yes' ] || [ $$answer = 'Y' ]; then \ echo "Overwritting previous $(HELPER_LAUNCHER_NAME)..."; \ install $(HELPER_LAUNCHER_NAME) $(HELPER_LAUNCHER_PREFIX); \ fi; \ else \ install -d $(HELPER_LAUNCHER_PREFIX); \ install $(HELPER_LAUNCHER_NAME) $(HELPER_LAUNCHER_PREFIX); \ fi; \ fi; \ echo "Installing arts"; \ install -d $(DATA_PREFIX); \ install -m 644 $(ART)/$(TRAY_ICON_DISCONNECTED_NAME) $(DATA_PREFIX); \ install -m 644 $(ART)/$(TRAY_ICON_LOW_NAME) $(DATA_PREFIX); \ install -m 644 $(ART)/$(TRAY_ICON_MEDIUM_NAME) $(DATA_PREFIX); \ install -m 644 $(ART)/$(TRAY_ICON_HIGH_NAME) $(DATA_PREFIX); \ install -d $(ICON_16X16_PREFIX); \ install -m 644 $(ART)/$(ICON_16X16_NAME) $(ICON_16X16_PREFIX)/$(ICON_FINAL_NAME); \ install -d $(ICON_32X32_PREFIX); \ install -m 644 $(ART)/$(ICON_32X32_NAME) $(ICON_32X32_PREFIX)/$(ICON_FINAL_NAME); \ install -d $(ICON_48X48_PREFIX); \ install -m 644 $(ART)/$(ICON_48X48_NAME) $(ICON_48X48_PREFIX)/$(ICON_FINAL_NAME); \ install -d $(ICON_64X64_PREFIX); \ install -m 644 $(ART)/$(ICON_64X64_NAME) $(ICON_64X64_PREFIX)/$(ICON_FINAL_NAME); \ install -d $(ICON_128X128_PREFIX); \ install -m 644 $(ART)/$(ICON_128X128_NAME) $(ICON_128X128_PREFIX)/$(ICON_FINAL_NAME); \ echo "Installing $(DESKTOP_LAUNCHER) in $(DESKTOP_LAUNCHER_PREFIX)"; \ install -d $(DESKTOP_LAUNCHER_PREFIX); \ install -m 644 $(DESKTOP_LAUNCHER) $(DESKTOP_LAUNCHER_PREFIX); \ echo "Installing manual pages in $(MAN_PREFIX)"; \ install -d $(MAN_PREFIX); \ install -m 644 $(RUTILT_MAN) $(MAN_PREFIX); \ install -m 644 $(HELPER_MAN) $(MAN_PREFIX); \ gzip -f --best $(MAN_PREFIX)/$(RUTILT_MAN); \ gzip -f --best $(MAN_PREFIX)/$(HELPER_MAN); \ else echo Compile the program before, run \"make\".; \ false; \ fi # uninstall : @echo "Note : all user configuration files will be kept."; \ if [ -e $(RUTILT_PREFIX)/$(RUTILT_NAME) ]; then \ echo "Deleting $(RUTILT_PREFIX)/$(RUTILT_NAME)"; \ rm -f $(RUTILT_PREFIX)/$(RUTILT_NAME); \ fi; \ if [ -e $(HELPER_PREFIX)/$(HELPER_NAME) ]; then \ echo "Deleting $(HELPER_PREFIX)/$(HELPER_NAME)"; \ rm -f $(HELPER_PREFIX)/$(HELPER_NAME); \ rmdir -p $(HELPER_PREFIX) &> /dev/null; \ fi; \ if [ -e $(HELPER_LAUNCHER_PREFIX)/$(HELPER_LAUNCHER_NAME) ]; then \ echo "Deleting $(HELPER_LAUNCHER_PREFIX)/$(HELPER_LAUNCHER_NAME)"; \ rm -f $(HELPER_LAUNCHER_PREFIX)/$(HELPER_LAUNCHER_NAME); \ rmdir -p $(HELPER_LAUNCHER_PREFIX) &> /dev/null; \ fi; \ if [ -e $(IP_SCRIPT_PREFIX)/$(IP_SCRIPT_NAME) ]; then \ echo "Deleting $(IP_SCRIPT_PREFIX)/$(IP_SCRIPT_NAME)"; \ rm -f $(IP_SCRIPT_PREFIX)/$(IP_SCRIPT_NAME); \ rmdir -p $(IP_SCRIPT_PREFIX) &> /dev/null; \ fi; \ if [ -e $(ICON_PREFIX) ]; then \ echo "Deleting all arts"; \ rm -f $(DATA_PREFIX)/$(TRAY_ICON_DISCONNECTED_NAME) $(DATA_PREFIX)/$(TRAY_ICON_LOW_NAME) $(DATA_PREFIX)/$(TRAY_ICON_MEDIUM_NAME) $(DATA_PREFIX)/$(TRAY_ICON_HIGH_NAME) $(ICON_16X16_PREFIX)/$(ICON_FINAL_NAME) $(ICON_32X32_PREFIX)/$(ICON_FINAL_NAME) $(ICON_48X48_PREFIX)/$(ICON_FINAL_NAME) $(ICON_64X64_PREFIX)/$(ICON_FINAL_NAME) $(ICON_128X128_PREFIX)/$(ICON_FINAL_NAME); \ rmdir -p $(DATA_PREFIX) &> /dev/null; \ rmdir -p $(ICON_16X16_PREFIX) &> /dev/null; \ rmdir -p $(ICON_32X32_PREFIX) &> /dev/null; \ rmdir -p $(ICON_48X48_PREFIX) &> /dev/null; \ rmdir -p $(ICON_64X64_PREFIX) &> /dev/null; \ rmdir -p $(ICON_128X128_PREFIX) &> /dev/null; \ fi; \ if [ -e $(DESKTOP_LAUNCHER_PREFIX)/$(DESKTOP_LAUNCHER) ]; then \ echo "Deleting $(DESKTOP_LAUNCHER_PREFIX)/$(DESKTOP_LAUNCHER)"; \ rm -f $(DESKTOP_LAUNCHER_PREFIX)/$(DESKTOP_LAUNCHER); \ rmdir -p $(DESKTOP_LAUNCHER_PREFIX) &> /dev/null; \ fi; \ if [ -e $(MAN_PREFIX)/$(RUTILT_MAN).gz ]; then \ echo "Deleting RutilT man pages in $(MAN_PREFIX)"; \ rm -f $(MAN_PREFIX)/$(RUTILT_MAN).gz; \ rm -f $(MAN_PREFIX)/$(HELPER_MAN).gz; \ rmdir $(MAN_PREFIX) &> /dev/null; \ fi # RutilTv0.18/set_ip.sh0000644000175000017500000000417611054622203014154 0ustar romainromain#!/bin/sh # Copyright (c) 2005-2008 Romain BONDUE # This file is part of RutilT. # # RutilT 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. # # RutilT 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 RutilT; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # # This script is called by RutilT with 2 arguments : the device name, and # the network ESSID. # # WARNING : This script is executed with root privileges, so beware. # case $2 in # RutilT doesn't support static IPs currently, until it does, if ever, you can # customize this script to do the job, don't forget to set the IP setting to # "Automatic" in the matching profile. # Here is an example on how you could set a static IP for networks "foo" and/or # "bar". The two ";;" at the end of the line are required. # The "#" at the beginning of the line means comment, so you definetely don't # want to put one on yours. # 'foo') /sbin/ifconfig $1 192.168.1.2;; # 'bar') /sbin/ifconfig $1 192.168.1.3;; # Note that setting the address is usually not enough, the gateway, netmask # and dns server address should typically be set too. Have a look at "ifconfig" # man page and your distribution documentation. # # WARNING : Always put your static settings above this line. # No known essid, fallback on DHCP but first kill any previously running # dhcp client : *) if [ -e /sbin/dhclient ]; then pkill -f "dhclient $1" exec /sbin/dhclient $1 else if [ -e /sbin/dhcpcd ]; then pkill -f "dhcpcd $1" exec /sbin/dhcpcd $1 else echo "set_ip.sh : Cannot find a dhcp client." fi fi;; esac RutilTv0.18/INSTALL0000644000175000017500000001323110722350736013370 0ustar romainromain == Upgrading from a previous version == If you had an earlier version of RutilT, you may be concerned about those warnings : - Before v0.16, profiles were recorded in one file (or several eventually) for each interface. This is no longer the case, as a result, profiles recorded with earlier versions will not be loaded. - Starting from v0.16, RutilT's data directory is now (by default) /usr/local/share/apps/rutilt, it was /usr/local/share/rutilt/ prior to this version. - The location where RutilT's icons are installed has changed between v0.15 and v0.16, it used to be (by default) /usr/local/share/pixmaps/rutilt/, it is now /usr/local/share/icons/hicolor//apps/ in accordance with the freedesktop.org specification ; These files have been renamed accordingly too. Arts used for the tray icon are not concerned by this change, however, they are now installed in RutilT's data directory. - Up to v0.15 (included), the helper was installed with the various scripts in $prefix/share/rutilt. Since v0.16, it is installed in $prefix/bin like the main binary. - RutilT v0.15 WPA support for rt2570 is not compatible with older version of the driver, make sure your rt2570 driver supports WPA2PSK (even if you do not plan to use it). - RutilT's arts are not installed at the same place since v0.14, it was (by default) /usr/local/share/rutilt/, it is now (by default) /usr/local/share/pixmaps/rutilt/. You can safely remove previous icons. - RutilT's desktop launcher used to be installed in /usr/share/applications before v0.14. Since that version, the default directory is now /usr/local/share/applications. - RutilT helper's install path has changed between v0.07 and v0.08. Before, it was /usr/libexec/, it is now /usr/local/share/rutilt/. Ditto with the main binary, is was previously installed in /usr/bin/, it is now in /usr/local/bin/. Make sure you erase the old binaries. - Rfmontx support was enabled by default in v0.07, this is not the case in v0.08 anymore. - RutilT user's directory has changed between v0.05 and v0.06. Before, it was $HOME/.rutilt, it is now $HOME/.config/rutilt. Erase your old directories. Moreover, the profiles file has been renamed too, the old file will not be loaded. - "make install" installed the program in /usr/sbin before v0.06, it is now /usr/bin. Make sure you erase your old binary. - I made an incompatible change between version 0.03 and 0.04, erase your "profiles.xml" file if you have created profiles with RutilT v0.03. == Requirement == To compile RutilT, you need your Linux kernel headers or sources (with wireless extensions version 16 minimum) and the gtk+2 development files (at least version 2.6). If you have trouble compiling, running or install it, please contact me (see the README file). == Installation == First, run "./configure.sh". This script checks if dependencies are fulfilled and generates some required files and scripts. Check the options with "./configure.sh --help", or have a look at the section "Compilation options" if the default settings does not suit you. NOTE : **Ubuntu** users and people using a distribution where the root account is disabled, run : "./configure.sh --launcher=external" Type "make" to compile the program. It is known to compile with g++-3.3, previous version have not been tested and are unsupported. Then install RutilT with "make install", it must be done as root if you want to use the built-in helper launcher and/or install it system-wide. Finally, run the program with "rutilt". "make uninstall" (as root if you installed it as root) removes the program. Note : User's configuration files are kept, they are located in $USER_HOME/.config/rutilt/ in case you want to remove them too. == Compilation options == - Run "make clean" to erase all compiled binary. - To cross-compile RutilT for another kernel, or if your sources are not installed in the default directory (/lib/modules/`uname -r`/build/), use the "--kernel_sources=PATH" option, where PATH is your custom path. - If your kernel sources are not available, and the installed kernel headers does not match your running kernel, you can force the use of those headers with the "--force" option. Depending on the wireless extensions version of the headers and your kernel, this may not be a problem at all. - To change the default installation path (/usr/local), run the configure.sh script with the "--prefix=PATH" option, where PATH is your custom path. - You can change the helper launcher with the "--launcher=built-in | disabled | nopasswd | external" configure.sh option : built-in : Use the built-in launcher, it implies that the helper will be installed setuid (that is the default). disabled : No helper, RutilT itself will have to be launched directly as root to change wireless settings. nopasswd : Exactly as "built-in", but will not prompt for the root password. Everyone can configure the device like root. external : configure.sh will generate a script that will be run when root privileges are needed. This script must launch the helper as root, by default, gksu or kdesu are used but you can freely tune the script to match your need. In that case the helper is not installed setuid. - To compile RutilT with debugging output enabled, use the "--debug" option. This turns optimizations off, unless you set your own compilation parameters. - To specify the compilation parameters, use the "--cflags=YOUR_PARAMETERS" option. - You can set the version label with this option : "--version=LABEL_HERE". Of course, all these options can be combined. RutilTv0.18/rutilt.10000644000175000017500000000427511054622203013742 0ustar romainromain.TH RUTILT "1" "August 2008" "RutilT v0.18" "User Commands" .SH NAME RutilT \- manage your wireless network interfaces .SH SYNOPSIS .B rutilt [\fIIFACE_NAME\fR] [\fIOPTION\fR]... .SH DESCRIPTION .PP RutilT is a Gtk+ program designed to set up any wireless network interface, find and connect to networks in range and get some information such as the quality of association etc... Althought primally written for Ralink devices, it supports any Linux wireless extensions compliant kernel module. Currently, there is extra support for the following modules (rt2x00 project's legacy drivers) : rt2400, rt2500, rt2570, rt61 and rt73. rt2x00 itself will be supported in a future release. Short options can be combined, options with an argument must appear last in this case. Mandatory arguments to long options are mandatory for short options too. If IFACE_NAME is specified, rutilt will try to use this network interface and will not prompt the interface chooser. .TP \fB\-t\fR, \fB\-\-hide\fR force to start hidden in tray .TP \fB\-p\fR, \fB\-\-profile\fR PROFILE_NAME apply PROFILE_NAME on start (quote PROFILE_NAME if it contains spaces), the IP settings of that profile will not be applied. .TP \fB\-d\fR, \fB\-\-dhcp\fR use dhcp (run the set_ip.sh script) on start .TP \fB\-L\fR, \fB\-\-max\-line\-length\fR print the length of the longest line .TP \fB\-e\fR, \fB\-\-exit\fR exit after processing the command line options (do not start the gui) IFACE_NAME must be specified when using this options with --dhcp or --profile and the application executed as root. .TP \fB\-h\fR, \fB\-\-help\fR display this help and exit .TP \fB\-v\fR, \fB\-\-version\fR output version information and exit .SH AUTHOR Written by Romain BONDUE. See the AUTHORS file or the about dialog for all contributors. .SH "REPORTING BUGS" Report bugs to , on the rt2x00 mailing lists or on the forum . .SH COPYRIGHT Copyright \(co 2005-2008 Romain BONDUE .br This is free software. You may redistribute copies of it under the terms of the GNU General Public License . There is NO WARRANTY, to the extent permitted by law. .SH "SEE ALSO" \fBifconfig\fR(8), \fBwireless\fR(7) RutilTv0.18/configure.sh0000755000175000017500000003160211054622203014647 0ustar romainromain#!/bin/sh # Copyright (c) 2005-2008 Romain BONDUE # This file is part of RutilT. # # RutilT 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. # # RutilT 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 RutilT; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # # Variables : prefix=/usr/local launcher= helper_mode=4755 makefile_target='$(RUTILT_NAME) $(HELPER_NAME)' kernel_sources_path='/lib/modules/'`uname -r`'/build/include/' cflags_base='-pipe -Wall' cflags= # Generated variables : rutilt_name=rutilt rutilt_prefix=bin/ helper_name=rutilt_helper helper_prefix=bin/ ip_script_name=set_ip.sh data_prefix=share/apps/rutilt/ ip_script_prefix=$data_prefix helper_launcher_name=helper_launcher.sh helper_launcher_prefix=$data_prefix user_config_name=rutilt/ user_config_prefix=/.config/ # There's a distinction between menu icons and the other arts. tray_icon_disconnected_name=disconnected_tray.png tray_icon_low_name=low_tray.png tray_icon_medium_name=medium_tray.png tray_icon_high_name=high_tray.png icons_prefix=share/icons/hicolor icons_suffix=apps icon_final_name=rutilt.png icon_16x16_name=RutilT16x16.png icon_32x32_name=RutilT32x32.png icon_48x48_name=RutilT48x48.png icon_64x64_name=RutilT64x64.png icon_128x128_name=RutilT128x128.png icon_16x16_prefix=$icons_prefix/16x16/$icons_suffix/ icon_32x32_prefix=$icons_prefix/32x32/$icons_suffix/ icon_48x48_prefix=$icons_prefix/48x48/$icons_suffix/ icon_64x64_prefix=$icons_prefix/64x64/$icons_suffix/ icon_128x128_prefix=$icons_prefix/128x128/$icons_suffix/ options_name=RutilT_options.xml desktop_launcher_name=rutilt.desktop desktop_launcher_prefix=share/applications/ man_name=rutilt.1 man_helper_name=rutilt_helper.1 man_prefix=share/man/man1 version=v0.18 # # # Parse options : for arg_iter in "$@"; do arg=`echo $arg_iter | cut -f1 -d=` arg_value=`echo $arg_iter | cut -f2 -d=` case $arg in --help) echo "This script generates RutilT's configuration and build files. It also checks if all dependencies are fulfilled. Used without arguments, default settings are applied. Arguments are : --help : Display this message and exit. --force : If the kernel sources are not found, use the installed headers even if they do not match the running kernel. --prefix=PATH : Set PATH as file-system root for installation. --kernel_sources=PATH : Use the kernel sources located into PATH. --debug : Compile the program with debugging output enabled, and turn off optimizations (unless --cflags is used). --cflags=PARAMETERS : Pass PARAMETERS to the compiler. --version=LABEL : Use LABEL as version label. --launcher=built-in | disabled | nopasswd | external : Set how the helper is launched as root and therefore how users' identity is checked : built-in : The default setting, use the built-in launcher, it implies that the helper will be installed setuid. disabled : No helper, RutilT will have to be launched as root to change wireless settings. nopasswd : Like \"built-in\", but will not ask for the root password. external : A script will be run when root privileges are needed. This script must launch the helper as root, by default, gksu or kdesu are used (helper not installed setuid)." exit 0;; --prefix) prefix=$arg_value;; --launcher) case $arg_value in built-in) echo "Using built-in launcher.";; disabled) launcher="#define NHELPER" makefile_target='$(RUTILT_NAME)' echo "No launcher : helper disabled.";; nopasswd) launcher="#define NOROOTPASSCHECK" echo "Password check disabled when launching the helper.";; external) launcher="#define EXTERNALLAUNCHER #define NOROOTPASSCHECK" helper_mode=755 echo "Using $helper_launcher_name as launcher proxy, you may need or want to tune this script.";; *) echo "Invalid value for --launcher, expected \"built-in\", \"disabled\", \"nopasswd\", or \"external\"." exit 1;; esac;; --kernel_sources) kernel_sources_path=$arg_value'/include/' if [ -e $kernel_sources_path ]; then echo "Kernel sources path set to : $arg_value" else echo "No kernel sources found in : $arg_value" exit 1 fi;; --force) force=1;; --debug) echo 'Enabling debugging output, turning optimizations off.' if [ -z "$cflags" ]; then cflags="$cflags_base -g" fi;; --cflags) echo "Using : \"$arg_value\" as compilation options." cflags="$arg_value ";; --version) echo "Labelling RutilT : \"$arg_value\"" version=$arg_value;; *) echo "Invalid argument : $arg Use \"./configure.sh --help\" for help." exit 1;; esac done if [ -z "$cflags" ]; then cflags="$cflags_base -s -O3 -DNDEBUG" fi # # # Dependencies check : # Gtk+ : if ! pkg-config --print-errors --exists 'gtk+-2.0 >= 2.6.0'; then echo 'Please install (or upgrade to) GTK+ 2.6.0, at least.' exit 1 fi # Kernel sources : if [ -e $kernel_sources_path/linux/wireless.h ]; then if [ `grep "#define WIRELESS_EXT" $kernel_sources_path/linux/wireless.h | tr -s '\t' ' ' | cut -d' ' -f3` -lt 16 ]; then echo 'According to its sources, this kernel does not have recent enough wireless extensions.' exit 1 fi else echo 'Kernel sources cannot be found.' # Fallback on headers : if [ -e /usr/include/linux/wireless.h ] && [ -e /usr/include/linux/version.h ]; then if [ `grep "#define WIRELESS_EXT" /usr/include/linux/wireless.h | tr -s '\t' ' ' | cut -d' ' -f3` -lt 16 ]; then echo 'According to your kernel headers, the wireless extensions used in that kernel are too old.' exit 1 else echo -n 'Kernel headers found. ' if [ `grep "#define UTS_RELEASE" /usr/include/linux/version.h | tr -s '\t' ' ' | cut -d' ' -f3 | tr -d '"'` != `uname -r` ]; then echo -n 'They do not match your running kernel. ' if [ $force ]; then echo -n '' else echo exit 1 fi fi echo fi else echo 'Your kernel headers cannot be found.' exit 1 fi fi # # # Makefile_cst : echo -n "Generating Makefile constants... " echo "# WARNING : Auto-generated file, edit with care. CFLAGS := $cflags PREFIX := $prefix KERNEL_SOURCES_PATH := $kernel_sources_path RUTILT_NAME := $rutilt_name RUTILT_PREFIX = \$(PREFIX)/$rutilt_prefix HELPER_NAME := $helper_name HELPER_PREFIX = \$(PREFIX)/$helper_prefix HELPER_MODE := $helper_mode HELPER_LAUNCHER_PREFIX = \$(PREFIX)/$helper_launcher_prefix HELPER_LAUNCHER_NAME := $helper_launcher_name IP_SCRIPT_NAME := $ip_script_name IP_SCRIPT_PREFIX = \$(PREFIX)/$ip_script_prefix USER_CONFIG_NAME := $user_config_name USER_CONFIG_PREFIX := $user_config_prefix DATA_PREFIX = \$(PREFIX)/$data_prefix TRAY_ICON_DISCONNECTED_NAME := $tray_icon_disconnected_name TRAY_ICON_LOW_NAME := $tray_icon_low_name TRAY_ICON_MEDIUM_NAME := $tray_icon_medium_name TRAY_ICON_HIGH_NAME := $tray_icon_high_name ICON_16X16_NAME := $icon_16x16_name ICON_32X32_NAME := $icon_32x32_name ICON_48X48_NAME := $icon_48x48_name ICON_64X64_NAME := $icon_64x64_name ICON_128X128_NAME := $icon_128x128_name ICON_FINAL_NAME := $icon_final_name ICON_16X16_PREFIX = \$(PREFIX)/$icon_16x16_prefix ICON_32X32_PREFIX = \$(PREFIX)/$icon_32x32_prefix ICON_48X48_PREFIX = \$(PREFIX)/$icon_48x48_prefix ICON_64X64_PREFIX = \$(PREFIX)/$icon_64x64_prefix ICON_128X128_PREFIX = \$(PREFIX)/$icon_128x128_prefix DESKTOP_LAUNCHER := $desktop_launcher_name DESKTOP_LAUNCHER_PREFIX = \$(PREFIX)/$desktop_launcher_prefix RUTILT_MAN := $man_name HELPER_MAN := $man_helper_name MAN_PREFIX = \$(PREFIX)/$man_prefix BUILD := $makefile_target" > Makefile_cst echo done # # # include/StaticSettings.h echo -n "Generating program constants... " echo "/** \file StaticSettings.h \author Romain BONDUE \date 23/06/2006 \warning Auto-generated file, edit with care. */ #ifndef __STATICSETTINGS_H__ #define __STATICSETTINGS_H__ #include namespace nsCore { $launcher const std::string UserConfigPrefix (\"$user_config_prefix\"); const std::string UserConfigName (\"$user_config_name\"); const std::string HelperPrefix (\"$prefix/$helper_prefix\"); const std::string HelperName (\"$helper_name\"); const std::string HelperLauncherPath (\"$prefix/$helper_launcher_prefix$helper_launcher_name\"); const std::string DhcpScriptPrefix (\"$prefix/$ip_script_prefix\"); const std::string DhcpScriptName (\"$ip_script_name\"); const std::string TrayIconDisconnectedPath (\"$prefix/$data_prefix$tray_icon_disconnected_name\"); const std::string TrayIconLowPath (\"$prefix/$data_prefix$tray_icon_low_name\"); const std::string TrayIconMediumPath (\"$prefix/$data_prefix$tray_icon_medium_name\"); const std::string TrayIconHighPath (\"$prefix/$data_prefix$tray_icon_high_name\"); const std::string OptionsFileName (\"$options_name\"); const std::string Icon16Path (\"$prefix/$icon_16x16_prefix$icon_final_name\"); const std::string Icon32Path (\"$prefix/$icon_32x32_prefix$icon_final_name\"); const std::string Icon48Path (\"$prefix/$icon_48x48_prefix$icon_final_name\"); const std::string Icon64Path (\"$prefix/$icon_64x64_prefix$icon_final_name\"); const std::string Icon128Path (\"$prefix/$icon_128x128_prefix$icon_final_name\"); const std::string VersionLabel (\"$version\"); } // namespace nsCore #endif // __STATICSETTINGS_H__" > include/StaticSettings.h echo done # # # Icon=$prefix/$icon_prefix$icon_48x48_name # rutilt.desktop echo -n "Generating desktop launcher... " echo "[Desktop Entry] Name=RutilT WLAN Manager Name[fr]=Utilitaire de Configuration Wifi RutilT Name[it]=Strumento di Configurazione WiFi RutilT GenericName=WLAN Manager GenericName[fr]=Utilitaire de Configuration Wifi GenericName[it]=Strumento di Configurazione WiFi Comment=Manage your wireless network interfaces Comment[fr]=Configurer vos cartes Wifi Comment[it]=Configura le tue schede WiFi Terminal=false Type=Application Categories=GTK;System;Settings;Network; Version=1.0 StartupNotify=false Icon=`echo $icon_final_name | cut -f1 -d.` Exec=$rutilt_name" > $desktop_launcher_name echo done # # # helper_launcher.sh if [ $helper_mode -eq 755 ]; then echo -n "Generating $helper_launcher_name... " echo "#!/bin/sh # Copyright (c) 2005-2008 Romain BONDUE # This file is part of RutilT. # # RutilT 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. # # RutilT 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 RutilT; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # # This script is called by RutilT with 1 argument that MUST be forward to the # helper, it is the user running the utility UID. This value can be useful # within this script too to apply different policy for each user. # This script is not executed with root privileges. # if which gksu > /dev/null 2>&1 ; then if test \"X\$KDE_FULL_SESSION\" = \"Xtrue\" && which kdesu > /dev/null 2>&1; then exec kdesu \"$prefix/$helper_prefix$helper_name \$1\" else exec gksu \"$prefix/$helper_prefix$helper_name \$1\" fi; elif which kdesu > /dev/null 2>&1 ; then exec kdesu \"$prefix/$helper_prefix$helper_name \$1\" elif which sux > /dev/null 2>&1 ; then exec sux \"$prefix/$helper_prefix$helper_name \$1\" else echo \"$helper_launcher_name : Cannot find a launcher.\" fi" > $helper_launcher_name echo done fi RutilTv0.18/art/0000755000175000017500000000000011054676046013131 5ustar romainromainRutilTv0.18/art/medium_tray.png0000644000175000017500000000177010636002145016147 0ustar romainromainPNG  IHDRw=bKGD pHYstIME. mIDATHmLUb] ݐ߰ 9Rfd**MdX+e4Q82h$ĥ 0k 62_3<{=ү`Kyl̃)lEpu!Z,eΞ#jKid+7ٌs zVۊ8e_|ܙ˖=^wI5EQWJ3v:[Gs99fjʍKt}hVLoeZh{+V-VWWxC&}w7bRlikҨ21p7BZB,SyȚ?H7 b"5D_-A$$I ! r<6RÒH%%%ک=:~Z5>::: &)vxxvV(((WuXf4m1J@ @BB$%%-h4CkLLLjkr9~ZMbb"sss|>n7ȕQt)WwdggǪT*fgg B(J<pOOOؘZi)))׫T "s!wwuu\_eYIENDB`RutilTv0.18/art/RutilT16x16.png0000644000175000017500000000154410636002145015560 0ustar romainromainPNG  IHDRabKGD pHYs  ~tIME'TԎPIDAT8˥]HSqƟq;;t; M].J\RbaTyaHdMv Q]Y&EwwAD"IVb m}lg.(nݽ/"f"uSAa1H3XOqMGV3 K_p@HKŷх$e=j>lO2pf56Eٕ.5x&jxu]A h,P"gJ%R|္5iɶ'+,U_cLx"^pDՒ1BT|WJ$N},;zE-rzn6E{izQ%޽Ui z#e.>gP=PԂq?zwЧmUPa.vUEEw >Ovoؤ%VT/?;t0t3GaeyL!f#)Qu% \!%?/X,LL/ 8-Ϛ ;KJh~ǥ";ٗ5?kutӤ lqz qKRs>)6!tI[&V ? E@4IENDB`RutilTv0.18/art/high_tray.png0000644000175000017500000000250710636002145015605 0ustar romainromainPNG  IHDRw=bKGD pHYstIME:7IDATHǵLe_ wp8r&P`??bxM#AQpVJZC-:g"b2zB$xD81Mm|?y>$D@eE>T|*& 84bwzyB$amrxn=Yίs>`J1S6Z"Y\<3tRqĎu4 Ж,(\}?)WZFfJe>uೠ[|11F$ q2HۀOr#^MY"IEkszr^wK948=!Uc"M C\1  frl @W>a/n3iz#;V-`LHحOc'B.4kWrタ,Rp=8I4KP\N]ZjL侎uylB8a U(챧;@>mdz!c50930vto0L|(x+NԊ m7ds69dc`P S7:w{j;NJ`Jq]FǝwŘ$x4ǩ"`? *rFQk.Kj"1ATs6J@ 0% U~>6^9b'G>WH@cҴ%}kYv $ZbIKPh# і(Қ(8ypԧWQ2Q"[IiICS<0/ccECԃ7`ut' EgV{f7HO,|4C!J.<%>/uМ(x%a{"+x+LOOׯc\܋h'u_>ު` G!G?lKjz dHaE#SSSEqq 8<~\.G&MTDe*((-TsJ[BBBkssUbO\QQvsYYtBӉa6;w.q 33sefffB///QTÇ꺟I͛y**F&a6Q*244dӧOpՉvxFjDDı$IXVGBAWW$`|VmHHH~ppp$Ir*ۄ?VVVX,ݏ" "º߶IENDB`RutilTv0.18/art/RutilT128x128.png0000644000175000017500000004743210636002145015736 0ustar romainromainPNG  IHDR>abKGD pHYs  ~tIMEV5 IDATxwdWu/Ws4# e@H%Ʋ&c}XI6$ 68a0 2AHH49tΩrUuL ykUջ>J$IO(|*d#mp) \IJ0({;i$WI x"9xwbPj<um7ҥ$py &e{~-m1ӥB\ۇ9ƭif0}pj ӮAc B _}90-Kӿya-*!د H&X,֥m;׹{Vd]-l4t:;lBD Ntz8ihSC`C# ːu8X]"V&wO_/X,~)|@jVY$EQPU9}aBSaFAQvSJФ~24 CctlH CJtq;QL`?PzJGsEMU.uAQ\q\=|ߧ >s Y ѲBGq#1suuW.>wZeY5i UpN"F`q"llloll|K8ya,̊{yHHzoI B -eߑg߹{-o9e.4ACB!_hyQO?OV< ?_YUWE"FIDZqu<^Yt)_ T-m[(B:g|3 D0LpG0 Y!:Xd?Hd_kkB #ԩ(2̽ﯠWR"T@T_( :R(ϽvJ t`KD hC"&`ل"LfX`Of "Z񦁩 C}$i!$I \ήZ⯘ @B!*Jeii?oAtW-au hM@:&Yӆl<=e>ǸFDf39J\GLAUf^z`5/@ bR B]s~,ݷqȲ! aa 1Pe?ư 1)^@9M)d)BG$jP Df JkW>FY^^пٯ|\2hleK6ġ7 H.'2?{pԼ1,=.ҧ}vac:SPDhCJPNJ( MMMQ__w-_,8ӇG#򵽬SC2`s БTTσRrp2uoSy>}gn8lLA{R*bc./6hF"h-?5  \y8CT bm(M4)^JK޽̺% G y]z.tPb4 (0B~=. ;8/ŮlJAG R1Tp\ <=%ǔ#]=uuuV5PUVO<gݺ>Rz뭇VtIKVЬ s`‚v)?L=<.l6# SГDB€M}8T "kOҮ~.`CŷNfh6'O'w᰾n^>?}< >dcY!INԑTGa@X 3&u-3_w]87b_Ŧ|h! q,*.WQ¼OO*=Ul @ŷlX.DV,޼[O:2 Ѷ{>JMTY2F @q|']i[~&t :DM&4TV_"13z)>*ȵl@BBU7P%Fљɹ |Y|-hBʀ *B(_Io0KYf@Hzx&Yޥ. &,Y0Ɛ5G Y'Wשuȣ ޘG=r纐-D@c~7E>FY)P8%\ 5 P,_UU$|>t*HKttIyߏ#e)y҆B.d"5ӹ%ǒlOw^ÌL OS CD QYd[f=맙5@"4H1`΂)%,#Ï72̗#$|L>JW$_,2_cO4W?&Y҆0 w% $R+\@jePEqlI&Snc&4`HPa]&ƔGV]!ѤLbIPa9w;W_h}&0g}6E!_M qgRibp/! ah@O z(s+ȸx-k䥨\,| Cm(BTa}kYUЮ`{|Wjh@UUuJ%Z[[h6 (T5iVo>Ԩh^]C&aˆ!R0}93wq̻=ܷ1tlCކn"B ?B桳dOQ_HtU% %Hҷ_w:?b[z#4 ) ] RqUT9*[֭'q>Z z?$oA?q8'H%1 ڧWk9awk?eA,z̀( ak6Qh| _pN`(Ab uH(ݤ|351~bw> ?c1ᾋ8'0SBp5]& Ya % SrDa"bFDC!}fh<IRjJ%dqN[꟡FJ%粎$S4DbUz۶kLB&a[l#}?e>;://xM_OφT}]zͯwݯCs[W´3 l C!m:3ۿ ?ʔWgY= D7ALn%aa4Фip.asִ%># C> ьXڈ+ clTyGF{H먯RN5adI&Yfǎ/}XyWq̼e8^huW4iP6R/x'E$9GT]OoDN|"K%"IR@R&dY5-^ʹ=L4z* CH&:w˲L80t|077]ﮫy,.\udpp۶9q83˳T*L4M Aяh6|xexDzijk}/s,-dl뱴ezzt*%{9k<3q݌_g(ZH21f3wUݽ*@@V. +ۈa4QEE@Xqy?Bݬ"t̤hEW 'ת|ռ2|BRDz:sn8HR$ LdttP~6M-͌\aܟ~Ew855I:jٵLOBӺ,.pC;:J,[v\)?ɾ l*|DxzX4䆆Js <35'S}tPJ`h*I4TW/D} l$&T%K <9NFvRک h؏-,P>Z<9Ad7ś4Kts*ڢ:KKKD"KJ:ǏaY U*A~<86SSr9l̮ܿc%e°P,V*ZaIɂkf280,e% ",^U2s ́eYgQS$ؽeTU4i: %LmXvbbmr)MBZhЏzPt`÷r޽vwE MiTɩ翴9H$hD2vA]]=w)2QUUd2GWW\r p_&S>YDRThIq-L* ^)$ɲ DY5PTYQJLb|b0.кi3k(`Mrie;pt gây?6C/(97 OC jMq@<4 5Q - ݻYVD" L2`zzEQd˖DQ~+wۆ!F>P ضU#*% GID"D0Dull)j0=ͱÇl:F"Q,\ZZ:KG`]JOh d0v *"}Y0oC;khV^AI_ =Dg; YMU,n Qg_&?aP($IFEx"T*Z[[ 7pwP.ٸq#\p!CׇahKo]װm 0p]˲Ni2ʔJ% }1@{hsedr[RQdױEj}fUtjod¢G_a܄1ĒϬMѮFE90o Y`Wx&M1+E_10sK w1Y gC!mP°@' b; R IDATڽiVP(HOO/7p7x#P￟뷻m5u&*KIC!H$\kR+*3wt\ez~|n196:3;7Tjߚҝ6$؇'&&N- z-> !9,0Z! fܯBZelCw![Xx ѩ~=NOX#@鈺ļ  g>Ɛe>Ĵy!h1CczM!Cun&577{"uBPTX~=mN[[{塇bvv2ĭA5{ -H'M\AUSLqHI~5n,^RAvֆ2 {׌[ӥaXl+Ls{MuoG{Bn]َؠs ": ,w2j]HoB )S[ -XtTr;->oqqYMMmI$"/4X(À\ۙP.!ˑNKyOoo/R]'?uu [!hF$"<EQXXXA'k>bd|BB=|{*.-]f(lRp!Ȟ e8^V)5U1.]y[B2h1;wJpܜf3T<1.M}#C<-1:h| &*0j,_},Zȇo ̘*ݴ!aAQ#:R֓x>^<l2WȲPvB!$HT*E}}/zыȑù^dYQUy4RT+QZcu]cddm۶qdp,AcK3]}b!&8:2eISf=]_ѧ!0ԇ__a 'YX |7ң|͡z6D+*(I SE8VwCgml0 F3.$jCcEyLC6&'u?oi*8]̰/hs^Nѽ9z̚+i1~uqG1h9@*EbyK܂ ^ՉER(b&QXIJleJ?ԵnHk*: ) __m!с,TYC5FzfSh["b6E^aCEqQkz])=3k Q;.d0Q%8jv>c#ē'Wrt9u0]*:TahD s -Ɲ0j,Yt̤ B8 x5,P*hllzL&8v\~(Y @`*!Ȧ m:Nb>Õ5TEAQ/W^쥓XoΈH$S7YExG2s}`;1h .Gp Ǭt ǫMLHcF:j YPAcgmY&7wP_# FڑR \ 9 A3X;I*/p z'J ӂB۞bqq]אeD"A}}=6lĉ,..PHh8Ji\,㉉ vISCm@GWXYQCFp#E8P#O8\J`=9AsIGLH=?RCf)͜9X*0z茝iG xhnt/18Q(Jp@f޷W8e\.ǫ* KKKLMM3>>ƱcG0 6oL5(d6I,#TEJ˲pf :ĺuph,F*Du(T$/F3mLMyO:E122,Ӗ텬S᝜- 1W!L9X kK "ݿ<W ڒPD# QRPo;m8h.sP-_|ƒo.3T7eYȲ\<,3M4)LOOsIEa˖477~EPA8 TT*e>LOwwu7mK_TB7W"NxoQ+zc2p-q$A8 RB@DZv7=/E@N3MY6d?tiRThlld͸z_,R}pPbMS99t$b9lfi9$K\ c1`fjdg891Xh\& p0{<ΘJ353   0&zT`vC0v# v.@]aeXAS;=_~&No7V`E! ŋ4gb$X@$H򘙙AUUZ[[<z۶ RG"%H(8Lr%],ݻuk#j%I" @ . L&)RTO27uFmY%:ӫaYI0ZC[#sõk,l2 v Ū LX%8iǘAM 8Ĵ+ bQH:EQ<K08_c-4IWٖ<ߟ'qTU $`Y6ø_W<]x>C֒.r(VcVFR PsV*~ #y8P;M{^CmIKB}Lٖ%ϋ?ltX| ۉ:`I䅮M!.& \Wll 'pb:F.q9[bK:d:*m\ر y.2B0?k/!0P-],//G̞嗳N7;` ET0,Ɉk|͵7AL`ñ3a=Y ~S,ܷ67c+DɈM;,A0d _;\ XGY4\4hdnr64V'1<<$ nt]?!˪D bt /0;;úu7Y}O~{HDYO hW%B8a1OX3]JXP?d09q ^&D`qM濣JIj#$f؅tN-NUAU !q{lr5,$Ӗ[]'߿y%ɷi^kO஻"pu4k{UUbȲLRs]Y\u?y^{Қ e!h6 0{ ~^v6ϫ-~J.`$¾612/ \;$F)WB@C] D,&^?U qX^'PX4a„ f#߳}Y$ٺGX,277G*b۶meǰm6Tkj(L\Fu^DOLLY7BJz P \`K1lƔNpKj_,ʈ!{*YN:F=y<;U`z+ `H@]LODXȹ;("I Fl'u߉),G.;RTKӴPD@P`aa:6l@Rajj*0QTRjiqt]\!J /Tޙ3:4IlOb=b!s1fu/~VwvHEwP<ZU7-ew&Vidoa, ,?9¿D"p8r(xGTbaah4͢Ivffuk3~^X.j]] ]7?A 1k/2f3aX;kkKqn,nP(\kGkll䢋.bݺ>~qbY)C-l[FRDF1 D`YܡC/?|Q`&S|~v~vWůܞ p--WS@#/AS=N[i/N ,Ӯ'No\,3lfvv'ȲĮ]0M|2i;J*Jm#$---M8g?>v wǸ+M/Xpu;_'+ xx| O RUV|{wz ۶[J%d{_vM9r])iF4BPc0E[[[ƍ;dϞéuzAkz'x@0f= Nd!ZGdmÎ0t( 3ѷ|>,,,w^پ};[n0 V'a%RMl:==M$g\d2zTU.el S5`f<)g_T- 1j= { p$|QYP߬S4(D̡?kii#2lÇEW>g<|t]|-DP0 lۢR)f MOOL&v]ze"B%"Bڰ'ߝ= #Xk<2_c~{ӹ`ĩ'H]Z h !. ggVGͱgϞu} Xy#„aGd355M::kOEmĥM4j0i1C_Xr}y%hM)"5'+ve+㵖)&''ٺu }A@QTPel[ ʚ&J_sY( EREʋ% ☝_ Q*D/ۢ\ Ƥ=p {P.C\az֯_83 VIrm4MM/kzwG[02YW0"=S0lk93V'6,OBU1Xa.fy2$!P2y&4MchhDZk*DR\.nk;mNm$1XI(eI47ᠹGO?4eLٝ .Xr?RIGض *xaa۶ٺu+eN9V,jRhTLCYZZ^{{w*cǬm?c}=ɼx&^:h^JX ?g"~#]ex_,#l&:z{PU!k ERUՈbA(dNױ0o7 _GXjt;k9=ɳBΓ|󢩿/G2 G($hd2IwwHqffk ٺA UUXG 4s|%K's=,4K/ ?l68,uV:;PU팡ph4㈉eaYKKKRW\~W?p/WGVZM7~Z+YP`bbMرcmmmi4u]|0\=^z_ˁڼ* !˩B[[+mfWU%9eY xʱt1$m;rZD4{^=K$ *AiPg9|0O:]wJ D"@Re2k/ nx~j$v&9DdBf}g~~xK{{;x<]7F5! LX/OW ,= jdz"+47GGGr333ɓȲDoottR@( }?er9"_vٳ>< Ut {UVW_ni$:411ll̤,..0==C8X,v GP/t],e ӬԦJE/O+=T]SQTE8 $\Bp40L]e}gqqIdY1ȧ#8x !mSJTjABUTUTVTBPU%Qz6P #v G|^9vv73wf㐨zjռ~?pϻw"zD ـm{EfEbغe$IF4M߹oyNXZZY^^z_]lYޕJ%0 X,nt Z?,7X I6yE=|Pf[>g{{{߻smML6ȴxp x8-el+XW/ vmgөG'''/юІFq!2TUEi\.4W9]7pzͦ I "A(Vǁ>7v~#[wh77};7>cOө,yabE!NÅ|D ="D4XW҇ Qh8uL]G_O cbjvZ]G8H4̣/_z橧vvNJPȫ-j 46DQlUUվ#x]hǞ#?Lwa21B|ypjKstc>\~7L7GPl87j]J8~j Ws%X@,5 aQd t!"LHpmT Ȫ˶: $] Z ^AD"(wg+Hl4t4 ### 4`?]7Pyx^mE}}gvvwr\z7E fthww pS5, (AEdRH%MD< N֡ nAVl_3"|SAVCވl>=r\SUuP48 /_ l,ѓ醪X-x8ömpnB7nVoJ%?e&eSP ! "dABHH J(0^a*\F'_> ,F,@o K#T*}XjzTEHt$IB_8 p0`GV*<+gΜ)r]-!E}pppr ؎! "A* H"/ < 1RT 4@fՄt:X4=^V.۶_1  c$YFVG*ƎvmV9 ,$,$(j";v$ox2iSQ)UAi(#C* os-O(&W"xԍ.?{ǣ8y122m EU080$z[ԲVt:]vnGeR,JlXD$H(ʴ-ەDz4 4jr e4f7ɞXreeeX,_!h6s`Y Kݴ i(صvt;2 ::: ݻ{n@ ZőOXm:wۈ"ba*J% i( h:z i8)\ #qX( E 4 ,.-ܹ h,GX,xҝH$qi!ے{l%E6!gOa`p] j a%2Q@jBȲQ4[i:p)_jv&CQo4@+xWh_˓>Je!dq<+EB*tYlSuuuyAGV+ee4~~^#G̮hwv .Mb"s0Z$(NVR*£`ȁHY $ ob%Ȳ,lFPJ 8v8υk7:$E''N4pםw,HDQ@X#xv-_(yniuu'NZL])qmhU4 #O" ő%ߑ0DUñ$h CQVQ,`ii333_X@Z_ei;xɰ }m~?=̳K7z/}}}D˲Gk-p+܃ ~ك$I`eSV+5xy6x Ȫ=.\8u+$/UG:{{c M10 pƍ$ ?-)4v77M"E'( "@ӧO?{ӕoŘjylyC.@e{0 '/n^\\آi/*M}RΊM6e${ (9vy˟|͡Pb0ǏcG(&'CR\3s(8N =nxxx(LK'z… T*_ 4̀e9UM{56<bo8։5zǭcMjNIENDB`RutilTv0.18/art/RutilT48x48.png0000644000175000017500000001104710636002145015571 0ustar romainromainPNG  IHDR00WbKGD pHYs  ~tIMEr IDAThՙyTյ;*uO>9|B9S*=yxz~Ɇ0@"a4%$IbAD 0t$ӗ13ge H3>m&Y4q&*I7_a?T'cprYR0MQe ՆfCQ-55ee^<%YLcA˴jYh{89u-Bqɯ"a.QDQDELvW0n ,hAfJzʖ{I6_sUL6[X] o3|-fLfs"(`X] Ø #jg3wϝ0FHZ\[0L`+NL@+zeiM!ȁ_ w|y D|IE*%K7(gK.3S2_OI$ 0l8N r;t_j,&r9A0]Ǚ?Z1<b ǫhL+u#TaK|Bѩ4h RMZ$06M@6Tw-O}LWuX^XRtSEEşKX$yEQbH$0 4 h4$IX6Kvy.I*]'"&a~e/jw+y^׆QD>7 =mÏ?\wF,)U:~p8(Ir\A*ql6"zDLyyy,!"D$츞 >xZK!ss 3S/ ofo.n"ck<:!gQ)R/@Vu S,f? Rm3L4M#iMMMbfs;kkk$ՅԚ0?)迾7/O oaouܾz#wȑxy;5*s>G4-<C]01nq$*_: sW4Mt]Gl6~?X__\]FڈF#Ģ!ɛ\xbWnVΒ$](Kӣ-̫`u9#)}1($S"̖*}5j~%p4Xӄ}-`Z :}4͈fEERSSh<˲\vqrXFVjjXbX'hi?<_Oݑ===$I {uwbLf4 U0 YV^ƭ;G{LO&=+ٷƦ139ge}!h독B\D: A 81 #_|;ө6qp\#CZ5Ax4!,\x}س1Mk+k֛)Ȳ*iNT^~dhA.;][w*}^5y(i6 vkcl8zY9awP#$  " (m(P^1Chsϝ ~rny"+\.l6X Mv, BB#7-_{k-qU醵:CMCTdiTaSzjYd3s3b7PE_A6^v(a4&U3#5o 555hZ$F&›VyE9}rvST4IFVXTC9ybrênWErn?gm}hl#\Xv,hvօ} _`g) BWM?{,u?rDQ@DTU=A0e!NC ^آI*pnEV9%Pljgv0Og)4An.BX>0|aoW^K%j+޷o/,1i8DQ$_}E}sL^+KSE2ks{aivx! me.`,/qC  >ʎXRncoV?R 9<ָѨ K'&6;vYI (jg^2ZXI/ֻ:= jRǝ4^!(MO#oR߻L`n-8s`<^usig)&z/1V-rԩSD"[h!55O:@ =i~=M\|J6U[~ =₩L˅ݰ/\Ԓ $49>|m~oƏ5 ۷i4Myv+Vl&LD@5pd2<2 Msn͟δ\솥5{y;8o|gx|Kv6oDh4"%%t\ol;6(a}Ń)LቆX) 'gu<հZ g̓k׮t]W_(%%%8vpbM<` g0%i0XՑ'UtÇP/4ǷUYYeMQU"VNM/F^uUc5l㙪0O7ɚ"v9{)bG1+9b~\NfF&Njb(HӉ: ¢+W~E1p@FѣQZ ̑#=LnnhZ8~]Z˲hÆ _ƴiRw7R\ʉNR%ݻRu$͆2]ZQQQC9mx,O$|>YXlʦښw8GSp׋,bh4ٳ'[8\{/avzB$ @ GOSFU+nmGȳӊ 1hsX-IoO7v`-á^3 K&HOOwfdd=iZuX,k-EiӦϒ%KSzLvay$XVE)Iv$iHC T#->G|i^/?? ùhYEQdY>yDEQn޺uӖ_j]*abǒz;vH7USSS_ggxϋ ;q{3S!@8^N834M;Ci^-ypa"fd4՝mS@Cd =;NkWbh'[s_!wKB0q j_ Ţ(Nu ,DQBU#"bz(:ev,޹m۶}ŎC : *P窣~$gq}7:'N[)EQ0 bQ4MDQDEA@eEA2M]vD2Sq-+ ]Bgn}ob}=vey/RPi酻M%ocf"ADIA`8&:EL\< lIg} KZ.b9<:kXCWXP zn$۸Vm2N1속/G~[v*DQe8 JlF)$ب'aޓhB5(89h>&O'0&{3aqXeJVB.P{+%~p!sغ'5wR4`IJ6'$þ_+S_!8F5_.n )%Be˅$I FT9\!~ hTΛR`_ٓ]v@Z?`Qf& *+P^Z`%?fw=aB&,r-*N+bbwibK 1溾*“wHTڮÅiIL9]d~ƪZޡ, 5^ Eq6x!w Eհw x/3Ql0 <. BDt]C5T67 >e}UFIջ($I($I IP(v;tZix>!f_}}9cr(n M\⹟pI7p]rn*P78ҒM_ $*mǟ,KMSLjear9$Ibjd_$)U@QE? I4R&KeѰs_$ _&N^^SSV[[p{.Y^!ztx\-1TwLJ&{;תn pGߏ$Ȥh~!;1' |rB|])E `Ϟ=D"QdYBD\.D"o߾uttB__Bl6TD" Wo;oƬ{jj|Fy_7Bul*-Iv2l.Ys?'@F9J&0+iOT{b,H([>8^ӊy Ӊ(D"5MwWʲDggmR)R$|D" ]tEu7~망>3#U,n2vTl EM֥`t,;ar S_h&mODG L JhEA=1:$(l2YX,tFR":;=iپx@ҏdR\$2hZ dsnn$ v?rdM<Ϋ_q0UZi ☷If)(oQa/tH=' Qz;΀ThӒ$Rw:"6M&):VEt)L鞐 *5 à?e?5Y: g7cko\LUPEZE2} ,jv,WNFEWa3P${s*^ctAGRѣ C3,Z$UUr䦊<ِN4Bagg]9;ya YnaphL&;Y;UW0p4ږ.Rh"䄜-h76hc 29 vE4oea`T+V4_vz! q>*{2DEvTƍ+KeVSW$谱i3niPS|)\Ep8F;JgzPyF?dI8%'5БKwl Tl6;t[޽>q EBj@|.EVNN6Et "a>gBRCkG^Աu[Հ,.l? 2-ş;!p)ВCh~>iΫItw} 9R\΁Y)Q!XGu`r+\|*P(0e0xL{n-{!K2BӊvކF4h LDMUZζo*X佒aK\66vЙ ǙsI?$2rڴz;|мggB3gUp(}^]s=/HIe9L[[^ƆEFFQdP(*DBZD]^x~{53os a{4pW/ JΒVqyp B*3QؚH-&2,vD6:x"}}1A\\]Tx4/}M0JB(h4ʁI$v0hllbQCD~p'Nc:` ʫ8]Rf7\]EaP%U6k+^9\U~.WVb@al7sAx:kY^).~ְ%dFai3NX_g^% F`jmmc]߿:F5L3Dlh?. S0UZQ l*,6'2זaa 85^??g~ a}/l;7wRJ:O (gVCgn&c^lg+uSQ:E݉(Z0c xQUM*4K2Z& K3{clHF鼖_NF`;3v7W70$^=q/| hLDz8Ua>XJz.;-<͍DFW@ lp0x饗hll`FTA>#R,j755*ܗsI-T7bϰKĻނm]JV7TA@vp3M޾}3o }vB'N@uEP,D" \vw%5Nth;J`߳95eʪV &vɚmHq\L< 2QEX]׿|LN:?WCƀJc$ N|Vw3iZ6Se~(!2ƍ'с,KE&pQUU ?yt82ҙčq/Ed'6/B?Y rqn9iZL4T*MKAd/  a֭v Ct]4 <ϝNhjjn7L͛wGB@QLT2^ @t$IrF4_Νk c{zp8xܢå#TTTcȁ .\[r@ H(cr{sZ[|"9\fNA}]-seUCUc{{ʞux ǃAJ{Ha˒%K~dpo|,#݉e Mj+Ìn6o3G K6ۺ䟟~z``!JɤE 2IRHL(B[KӠ_MtQ,g$396vȤ FP }Q"ws dEr E 2~~~[lެɗ^}ͯ9v:KP R &H5g:NtQeE\>Cm?e2ِ$ːdp8% E 6<EUbڍ{ot:QĀwJ0dPqMM[aZ2lpI~ڵkv5S%$n@XP$~(6>z/ִ, χMU' .+V\C?4{< _LlhzʫIgtPK+񡓂J ?-|w~?@<OLSJD6hQ8.˅aB!4>t?BhҥWw~p9;Ǎۍ(TRTytGXvI?λqlmmmYEEq~>N(jvBiB!A|6\968…,r 2EtRPVVF?`D{H$0M\g6U~2\^^n}˒TẮ/+˷oP+2TDLM/Q:0܊";"lԂ,CUp=E]{qnJ]U~i&|(Ҫp8Y0ر#&>lUomF|km6bH6Ų۬*inA۷oGڙJvӉ$IH 2NffTmT~n^UU;v-@U?۲xM0aZ|t8c>}`Ku^zi?۾}^KR+lT%$ vuuSXt9NL|9gL$IB![ZZ_M$D@bIENDB`RutilTv0.18/art/COPYING0000644000175000017500000000020210454255031014144 0ustar romainromainAll files in this folder are the work of Cyril BONDUE . They are unlicensed and are in the public domain. RutilTv0.18/art/disconnected_tray.png0000644000175000017500000000160510636002145017326 0ustar romainromainPNG  IHDRw=bKGD pHYs  ~tIME/ZbIDATHǵ_LWh Uh-1Dє %f fb W#b(Ol$ k7bR'@`2*aΖZ<^ dE{wy{N9GT%S+[ vc2~ ;gA܀}8 C+JXf ؖu6jiodۛz{+:O|،?wzMNJKu{V:<,I]poC'"JT ZZ|yf<3s2 נ 0,- ŶmOڠPwpQu'lGU}U 1kc4Ij*?fg?ՐZeh6ciiL*ʋa-lLP{F#IBDe –طR@gh&%07 ȤedYN}{X|tC nӍSf9%>>>qIIɨ嚎:A0ù.['&&tݢF8Q]]-<N`T}9 }Ζcc-&ikVVeeeSXXN#111b|hL$oN;?ښcZIOO,xD 'A%^( hD̈́ ꢼ"h#d\ҚlI'r眷.u,w/_x~^ب=e=Gw=p'b9t:M \زZ@F[ 7}0v|]dW5i1>n<6PÛ2 "pNR$TebyCeeC=KePZFB{f|>>NLOѵ0Cˋvu&@q`k* [W;Jow)|DpzGX,]6ۧpH 0.(kAH ]OLqu!,t]Gu^]iz Tш`eGGu~~nX,檪驩@,uuuɁ@BOOhkkbddD,,,<:hjjt8fYeh4Jnn.l>j[ Z hB^^xEQBx3}{/sY9!@NNJԃe9hz=sT*]m8k[ϵpQĂb5pϲ,#Ȳ FGU*(%vRBT _D]vC~]nZGwj+ (}$򾾾jGSHT!BEqGii"r0'=5#_~_#ϡ oDY.<"S }}}x<^,1%_K87/L繪 m{ :uԨaQFVdF(}eYf={Fhz3ØO+>28ͅx +3g3ϸPyZ<)y+>3eTLP*E4-zP|[ Q@4 ˊ50beY,jm*f^Jj73մlBw|ZzPxxmFA㶙B]]>zapW= ԨGRays)>@<ǹ跣QDh}>Sן3ۢz{-f͎7#rЖnVx^^sTTs\ }N ֘蠅[yGb pJg$j[q[텚9UC>@jޣ4XkAzP MM9s_NdrBYDk=LLj%';L ̾q13>bڇ5ş^;L&ii鈢Hgg'2 %rx" HWP?ɓWa nb~L̦=ۿ f{ H2< e[92U_|ޙLff&^FUUyA9ƕҿ(mKLmVNde!loy8qY eOh&12K+U,/\Pζcǎ;75%{##(Xt\WR03H&3O̟LWѷP^Y6cAwpVU||L~fz|h4j$)0q9mڝy7TUV[Yra2a05RСeN:9 z?NK˻z 33/k$2$6:&29բ2MBAo_WT$K{~rW,+ko4@oPHh gTyPQmqeI׎;jRBy<cZ6#:ڸ1"{yq IENDB`RutilTv0.18/lib/0000755000175000017500000000000011054676047013112 5ustar romainromainRutilTv0.18/lib/src/0000755000175000017500000000000011054676050013673 5ustar romainromainRutilTv0.18/lib/src/CWirelessMsgHandler.cxx0000644000175000017500000001334010705134325020261 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CWirelessMsgHandler.cxx \author Romain BONDUE \date 17/02/2006 */ #include #include "CWirelessMsgHandler.h" #include "SuWProtocolCodes.h" #include "WE17Driver.h" #include "ErrorsCode.h" namespace { template T Extract (const std::string& Str) throw (nsErrors::CException) { std::istringstream Is (Str); T Value; Is >> Value; if (Is) return Value; throw nsErrors::CException ("Invalid data read (from helper).", nsErrors::InvalidDataFromHelper); } // Extract() nsWireless::CEncryptionD ExtractEncryptionD (const std::string& Str) throw (nsErrors::CException) { int Encrypt; // Can't be EncryptType_e because of the extractor. int Auth; // Ditto. unsigned DefaultKey; std::istringstream Is (Str); Is >> Encrypt >> Auth >> DefaultKey; if (!Is) throw nsErrors::CException ("Invalid data read (from helper).", nsErrors::InvalidDataFromHelper); nsWireless::CEncryptionD Descriptor; Descriptor.SetEncrypt (nsWireless::EncryptType_e (Encrypt)); Descriptor.SetAuth (nsWireless::AuthType_e (Auth)); Descriptor.SetDefaultKey (DefaultKey); Is.ignore(); // The separator. for (unsigned I (0) ; I < nsWireless::CEncryptionD::MaxNbKey ; ++I) { std::string KeyStr; getline (Is, KeyStr); try { Descriptor.SetKey (KeyStr.empty() ? nsWireless::CHexaKey() : nsWireless::CHexaKey (KeyStr), I); } catch (const nsWireless::CHexaKey::CBadFormatExc&) { throw nsErrors::CException ("Invalid data read (from helper).", nsErrors::InvalidDataFromHelper); } } if (!Is) throw nsErrors::CException ("Invalid data read (from helper).", nsErrors::InvalidDataFromHelper); return Descriptor; } // ExtractEncryptionD() } // anonymous namespace nsRoot::CMsg nsRoot::CWirelessMsgHandler::operator () (const CMsg& Msg) throw (nsErrors::CException, std::bad_alloc) { try { if (Msg.GetCode() == nsWireless::DeviceNameC) SetDriver (Msg.GetText()); else { if (!m_pDriver.get()) throw nsErrors::CException ("No driver set.", nsErrors::NoDriverSet); switch (Msg.GetCode()) { case nsWireless::SSIDC : m_pDriver->SetSSID (Msg.GetText()); break; case nsWireless::FrequencyC : m_pDriver->SetFrequency (Extract (Msg.GetText())); break; case nsWireless::ChannelC : m_pDriver->SetChannel (Extract (Msg.GetText())); break; case nsWireless::GEncryptionC : { const nsWireless::CEncryptionD Descriptor (m_pDriver->GetEncryption()); std::ostringstream Os; Os << Descriptor.GetEncrypt() << ' ' << Descriptor.GetAuth() << ' ' << Descriptor.GetKey().GetStr(); return CMsg (Os.str()); } //break; case nsWireless::SEncryptionC : m_pDriver->SetEncryption (ExtractEncryptionD (Msg.GetText())); break; case nsWireless::ModeC : m_pDriver->SetMode (nsWireless::Mode_e (Extract (Msg.GetText()))); break; case nsWireless::TxRateC : m_pDriver->SetTxRate (Extract (Msg.GetText())); break; case nsWireless::ApMacAddrC : m_pDriver->SetAPMacAddr (nsWireless::CMacAddress (Msg.GetText())); break; case nsWireless::ScanC : m_pDriver->Scan(); break; case nsWireless::CommitC : m_pDriver->Commit(); break; default : throw nsErrors::CException ("Unknown command.", nsErrors::InvalidCommand); } } } catch (const nsErrors::CException& Exc) { return CMsg (Exc.GetMsg(), Exc.GetCode()); } return CMsg(); } // operator() () void nsRoot::CWirelessMsgHandler::SetDriver (const std::string& DeviceName) throw (std::bad_alloc, nsErrors::CException) { SetDriver (new nsWireless::CWE17Driver (DeviceName)); } // SetDriver() RutilTv0.18/lib/src/WE17DriverRoot.cxx0000644000175000017500000000217510376134307017127 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file WE17DriverRoot.cxx \author Romain BONDUE \date 18/02/2006 */ #include "WE17DriverRoot.h" #include "SuWProtocolCodes.h" nsWireless::CWE17DriverRoot::CWE17DriverRoot (const std::string& DeviceName) throw (nsErrors::CSystemExc, std::bad_alloc) : CWE17Driver (DeviceName), CSuWProtocol (WE17Handler, DeviceName) {} RutilTv0.18/lib/src/TrayIcon.cxx0000644000175000017500000000434210722350737016154 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file TrayIcon.cxx \author Romain BONDUE \date 08/07/2006 */ #include "TrayIcon.h" extern "C"{ #include "eggtrayicon.h" } nsGUI::CTrayIcon::CTrayIcon (const std::string& FileName, ::GCallback CallBack, void* pData) throw() : m_pTrayIcon (0), m_pIcon (0), m_pToolTipsGroup (::gtk_tooltips_new()), m_CurrentIconFileName (FileName), m_CallBack (CallBack), m_pCallBackData (pData) { } // CTrayIcon() nsGUI::CTrayIcon::~CTrayIcon () throw() { if (m_pTrayIcon) ::gtk_widget_destroy (GTK_WIDGET (m_pTrayIcon)); ::gtk_object_destroy (GTK_OBJECT (m_pToolTipsGroup)); } // ~CTrayIcon() void nsGUI::CTrayIcon::Show () throw() { if (!m_pTrayIcon) { m_pTrayIcon = GTK_WIDGET (::egg_tray_icon_new ("RutilT")); m_pIcon = GTK_IMAGE (::gtk_image_new_from_file (m_CurrentIconFileName.c_str())); ::GtkWidget* const pEventBox (::gtk_event_box_new()); ::g_signal_connect_swapped (G_OBJECT (pEventBox), "button-press-event", m_CallBack, m_pCallBackData); ::gtk_container_add (GTK_CONTAINER (pEventBox), GTK_WIDGET (m_pIcon)); ::gtk_container_add (GTK_CONTAINER (m_pTrayIcon), pEventBox); ::gtk_widget_show_all (m_pTrayIcon); } } // Show() void nsGUI::CTrayIcon::Hide () throw() { if (m_pTrayIcon) { ::gtk_widget_destroy (m_pTrayIcon); m_pTrayIcon = 0; } } // Hide() RutilTv0.18/lib/src/GtkGUI.cxx0000644000175000017500000016654211054617534015531 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file GtkGUI.cxx \author Romain BONDUE \date 23/07/2005 */ #include #include // find() #include #include #include #include // std::memset() #ifndef NDEBUG #include #endif // NDEBUG extern "C"{ #include // ::getuid() #include } #include "GtkGUI.h" #include "IDriver.h" #include "Module.h" #include "Parameters.h" #include "Su.h" #include "UserData.h" #include "NetTools.h" #include "IfaceRoot.h" #include "WWidgets.h" #include "OptionsFile.h" #include "ErrorsCode.h" #include "StaticSettings.h" namespace { void TriggerResponseCallBack (::GtkEntry*, ::GtkDialog* pDialog) throw() { ::gtk_dialog_response (pDialog, GTK_RESPONSE_OK); } // TriggerResponseCallBack() void SetFocusCallBack (::GtkEntry*, ::GtkWidget* pWidget) throw() { ::gtk_widget_grab_focus (pWidget); } // SetFocusCallBack() const unsigned NbColumn (3); const char* ColumnTitle [NbColumn] = {"Interface", "Device name", "Special support"}; class CInterfaceSelector { private : ::GtkWidget* m_pListView; unsigned m_SelectedRow; static bool RowSelectedCallBack (::GtkTreeSelection*, ::GtkTreeModel*, ::GtkTreePath* pTreePath, bool, CInterfaceSelector* This) throw() { This->m_SelectedRow = ::gtk_tree_path_get_indices (pTreePath) [0]; return true; } // RowSelectedCallBack() public : CInterfaceSelector (const std::vector& DevicesVec) throw() : m_pListView (0), m_SelectedRow (0) { // Create UI componenents : ::GtkListStore* const pListStore (GTK_LIST_STORE (::gtk_list_store_new (NbColumn, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING))); m_pListView = ::gtk_tree_view_new_with_model (GTK_TREE_MODEL (pListStore)); GtkCellRenderer* const pRenderer (::gtk_cell_renderer_text_new()); for (unsigned i (0) ; i < NbColumn ; ++i) ::gtk_tree_view_append_column (GTK_TREE_VIEW (m_pListView), ::gtk_tree_view_column_new_with_attributes (ColumnTitle [i], pRenderer, "text", i, static_cast (0))); // Callbacks : ::gtk_tree_selection_set_select_function (::gtk_tree_view_get_selection (GTK_TREE_VIEW (m_pListView)), reinterpret_cast< ::GtkTreeSelectionFunc> (RowSelectedCallBack), this, 0); // Put data : for (unsigned i (0) ; i < DevicesVec.size() ; ++i) { // Create the row : ::GtkTreeIter Iter; ::gtk_list_store_insert (pListStore, &Iter, i); // Set the data : ::gtk_list_store_set (pListStore, &Iter, 0, DevicesVec [i].GetDeviceName().c_str(), 1, DevicesVec [i].GetProtoName().c_str(), 2, nsCore::IsSupported (DevicesVec [i]) ? "yes" : "no", -1); } // Cleaning : ::g_object_unref (pListStore); } // CInterfaceSelector() operator ::GtkWidget* () throw() { return m_pListView; } // operator ::GtkWidget*() unsigned GetSelectedRow () const throw() { return m_SelectedRow; } // GetSelectedRow() }; // CInterfaceSelector int SelectInterface (::GtkWindow* pMainWindow, const std::vector& DevicesVec) throw (nsErrors::CException) { ::GtkWidget* const pDialog (::gtk_dialog_new_with_buttons ( "Interface selection", 0, ::GtkDialogFlags (0), GTK_STOCK_CANCEL, GTK_RESPONSE_DELETE_EVENT, GTK_STOCK_OK, GTK_RESPONSE_OK, static_cast (0))); ::gtk_window_set_resizable (GTK_WINDOW (pDialog), false); ::gtk_dialog_set_has_separator (GTK_DIALOG (pDialog), false); if (pMainWindow) ::gtk_window_set_transient_for (GTK_WINDOW (pDialog), GTK_WINDOW (pMainWindow)); ::gtk_container_set_border_width (GTK_CONTAINER (pDialog), 6); ::gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pDialog)->vbox), ::gtk_label_new ("Select the interface to use" " :")); CInterfaceSelector IfaceSelector (DevicesVec); ::gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (pDialog)->vbox), IfaceSelector); ::gtk_widget_show_all (GTK_DIALOG (pDialog)->vbox); if (::gtk_dialog_run (GTK_DIALOG (pDialog)) != GTK_RESPONSE_DELETE_EVENT) { ::gtk_widget_destroy (pDialog); return IfaceSelector.GetSelectedRow(); } else { ::gtk_widget_destroy (pDialog); return -1; } } // SelectInterface() inline bool IsReallyRoot () throw() { return !::getuid(); } // IsReallyRoot() void SignalsCallback (int) throw() { if (::gtk_main_level()) ::gtk_main_quit(); } // SignalsCallback() void TrapSignals () throw() { struct sigaction Settings; std::memset (&Settings, 0, sizeof (struct sigaction)); Settings.sa_handler = SignalsCallback; // If those calls fail, we can live with it. ::sigaction (SIGINT, &Settings, 0); ::sigaction (SIGTERM, &Settings, 0); } // TrapSignals() const unsigned SiteSurveyTimerPeriod (1000); const unsigned GlobalTimerPeriod (3000); const unsigned InvalidProfileI (std::numeric_limits::max()); const char* const IfaceStatusLabelDown ("down"); const char* const IfaceStatusLabelUp ("up"); // FIXME Horrible... Only used by the tray icon. // That could make sense however, the main window is a singleton. nsGUI::CGtkGUI* GlobalUglyThis; } // anonymous namespace void nsGUI::NotifyError (const std::string& Msg, int Code, ::GtkWindow* pWindow) throw() { ::GtkWidget* const pDialog (::gtk_message_dialog_new (pWindow, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, Code ? "%s\nCode : %d" : Msg.c_str(), Msg.c_str(), Code)); ::gtk_dialog_run (GTK_DIALOG (pDialog)); ::gtk_widget_destroy (pDialog); } // NotifyError() bool nsGUI::AskUser (const std::string& Msg, ::GtkWindow* pWindow) throw() { ::GtkWidget* const pDialog (::gtk_message_dialog_new (pWindow, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, Msg.c_str())); const int Result (::gtk_dialog_run (GTK_DIALOG (pDialog))); ::gtk_widget_destroy (pDialog); return Result == GTK_RESPONSE_YES; } // AskUser() nsGUI::CGtkGUI::CGtkGUI () throw (nsErrors::CException) : m_pModule (0), m_pWindow (GTK_WINDOW (::gtk_window_new (GTK_WINDOW_TOPLEVEL))), m_pNoteBook (GTK_NOTEBOOK (::gtk_notebook_new())), m_Exc ("", 0), m_GlobalTimer (0), m_SiteSurveyTab (this), m_SiteSurveyTabTimer (0), m_TimeRemaining (0), m_ProfileTab (this), m_TrayIcon (nsCore::TrayIconDisconnectedPath, G_CALLBACK (TrayIconClickedCallBack), this), m_Flags (IsReallyRoot() ? IsRootF : 0U), #ifdef NHELPER m_PrefsPage (true), #else m_PrefsPage (IsRoot()), #endif // NHELPER m_LeaveRootModeTimer (0), m_CurrentRateIndex (0), m_pTrayMenu (0) { ::gtk_window_set_position (m_pWindow, GTK_WIN_POS_CENTER); ::gtk_window_set_resizable (m_pWindow, false); ::gtk_notebook_append_page (m_pNoteBook, m_LinkStatusTab, ::gtk_label_new ("Link status")); ::gtk_notebook_append_page (m_pNoteBook, m_StatsPage, ::gtk_label_new ("Statistics")); ::gtk_notebook_append_page (m_pNoteBook, m_ProfileTab, ::gtk_label_new ("Profiles")); ::gtk_notebook_append_page (m_pNoteBook, m_SiteSurveyTab, ::gtk_label_new ("Site survey")); ::gtk_notebook_append_page (m_pNoteBook, m_PrefsPage, ::gtk_label_new ("Options")); ::gtk_container_add (GTK_CONTAINER (m_pWindow), GTK_WIDGET (m_pNoteBook)); if (IsRoot()) m_PrefsPage.SetRootMode (true); m_PrefsPage.AddChangeInterfaceCallBack (G_CALLBACK (ChangeInterfaceCallBack), this); m_PrefsPage.AddAutoLeaveRootModeCallBack (G_CALLBACK (AutoLeaveRootModeCallBack), this); m_PrefsPage.AddRootModeChangedCallBack (G_CALLBACK (RootModeChangedCallBack), this); m_PrefsPage.AddRateChangedCallBack (G_CALLBACK (RateChangedCallBack), this); m_PrefsPage.AddTrayIconButtonCallBack (G_CALLBACK (DisplayTrayIconButtonCallBack), this); m_PrefsPage.AddStartMinimizedCallBack (G_CALLBACK (StartMinimizedButtonCallBack), this); m_PrefsPage.AddIfaceStatusChangeCallBack (G_CALLBACK (IfaceStatusChangedCallBack), this); TrapSignals(); LoadOptions(); SetWindowIcons(); #ifndef NDEBUG std::cerr << "GUI successfully initialized.\nIs launched as root : " << std::boolalpha << IsRoot() << std::noboolalpha << std::endl; #endif // NDEBUG GlobalUglyThis = this; } // CGtkGUI() nsGUI::CGtkGUI::~CGtkGUI () throw() { ::gtk_widget_destroy (GTK_WIDGET (m_pWindow)); if (m_GlobalTimer) ::g_source_remove (m_GlobalTimer); if (m_SiteSurveyTabTimer) ::g_source_remove (m_SiteSurveyTabTimer); if (m_pTrayMenu) ::gtk_object_destroy (GTK_OBJECT (m_pTrayMenu)); } // ~CGtkGUI() void nsGUI::CGtkGUI::SetWindowIcons () throw() { ::GList* pIconsList (0); ::GError* pError (0); pIconsList = ::g_list_append (pIconsList, ::gdk_pixbuf_new_from_file (nsCore::Icon16Path.c_str(), &pError)); pIconsList = ::g_list_append (pIconsList, ::gdk_pixbuf_new_from_file (nsCore::Icon32Path.c_str(), &pError)); pIconsList = ::g_list_append (pIconsList, ::gdk_pixbuf_new_from_file (nsCore::Icon48Path.c_str(), &pError)); pIconsList = ::g_list_append (pIconsList, ::gdk_pixbuf_new_from_file (nsCore::Icon64Path.c_str(), &pError)); pIconsList = ::g_list_append (pIconsList, ::gdk_pixbuf_new_from_file (nsCore::Icon128Path.c_str(), &pError)); if (pError) { NotifyError (std::string ("Could not load application icons : ") + pError->message, pError->code, m_pWindow); ::g_error_free (pError); } else ::gtk_window_set_default_icon_list (pIconsList); ::g_list_free (pIconsList); } // SetWindowIcons() void nsGUI::CGtkGUI::Run (const nsCore::CCLIOpt& Opt) throw (nsErrors::CException) { #ifndef NDEBUG std::cerr << "Loading module...\n"; #endif // NDEBUG try{if (!ChangeModule (Opt.IfaceName())) return;} catch (const nsErrors::CException& Exc) { #ifndef NDEBUG std::cerr << "Couldn't load module : " << Exc.GetMsg() << ' ' << Exc.GetCode() << std::endl; #endif // NDEBUG if (Exc.GetCode() == m_Exc.GetCode() || ProcessError (Exc) || !m_pModule.get()) throw; } // We can't set this signal and "delete_event" before having a module. ::g_signal_connect (G_OBJECT (m_pNoteBook), "switch-page", G_CALLBACK (PageSwitchCallBack), this); if (!m_PrefsPage.StartMinimized() && !Opt.Hidden()) ::gtk_widget_show_all (GTK_WIDGET (m_pWindow)); if (m_PrefsPage.DisplayTrayIcon()) { m_TrayIcon.Show(); m_ExitHandlerID = ::g_signal_connect_swapped (G_OBJECT (m_pWindow), "delete_event", G_CALLBACK (HideCallBack), this); } else m_ExitHandlerID = ::g_signal_connect (G_OBJECT (m_pWindow), "delete_event", G_CALLBACK (DeleteCallBack), 0); if (Opt.Profile()) { unsigned I (0); for ( ; I < m_pModule->GetNbProfile() ; ++I) if (m_pModule->GetProfile (I).GetName() == Opt.ProfileName()) { if (BecomeRoot()) { #ifndef NDEBUG std::cerr << "Applying the profile (command line)...\n"; #endif // NDEBUG m_pModule->ApplyProfile (I); } #ifndef NDEBUG else std::cerr << "Cannot apply the profile (command line) :" " not root.\n"; #endif // NDEBUG break; } if (I == m_pModule->GetNbProfile()) throw (nsErrors::CException (std::string ("Profile not found : ") + Opt.ProfileName(), nsErrors::ProfileNotFound)); } if (Opt.Dhcp() && BecomeRoot()) { #ifndef NDEBUG std::cerr << "Running DHCP client (command line option).\n"; #endif // NDEBUG m_pIface->SetIPFromDHCP (m_pModule->GetDriver().GetSSID()); } #ifndef NDEBUG std::cerr << "Running main loop...\n"; #endif // NDEBUG ::gtk_main(); #ifndef NDEBUG std::cerr << "Exiting main loop...\n"; #endif // NDEBUG if (m_Exc.GetCode()) { #ifndef NDEBUG std::cerr << "Error.\n"; #endif // NDEBUG throw nsErrors::CException (m_Exc); } } // Run() void nsGUI::CGtkGUI::PageSwitchCallBack (::GtkNotebook* Notebook, ::GtkNotebookPage* pPage, PageNum_e PageNum, CGtkGUI* This) throw() { /* WARNING TrayIconClickedCallBack() calls this function with a null pointer for the GtkNotebookPage. */ try { switch (PageNum) { case LinkStatus : This->RefreshLinkStatus(); break; case Stats : This->IsStatsAvailable (This->RefreshStats()); break; case SiteSurvey : This->SelectCurrentCell(); //break; default :; // To avoid a warning. } } catch (const nsErrors::CException& Exc) {This->ProcessError (Exc);} } // PageSwitchCallBack() bool nsGUI::CGtkGUI::GlobalTimerWithTrayCallBack (CGtkGUI* This) throw() { try { nsWireless::CMacAddress APMacAddr; try { APMacAddr = This->m_pModule->GetDriver().GetAPMacAddr(); } catch (const nsErrors::CSystemExc& Exc) { if (Exc.GetCode() != ENETDOWN) throw; else This->IfaceIsDown(); } if (APMacAddr.Empty()) { This->m_TrayIcon.SetIcon (nsCore::TrayIconDisconnectedPath); This->m_TrayIcon.SetTooltip ("Disconnected"); if (GTK_WIDGET_VISIBLE (GTK_WIDGET (This->m_pWindow))) This->m_LinkStatusTab.Clear(); This->m_ToolTipHeader.erase(); } else { if (This->m_ToolTipHeader.empty()) This->m_ToolTipHeader = This->m_pModule->GetDriver().GetProtoName() + " (" + This->m_pModule->GetDriver().GetDeviceName() + ")\n\n" + "ESSID : " + This->m_pModule->GetDriver().GetSSID(); nsWireless::CQuality Quality; unsigned TxRate (0); try { Quality = This->m_pModule->GetDriver().GetQuality(); } catch (...) {} try { TxRate = This->m_pModule->GetDriver().GetTxRate(); } catch (...) {} This->RefreshTray (Quality, TxRate); if (GTK_WIDGET_VISIBLE (GTK_WIDGET (This->m_pWindow))) switch (::gtk_notebook_get_current_page (This->m_pNoteBook)) { case LinkStatus : This->RefreshLinkStatus (Quality, TxRate, APMacAddr); break; case Stats : if (This->IsStatsAvailable()) This->IsStatsAvailable (This->RefreshStats()); break; case SiteSurvey : This->SelectCurrentCell (APMacAddr); //break; default :; // To avoid a warning. } } } catch (const nsErrors::CException& Exc) { return !This->ProcessError (Exc); } return true; // Keep the timer running. } // GlobalTimerWithTrayCallBack() bool nsGUI::CGtkGUI::GlobalTimerWithoutTrayCallBack (CGtkGUI* This) throw() { try { if (GTK_WIDGET_VISIBLE (GTK_WIDGET (This->m_pWindow))) switch (::gtk_notebook_get_current_page (This->m_pNoteBook)) { case LinkStatus : This->RefreshLinkStatus(); break; case Stats : if (This->IsStatsAvailable()) This->IsStatsAvailable (This->RefreshStats()); break; case SiteSurvey : This->SelectCurrentCell(); //break; default :; // To avoid a warning. } } catch (const nsErrors::CException& Exc) { return !This->ProcessError (Exc); } return true; // Keep the timer running. } // GlobalTimerCallWithoutTrayCallBack int nsGUI::CGtkGUI::DeleteCallBack (::GtkWidget*, ::GdkEvent*, void*) throw() { // Used with a different signature by the callback of the tray menu. if (::gtk_main_level()) ::gtk_main_quit(); return true; // Don't destroy the window (the destructor will do). } // DeleteCallBack() bool nsGUI::CGtkGUI::Connect (unsigned CellI) throw() { #ifndef NDEBUG std::cerr << "Connecting..." << std::endl; #endif // NDEBUG try { const unsigned ProfileI (CreateProfile (CellI)); if (ProfileI != InvalidProfileI && BecomeRoot()) { const nsWireless::CCell& Cell (m_CellVec [CellI]); try { m_pModule->ApplyProfile (ProfileI, Cell.GetAPMacAddress()); } catch (const nsErrors::CException& Exc) { if (Exc.GetCode() == ENETDOWN && BringIfaceUp()) m_pModule->ApplyProfile (ProfileI, Cell.GetAPMacAddress()); else throw; } SetIPFromProfile (ProfileI); SelectMatchingProfile (Cell); RefreshRates(); m_ToolTipHeader.clear(); return true; // Select the row. } } catch (const std::bad_alloc& Exc) { ProcessError (nsErrors::CException (Exc.what(), nsErrors::OutOfMemory)); } catch (const nsErrors::CException& Exc) { // We may have been disconnected from the previous ap. if (!ProcessError (Exc)) try{SelectCurrentCell();} catch (const nsErrors::CSystemExc&) {} // Ignored. } return false; // Don't select the row. } // Connect() unsigned nsGUI::CGtkGUI::CreateProfile (unsigned CellI) throw() { const unsigned NProfile (m_pModule->GetNbProfile()); ::gint ActiveProfile (0); if (NProfile) { ::GtkDialog* const pDialog (GTK_DIALOG (::gtk_dialog_new_with_buttons ("Connection", m_pWindow, ::GtkDialogFlags (GTK_DIALOG_MODAL), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, static_cast (0)))); ::gtk_window_set_resizable (GTK_WINDOW (pDialog), false); ::gtk_box_pack_start_defaults (GTK_BOX (pDialog->vbox), ::gtk_label_new ("Select which profile to use : ")); ::GtkComboBox* const pComboBox (GTK_COMBO_BOX (::gtk_combo_box_new_text())); ::gtk_combo_box_append_text (pComboBox, ""); for (unsigned I (0) ; I < NProfile ; ++I) { const nsUserData::CProfile& Profile (m_pModule->GetProfile (I)); ::gtk_combo_box_append_text (pComboBox, Profile.GetName().c_str()); if (Profile.Match (m_CellVec [CellI])) ActiveProfile = I + 1; } ::gtk_combo_box_set_active (pComboBox, ActiveProfile); ::gtk_box_pack_start (GTK_BOX (pDialog->vbox), GTK_WIDGET (pComboBox), FALSE, FALSE, 8); ::gtk_container_set_border_width (GTK_CONTAINER (pDialog->vbox), 100); ::gtk_widget_show_all (GTK_WIDGET (pDialog)); for ( ; ; ) { if (::gtk_dialog_run (pDialog) == GTK_RESPONSE_OK) { ActiveProfile = ::gtk_combo_box_get_active (pComboBox); if (!ActiveProfile) { if (!NewProfile (CellI)) continue; ActiveProfile = NProfile; } else --ActiveProfile; // First raw is : break; } ::gtk_widget_destroy (GTK_WIDGET (pDialog)); return InvalidProfileI; } ::gtk_widget_destroy (GTK_WIDGET (pDialog)); } else if (!NewProfile (CellI)) // Will create a new profile, so return return InvalidProfileI; // 0 if successful : it's now a valid index. return ActiveProfile; } // CreateProfile() void nsGUI::CGtkGUI::Scan () throw() { try { if (BecomeRoot()) { m_CellVec.clear(); try { m_pModule->GetDriver().Scan(); } catch (const nsErrors::CException& Exc) { if (Exc.GetCode() == ENETDOWN && BringIfaceUp()) m_pModule->GetDriver().Scan(); else throw; } m_SiteSurveyTab.ScanningStarted(); m_TimeRemaining = 15000; // The driver has 15 seconds. m_SiteSurveyTabTimer = ::g_timeout_add (SiteSurveyTimerPeriod, reinterpret_cast< ::gboolean (*) (void*)> (RefreshCellListCallBack), this); } } catch (const nsErrors::CException& Exc) { ProcessError (Exc); } } // Scan() bool nsGUI::CGtkGUI::RefreshCellListCallBack (CGtkGUI* This) throw() { #ifndef NDEBUG std::cerr << "CGtkGUI::RefreshCellListCallBack()\n"; #endif // NDEBUG This->m_TimeRemaining -= SiteSurveyTimerPeriod; try { if (!This->m_TimeRemaining) throw nsErrors::CException ("Failed to get scan result in time.", nsErrors::ScanningTimeOut); This->m_pModule->GetDriver().GetScanResult (This->m_CellVec); #ifndef NDEBUG std::cerr << "\tGot the results.\n"; #endif // NDEBUG const nsWireless::CMacAddress Addr (This->m_pModule->GetDriver().GetAPMacAddr()); const nsWireless::CCell* const pCurrentCell (This->m_SiteSurveyTab.AddCells (This->m_CellVec, Addr)); if (pCurrentCell) { #ifndef NDEBUG std::cerr << "\tSelecting matching profile.\n"; #endif // NDEBUG This->SelectMatchingProfile (*pCurrentCell); } } catch (const std::bad_alloc& Exc) { This->ProcessError (nsErrors::CException (Exc.what(), nsErrors::OutOfMemory)); return false; } catch (const nsErrors::CException& Exc) { #ifndef NDEBUG std::cerr << "\tError : " << Exc.GetMsg() << ' ' << Exc.GetCode() << std::endl; #endif // NDEBUG if (Exc.GetCode() == EINTR || Exc.GetCode() == EAGAIN) return true; // We go for another SiteSurveyTimerPeriod. This->ProcessError (Exc); } This->m_SiteSurveyTab.ScanningStopped(); This->m_SiteSurveyTabTimer = 0; #ifndef NDEBUG std::cerr << "Exiting CGtkGUI::RefreshCellListCallBack()\n"; #endif // NDEBUG return false; } // RefreshCellListCallBack() bool nsGUI::CGtkGUI::ProcessError (const nsErrors::CException& Exc) throw() { switch (Exc.GetCode()) { case nsErrors::ScanningTimeOut : case nsErrors::CannotExecuteHelper : NotifyError (Exc.GetMsg(), 0, m_pWindow); return false; case EPIPE : NotifyError ("Your privileged session has been terminated, please try " "again.", 0, m_pWindow); SetNoRoot(); return false; case EOPNOTSUPP : NotifyError (Exc.GetMsg() + "\nOperation not supported by the driver.", 0, m_pWindow); break; case ENETDOWN : NotifyError ("Failed : the interface is currently down. Bring it up and" " try again.", 0, m_pWindow); IfaceIsDown(); return false; case EPERM : SetNoRoot(); // No break. case EAGAIN : case EBUSY : case EINVAL : case ENOSYS : case ENOTCONN : case nsErrors::InvalidData : case nsErrors::InvalidRootPassword : case ENOENT : NotifyError (std::string ("An error occured :\n") + Exc.GetMsg(), Exc.GetCode(), m_pWindow); return false; // true on critical error, the program will exit. case nsErrors::OutOfMemory : return true; default : NotifyError (std::string ("Critical error :\n") + Exc.GetMsg(), Exc.GetCode(), m_pWindow); m_Exc = Exc; if (::gtk_main_level()) ::gtk_main_quit(); } return true; } // ProcessError() bool nsGUI::CGtkGUI::ApplyProfile (unsigned ProfileI) throw() { #ifndef NDEBUG std::cerr << "Applying a profile..." << std::endl; #endif // NDEBUG try { if (BecomeRoot()) { try { m_pModule->ApplyProfile (ProfileI); } catch (const nsErrors::CException& Exc) { if (Exc.GetCode() == ENETDOWN && BringIfaceUp()) m_pModule->ApplyProfile (ProfileI); else throw; } SetIPFromProfile (ProfileI); ::g_timeout_add (800, reinterpret_cast< ::gboolean (*) (void*)> (RefreshRateDelayedCallBack), this); m_ToolTipHeader.clear(); return true; // Select the row. } } catch (const nsErrors::CException& Exc) { ProcessError (Exc); } return false; // Don't select the row. } // ApplyProfile() bool nsGUI::CGtkGUI::DeleteProfile (unsigned ProfileI) throw() { ::GtkDialog* const pDialog (GTK_DIALOG (::gtk_message_dialog_new ( m_pWindow, ::GtkDialogFlags (0), GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Do you want to delete this " "profile : %s?", m_pModule->GetProfile (m_ProfileTab.GetSelectedRow()).GetName().c_str()))); const int Response (::gtk_dialog_run (pDialog)); ::gtk_widget_destroy (GTK_WIDGET (pDialog)); if (Response == GTK_RESPONSE_YES) { m_pModule->DeleteProfile (ProfileI); StoreProfiles(); return true; // Delete the profile from the list. } return false; // Don't delete the profile from the list. } // DeleteProfile() void nsGUI::CGtkGUI::SelectMatchingProfile (const nsWireless::CCell& Cell) throw() { for (unsigned i (m_pModule->GetNbProfile()) ; i-- ; ) m_ProfileTab.SetSelected (i, m_pModule->GetProfile (i).Match (Cell)); } // SelectMatchingProfile() bool nsGUI::CGtkGUI::ChangeModule (const std::string& IfaceName) throw (nsErrors::CException) { #ifndef NDEBUG std::cerr << "CGtkGUI::ChangeModule()\n"; #endif // NDEBUG std::vector DevicesVec; nsCore::GetWirelessDevice (DevicesVec); if (DevicesVec.empty()) throw nsErrors::CException ("Can't find any wireless network" " interface.", nsErrors::NoDeviceFound); int Pos (0); if (IfaceName.empty()) { if (DevicesVec.size() > 1 || m_pModule.get()) Pos = SelectInterface (GTK_WIDGET_VISIBLE (GTK_WIDGET (m_pWindow)) ? m_pWindow : 0, DevicesVec); } else { for ( ; unsigned (Pos) < DevicesVec.size() && DevicesVec [Pos].GetDeviceName() != IfaceName ; ++Pos); if (unsigned (Pos) == DevicesVec.size()) throw nsErrors::CException (std::string ("Can't find interface : ") + IfaceName, nsErrors::NoDeviceFound); } if (Pos == -1 || m_pModule.get() && m_pModule->GetDriver().GetDeviceName() == DevicesVec [Pos].GetDeviceName()) return false; nsCore::IModule* pModule (0); #ifndef NDEBUG std::cerr << "Instanciating module...\n"; #endif // NDEBUG try{pModule = nsCore::MakeModule (DevicesVec [Pos], this);} catch (const std::bad_alloc& Exc) { throw nsErrors::CException (Exc.what(), nsErrors::OutOfMemory); } if (!pModule) return false; if (m_GlobalTimer) ::g_source_remove (m_GlobalTimer); m_pModule.reset (pModule); try { if (IsRoot() && !IsReallyRoot()) m_pModule->BecomeRoot(); #ifndef NDEBUG std::cerr << "Instanciating interface...\n"; #endif // NDEBUG m_pIface.reset (new nsNet::CInterface (m_pModule->GetDriver().GetDeviceName())); } catch (const std::bad_alloc&) { throw nsErrors::CException ("Out of memory.", nsErrors::OutOfMemory); } const bool IsIfaceUp (m_pIface->IsUp()); #ifndef NDEBUG std::cerr << "Interface is initially : " << (IsIfaceUp ? IfaceStatusLabelUp : IfaceStatusLabelDown) << std::endl; #endif // NDEBUG IsIgnored (true); m_PrefsPage.IfaceStatus (IsIfaceUp); m_PrefsPage.IfaceLabel (IsIfaceUp ? IfaceStatusLabelUp : IfaceStatusLabelDown); IsIgnored (false); m_ProfileTab.Clear(); for (unsigned i (0) ; i < m_pModule->GetNbProfile() ; ++i) m_ProfileTab.AddProfile (m_pModule->GetProfile (i)); ::gtk_window_set_title (m_pWindow, (m_pModule->GetDriver().GetProtoName() + " - RutilT").c_str()); ::gtk_notebook_remove_page (m_pNoteBook, Private); if (m_pModule->GetPrivateTab()) { ::gtk_notebook_append_page (m_pNoteBook, m_pModule->GetPrivateTab(), ::gtk_label_new ( m_pModule->GetDriver().GetProtoName().c_str())); ::gtk_widget_show_all (m_pModule->GetPrivateTab()); } m_CellVec.clear(); if (IsIfaceUp) // Limits possible errors. RefreshCellListCallBack (this); #ifndef NDEBUG if (m_Exc.GetCode()) std::cerr << "Error detected after fetching scan results : " << m_Exc.GetMsg() << "\tCode : " << m_Exc.GetCode() << std::endl; #endif // NDEBUG RefreshRates(); if (m_PrefsPage.DisplayTrayIcon()) { m_GlobalTimer = ::g_timeout_add (GlobalTimerPeriod, reinterpret_cast< ::gboolean (*) (void*)> (GlobalTimerWithTrayCallBack), this); GlobalTimerWithTrayCallBack (this); } else { m_GlobalTimer = ::g_timeout_add (GlobalTimerPeriod, reinterpret_cast< ::gboolean (*) (void*)> (GlobalTimerWithoutTrayCallBack), this); GlobalTimerWithoutTrayCallBack (this); } #ifndef NDEBUG std::cerr << "Exiting CGtkGUI::ChangeModule()\n"; #endif // NDEBUG return true; } // ChangeModule() bool nsGUI::CGtkGUI::NewProfile (unsigned CellI) throw() { nsWireless::CCell& Cell (m_CellVec [CellI]); bool IsCurrentCell (false); try { if (m_pModule->GetDriver().GetAPMacAddr() == Cell.GetAPMacAddress()) IsCurrentCell = true; } catch (const nsErrors::CSystemExc& Exc) {} // Ignored. const nsUserData::CProfile* const pProfile (m_pModule->NewProfile (m_pWindow, Cell)); if (pProfile) // The user may change his mind and "cancel". { m_ProfileTab.AddProfile (*pProfile); // Check if the user hasn't modified the profile. if (IsCurrentCell && pProfile->Match (Cell)) m_ProfileTab.SetSelected (m_pModule->GetNbProfile() - 1, true); return true; } return false; } // NewProfile() void nsGUI::CGtkGUI::SelectCurrentCell () throw (nsErrors::CSystemExc) { nsWireless::CMacAddress Addr; try { Addr = m_pModule->GetDriver().GetAPMacAddr(); } catch (const nsErrors::CSystemExc& Exc) { if (Exc.GetCode() != ENETDOWN) throw; } SelectCurrentCell (Addr); } // SelectCurrentCell() void nsGUI::CGtkGUI::SelectCurrentCell (const nsWireless::CMacAddress& Addr) throw() { for (unsigned i (m_CellVec.size()) ; i-- ; ) m_SiteSurveyTab.SetSelected (i, m_CellVec [i].GetAPMacAddress() == Addr); } // SelectCurrentCell() bool nsGUI::CGtkGUI::BecomeRoot () throw (nsErrors::CException) { if (!IsRoot()) { #ifdef NHELPER ::GtkWidget* const pDialog = ::gtk_message_dialog_new (m_pWindow, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "RutilT must be ran as root to" " do that."); ::gtk_dialog_run (GTK_DIALOG (pDialog)); ::gtk_widget_destroy (pDialog); #else #ifdef NOROOTPASSCHECK if (nsRoot::CSu::Init ("")) { m_pModule->BecomeRoot(); m_pIface.reset (new nsNet::CInterfaceRoot (*m_pIface)); SetRoot(); IsIgnored (true); m_PrefsPage.SetRootMode (IsRoot()); IsIgnored (false); AutoLeaveRootModeCallBack (this); } else { NotifyError ("An error occured.\nPlease try again.", 0, m_pWindow); SetNoRoot(); } #else ::GtkDialog* const pDialog (GTK_DIALOG (::gtk_dialog_new_with_buttons ("Enter password", m_pWindow, ::GtkDialogFlags (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, static_cast (0)))); ::GtkContainer* const pHbox (GTK_CONTAINER (::gtk_hbox_new (false, 6))); ::gtk_container_add (pHbox, ::gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG)); ::gtk_container_add (pHbox, ::gtk_label_new ("You need administrator" " privileges to do this,\nplease enter your root password.")); ::gtk_container_add (GTK_CONTAINER (pDialog->vbox), GTK_WIDGET (pHbox)); ::GtkEntry* const pEntry (GTK_ENTRY (::gtk_entry_new())); ::gtk_entry_set_visibility (pEntry, false); ::g_signal_connect (G_OBJECT (pEntry), "activate", G_CALLBACK (TriggerResponseCallBack), pDialog); ::gtk_container_add (GTK_CONTAINER (pDialog->vbox), GTK_WIDGET (pEntry)); ::gtk_container_set_border_width (GTK_CONTAINER (pDialog), 6); ::gtk_window_set_resizable (GTK_WINDOW (pDialog), false); ::gtk_widget_show_all (GTK_WIDGET (pDialog)); try { bool IsMsgDisplayed (false); while (!IsRoot() && ::gtk_dialog_run (pDialog) == GTK_RESPONSE_OK) if (nsRoot::CSu::Init (::gtk_entry_get_text (pEntry))) { m_pModule->BecomeRoot(); m_pIface.reset (new nsNet::CInterfaceRoot (*m_pIface)); SetRoot(); AutoLeaveRootModeCallBack (this); } else { ::gtk_entry_set_text (pEntry, ""); if (!IsMsgDisplayed) { ::GtkWidget* const pLabel (::gtk_label_new ("Invalid password, please try again.")); ::gtk_box_pack_start_defaults (GTK_BOX (pDialog->vbox), pLabel); ::gtk_widget_show (pLabel); IsMsgDisplayed = true; } } } catch (const std::bad_alloc& Exc) { ::gtk_widget_destroy (GTK_WIDGET (pDialog)); IsIgnored (true); m_PrefsPage.SetRootMode (IsRoot()); IsIgnored (false); throw nsErrors::CSystemExc (Exc.what(), nsErrors::OutOfMemory); } catch (const nsErrors::CException& Exc) { ::gtk_widget_destroy (GTK_WIDGET (pDialog)); IsIgnored (true); m_PrefsPage.SetRootMode (IsRoot()); IsIgnored (false); throw; } IsIgnored (true); m_PrefsPage.SetRootMode (IsRoot()); IsIgnored (false); ::gtk_widget_destroy (GTK_WIDGET (pDialog)); #endif // NOROOTPASSCHECK #endif // NHELPER } return IsRoot(); } // BecomeRoot() bool nsGUI::CGtkGUI::RefreshStats () throw() { try { m_pIface->RefreshStats(); m_StatsPage.SetTXBytes (m_pIface->GetTXBytes()); m_StatsPage.SetTXPackets (m_pIface->GetTXPackets()); m_StatsPage.SetTXErrors (m_pIface->GetTXErrors()); m_StatsPage.SetCollisions (m_pIface->GetCollisions()); m_StatsPage.SetRXBytes (m_pIface->GetRXBytes()); m_StatsPage.SetRXPackets (m_pIface->GetRXPackets()); m_StatsPage.SetRXErrors (m_pIface->GetRXErrors()); } catch (const nsErrors::CException& Exc) { if (Exc.GetCode() == nsErrors::StatsParsing) NotifyError ("Statistics unavailable.", 0, m_pWindow); else NotifyError (Exc.GetMsg(), Exc.GetCode(), m_pWindow); return false; } return true; } // RefreshStats() void nsGUI::CGtkGUI::SetIPFromProfile (unsigned ProfileI) throw (nsErrors::CException) { const nsUserData::CProfile& Profile (m_pModule->GetProfile (ProfileI)); if (Profile.GetIPSettings().GetSetting() == nsUserData::Dhcp) { m_pIface->SetIPFromDHCP (Profile.GetSSID()); IsIgnored (true); m_PrefsPage.IfaceStatus (true); m_PrefsPage.IfaceLabel (IfaceStatusLabelUp); IsIgnored (false); } } // SetIPFromProfile() void nsGUI::CGtkGUI::RefreshLinkStatus () throw (nsErrors::CException) { nsWireless::CQuality Quality; unsigned TxRate (0); try { Quality = m_pModule->GetDriver().GetQuality(); } catch (...) {} try { TxRate = m_pModule->GetDriver().GetTxRate(); } catch (...) {} nsWireless::CMacAddress Addr; try { Addr = m_pModule->GetDriver().GetAPMacAddr(); } catch (...) {} RefreshLinkStatus (Quality, TxRate, Addr); } // RefreshLinkStatus() void nsGUI::CGtkGUI::RefreshLinkStatus (const nsWireless::CQuality& Quality, unsigned TxRate, const nsWireless::CMacAddress& APMacAddr) throw (nsErrors::CException) { try { m_LinkStatusTab.SetChannel (m_pModule->GetDriver().GetChannel(), m_pModule->GetDriver().GetFrequency()); m_LinkStatusTab.SetMode (nsWireless::GetModeName (m_pModule->GetDriver().GetMode())); } catch (const nsErrors::CSystemExc& Exc) { if (Exc.GetCode() != ENETDOWN) throw; IfaceIsDown(); m_LinkStatusTab.SetChannel (0, 0.); m_LinkStatusTab.SetMode ("N/A"); } if (!APMacAddr.Empty()) { m_LinkStatusTab.SetStatus (m_pModule->GetDriver().GetSSID(), APMacAddr.GetStr()); m_LinkStatusTab.SetLinkQuality (Quality.GetLinkQuality()); m_LinkStatusTab.SetSignalLevel (Quality.GetSignalLevel()); m_LinkStatusTab.SetNoiseLevel (Quality.GetNoiseLevel()); m_LinkStatusTab.SetTxRate (TxRate); } else m_LinkStatusTab.Clear(); try{m_LinkStatusTab.SetAddr (m_pIface->GetIP().GetStr());} catch (const nsErrors::CSystemExc& Exc) { if (Exc.GetCode() == EADDRNOTAVAIL) m_LinkStatusTab.SetAddr ("N/A"); else throw; } } // RefreshLinkStatus() void nsGUI::CGtkGUI::TrayIconClickedCallBack (CGtkGUI* This, ::GdkEventButton* pEvent) throw() { if (pEvent->button == 3) // Right button. This->TrayIconMenu (*pEvent); else if (GTK_WIDGET_VISIBLE (GTK_WIDGET (This->m_pWindow))) HideCallBack (This); else ShowCallBack (This); } // TrayIconClickedCallBack() void nsGUI::CGtkGUI::RefreshTray (const nsWireless::CQuality& Quality, unsigned TxRate) throw() { unsigned Average (Quality.GetLinkQuality()); Average += unsigned ((Quality.GetSignalLevel() + 256U) / 256.0 * 100U); Average += unsigned (Quality.GetNoiseLevel() / 256.0 * -100); Average /= 3U; if (Average > 66U) m_TrayIcon.SetIcon (nsCore::TrayIconHighPath); else if (Average > 33U) m_TrayIcon.SetIcon (nsCore::TrayIconMediumPath); else m_TrayIcon.SetIcon (nsCore::TrayIconLowPath); std::ostringstream Os; Os << m_ToolTipHeader << '\n' << "Link quality : " << Quality.GetLinkQuality() << " %\n" << "Signal level : " << Quality.GetSignalLevel() << " dBm\n" << "Noise level : " << Quality.GetNoiseLevel() << " dBm\n" "Tx rate : "; if (TxRate) Os << TxRate / 1000.0 << " Mbps"; else Os << "Unknown."; m_TrayIcon.SetTooltip (Os.str()); } // RefreshTray() void nsGUI::CGtkGUI::RootModeChangedCallBack (CGtkGUI* This) throw() { if (!This->IsIgnored()) { if (This->IsRoot()) This->SetNoRoot(); else try { This->BecomeRoot(); } catch (const nsErrors::CException& Exc) { if (!This->ProcessError (Exc)) This->SetNoRoot(); } } } // RootModeChangedCallBack() void nsGUI::CGtkGUI::ChangeInterfaceCallBack (CGtkGUI* This) throw() { try {This->ChangeModule();} catch (const nsErrors::CException& Exc) {This->ProcessError (Exc);} } // ChangeInterfaceCallBack() void nsGUI::CGtkGUI::AutoLeaveRootModeCallBack (CGtkGUI* This) throw() { if (!This->IsIgnored()) { if (This->IsRoot()) { if (This->m_LeaveRootModeTimer) { ::g_source_remove (This->m_LeaveRootModeTimer); This->m_LeaveRootModeTimer = 0; } const unsigned Delay (This->m_PrefsPage.GetAutoLeaveRootDelay() * 1000); if (Delay) This->m_LeaveRootModeTimer = ::g_timeout_add (Delay, reinterpret_cast< ::gboolean (*) (void*)> (LeaveRootModeTimerCallBack), This); } This->StoreOptions(); } } // AutoLeaveRootModeCallBack() bool nsGUI::CGtkGUI::LeaveRootModeTimerCallBack (CGtkGUI* This) throw() { This->SetNoRoot(); return false; // Stop the timer. } // LeaveRootModeTimerCallBack() void nsGUI::CGtkGUI::RateChangedCallBack (CGtkGUI* This) throw() { #ifndef NDEBUG std::cerr << "Entering CGtkGUI::RateChangedCallBack(), ignoring : " << std::boolalpha << This->IsIgnored() << std::noboolalpha << std::endl; #endif // NDEBUG if (!This->IsIgnored()) { try { if (This->BecomeRoot()) { This->m_pModule->GetDriver().SetTxRate (This->m_PrefsPage.GetSelectedRate()); This->m_CurrentRateIndex = This->m_PrefsPage.GetSelectedRateIndex(); return; } } catch (const nsErrors::CException& Exc) { if (This->ProcessError (Exc)) return; } // Revert to previous state (in case of error, not root etc...). This->IsIgnored (true); This->m_PrefsPage.SetRateIndex (This->m_CurrentRateIndex); This->IsIgnored (false); } #ifndef NDEBUG std::cerr << "Leaving CGtkGUI::RateChangedCallBack()" << std::endl; #endif // NDEBUG } // RateChangedCallBack() void nsGUI::CGtkGUI::SetNoRoot () throw() { m_Flags &= ~IsRootF; nsRoot::CSu::Close(); IsIgnored (true); m_PrefsPage.SetRootMode (false); IsIgnored (false); if (m_LeaveRootModeTimer) { ::g_source_remove (m_LeaveRootModeTimer); m_LeaveRootModeTimer = 0; } } // SetNoRoot() void nsGUI::CGtkGUI::RefreshRates () throw() { #ifndef NDEBUG std::cerr << "CGtkGUI::RefreshRates()\n"; #endif // NDEBUG std::vector RatesVec; try {m_pModule->GetDriver().GetSupportedRates (RatesVec);} catch (const nsErrors::CException& Exc) { #ifndef NDEBUG std::cerr << "Cannot get supported rates : " << Exc.GetMsg() << ' ' << Exc.GetCode() << std::endl; #endif // NDEBUG } IsIgnored (true); m_PrefsPage.SetRates (RatesVec); IsIgnored (false); if (!RatesVec.empty()) { unsigned Index (0); try { Index = std::find (RatesVec.begin(), RatesVec.end(), m_pModule->GetDriver().GetTxRate()) - RatesVec.begin(); } catch (const nsErrors::CException& Exc) { #ifndef NDEBUG std::cerr << "Cannot get current TX rate : " << Exc.GetMsg() << ' ' << Exc.GetCode() << std::endl; #endif // NDEBUG } IsIgnored (true); m_PrefsPage.SetRateIndex (Index); m_CurrentRateIndex = Index; IsIgnored (false); } #ifndef NDEBUG std::cerr << "Exiting CGtkGUI::RefreshRates()\n"; #endif // NDEBUG } // RefreshRates() bool nsGUI::CGtkGUI::RefreshRateDelayedCallBack (CGtkGUI* This) throw() { This->RefreshRates(); return false; } // RefreshRateDelayedCallBack() void nsGUI::CGtkGUI::DisplayTrayIconButtonCallBack (CGtkGUI* This) throw() { if (!This->IsIgnored()) { ::g_signal_handler_disconnect (This->m_pWindow, This->m_ExitHandlerID); if (This->m_PrefsPage.DisplayTrayIcon()) { This->m_TrayIcon.Show(); ::g_source_remove (This->m_GlobalTimer); This->m_ExitHandlerID = ::g_signal_connect_swapped (G_OBJECT (This->m_pWindow), "delete_event", G_CALLBACK (HideCallBack), This); This->m_GlobalTimer = ::g_timeout_add (GlobalTimerPeriod, reinterpret_cast< ::gboolean (*) (void*)> (GlobalTimerWithTrayCallBack), This); GlobalTimerWithTrayCallBack (This); } else { This->m_TrayIcon.Hide(); ::g_source_remove (This->m_GlobalTimer); This->m_ExitHandlerID = ::g_signal_connect (G_OBJECT (This->m_pWindow), "delete_event", G_CALLBACK (DeleteCallBack), 0); This->m_GlobalTimer = ::g_timeout_add (GlobalTimerPeriod, reinterpret_cast< ::gboolean (*) (void*)> (GlobalTimerWithoutTrayCallBack), This); GlobalTimerWithoutTrayCallBack (This); } This->StoreOptions(); } } // DisplayTrayIconButtonCallBack() void nsGUI::CGtkGUI::StartMinimizedButtonCallBack (CGtkGUI* This) throw() { if (!This->IsIgnored()) This->StoreOptions(); } // StartMinimizedButtonCallBack() void nsGUI::CGtkGUI::LoadOptions () throw() { // The constructor parameters are the default settings. nsUserData::COptionsFile OptionsFile (true, false, 10); try{OptionsFile.Extract();} catch (...) {} // Ignore all errors. IsIgnored (true); m_PrefsPage.DisplayTrayIcon (OptionsFile.DisplayTrayIcon()); m_PrefsPage.StartMinimized (OptionsFile.StartMinimized()); m_PrefsPage.SetAutoLeaveRootDelay (OptionsFile.LeaveRootDelay()); IsIgnored (false); } // LoadOptions() void nsGUI::CGtkGUI::StoreProfiles () throw() { try { m_pModule->RecordProfiles(); } catch (const nsErrors::CException& Exc) { NotifyError ("Profiles could not have been recorded.", Exc.GetCode(), m_pWindow); } } // StoreProfiles() void nsGUI::CGtkGUI::StoreOptions () throw() { try { nsUserData::COptionsFile OptionsFile (m_PrefsPage.DisplayTrayIcon(), m_PrefsPage.StartMinimized(), m_PrefsPage.GetAutoLeaveRootDelay()); OptionsFile.Record(); } catch (const nsErrors::CException& Exc) { NotifyError ("Options could not have been recorded.", Exc.GetCode(), m_pWindow); } } // StoreOptions() void nsGUI::CGtkGUI::IfaceStatusChangedCallBack (CGtkGUI* This) throw() { if (!This->IsIgnored()) { const bool BringDown (!This->m_PrefsPage.IfaceStatus()); if (This->BecomeRoot()) try { if (BringDown) { This->m_pIface->Down(); This->m_PrefsPage.IfaceLabel (IfaceStatusLabelDown); } else { This->m_pIface->Up(); This->m_PrefsPage.IfaceLabel (IfaceStatusLabelUp); } return; } catch (const nsErrors::CException& Exc) { if (This->ProcessError (Exc)) return; } // Revert to previous state (in case of error, not root etc...). This->IsIgnored (true); This->m_PrefsPage.IfaceStatus (BringDown); This->IsIgnored (false); } } // IfaceStatusChangedCallBack() bool nsGUI::CGtkGUI::BringIfaceUp () throw() { bool B (AskUser ("The interface needs to be up to perform this" " action.\nBring it up now?", m_pWindow)); if (B) try { m_pIface->Up(); } catch (const nsErrors::CSystemExc& Exc) { if (ProcessError (Exc)) return false; B = false; } IsIgnored (true); m_PrefsPage.IfaceStatus (B); m_PrefsPage.IfaceLabel (B ? IfaceStatusLabelUp : IfaceStatusLabelDown); IsIgnored (false); return B; } // BringIfaceUp() void nsGUI::CGtkGUI::IfaceIsDown () throw() { IsIgnored (true); m_PrefsPage.IfaceStatus (false); m_PrefsPage.IfaceLabel (IfaceStatusLabelDown); IsIgnored (false); } // IfaceIsDown() void nsGUI::CGtkGUI::TrayIconMenu (::GdkEventButton& Event) throw() { if (m_pTrayMenu) ::gtk_object_destroy (GTK_OBJECT (m_pTrayMenu)); m_pTrayMenu = GTK_MENU_SHELL (::gtk_menu_new()); ::gtk_menu_shell_append (m_pTrayMenu, MakeMenuVisibilityItem()); ::gtk_menu_shell_append (m_pTrayMenu, MakeMenuProfileItem()); ::gtk_menu_shell_append (m_pTrayMenu, ::gtk_separator_menu_item_new()); ::gtk_menu_shell_append (m_pTrayMenu, MakeMenuExitItem()); ::gtk_widget_show_all (GTK_WIDGET (m_pTrayMenu)); ::gtk_menu_popup (GTK_MENU (m_pTrayMenu), 0, 0, 0, 0, Event.button, Event.time); } // TrayIconMenu() ::GtkWidget* nsGUI::CGtkGUI::MakeMenuVisibilityItem () throw() { ::GtkWidget* pItem; if (GTK_WIDGET_VISIBLE (GTK_WIDGET (m_pWindow))) { pItem = ::gtk_menu_item_new_with_label ("Hide window"); ::g_signal_connect_swapped (pItem, "activate", G_CALLBACK (HideCallBack), this); } else { pItem = ::gtk_menu_item_new_with_label ("Show window"); ::g_signal_connect_swapped (pItem, "activate", G_CALLBACK (ShowCallBack), this); } return pItem; } // MakeMenuVisibilityItem() ::GtkWidget* nsGUI::CGtkGUI::MakeMenuProfileItem () throw() { ::GtkWidget* const pItem (::gtk_menu_item_new_with_label ("Apply profile")); ::GtkMenuShell* const pSubMenu (GTK_MENU_SHELL (::gtk_menu_new())); ::gtk_menu_item_set_submenu (GTK_MENU_ITEM (pItem), GTK_WIDGET (pSubMenu)); const ::gint NProfile (::gint (m_pModule->GetNbProfile())); if (NProfile) { for (::gint I (0) ; I < NProfile ; ++I) { ::GtkWidget* const pProfileItem (::gtk_menu_item_new_with_label (m_pModule->GetProfile (I).GetName().c_str())); ::gtk_menu_shell_append (pSubMenu, pProfileItem); ::g_signal_connect_swapped (pProfileItem, "activate", G_CALLBACK (ApplyProfileTrayCallBack), GINT_TO_POINTER (I)); } ::gtk_menu_shell_append (pSubMenu, ::gtk_separator_menu_item_new()); } ::GtkWidget* const pNewProfileItem (::gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, 0)); ::g_signal_connect_swapped (pNewProfileItem, "activate", G_CALLBACK (CreateProfileAndApplyCallBack), this); ::gtk_menu_shell_append (pSubMenu, pNewProfileItem); return pItem; } // MakeMenuProfileItem() ::GtkWidget* nsGUI::CGtkGUI::MakeMenuExitItem() throw() { ::GtkWidget* const pItem (::gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, 0)); // The signature of DeleteCallBack() does not quite match. ::g_signal_connect (pItem, "activate", G_CALLBACK (DeleteCallBack), 0); return pItem; } // MakeMenuExitItem() void nsGUI::CGtkGUI::HideCallBack (CGtkGUI* This) throw() { ::gtk_widget_hide (GTK_WIDGET (This->m_pWindow)); } // HideCallBack() void nsGUI::CGtkGUI::ShowCallBack (CGtkGUI* This) throw() { ::gtk_widget_show_all (GTK_WIDGET (This->m_pWindow)); try { // WARNING The NoteBookPage is NOT passed. PageSwitchCallBack (This->m_pNoteBook, 0, PageNum_e (::gtk_notebook_get_current_page (This->m_pNoteBook)), This); } catch (const nsErrors::CException& Exc) {This->ProcessError (Exc);} } // ShowCallBack() void nsGUI::CGtkGUI::CreateProfileAndApplyCallBack (CGtkGUI* This) throw() { const unsigned LastProfileI (This->m_pModule->GetNbProfile()); const nsUserData::CProfile* pProfile (This->NewProfile()); if (pProfile) { This->m_ProfileTab.AddProfile (*pProfile); This->m_ProfileTab.SetSelected (LastProfileI, This->ApplyProfile (LastProfileI)); This->SelectMatchingProfile (LastProfileI); } } // CreateProfileAndApplyCallBack() void nsGUI::CGtkGUI::SelectMatchingProfile (unsigned ProfileI) throw() { for (unsigned I (m_pModule->GetNbProfile()) ; I-- ; ) // FIXME Could check if profiles are "equals". m_ProfileTab.SetSelected (I, I == ProfileI); } // ProfileI() void nsGUI::CGtkGUI::ApplyProfileTrayCallBack (::gpointer ProfileIPtr) throw() { const ::gint ProfileI (GPOINTER_TO_INT (ProfileIPtr)); if (GlobalUglyThis->ApplyProfile (ProfileI)) GlobalUglyThis->SelectMatchingProfile (ProfileI); } // ApplyProfileTrayCallBack() const nsUserData::CProfile* nsGUI::CGtkGUI::EditProfile () throw() { if (m_pModule->EditProfile (m_pWindow, m_ProfileTab.GetSelectedRow())) { StoreProfiles(); return &m_pModule->GetProfile (m_ProfileTab.GetSelectedRow()); } return 0; } // EditProfile() const nsUserData::CProfile* nsGUI::CGtkGUI::NewProfile () throw() { const nsUserData::CProfile* const pProfile (m_pModule->NewProfile (m_pWindow)); if (pProfile) StoreProfiles(); return pProfile; } // NewProfile() RutilTv0.18/lib/src/WE17Driver.cxx0000644000175000017500000006013510715167052016263 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file WE17Driver.cxx \author Romain BONDUE \date 05/07/2005 \note Many functions here could have been "inline", but since they are also "virtual", it's almost useless. */ #include #include // pow() #include // strncpy() #include #include // sort() #ifndef NDEBUG #include #endif // NDEBUG extern "C"{ #include } #include "WE17Driver.h" #include "ErrorsCode.h" namespace { inline nsWireless::CQuality iw_qualityToCQuality (const ::iw_quality& Iw) throw() { // There's an unusual 8 bits arithmetic, that's why the -256. return nsWireless::CQuality (Iw.qual, -256 + Iw.level, -256 + Iw.noise); } // iw_qualityToCQuality() inline nsWireless::CEncryptionD MakeCEncryption (const char* Key, unsigned Length, int Flags) throw() { return nsWireless::CEncryptionD (Flags & IW_ENCODE_DISABLED ? nsWireless::CHexaKey() : nsWireless::CHexaKey (Key, Length), Flags & IW_ENCODE_RESTRICTED ? nsWireless::Shared : nsWireless::Open, Flags & IW_ENCODE_DISABLED ? nsWireless::None : nsWireless::WEP); } // MakeCEncryption() std::string CatStringNInt (std::string Str, int Number) throw() { std::ostringstream Os; Os << Str << Number; return Os.str(); } // CatStringNInt() inline double iw_freqToDouble (::iw_freq Freq) throw() { return Freq.m / pow (10, 9 - Freq.e); } // iw_freqToDouble() const unsigned TxUnit (1000); } // anonymous namespace nsWireless::CWE17Driver::CWE17Driver (const std::string& Name) throw (nsErrors::CSystemExc) : m_Data (m_Req.u) { // Starting from here, we just collect informations : Name.copy (m_Req.ifr_ifrn.ifrn_name, IFNAMSIZ); m_Req.ifr_ifrn.ifrn_name [Name.size() > IFNAMSIZ - 1 ? IFNAMSIZ - 1 : Name.size()] = '\0'; Ioctl (SIOCGIWNAME, "Can't get protocol/provider name."); m_ProtoName = m_Req.u.name; ::iw_range Range; m_Req.u.data.pointer = reinterpret_cast< ::caddr_t> (&Range); m_Req.u.data.length = sizeof (Range); m_Req.u.data.flags = 0; try { // Only used to get channels values. Ioctl (SIOCGIWRANGE, "Can't get interface informations."); for (unsigned i (0) ; i < Range.num_frequency ; ++i) m_SupportedFreqVec.push_back (CFreq (Range.freq [i].i, iw_freqToDouble (Range.freq [i]))); } catch (const nsErrors::CSystemExc& Exc) { #ifndef NDEBUG std::cerr << "CWE17Driver::CWE17Driver() Can't get interface" " information : " << Exc.GetCode() << std::endl; #endif // NDEBUG if (Exc.GetCode() != EOPNOTSUPP && Exc.GetCode() != ENETDOWN) throw; } if (m_SupportedFreqVec.empty()) { #ifndef NDEBUG std::cerr << "CWE17Driver::CWE17Driver() generate channel list." << std::endl; #endif // NDEBUG for (unsigned i (1) ; i < 14 ; ++i) // Let's put the whole spectrum. m_SupportedFreqVec.push_back (CFreq (i, 2.412 + (i - 1) * 0.005)); m_SupportedFreqVec.push_back (CFreq (14, 2.484)); } } // CWE17Driver() std::string nsWireless::CWE17Driver::GetSSID () const throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::GetSSID()" << std::endl; #endif // NDEBUG char Buffer [IW_ESSID_MAX_SIZE]; m_Req.u.data.pointer = reinterpret_cast< ::caddr_t> (Buffer); m_Req.u.data.length = IW_ESSID_MAX_SIZE; m_Req.u.data.flags = 0; Ioctl (SIOCGIWESSID, "Can't get SSID."); #ifndef NDEBUG std::cerr << "CWE17Driver::GetSSID() : " << std::string (reinterpret_cast (m_Req.u.data.pointer), 0, m_Req.u.data.length) << std::endl; #endif // NDEBUG if (!m_Req.u.data.length) return std::string(); return std::string (Buffer, 0, m_Req.u.data.length); } // GetSSID() // No control on the SSID, however it'll be truncated if too long. void nsWireless::CWE17Driver::SetSSID (const std::string& SSID) throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::SetSSID() " << SSID << std::endl; #endif // NDEBUG m_Req.u.data.pointer = const_cast< ::caddr_t> (SSID.c_str()); #if WIRELESS_EXT < 21 m_Req.u.data.length = SSID.size() + 1 > IW_ESSID_MAX_SIZE ? IW_ESSID_MAX_SIZE /* + 1 for the '\0'. */ : SSID.size() + 1; #else m_Req.u.data.length = SSID.size() > IW_ESSID_MAX_SIZE ? IW_ESSID_MAX_SIZE : SSID.size(); #endif // WIRELESS_EXT m_Req.u.data.flags = 1; // Only use *this* SSID. Ioctl (SIOCSIWESSID, std::string ("Can't set SSID : ") + SSID); } // SetSSID() unsigned nsWireless::CWE17Driver::GetChannel () const throw (nsErrors::CException) { const double Value (GetDriverFreqValue()); if (Value > 0) return GetMatchingFreq (0, Value).GetChannel(); return unsigned (-Value); } // GetChannel() void nsWireless::CWE17Driver::SetChannel (unsigned Channel) throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::SetChannel() " << Channel << std::endl; #endif // NDEBUG m_Req.u.freq.m = Channel; m_Req.u.freq.e = 0; #if WIRELESS_EXT > 16 m_Req.u.freq.flags = IW_FREQ_FIXED; #endif Ioctl (SIOCSIWFREQ, CatStringNInt ("Can't set channel : ", Channel)); } // SetChannel() double nsWireless::CWE17Driver::GetFrequency () const throw (nsErrors::CException) { const double Value (GetDriverFreqValue()); if (Value > 0) return Value; return GetMatchingFreq (unsigned (-Value)).GetFrequency(); } // GetFrequency() void nsWireless::CWE17Driver::SetFrequency (double F) throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::SetFrequency() " << F << std::endl; #endif // NDEBUG m_Req.u.freq.m = unsigned (F * 1e8); m_Req.u.freq.e = 1; #if WIRELESS_EXT > 16 m_Req.u.freq.flags = IW_FREQ_FIXED; #endif Ioctl (SIOCSIWFREQ, CatStringNInt ("Can't set frequency : ", m_Req.u.freq.m)); } // SetFrequency() nsWireless::CEncryptionD nsWireless::CWE17Driver::GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) { #ifndef NDEBUG std::cerr << "CWE17Driver::GetEncryption()" << std::endl; #endif // NDEBUG /* ? FIXME ? The key index is not considered and only the first key is reported. */ char Buffer [IW_ENCODING_TOKEN_MAX]; m_Req.u.data.pointer = reinterpret_cast< ::caddr_t> (Buffer); m_Req.u.data.length = IW_ENCODING_TOKEN_MAX; m_Req.u.data.flags = 0; Ioctl (SIOCGIWENCODE, "Can't get WEP status."); return MakeCEncryption (Buffer, m_Req.u.data.length, m_Req.u.data.flags); } // GetEncryption() void nsWireless::CWE17Driver::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { #ifndef NDEBUG std::cerr << "CWE17Driver::SetEncryption() " << GetAuthName (Descriptor.GetAuth()) << '\t' << GetEncryptName (Descriptor.GetEncrypt()); for (unsigned i (0) ; i < CEncryptionD::MaxNbKey ; ++i) std::cerr << "\n\t" << i << " : " << Descriptor.GetKey (i).GetStr(); std::cerr << std::endl; #endif // NDEBUG if (Descriptor.GetEncrypt() == nsWireless::WEP) { const int AuthFlag (Descriptor.GetAuth() == nsWireless::Shared ? IW_ENCODE_RESTRICTED : IW_ENCODE_OPEN); for (unsigned I (CEncryptionD::MaxNbKey) ; I ; ) { m_Req.u.data.flags = AuthFlag; m_Req.u.data.flags |= I; if (Descriptor.GetKey (--I).Empty()) // Decremented here. { m_Req.u.data.pointer = 0; m_Req.u.data.length = 0; m_Req.u.data.flags |= IW_ENCODE_NOKEY | IW_ENCODE_DISABLED; } else { m_Req.u.data.pointer = const_cast< ::caddr_t> (Descriptor.GetKey (I).Get()); m_Req.u.data.length = Descriptor.GetKey (I).Size(); } Ioctl (SIOCSIWENCODE, CatStringNInt (std::string ("Can't set WEP encryption with key : ") + Descriptor.GetKey (I).GetStr() + " Index : ", I)); } try // Now activate the default key, it may fail because previous { // calls may have already activated it with some driver. m_Req.u.data.pointer = 0; m_Req.u.data.length = 0; m_Req.u.data.flags = AuthFlag | IW_ENCODE_NOKEY | (Descriptor.GetDefaultKey() + 1); Ioctl (SIOCSIWENCODE, "Can't activate default key."); } catch (const nsErrors::CException& Exc) { #ifndef NDEBUG std::cerr << Exc.GetMsg() << ' ' << Exc.GetCode() << std::endl; #endif // NDEBUG } } else { m_Req.u.data.flags = IW_ENCODE_NOKEY | IW_ENCODE_DISABLED; m_Req.u.data.pointer = 0; m_Req.u.data.length = 0; Ioctl (SIOCSIWENCODE, "Can't disable WEP encryption."); } } // SetEncryption() nsWireless::Mode_e nsWireless::CWE17Driver::GetMode () const throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::GetMode()" << std::endl; #endif // NDEBUG Ioctl (SIOCGIWMODE, "Can't get operating mode."); #ifndef NDEBUG std::cerr << "CWE17Driver::GetMode() " << GetModeName (Mode_e (m_Req.u.mode)) << std::endl; #endif // NDEBUG return Mode_e (m_Req.u.mode); } // GetMode() void nsWireless::CWE17Driver::SetMode (Mode_e Mode) throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::SetMode() " << GetModeName (Mode) << std::endl; #endif // NDEBUG m_Req.u.mode = Mode; Ioctl (SIOCSIWMODE, std::string ("Can't set operating mode : ") + GetModeName (Mode)); } // SetMode() nsWireless::CQuality nsWireless::CWE17Driver::GetQuality () const throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::GetQuality()" << std::endl; #endif // NDEBUG ::iw_statistics Stat; m_Req.u.data.pointer = reinterpret_cast < ::caddr_t> (&Stat); m_Req.u.data.length = sizeof (Stat); m_Req.u.data.flags = 0; Ioctl (SIOCGIWSTATS, "Can't get signal quality."); return iw_qualityToCQuality (Stat.qual); } // GetQuality() int nsWireless::CWE17Driver::GetTxRate () const throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::GetTxRate()" << std::endl; #endif // NDEBUG Ioctl (SIOCGIWRATE, "Can't get TX rate."); #ifndef NDEBUG std::cerr << "CWE17Driver::GetTxRate() " << m_Req.u.bitrate.value << std::endl; #endif // NDEBUG return m_Req.u.bitrate.value / TxUnit; } // GetTxRate() void nsWireless::CWE17Driver::SetTxRate (int TxRate) throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::SetTxRate() " << TxRate << std::endl; #endif // NDEBUG m_Req.u.bitrate.value = TxRate * TxUnit; m_Req.u.bitrate.fixed = 0; // Hardware should use auto-select. m_Req.u.bitrate.disabled = 0; m_Req.u.bitrate.flags = 0; Ioctl (SIOCSIWRATE, CatStringNInt ("Can't set TX rate : ", TxRate)); } // SetTxRate() nsWireless::CMacAddress nsWireless::CWE17Driver::GetAPMacAddr () const throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::GetAPMacAddr()" << std::endl; #endif // NDEBUG try {Ioctl (SIOCGIWAP, "Can't get access point Mac address.");} catch (const nsErrors::CSystemExc& Exc) { // I don't consider this an error. #ifndef NDEBUG std::cerr << Exc.GetMsg() << ' ' << Exc.GetCode() << std::endl; #endif // NDEBUG if (Exc.GetCode() == ENOTCONN) return CMacAddress(); throw; } #ifndef NDEBUG std::cerr << "CWE17Driver::GetAPMacAddr() " << std::hex; const unsigned char* const RawData (reinterpret_cast (m_Req.u.ap_addr.sa_data)); for (unsigned i (0) ; i < 6 ; ++i) std::cerr << unsigned (RawData [i]) << ' '; std::cerr << std::dec << std::endl; #endif // NDEBUG return CMacAddress (m_Req.u.ap_addr.sa_data); } // GetAPMacAddr() void nsWireless::CWE17Driver::SetAPMacAddr (const CMacAddress& Addr) throw (std::bad_alloc, nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::SetAPMacAddr() " << Addr.GetStr() << std::endl; #endif // NDEBUG m_Req.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy (m_Req.u.ap_addr.sa_data, Addr.Get(), CMacAddress::Size); Ioctl (SIOCSIWAP, std::string ("Can't set access point Mac address : ") + Addr.GetStr()); } // SetAPMacAddr() void nsWireless::CWE17Driver::Scan () throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::Scan()" << std::endl; #endif // NDEBUG m_Req.u.data.pointer = 0; m_Req.u.data.length = 0; // Full scanning. m_Req.u.data.flags = IW_SCAN_ALL_ESSID | IW_SCAN_ALL_FREQ | IW_SCAN_ALL_MODE | IW_SCAN_ALL_RATE; Ioctl (SIOCSIWSCAN, "Can't trigger scanning."); } // Scan() void nsWireless::CWE17Driver::GetScanResult (std::vector& CellVec) const throw (nsErrors::CException, std::bad_alloc) { #ifndef NDEBUG std::cerr << "CWE17Driver::GetScanResult()" << std::endl; #endif // NDEBUG m_Req.u.data.flags = 0; std::vector Buffer (256); // In iwlist, the starting size is 128. for ( ; ; ) { m_Req.u.data.pointer = reinterpret_cast < ::caddr_t> (&Buffer [0]); m_Req.u.data.length = Buffer.size(); try { Ioctl (SIOCGIWSCAN, "Can't get scan results."); break; } catch (const nsErrors::CSystemExc& Exc) { #ifndef NDEBUG std::cerr << "\n\tCWE17Driver::GetScanResult() failed" << std::endl; #endif // NDEBUG if (Exc.GetCode() == E2BIG) { // If the driver gives the expected size. #ifndef NDEBUG std::cerr << " : Buffer too small" << std::endl; #endif // NDEBUG if (m_Req.u.data.length > Buffer.size()) Buffer.resize (m_Req.u.data.length); // Else double the size. else Buffer.resize (Buffer.size() * 2U); } else throw; } } // Things are MUCH more complicated in iwlib.c... const char* const pEvents (&Buffer [0]); for (unsigned Offset (0) ; Offset < m_Req.u.data.length ; ) Offset += FillCellVec (reinterpret_cast (pEvents + Offset), CellVec); } // GetScanResult() unsigned nsWireless::CWE17Driver::FillCellVec (const ::iw_event* pEvent, std::vector& Vec) const throw (nsErrors::CException) { #ifndef NDEBUG std::cerr << "\n\tEvent : " << std::hex << pEvent->cmd << std::dec; #endif // NDEBUG // Jean Tourrilhes in iwlib.c warns that data may be unaligned. switch (pEvent->cmd) { case SIOCGIWAP : { #ifndef NDEBUG std::cerr << "\n\tSIOCGIWAP : " << std::hex; const unsigned char* const RawData (reinterpret_cast (m_Req.u.ap_addr.sa_data)); for (unsigned i (0) ; i < 6 ; ++i) std::cerr << unsigned (RawData [i]) << ' '; std::cerr << std::dec << std::endl; #endif // NDEBUG Vec.push_back (CCell (CMacAddress (pEvent->u.ap_addr.sa_data))); } break; case SIOCGIWMODE : #ifndef NDEBUG std::cerr << "\n\tSIOCGIWMODE : " << GetModeName (Mode_e (pEvent->u.mode)); #endif // NDEBUG Vec.back().m_Mode = Mode_e (pEvent->u.mode); break; case SIOCGIWESSID : { /* From wireless.h (v19) : iw_point events are special. * First, the payload (extra data) come at the end of the event, * so they are bigger than IW_EV_POINT_LEN. * Second, we omit the pointer, so start at an offset. */ #if WIRELESS_EXT > 18 const unsigned CstLength (reinterpret_cast (reinterpret_cast (&pEvent->u) - sizeof (void*))->length); #else const unsigned CstLength (pEvent->u.essid.length); #endif #ifndef NDEBUG std::cerr << "\n\tSIOCGIWESSID length : " << CstLength << ' '; #endif // NDEBUG if (CstLength) /* From wireless.h (v17) : "Note : in the case of iw_point, * the extra data will come at the end of the event". */ Vec.back().m_SSID = std::string (reinterpret_cast (pEvent) + IW_EV_POINT_LEN, 0, CstLength); #ifndef NDEBUG std::cerr << '#' << Vec.back().GetSSID() << '#'; #endif // NDEBUG } break; case SIOCGIWENCODE : { /* From wireless.h (v19) : iw_point events are special. * First, the payload (extra data) come at the end of the event, * so they are bigger than IW_EV_POINT_LEN. * Second, we omit the pointer, so start at an offset. */ #if WIRELESS_EXT > 18 const unsigned CstLength (reinterpret_cast (reinterpret_cast (&pEvent->u) - sizeof (void*))->length); unsigned Flags (reinterpret_cast (reinterpret_cast (&pEvent->u) - sizeof (void*))->flags); #else const unsigned CstLength (pEvent->u.essid.length); unsigned Flags (pEvent->u.essid.flags); #endif const char* Data (0); if (CstLength) Data = reinterpret_cast (pEvent) + IW_EV_POINT_LEN; else Flags |= IW_ENCODE_NOKEY; #ifndef NDEBUG std::cerr << "\n\tSIOCGIWENCODE length : " << CstLength << " flags : " << Flags;; #endif // NDEBUG Vec.back().m_EncDescriptor = MakeCEncryption (Data, CstLength, Flags); #ifndef NDEBUG std::cerr << "\n\t" << GetAuthName (Vec.back().GetEncryptionD().GetAuth()) << ' ' << GetEncryptName (Vec.back().GetEncryptionD().GetEncrypt()); #endif // NDEBUG } break; case SIOCGIWFREQ : { #ifndef NDEBUG std::cerr << "\n\tSIOCGIWFREQ : " << pEvent->u.freq.m << ' ' << pEvent->u.freq.e << ' ' << pEvent->u.freq.i << ' ' << pEvent->u.freq.flags << std::endl; #endif // NDEBUG if (pEvent->u.freq.m > 1000) Vec.back().m_Channel = GetMatchingFreq (0, iw_freqToDouble (pEvent->u.freq)).GetChannel(); else Vec.back().m_Channel = pEvent->u.freq.m; } break; case IWEVQUAL : #ifndef NDEBUG std::cerr << "\n\tIWEVQUAL"; #endif // NDEBUG Vec.back().m_Quality = iw_qualityToCQuality (pEvent->u.qual); break; case SIOCGIWRATE : #ifndef NDEBUG std::cerr << "\n\tSIOCGIWRATE " << pEvent->u.bitrate.value; #endif // NDEBUG Vec.back().m_Rate = pEvent->u.bitrate.value / TxUnit; break; #ifndef NDEBUG default : std::cerr << " Unknown."; //break; #endif // NDEBUG } #ifndef NDEBUG std::cerr << "\n\tEvent length : " << pEvent->len << std::endl; #endif // NDEBUG return pEvent->len; } // FillCellVec() nsWireless::CFreq nsWireless::CWE17Driver::GetMatchingFreq (unsigned Channel, double Frequency) const throw() { #ifndef NDEBUG std::cerr << "CWE17Driver::GetMatchingFreq() " << Channel << ' ' << Frequency << " : "; #endif // NDEBUG for (unsigned i (m_SupportedFreqVec.size()) ; i-- ; ) if (m_SupportedFreqVec [i].GetChannel() == Channel || m_SupportedFreqVec [i].GetFrequency() == Frequency) { #ifndef NDEBUG std::cerr << "matched.\n"; #endif // NDEBUG return m_SupportedFreqVec [i]; } #ifndef NDEBUG std::cerr << "no match.\n"; #endif // NDEBUG return CFreq (0U, 0.0); } // GetMatchingFreq() double nsWireless::CWE17Driver::GetDriverFreqValue () const throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::GetDriverFreqValue()\n"; #endif // NDEBUG Ioctl (SIOCGIWFREQ, "Can't get frequency/channel."); if (m_Req.u.freq.m > 1000) return iw_freqToDouble (m_Req.u.freq); #ifndef NDEBUG std::cerr << "CWE17Driver::GetDriverFreqValue " << m_Req.u.freq.m << ' ' << m_Req.u.freq.e << ' ' << m_Req.u.freq.i << ' ' << m_Req.u.freq.flags << std::endl; #endif // NDEBUG return -m_Req.u.freq.m; } // GetDriverFreqValue()) unsigned nsWireless::CWE17Driver::GetPrivateIoctls (::iw_priv_args* Tab, unsigned TabSize) throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::GetPrivateIoctls()\n"; #endif // NDEBUG m_Data.data.pointer = reinterpret_cast< ::caddr_t> (Tab); m_Data.data.length = TabSize; m_Data.data.flags = 0; Ioctl (SIOCGIWPRIV, "Can't get private ioctl interface."); return m_Data.data.length; } // GetPrivateIoctl() void nsWireless::CWE17Driver::Commit () throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::Commit()\n"; #endif // NDEBUG m_Data.data.pointer = 0; m_Data.data.length = 0; m_Data.data.flags = 0; Ioctl (SIOCSIWCOMMIT, "Can't commit."); } // Commit() void nsWireless::CWE17Driver::GetSupportedRates (std::vector& RatesVec) const throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "CWE17Driver::GetSupportedRates()\n"; #endif // NDEBUG ::iw_range Range; m_Req.u.data.pointer = reinterpret_cast< ::caddr_t> (&Range); m_Req.u.data.length = sizeof (Range); m_Req.u.data.flags = 0; Ioctl (SIOCGIWRANGE, "Can't get supported rates."); for (unsigned i (0) ; i < Range.num_bitrates ; ++i) RatesVec.push_back (Range.bitrate [i] / TxUnit); std::sort (RatesVec.rbegin(), RatesVec.rend()); #ifndef NDEBUG std::cerr << "Exit CWE17Driver::GetSupportedRates()\n"; #endif // NDEBUG } // GetSupportedRates() RutilTv0.18/lib/src/Parameters.cxx0000644000175000017500000002545710722350737016541 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Parameters.cxx \author Romain BONDUE \date 07/07/2005 */ #include // isxdigit(), toupper() #include // memcpy(), memset(), strcmp() #ifndef NDEBUG #include #endif // NDEBUG #include "Parameters.h" namespace { // Convert 0000 1110 to 'E' for instance (without check). inline unsigned char BitsToHexChar (unsigned char Bits) throw() { return Bits + (Bits < 10 ? '0' : 'A' - 10); } // BitsToHexChar() // Convert 'E' to 0000 1110 for instance (without check). inline unsigned char HexCharToBits (unsigned char HexChar) throw() { HexChar = toupper (HexChar); return HexChar - (HexChar > '9' ? 'A' - 10 : '0'); } // HexCharToBits() const std::string AutoName ("Auto"); const std::string AdHocName ("Ad-Hoc"); const std::string ManagedName ("Managed"); const std::string MasterName ("Master"); const std::string RepeaterName ("Repeater"); const std::string SecondaryName ("Secondary"); const std::string MonitorName ("Monitor"); const std::string UnknownModeNTCTS ("Unknown mode"); const std::string NoneName ("NONE"); const std::string WEPName ("WEP"); const std::string AESName ("AES"); const std::string TKIPName ("TKIP"); const std::string TKIPAESName ("TKIP, AES"); const std::string UnknownEncryptNTCTS ("UNKNOWN"); const std::string OpenName ("OPEN"); const std::string SharedName ("SHARED"); const std::string WPAPSKName ("WPAPSK"); const std::string WPANONEName ("WPANONE"); const std::string WPA2PSKName ("WPA2PSK"); const std::string WPAName ("WPA"); const std::string WPA2Name ("WPA2"); const std::string UnknownAuthNTCTS ("UNKNOWN"); } // anonymous namespace bool nsWireless::CMacAddress::Empty () const throw() { if (CHexaKey::Empty()) return true; const std::string& Str (GetStr()); std::string::size_type i (0); while (i < Str.size() && Str [i] == '0') ++i; return i == Str.size(); } // Empty() const std::string& nsWireless::GetModeName (Mode_e Mode) throw() { switch (Mode) { case Auto : return AutoName; case AdHoc : return AdHocName; case Managed : return ManagedName; case Master : return MasterName; case Repeater : return RepeaterName; case Secondary : return SecondaryName; case Monitor : return MonitorName; default : return UnknownModeNTCTS; } } // GetModeName() nsWireless::Mode_e nsWireless::GetModeFromName (const std::string& Mode) throw() { if (Mode == AutoName) return Auto; if (Mode == AdHocName) return AdHoc; if (Mode == ManagedName) return Managed; if (Mode == MasterName) return Master; if (Mode == RepeaterName) return Repeater; if (Mode == SecondaryName) return Secondary; if (Mode == MonitorName) return Monitor; return Unknown; } // GetModeFromName() const std::string& nsWireless::GetEncryptName (EncryptType_e Encrypt) throw() { switch (Encrypt) { case None : return NoneName; case WEP : return WEPName; case AES : return AESName; case TKIP : return TKIPName; case TKIPAES : return TKIPAESName; default : return UnknownEncryptNTCTS; } } // GetEncryptName() nsWireless::EncryptType_e nsWireless::GetEncryptFromName (const std::string& Name) throw() { if (Name == WEPName) return WEP; if (Name == NoneName) return None; if (Name == TKIPName) return TKIP; if (Name == AESName) return AES; if (Name == TKIPAESName) return TKIPAES; return UnknownEnc; } // GetEncryptFromName() const std::string& nsWireless::GetAuthName (AuthType_e Auth) throw() { switch (Auth) { case Open : return OpenName; case Shared : return SharedName; case WPAPSK : return WPAPSKName; case WPANONE : return WPANONEName; case WPA2PSK : return WPA2PSKName; case WPA : return WPAName; case WPA2 : return WPA2Name; default : return UnknownAuthNTCTS; } } // GetAuthName() nsWireless::AuthType_e nsWireless::GetAuthFromName (const std::string& Name) throw() { if (Name == OpenName) return Open; if (Name == SharedName) return Shared; if (Name == WPAPSKName) return WPAPSK; if (Name == WPANONEName) return WPANONE; if (Name == WPA2PSKName) return WPA2PSK; if (Name == WPAName) return WPA; if (Name == WPA2Name) return WPA2; return UnknownAuth; } // GetAuthFromName() nsWireless::CHexaKey& nsWireless::CHexaKey::operator = (const CHexaKey& Key) throw (std::bad_alloc) { if (this == &Key) return *this; Set (Key.m_Key, Key.m_Size); m_StrKey = Key.m_StrKey; return *this; } // operator = () void nsWireless::CHexaKey::Set (const char* Key, unsigned Size) throw (std::bad_alloc) { if (Key) { m_StrKey.erase(); if (!Size) { delete[] m_Key; m_Key = 0; } else if (m_Size < Size) { delete[] m_Key; try{m_Key = new char [Size];} catch (const std::bad_alloc&) { m_Key = 0; m_Size = 0; throw; } } memcpy (m_Key, Key, Size); m_Size = Size; } } // Set() void nsWireless::CHexaKey::Set (std::string Key) throw (CBadFormatExc) { for (std::string::size_type i (Key.size()) ; i-- ; ) if (Key [i] == '-' || Key [i] == ':' || Key [i] == ' ') Key.erase (i, 1); else if (!isxdigit (static_cast (Key[i]))) { #ifndef NDEBUG std::cerr << "Bad format, key : #" << Key << "# byte " << i << " is not an hexadecimal digit." << std::endl; #endif // NDEBUG throw CBadFormatExc(); } else Key [i] = toupper (static_cast (Key[i])); if (Key.empty()) { #ifndef NDEBUG std::cerr << "Bad format, key : #" << Key << "# is empty." << std::endl; #endif // NDEBUG throw CBadFormatExc(); } m_Size = 0; delete[] m_Key; m_Key = 0; m_StrKey = Key; } // Set() void nsWireless::CHexaKey::SetFromASCII (const std::string& Key) throw (std::bad_alloc) { m_StrKey.erase(); if (m_Size < Key.size()) { delete[] m_Key; try{m_Key = new char [Key.size()];} catch (const std::bad_alloc&) { m_Key = 0; m_Size = 0; throw; } } m_Size = Key.size(); Key.copy (m_Key, m_Size); } // SetFromASCII() void nsWireless::CHexaKey::Clear () throw() { m_Size = 0; delete[] m_Key; m_Key = 0; m_StrKey.erase(); } // Clear() const std::string& nsWireless::CHexaKey::GetStr () const throw() { if (m_StrKey.empty() && m_Size) { /* 4 bits (1/2 byte) are represented with 1 hexadecimal * digit (1 byte). */ m_StrKey.reserve (m_Size * 2); for (unsigned i (0) ; i < m_Size ; ++i) { // This code assume sizeof (char) == 1. m_StrKey.push_back (BitsToHexChar (static_cast (m_Key [i]) >> 4)); m_StrKey.push_back (BitsToHexChar (m_Key [i] & 0x0F)); } } return m_StrKey; } // GetStr() const char* nsWireless::CHexaKey::Get () const throw (std::bad_alloc) { if (!m_Size && !m_StrKey.empty()) { m_Size = Size(); try{m_Key = new char [m_Size];} catch (const std::bad_alloc&) { m_Key = 0; m_Size = 0; throw; } memset (m_Key, 0, m_Size); for (std::string::size_type i (0) ; i < m_StrKey.size() ; ++i) m_Key [i / 2] |= HexCharToBits (m_StrKey [i]) << (i & 1 ? 0 : 4); } return m_Key; } // Get() bool nsWireless::CHexaKey::operator == (const CHexaKey& Key) const throw() { if (m_Size && Key.m_Size) { if (m_Size != Key.m_Size) return false; for (unsigned i (0) ; i < m_Size ; ++i) if (m_Key [i] != Key.m_Key [i]) return false; return true; } return GetStr() == Key.GetStr(); } // operator == () nsWireless::CEncryptionD& nsWireless::CEncryptionD::operator = (const CEncryptionD& D) throw (std::bad_alloc) { if (&D == this) return *this; m_Auth = D.m_Auth; m_Encrypt = D.m_Encrypt; m_DefaultKey = D.m_DefaultKey; for (unsigned I (0) ; I < MaxNbKey ; ++I) m_KeyTab [I] = D.m_KeyTab [I]; return *this; } // operator = () bool nsWireless::CEncryptionD::operator == (const CEncryptionD& D) const throw() { if (m_Auth == D.m_Auth && m_Encrypt == D.m_Encrypt || m_Encrypt == nsWireless::TKIPAES && (D.m_Encrypt == nsWireless::TKIP || D.m_Encrypt == nsWireless::AES) || D.m_Encrypt == nsWireless::TKIPAES && (m_Encrypt == nsWireless::TKIP || m_Encrypt == nsWireless::AES)) { for (unsigned I (0) ; I < MaxNbKey ; ++I) if (m_KeyTab [I] != D.m_KeyTab [I]) return false; return true; } return false; } // operator == () nsWireless::CCell::CCell (const CMacAddress& Addr, Mode_e Mode, const std::string& SSID, const CEncryptionD& Descriptor, unsigned Channel, const CQuality& Quality, unsigned Rate) throw (std::bad_alloc) : m_APAddr (Addr), m_Mode (Mode), m_SSID (SSID), m_EncDescriptor (Descriptor), m_Channel (Channel), m_Quality (Quality), m_Rate (Rate) {} RutilTv0.18/lib/src/CLIOpt.cxx0000644000175000017500000000772710543033310015512 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CLIOpt.cxx \author Romain BONDUE \date 29/10/2006 */ #include // strcmp() #include "CLIOpt.h" #include "ErrorsCode.h" nsCore::CCLIOpt::CCLIOpt (int argc, char* argv []) throw (nsErrors::CException) : m_Flags (None) { if (argc > 1) { int I (1); if (argv [I] [0] != '-') m_IfaceName = argv [I++]; for ( ; I < argc ; ++I) { if (argv [I] [0] != '-') throw nsErrors::CException (std::string ("Invalid argument : ") + argv [I], nsErrors::InvalidArguments); if (argv [I] [1] == '-') { if (ParseLongOption (argv [I] + 2) == ProfileFlag) { if (++I < argc) m_ProfileName = argv [I]; else throw nsErrors::CException ("Missing profile name.", nsErrors::InvalidArguments); } } else { if (ParseShortOption (argv [I] + 1) == ProfileFlag) { if (++I < argc) m_ProfileName = argv [I]; else throw nsErrors::CException ("Missing profile name.", nsErrors::InvalidArguments); } } } } } // CCLIOpt() int nsCore::CCLIOpt::ParseShortOption (const char* Options) throw (nsErrors::CException) { int LastFlag (None); for ( ; *Options ; ++Options) switch (*Options) { case 'h' : m_Flags |= HelpFlag; LastFlag = HelpFlag; break; case 'v' : m_Flags |= VersionFlag; LastFlag = VersionFlag; break; case 't' : m_Flags |= HiddenFlag; LastFlag = HiddenFlag; break; case 'e' : m_Flags |= ExitFlag; LastFlag = ExitFlag; break; case 'd' : m_Flags |= DhcpFlag; LastFlag = DhcpFlag; break; case 'p' : m_Flags |= ProfileFlag; LastFlag = ProfileFlag; break; } return LastFlag; } // ParseShortOption() int nsCore::CCLIOpt::ParseLongOption (const char* Options) throw (nsErrors::CException) { if (!std::strcmp (Options, "help")) { m_Flags |= HelpFlag; return HelpFlag; } if (!std::strcmp (Options, "version")) { m_Flags |= VersionFlag; return VersionFlag; } if (!std::strcmp (Options, "hide")) { m_Flags |= HiddenFlag; return HiddenFlag; } if (!std::strcmp (Options, "exit")) { m_Flags |= ExitFlag; return ExitFlag; } if (!std::strcmp (Options, "dhcp")) { m_Flags |= DhcpFlag; return DhcpFlag; } if (!std::strcmp (Options, "profile")) { m_Flags |= ProfileFlag; return ProfileFlag; } return None; } // ParseLongOption() RutilTv0.18/lib/src/IfaceMsgHandler.cxx0000644000175000017500000000322110543033310017355 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file IfaceMsgHandler.cxx \author Romain BONDUE \date 09/06/2006 */ #include "IfaceMsgHandler.h" #include "IfaceProtocolCodes.h" #include "ErrorsCode.h" nsRoot::CMsg nsRoot::CIfaceMsgHandler::operator () (const CMsg& Msg) throw (nsErrors::CException, std::bad_alloc) { switch (Msg.GetCode()) { case nsNet::DeviceNameC : m_Iface.SetName (Msg.GetText()); break; case nsNet::DhcpC : m_Iface.SetIPFromDHCP (Msg.GetText()); break; case nsNet::StaticIpC : //m_Iface.SetIP (); TODO break; case nsNet::UpC : m_Iface.Up(); break; case nsNet::DownC : m_Iface.Down(); break; default : throw nsErrors::CException ("Unknown command.", nsErrors::InvalidCommand); } return CMsg(); } // operator ()() RutilTv0.18/lib/src/RTDriversRoot.cxx0000644000175000017500000001654410636002145017152 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTDriversRoot.cxx \author Romain BONDUE \date 21/02/2006 */ #include "RTDriversRoot.h" #include "RTSuWProtocolCodes.h" nsWireless::CRT2400DriverRoot::CRT2400DriverRoot (const std::string& DeviceName) throw (nsErrors::CException, std::bad_alloc) : CRT2400Driver (DeviceName), CSuWProtocol (RT2400Handler, DeviceName) {} nsWireless::CRT2500DriverRoot::CRT2500DriverRoot (const std::string& DeviceName) throw (nsErrors::CException, std::bad_alloc) : CRT2500Driver (DeviceName), CSuWProtocol (RT2500Handler, DeviceName) {} nsWireless::CRT2570DriverRoot::CRT2570DriverRoot (const std::string& DeviceName) throw (nsErrors::CException, std::bad_alloc) : CRT2570Driver (DeviceName), CSuWProtocol (RT2570Handler, DeviceName) {} nsWireless::CRT61DriverRoot::CRT61DriverRoot (const std::string& DeviceName) throw (nsErrors::CException, std::bad_alloc) : CRT61Driver (DeviceName), CSuWProtocol (RT61Handler, DeviceName) {} nsWireless::CRT73DriverRoot::CRT73DriverRoot (const std::string& DeviceName) throw (nsErrors::CException, std::bad_alloc) : CRT73Driver (DeviceName), CSuWProtocol (RT73Handler, DeviceName) {} void nsWireless::CRT2500DriverRoot::SetWirelessMode (WirelessMode_e Mode) throw (nsErrors::CSystemExc) { SuDo (Mode, WModeC); SetFlag (IsB_Only, Mode == B_Only); } // SetWirelessMode() void nsWireless::CRT2500DriverRoot::SetTxBurst (bool TxBurstStatus) throw (nsErrors::CSystemExc) { SuDo (TxBurstStatus, TxBurstC); SetFlag (TxBurst, TxBurstStatus); } // SetTxBurst() void nsWireless::CRT2500DriverRoot::SetBGProtection (BGProtection_e BGProtection) throw (nsErrors::CSystemExc) { SuDo (BGProtection, BGProtectionC); SetBGProtectionFlag (BGProtection); } // SetBGProtection() void nsWireless::CRT2500DriverRoot::SetTxPreamble (TxPreamble_e TxPreamble) throw (nsErrors::CSystemExc) { SuDo (TxPreamble, TxPreambleC); SetTxPreambleFlag (TxPreamble); } // SetTxPreamble() void nsWireless::CRT2500DriverRoot::SetTurboRate (bool TurboRateState) throw (nsErrors::CSystemExc) { SuDo (TurboRateState, TurboRateC); SetFlag (TurboRate, TurboRateState); } // SetTurboRate() void nsWireless::CRT2500DriverRoot::SetAdHocOFDM (bool AdHocOFDMStatus) throw (nsErrors::CSystemExc) { SuDo (AdHocOFDMStatus, AdHocOFDMC); SetFlag (AdHocOFDM, AdHocOFDMStatus); } // SetAdHocOFDM() void nsWireless::CRT2500DriverRoot::SetRfmontx (bool RfmonTxStatus) throw (nsErrors::CSystemExc) { SuDo (RfmonTxStatus, RfmontxC); SetFlag (Rfmontx, RfmonTxStatus); } // SetRfmontx() void nsWireless::CRT61DriverRoot::SetWirelessMode (WirelessMode_e Mode) throw (nsErrors::CSystemExc) { SuDo (Mode, WModeC); SetFlag (IsB_Only, Mode == B_Only); } // SetWirelessMode() void nsWireless::CRT61DriverRoot::SetTxBurst (bool TxBurstStatus) throw (nsErrors::CSystemExc) { SuDo (TxBurstStatus, TxBurstC); SetFlag (TxBurst, TxBurstStatus); } // SetTxBurst() void nsWireless::CRT61DriverRoot::SetBGProtection (BGProtection_e BGProtection) throw (nsErrors::CSystemExc) { SuDo (BGProtection, BGProtectionC); SetBGProtectionFlag (BGProtection); } // SetBGProtection() void nsWireless::CRT61DriverRoot::SetTxPreamble (TxPreamble_e TxPreamble) throw (nsErrors::CSystemExc) { SuDo (TxPreamble, TxPreambleC); SetTxPreambleFlag (TxPreamble); } // SetTxPreamble() void nsWireless::CRT61DriverRoot::SetTurboRate (bool TurboRateState) throw (nsErrors::CSystemExc) { SuDo (TurboRateState, TurboRateC); SetFlag (TurboRate, TurboRateState); } // SetTurboRate() void nsWireless::CRT61DriverRoot::SetAdHocOFDM (bool AdHocOFDMState) throw (nsErrors::CSystemExc) { SuDo (AdHocOFDMState, AdHocOFDMC); SetFlag (AdHocOFDM, AdHocOFDMState); } // SetAdHocOFDM() void nsWireless::CRT61DriverRoot::SetRfmontx (bool RfmonTxStatus) throw (nsErrors::CSystemExc) { SuDo (RfmonTxStatus, RfmontxC); SetFlag (Rfmontx, RfmonTxStatus); } // SetRfmontx() void nsWireless::CRT73DriverRoot::SetWirelessMode (WirelessMode_e Mode) throw (nsErrors::CSystemExc) { SuDo (Mode, WModeC); SetFlag (IsB_Only, Mode == B_Only); } // SetWirelessMode() void nsWireless::CRT73DriverRoot::SetTxBurst (bool TxBurstStatus) throw (nsErrors::CSystemExc) { SuDo (TxBurstStatus, TxBurstC); SetFlag (TxBurst, TxBurstStatus); } // SetTxBurst() void nsWireless::CRT73DriverRoot::SetBGProtection (BGProtection_e BGProtection) throw (nsErrors::CSystemExc) { SuDo (BGProtection, BGProtectionC); SetBGProtectionFlag (BGProtection); } // SetBGProtection() void nsWireless::CRT73DriverRoot::SetTxPreamble (TxPreamble_e TxPreamble) throw (nsErrors::CSystemExc) { SuDo (TxPreamble, TxPreambleC); SetTxPreambleFlag (TxPreamble); } // SetTxPreamble() void nsWireless::CRT73DriverRoot::SetTurboRate (bool TurboRateState) throw (nsErrors::CSystemExc) { SuDo (TurboRateState, TurboRateC); SetFlag (TurboRate, TurboRateState); } // SetTurboRate() void nsWireless::CRT73DriverRoot::SetAdHocOFDM (bool AdHocOFDMState) throw (nsErrors::CSystemExc) { SuDo (AdHocOFDMState, AdHocOFDMC); SetFlag (AdHocOFDM, AdHocOFDMState); } // SetAdHocOFDM() void nsWireless::CRT73DriverRoot::SetRfmontx (bool RfmonTxStatus) throw (nsErrors::CSystemExc) { SuDo (RfmonTxStatus, RfmontxC); SetFlag (Rfmontx, RfmonTxStatus); } // SetRfmontx() RutilTv0.18/lib/src/WWidgets.cxx0000644000175000017500000003451410712653525016165 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file WWidgets.cxx \author Romain BONDUE \date 31/03/2006 */ #include // isxdigit() #include "WWidgets.h" namespace { ::GtkWidget* LabelWidget (::GtkWidget* pWidget, const char* Label) throw() { ::GtkBox* const pHBox (GTK_BOX (::gtk_hbox_new (false, 2))); ::gtk_box_pack_start_defaults (pHBox, ::gtk_label_new (Label)); ::gtk_box_pack_start_defaults (pHBox, pWidget); return GTK_WIDGET (pHBox); } // LabelWidget() inline bool IsDisplayable (char C) throw() { return !(C & 0x80) && C >= ' '; } // IsDisplayable() } // anonymous namespace nsGUI::CKeyEntry::CKeyEntry () throw() : m_pEntry (GTK_ENTRY (::gtk_entry_new())), m_pIsASCIIButton (GTK_TOGGLE_BUTTON (::gtk_check_button_new_with_label ("ASCII Key"))), m_pBox (GTK_BOX (::gtk_vbox_new (false, 2))) { ::g_signal_connect (G_OBJECT (m_pEntry), "insert-text", G_CALLBACK (NewTextTyped), this); ::g_signal_connect (G_OBJECT (m_pIsASCIIButton), "toggled", G_CALLBACK (ASCIIButtonToggled), this); ::gtk_box_pack_start_defaults (m_pBox, GTK_WIDGET (m_pEntry)); ::gtk_box_pack_start_defaults (m_pBox, GTK_WIDGET (m_pIsASCIIButton)); } // CKeyEntry() void nsGUI::CKeyEntry::NewTextTyped (::GtkEditable* pEditable, char* NewText, int Length, int* pNewPos, CKeyEntry* This) throw() { if (!::gtk_toggle_button_get_active (This->m_pIsASCIIButton) && !std::isxdigit (static_cast (*NewText))) ::g_signal_stop_emission_by_name (pEditable, "insert-text"); } // NewTextTyped() void nsGUI::CKeyEntry::ASCIIButtonToggled (::GtkToggleButton*, CKeyEntry* This) throw() { if (!::gtk_toggle_button_get_active (This->m_pIsASCIIButton)) for (const char* KeyStr (::gtk_entry_get_text (This->m_pEntry)) ; *KeyStr ; ++KeyStr) if (!std::isxdigit (static_cast (*KeyStr))) { This->Clear(); break; } } // ASCIIButtonToggled() void nsGUI::CKeyEntry::Set (const nsWireless::CHexaKey& Key) throw() { if (Key.Empty()) Clear(); else { for (unsigned I (0) ; I < Key.Size() ; ++I) if (!IsDisplayable (Key.Get() [I])) { ::gtk_toggle_button_set_active (m_pIsASCIIButton, false); ::gtk_entry_set_text (m_pEntry, Key.GetStr().c_str()); return; } ::gtk_toggle_button_set_active (m_pIsASCIIButton, true); ::gtk_entry_set_text (m_pEntry, std::string (Key.Get(), 0, Key.Size()).c_str()); } } // Set() nsWireless::CHexaKey nsGUI::CKeyEntry::Get () const throw() { nsWireless::CHexaKey Key; // The CBadFormatExc is occulted here... const char* EntryValue (::gtk_entry_get_text (m_pEntry)); if (*EntryValue) // Not Empty { if (::gtk_toggle_button_get_active (m_pIsASCIIButton)) Key.SetFromASCII (EntryValue); else Key.Set (EntryValue); } return Key; } // Get() nsGUI::CConfigDialog::CConfigDialog (const nsWireless::Mode_e* ModeTab, unsigned TabModeSize, const std::vector& FreqVec, const nsWireless::EncryptType_e* EncTab, unsigned EncTabSize, const nsWireless::AuthType_e* AuthTab, unsigned AuthTabSize) throw (std::bad_alloc) : m_pDialog (GTK_DIALOG (::gtk_dialog_new_with_buttons (0, 0, ::GtkDialogFlags (0), GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, static_cast (0)))), m_pNameEntry (GTK_ENTRY (::gtk_entry_new())), m_pSSIDEntry (GTK_ENTRY (::gtk_entry_new())), m_ModeBox (ModeTab, TabModeSize), m_EncryptBox (EncTab, EncTabSize), m_AuthBox (AuthTab, AuthTabSize), m_pIPNoneButton (GTK_RADIO_BUTTON (::gtk_radio_button_new_with_label (0, "Disabled"))), m_pIPDhcpButton (GTK_RADIO_BUTTON (::gtk_radio_button_new_with_label_from_widget (m_pIPNoneButton, "Automatic (DHCP)"))), m_pIPStaticButton (GTK_RADIO_BUTTON (::gtk_radio_button_new_with_label_from_widget (m_pIPNoneButton, "Manual (Might be for a future release.)"))) { SetAvailableChannel (FreqVec); BuildUI(); } // CConfigDialog() nsGUI::CConfigDialog::CConfigDialog (const nsWireless::Mode_e* ModeTab, unsigned TabModeSize, const nsWireless::EncryptType_e* EncTab, unsigned EncTabSize, const nsWireless::AuthType_e* AuthTab, unsigned AuthTabSize) throw (std::bad_alloc) : m_ChannelTab (0), m_ChannelTabSize (0), m_pDialog (GTK_DIALOG (::gtk_dialog_new_with_buttons (0, 0, ::GtkDialogFlags (0), GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, static_cast (0)))), m_pNameEntry (GTK_ENTRY (::gtk_entry_new())), m_pSSIDEntry (GTK_ENTRY (::gtk_entry_new())), m_ModeBox (ModeTab, TabModeSize), m_EncryptBox (EncTab, EncTabSize), m_AuthBox (AuthTab, AuthTabSize), m_pIPNoneButton (GTK_RADIO_BUTTON (::gtk_radio_button_new_with_label (0, "Disabled"))), m_pIPDhcpButton (GTK_RADIO_BUTTON (::gtk_radio_button_new_with_label_from_widget (m_pIPNoneButton, "Automatic (DHCP)"))), m_pIPStaticButton (GTK_RADIO_BUTTON (::gtk_radio_button_new_with_label_from_widget (m_pIPNoneButton, "Manual (Might be for a future release.)"))) { BuildUI(); } // CConfigDialog() nsGUI::CConfigDialog::~CConfigDialog () throw() { ::gtk_widget_destroy (GTK_WIDGET (m_pDialog)); delete[] m_ChannelTab; } // CConfigDialog() void nsGUI::CConfigDialog::BuildUI () throw() { ::gtk_window_set_resizable (GTK_WINDOW (m_pDialog), false); // There's 2 unused rows, they're just here to make a blank space. ::GtkTable* const pTable (GTK_TABLE (::gtk_table_new (6, 2, false))); ::gtk_container_set_border_width (GTK_CONTAINER (pTable), 5); ::gtk_table_set_row_spacings (pTable, 6); ::gtk_table_set_col_spacings (pTable, 12); ::gtk_table_attach_defaults (pTable, LabelWidget (GTK_WIDGET (m_pNameEntry), "Name"), 0, 1, 0, 1); ::gtk_table_attach_defaults (pTable, LabelWidget (GTK_WIDGET (m_pSSIDEntry), "SSID"), 1, 2, 0, 1); ::gtk_table_attach_defaults (pTable, LabelWidget (m_ModeBox, "Mode"), 0, 1, 1, 2); ::gtk_table_attach_defaults (pTable, LabelWidget (m_ChannelBox, "Channel"), 1, 2, 1, 2); ::gtk_table_attach_defaults (pTable, LabelWidget (m_AuthBox, "Authentication"), 0, 1, 4, 5); ::gtk_table_attach_defaults (pTable, LabelWidget (m_EncryptBox, "Encryption"), 1, 2, 4, 5); ::gtk_table_attach_defaults (pTable, m_MultiKey, 0, 2, 5, 6); ::GtkNotebook* const pNoteBook (GTK_NOTEBOOK (::gtk_notebook_new())); ::gtk_notebook_append_page (pNoteBook, GTK_WIDGET (pTable), ::gtk_label_new ("Wireless settings")); ::GtkBox* const pBox (GTK_BOX (::gtk_vbox_new (false, 2))); ::gtk_box_pack_start_defaults (pBox, GTK_WIDGET (m_pIPNoneButton)); ::gtk_box_pack_start_defaults (pBox, GTK_WIDGET (m_pIPDhcpButton)); ::gtk_box_pack_start_defaults (pBox, GTK_WIDGET (m_pIPStaticButton)); // TODO Remove this line and do the rest of the work : ::gtk_widget_set_sensitive (GTK_WIDGET (m_pIPStaticButton), false); ::gtk_notebook_append_page (pNoteBook, GTK_WIDGET (pBox), ::gtk_label_new ("IP settings")); ::gtk_box_pack_start_defaults (GetBox(), GTK_WIDGET (pNoteBook)); } // BuildUI() void nsGUI::CConfigDialog::SetAvailableChannel (const std::vector& FreqVec) throw (std::bad_alloc) { m_ChannelTabSize = FreqVec.size(); m_ChannelTab = new unsigned [m_ChannelTabSize]; for (unsigned I (0) ; I < m_ChannelTabSize ; ++I) m_ChannelTab [I] = FreqVec [I].GetChannel(); m_ChannelBox.SetElem (m_ChannelTab, m_ChannelTabSize); } // SetAvailableChannel() nsGUI::CSharedConfigDialog::CSharedConfigDialog (const nsWireless::Mode_e* TabMode, unsigned TabModeSize, const std::vector& FreqVec, const nsWireless::AuthType_e* AuthTab, unsigned AuthTabSize, const nsWireless::EncryptType_e* EncTab1, unsigned EncTabSize1, const nsWireless::EncryptType_e* EncTab2, unsigned EncTabSize2, const nsWireless::EncryptType_e* EncTab3, unsigned EncTabSize3) throw (std::bad_alloc) : CConfigDialog (TabMode, TabModeSize, FreqVec, EncTab1, EncTabSize1, AuthTab, AuthTabSize), m_AuthTabSize (AuthTabSize), m_AuthTab (AuthTab), m_EncryptTabSize1 (EncTabSize1), m_EncTab1 (EncTab1), m_EncryptTabSize2 (EncTabSize2), m_EncTab2 (EncTab2), m_EncryptTabSize3 (EncTabSize3), m_EncTab3 (EncTab3) { ::g_signal_connect (G_OBJECT (GetAuthBox().operator ::GtkWidget*()), "changed", G_CALLBACK (AuthButtonCallBack), this); ::g_signal_connect (G_OBJECT (GetEncryptBox().operator ::GtkWidget*()), "changed", G_CALLBACK (EncryptButtonCallBack), this); } // CSharedConfigDialog() nsGUI::CSharedConfigDialog::CSharedConfigDialog (const nsWireless::Mode_e* TabMode, unsigned TabModeSize, const nsWireless::AuthType_e* AuthTab, unsigned AuthTabSize, const nsWireless::EncryptType_e* EncTab1, unsigned EncTabSize1, const nsWireless::EncryptType_e* EncTab2, unsigned EncTabSize2, const nsWireless::EncryptType_e* EncTab3, unsigned EncTabSize3) throw (std::bad_alloc) : CConfigDialog (TabMode, TabModeSize, EncTab1, EncTabSize1, AuthTab, AuthTabSize), m_AuthTabSize (AuthTabSize), m_AuthTab (AuthTab), m_EncryptTabSize1 (EncTabSize1), m_EncTab1 (EncTab1), m_EncryptTabSize2 (EncTabSize2), m_EncTab2 (EncTab2), m_EncryptTabSize3 (EncTabSize3), m_EncTab3 (EncTab3) { ::g_signal_connect (G_OBJECT (GetAuthBox().operator ::GtkWidget*()), "changed", G_CALLBACK (AuthButtonCallBack), this); ::g_signal_connect (G_OBJECT (GetEncryptBox().operator ::GtkWidget*()), "changed", G_CALLBACK (EncryptButtonCallBack), this); } // CSharedConfigDialog() void nsGUI::CSharedConfigDialog::EncryptButtonCallBack (::GtkToggleButton* pButton, CSharedConfigDialog* This) throw() { if (This->GetEncryptBox().GetActive() != nsWireless::None) { ::gtk_widget_set_sensitive (This->GetMultiKey(), true); This->GetMultiKey().AdditionnalKeyAvailable ( This->GetEncryptBox().GetActive() == nsWireless::WEP); This->GetMultiKey().GetKeyEntry (0).ASCIIOnly ( This->GetEncryptBox().GetActive() != nsWireless::WEP); } else { ::gtk_widget_set_sensitive (This->GetMultiKey(), false); This->ClearKeyEntry(); } } // EncryptButtonCallBack() void nsGUI::CSharedConfigDialog::AuthButtonCallBack (::GtkToggleButton*, CSharedConfigDialog* This) throw() { This->ClearKeyEntry(); switch (This->GetAuthBox().GetActiveRow()) { case 0 : This->SetEncryptBox (This->m_EncTab1, This->m_EncryptTabSize1); break; case 1 : This->SetEncryptBox (This->m_EncTab2, This->m_EncryptTabSize2); break; default : This->SetEncryptBox (This->m_EncTab3, This->m_EncryptTabSize3); //break; } } // AuthButtonCallBack() RutilTv0.18/lib/src/SuWProtocol.cxx0000644000175000017500000001131010602753211016644 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file SuWProtocol.cxx \author Romain BONDUE \date 07/01/2006 */ #include #include "SuWProtocol.h" #include "SuWProtocolCodes.h" #include "ErrorsCode.h" nsWireless::CSuWProtocol::CSuWProtocol (const std::string& RemoteHandlerName, const std::string& DeviceName) throw (nsErrors::CSystemExc, std::bad_alloc) : m_Su (RemoteHandlerName) { SuDo (nsRoot::CMsg (DeviceName, DeviceNameC)); } // CSuWProtocol() void nsWireless::CSuWProtocol::SetSSID (const std::string& SSID) throw (nsErrors::CSystemExc) { SuDo (nsRoot::CMsg (SSID, SSIDC)); } // SetSSID() void nsWireless::CSuWProtocol::SetFrequency (double Frequency) throw (nsErrors::CSystemExc) { SuDo (Frequency, FrequencyC); } // SetFrequency() void nsWireless::CSuWProtocol::SetChannel (unsigned Channel) throw (nsErrors::CSystemExc) { SuDo (Channel, ChannelC); } // SetChannel() nsWireless::CEncryptionD nsWireless::CSuWProtocol::GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) { try { std::istringstream Is (SuDo (nsRoot::CMsg ("", GEncryptionC)).GetText()); Is.exceptions (std::ios_base::failbit | std::ios_base::badbit); int Encrypt; // Can't be EncryptType_e because of the extractor. int Auth; // Ditto. std::string Key; Is >> Encrypt >> Auth; Is.ignore(); // The separator. getline (Is, Key); return CEncryptionD (Key.empty() ? CHexaKey() : CHexaKey (Key), AuthType_e (Auth), EncryptType_e (Encrypt)); } catch (...) // Whatever happens, drop everything. { throw nsErrors::CSystemExc ("Invalid data read.", nsErrors::InvalidData); } } // GetEncryption() void nsWireless::CSuWProtocol::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { std::ostringstream Os; Os << Descriptor.GetEncrypt() << ' ' << Descriptor.GetAuth() << ' ' << Descriptor.GetDefaultKey() << ' '; for (unsigned I (0) ; I < CEncryptionD::MaxNbKey ; ++I) Os << Descriptor.GetKey (I).GetStr() << '\n'; SuDo (Os.str(), SEncryptionC); } // SetEncryption() void nsWireless::CSuWProtocol::SetMode (Mode_e Mode) throw (nsErrors::CSystemExc) { SuDo (Mode, ModeC); } // SetMode() void nsWireless::CSuWProtocol::SetTxRate (int TxRate) throw (nsErrors::CSystemExc) { SuDo (TxRate, TxRateC); } // SetTxRate() void nsWireless::CSuWProtocol::SetAPMacAddr (const CMacAddress& Address) throw (nsErrors::CSystemExc, std::bad_alloc) { SuDo (nsRoot::CMsg (Address.GetStr(), ApMacAddrC)); } // SetAPMacAddr() void nsWireless::CSuWProtocol::Scan () throw (nsErrors::CSystemExc) { SuDo (nsRoot::CMsg ("", ScanC)); } // Scan() nsRoot::CMsg nsWireless::CSuWProtocol::SuDo (const nsRoot::CMsg& Msg) throw (nsErrors::CSystemExc) { try { const nsRoot::CMsg ReturnedMsg (m_Su.Do (Msg)); if (ReturnedMsg.GetCode()) throw nsErrors::CSystemExc (ReturnedMsg.GetText(), ReturnedMsg.GetCode()); return ReturnedMsg; } catch (const nsErrors::CException& Exc) { throw nsErrors::CSystemExc (Exc.GetMsg(), Exc.GetCode()); } catch (const std::bad_alloc& Exc) { throw nsErrors::CSystemExc (Exc.what(), nsErrors::OutOfMemory); } } // SuDo() void nsWireless::CSuWProtocol::Commit () throw (nsErrors::CSystemExc) { SuDo (nsRoot::CMsg ("", CommitC)); } // Scan() RutilTv0.18/lib/src/UserData.cxx0000644000175000017500000003171311054621101016117 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file UserData.cxx \author Romain BONDUE \date 03/08/2005 */ #ifndef NDEBUG #include #endif // NDEBUG #include #include #include // getenv() #include // strcmp(), strlen() #include // isspace() #include extern "C"{ #include #include // ::chmod() #include } #include "UserData.h" #include "StaticSettings.h" #include "ErrorsCode.h" namespace { const char* const RootMarkupLabel ("Rutilt_Profiles"); const char* const ProfileName ("Name"); const char* const ProfileSSID ("SSID"); const char* const ProfileMode ("Mode"); const char* const ProfileChannel ("Channel"); const char* const ProfileEncryption ("Encryption"); const char* const ProfileEncryptionEncrypt ("Type"); const char* const ProfileEncryptionKey ("Key"); const char* const ProfileEncryptionAuth ("AuthenticationType"); const char* const ProfileEncryptionDefaultKey ("DefaultKey"); const char* const ProfileIPSettings ("IPSettings"); const char* const ProfileIPSettingsHow ("How"); std::string GetHomeDir () throw() { std::string HomeDir (::getenv("HOME")); #ifndef NDEBUG std::cerr << "Home directory from environment : " << HomeDir << std::endl; #endif // NDEBUG if (HomeDir.size() < 2U) // Couldn't get something useful. { #ifndef NDEBUG std::cerr << "Fetching home directory from passwd : "; #endif // NDEBUG const ::passwd* const pData (::getpwuid(::getuid())); if (pData) { #ifndef NDEBUG std::cerr << "success, got : " << pData->pw_dir << std::endl; #endif // NDEBUG HomeDir = pData->pw_dir; } #ifndef NDEBUG else { std::cerr << "failed, fallback to \"/root/\"" << std::endl; HomeDir = "/root/"; } #endif // NDEBUG } return HomeDir; } // GetHomeDir() std::string Normalize (const std::string& Str) throw() { std::string Result; Result.reserve (Str.size()); for (std::string::const_iterator Iter (Str.begin()) ; Iter != Str.end() ; ++Iter) Result += *Iter == '/' ? '_' : *Iter; return Result; } // Normalize() const std::string HomeDirectory (GetHomeDir()); const std::string ConfigDirectory (HomeDirectory + nsCore::UserConfigPrefix); const std::string ProfilesFilePath (ConfigDirectory + nsCore::UserConfigName + "RutilT_profiles.xml"); } // anonymous namespace const std::string nsUserData::AppDirectory (ConfigDirectory + nsCore::UserConfigName); void nsUserData::MakeAppDirectory () throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "Making directories : " << ConfigDirectory << " and " << AppDirectory << std::endl; #endif // NDEBUG if (::mkdir (ConfigDirectory.c_str(), 0755) && errno != EEXIST) throw nsErrors::CSystemExc ("Can't create \"" + ConfigDirectory + "\" directory."); if (::mkdir (AppDirectory.c_str(), 0755) && errno != EEXIST) throw nsErrors::CSystemExc ("Can't create \"" + AppDirectory + "\" directory."); } // MakeAppDirectory() nsUserData::CProfile::CProfile (const std::string& Name, const nsWireless::CCell& Cell) throw (std::bad_alloc) : m_Name (Name), m_SSID (Cell.GetSSID()), m_Mode (nsWireless::GetMatchingMode (Cell.GetMode())), m_Channel (Cell.GetChannel()), m_EncryptionD (Cell.GetEncryptionD()), m_IPSettings (Dhcp) { if (Cell.GetEncryptionD().GetEncrypt() == nsWireless::TKIPAES) m_EncryptionD.SetEncrypt (nsWireless::AES); } // CProfile() bool nsUserData::CProfile::Match (const nsWireless::CCell& Cell) const throw() { return m_Mode == nsWireless::GetMatchingMode (Cell.GetMode()) && m_Channel == Cell.GetChannel() && m_SSID == Cell.GetSSID() && m_EncryptionD.GetAuth() == Cell.GetEncryptionD().GetAuth() && m_EncryptionD.GetEncrypt() == Cell.GetEncryptionD().GetEncrypt(); } // Match() const char* const nsUserData::CProfilesFile::Indentation (" "); nsUserData::CProfilesFile::CProfilesFile () throw (nsErrors::CSystemExc) { MakeAppDirectory(); } // CProfilesFile() const char* nsUserData::CProfilesFile::GetRootMarkupLabel () const throw() { return "Profile"; } // GetRootMarkupLabel() void nsUserData::CProfilesFile::Extract () throw (nsErrors::CException) { CXMLParser::Extract (ProfilesFilePath); } // Extract() void nsUserData::CProfilesFile::RecordFields (std::ostream& Os, unsigned Pos) throw (std::ios_base::failure) { CProfile& Profile (GetProfile (Pos)); Os << Markup1B << ProfileSSID << Markup1E << ::g_markup_escape_text (Profile.GetSSID().c_str(), Profile.GetSSID().size()) << Markup2B << ProfileSSID << Markup2E << Indentation << Markup1B << ProfileMode << Markup1E << Profile.GetMode() << Markup2B << ProfileMode << Markup2E << Indentation << Markup1B << ProfileChannel << Markup1E<< Profile.GetChannel() << Markup2B << ProfileChannel << Markup2E; if (Profile.GetEncryptionD().GetEncrypt() != nsWireless::None) { Os << Indentation << Markup1B << ProfileEncryption << Markup2E << Indentation << Indentation << Markup1B << ProfileEncryptionEncrypt << Markup1E << Profile.GetEncryptionD().GetEncrypt() << Markup2B << ProfileEncryptionEncrypt << Markup2E << Indentation << Indentation; for (unsigned I (0) ; I < nsWireless::CEncryptionD::MaxNbKey ; ++I) Os << Markup1B << ProfileEncryptionKey << Markup1E << Profile.GetEncryptionD().GetKey (I).GetStr() << Markup2B << ProfileEncryptionKey << Markup2E << Indentation << Indentation; Os << Markup1B << ProfileEncryptionAuth << Markup1E << Profile.GetEncryptionD().GetAuth() << Markup2B << ProfileEncryptionAuth << Markup2E << Indentation << Indentation << Markup1B << ProfileEncryptionDefaultKey << Markup1E << Profile.GetEncryptionD().GetDefaultKey() << Markup2B << ProfileEncryptionDefaultKey << Markup2E << Indentation << Markup2B << ProfileEncryption << Markup2E; } if (Profile.GetIPSettings().GetSetting() != nsUserData::None) Os << Indentation << Markup1B << ProfileIPSettings << Markup2E << Indentation << Indentation << Markup1B << ProfileIPSettingsHow << Markup1E << Profile.GetIPSettings().GetSetting() << Markup2B << ProfileIPSettingsHow << Markup2E << Indentation << Markup2B << ProfileIPSettings << Markup2E; } // RecordFields() void nsUserData::CProfilesFile::Record () throw (nsErrors::CException) { #ifndef NDEBUG std::cerr << "Recording profiles in : " << ProfilesFilePath << std::endl; #endif std::ofstream Os (ProfilesFilePath.c_str(), std::ios_base::trunc); try { Os.exceptions (std::ios_base::badbit | std::ios_base::failbit); Os << XMLHeader << '\n' << Markup1B << RootMarkupLabel << Markup2E; const unsigned VecSize (Size()); for (unsigned i (0) ; i < VecSize ; ++i) { Os << Markup1B << GetRootMarkupLabel() << ' ' << ProfileName << "=\"" << GetProfile (i).GetName() << '"' << Markup2E << Indentation; RecordFields (Os, i); Os << Markup2B << GetRootMarkupLabel() << Markup2E; } Os << Markup2B << RootMarkupLabel << Markup2E; } catch (const std::ios_base::failure& Exc) { throw nsErrors::CException (Exc.what(), nsErrors::ProfilesRecordFailure); } // Keys are stored in this file, this is the least I can do... if (::chmod (ProfilesFilePath.c_str(), 00600)) { std::ostringstream Os; Os << "Can't set permission on file : " << ProfilesFilePath << '.'; throw nsErrors::CSystemExc (Os.str()); } } // Record() void nsUserData::CProfilesFile::StartElement (const char* ElementName, const char** AttributesNames, const char** AttributesValues) throw (std::bad_alloc, nsErrors::CException) { if (!strcmp (ElementName, GetRootMarkupLabel())) { if (!AttributesNames [0] || strcmp (AttributesNames [0], ProfileName) || !strlen (AttributesValues [0])) throw nsErrors::CException ("Invalid or missing profile name.", nsErrors::ProfilesExtractionMissingName); else NewProfile (AttributesValues [0]); } } // StartElement() void nsUserData::CProfilesFile::EndElement (const char* ElementName) throw (nsErrors::CException) { // Here we check if we have everything required. if (!strcmp (ElementName, GetRootMarkupLabel())) { CProfile& Profile (m_Profiles.back()); if (Profile.GetMode() == nsWireless::Unknown) throw nsErrors::CException ("Missing mode.", nsErrors::ProfilesExtractionMissingMode); else if (!Profile.GetChannel()) throw nsErrors::CException ("Missing channel.", nsErrors::ProfilesExtractionMissingChannel); } } // EndElement() void nsUserData::CProfilesFile::Text (const char* ElementName, const std::string& Text) throw (nsErrors::CException) { // FIXME HORRIBLE... *Shocked* static unsigned Cnt (0); CProfile& Profile (m_Profiles.back()); if (!strcmp (ElementName, ProfileSSID)) Profile.SetSSID (Text); else if (!strcmp (ElementName, ProfileMode)) { nsWireless::Mode_e Mode (nsWireless::Unknown); Mode = nsWireless::Mode_e (atoi (Text.c_str())); // I could have also check the value. if (Mode == nsWireless::Unknown) throw nsErrors::CException ("Invalid mode.", nsErrors::ProfilesExtractionInvalidMode); Profile.SetMode (Mode); } else if (!strcmp (ElementName, ProfileChannel)) { unsigned Channel (0); Channel = atoi (Text.c_str()); if (!Channel || Channel > 14) throw nsErrors::CException ("Invalid channel.", nsErrors::ProfilesExtractionInvalidChannel); Profile.SetChannel (Channel); } else if (!strcmp (ElementName, ProfileEncryptionKey)) try { nsWireless::CHexaKey Key; if (!Text.empty()) Key.Set (Text); Profile.GetEncryptionD().SetKey (Key, Cnt++); } catch (const nsWireless::CHexaKey::CBadFormatExc&) { throw nsErrors::CException ("Invalid key.", nsErrors::ProfilesExtractionInvalidKey); } else if (!strcmp (ElementName, ProfileEncryptionAuth)) // No check... Profile.GetEncryptionD().SetAuth (nsWireless::AuthType_e (atoi (Text.c_str()))); else if (!strcmp (ElementName, ProfileEncryptionEncrypt)) { // No check... Profile.GetEncryptionD().SetEncrypt (nsWireless::EncryptType_e (atoi (Text.c_str()))); Cnt = 0; } else if (!strcmp (ElementName, ProfileEncryptionDefaultKey)) // No check... Profile.GetEncryptionD().SetDefaultKey (atoi (Text.c_str())); else if (!strcmp (ElementName, ProfileIPSettingsHow)) // No check... Profile.GetIPSettings().SetSetting (IPSetting_e (atoi (Text.c_str()))); } // Text() RutilTv0.18/lib/src/CStatsPage.cxx0000644000175000017500000000734410662041272016421 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CStatsPage.cxx \author Romain BONDUE \date 08/05/2006 */ #include #include #include "CStatsPage.h" namespace { inline void NewLine (::GtkTable* pTable, const char* Label, ::GtkLabel* pWidget, unsigned Line) throw() { ::gtk_table_attach_defaults (pTable, ::gtk_label_new (Label), 0, 1, Line, Line + 1); ::gtk_table_attach_defaults (pTable, GTK_WIDGET (pWidget), 1, 2, Line, Line + 1); } // NewLine() inline long double ToMBytes (unsigned long NbBytes) { long double Bytes (NbBytes); return Bytes / 1024.L / 1024.L; } // ToMBytes() std::string BytesLabel (unsigned long NbBytes) throw() { std::ostringstream Os; Os << NbBytes << " (" << std::fixed << std::setprecision (1) << ToMBytes (NbBytes) << " MB)"; return Os.str(); } // BytesLabel() } // anonymous namespace nsGUI::CStatsPage::CStatsPage () throw() : m_pBox (GTK_BOX (::gtk_vbox_new (true, 2))), m_pTXBytes (GTK_LABEL (::gtk_label_new ("0"))), m_pTXPackets (GTK_LABEL (::gtk_label_new ("0"))), m_pTXErrors (GTK_LABEL (::gtk_label_new ("0"))), m_pCollisions (GTK_LABEL (::gtk_label_new ("0"))), m_pRXBytes (GTK_LABEL (::gtk_label_new ("0"))), m_pRXPackets (GTK_LABEL (::gtk_label_new ("0"))), m_pRXErrors (GTK_LABEL (::gtk_label_new ("0"))) {BuildUI();} void nsGUI::CStatsPage::BuildUI () throw() { ::gtk_container_set_border_width (GTK_CONTAINER (m_pBox), 6); ::GtkTable* pTable (GTK_TABLE (::gtk_table_new (2, 4, true))); NewLine (pTable, "Bytes", m_pTXBytes, 0); NewLine (pTable, "Packets", m_pTXPackets, 1); NewLine (pTable, "Errors", m_pTXErrors, 2); NewLine (pTable, "Collisions", m_pCollisions, 3); ::GtkWidget* pFrame (::gtk_frame_new ("Transmitted")); ::gtk_container_add (GTK_CONTAINER (pFrame), GTK_WIDGET (pTable)); ::gtk_box_pack_start_defaults (m_pBox, pFrame); // I reuse pFrame and pTable. The fourth line is blank. pTable = GTK_TABLE (::gtk_table_new (2, 4, true)); NewLine (pTable, "Bytes", m_pRXBytes, 0); NewLine (pTable, "Packets", m_pRXPackets, 1); NewLine (pTable, "Errors", m_pRXErrors, 2); pFrame = ::gtk_frame_new ("Received"); ::gtk_container_add (GTK_CONTAINER (pFrame), GTK_WIDGET (pTable)); ::gtk_box_pack_start_defaults (m_pBox, pFrame); } // BuildUI() void nsGUI::CStatsPage::SetTXBytes (unsigned long NbBytes) throw() { ::gtk_label_set_text (m_pTXBytes, BytesLabel (NbBytes).c_str()); } // SetTXBytes() void nsGUI::CStatsPage::SetRXBytes (unsigned long NbBytes) throw() { ::gtk_label_set_text (m_pRXBytes, BytesLabel (NbBytes).c_str()); } // SetRXBytes() void nsGUI::CStatsPage::SetLabel (::GtkLabel* pLabel, unsigned long N) throw() { std::ostringstream Os; Os << N; ::gtk_label_set_text (pLabel, Os.str().c_str()); } // SetLabel() RutilTv0.18/lib/src/Su.cxx0000644000175000017500000002245311037203750015006 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Su.cxx \author Romain BONDUE \date 19/12/2005 */ #include #include // abort() #include #include #include #include // memset() extern"C"{ #include #include // ::getpid() } #include "Su.h" #include "Msg.h" #include "StaticSettings.h" #include "ErrorsCode.h" namespace { template std::string ToString (const T& Value) throw() { std::ostringstream Os; Os << Value; return Os.str(); } // ToString() } // anonymous namespace nsSystem::CLocalSocket* nsRoot::CSu::pSock (0); unsigned long nsRoot::CSu::CurrentRemoteHandlerNumber (0); unsigned long nsRoot::CSu::InstanceCounter (1); bool nsRoot::CSu::Init (const std::string& RootPassword) throw (nsErrors::CException, std::bad_alloc) { Close(); nsSystem::CLocalSocket MasterSock; const ::pid_t Pid (::getpid()); MasterSock.Bind (ServerAddr + ToString (Pid)); MasterSock.Listen (1); if (!nsSystem::Fork()) { std::ostringstream OsArg1; try { MasterSock.Close(); OsArg1 << Pid; const std::string Arg1 (OsArg1.str()); #ifndef EXTERNALLAUNCHER const std::string HelperPath (nsCore::HelperPrefix + nsCore::HelperName); #endif // EXTERNALLAUNCHER const char* Argv [] = { #ifdef EXTERNALLAUNCHER nsCore::HelperLauncherPath.c_str(), #else HelperPath.c_str(), #endif // EXTERNALLAUNCHER Arg1.c_str(), 0}; nsSystem::Exec (Argv); } catch (nsErrors::CException& Exc) { std::cerr << "Error : " << Exc.GetMsg() << "\nCode : " << Exc.GetCode() << std::endl; } catch (...) {} // Ignore everything else. bool Unblocked (false); try { // The other process may block on accept(), let's prevent that. nsSystem::CLocalSocket Socket; const std::string Addr (ServerAddr + OsArg1.str()); ::timespec Timer; std::memset (&Timer, 0, sizeof (Timer)); Timer.tv_nsec = 20000L; // Try every 20ms for 3 seconds. for (unsigned Cnt (16) ; --Cnt && Unblocked == false ; ) try { ::nanosleep (&Timer, 0); Socket.Connect (Addr); Unblocked = true; } catch (...) {} // Ignore everything. } catch (nsErrors::CException& Exc) { std::cerr << "Error in error handler : " << Exc.GetMsg() << "\nCode : " << Exc.GetCode() << std::endl; } catch (...) {} // Ignore everything else. if (!Unblocked) ::kill (::getppid(), SIGKILL); abort(); } try { // Could possibly occur after helper's Connect(), but very unlikely. pSock = MasterSock.Accept(); pSock->SendCredential(); if (!pSock->CheckCredentialUID (0)) throw nsErrors::CException ("Helper authentication failed.", nsErrors::HelperAuthenticationFailed); #ifndef NOROOTPASSCHECK const int ACK (SendInternalCommand (CheckRootPassword, RootPassword)); if (ACK) { if (ACK == nsErrors::InvalidRootPassword) return false; throw nsErrors::CException ("Cannot send root password.", nsErrors::CannotSendRootPasswd); } #endif // NOROOTPASSCHECK pSock->Write (reinterpret_cast (&InstanceCounter), sizeof (InstanceCounter)); } catch (const nsErrors::CException& Exc) { if (pSock) try { Close(); } catch (...) {} // Ignore everything. #ifndef NDEBUG std::cerr << "Error while checking root password and/or authenticate: " << Exc.GetMsg() << "\nCode : " << Exc.GetCode() << std::endl; #endif // NDEBUG if (Exc.GetCode() == EINTR || Exc.GetCode() == nsErrors::CannotSendRootPasswd) return false; if (Exc.GetCode() == EPIPE || Exc.GetCode() == ECONNRESET) throw nsErrors::CException ("Cannot execute helper, check your" " installation.", nsErrors::CannotExecuteHelper); throw; } return true; } // Init() nsRoot::CSu::~CSu () throw() { try { if (pSock) SendInternalCommand (DeleteRemoteHandlerCmd, ToString (m_InstanceNumber)); } catch (...) {} // We just ignore errors. } // ~CSu() void nsRoot::CSu::CreateRemoteHandler (const std::string& RemoteHandlerTypeName) throw (nsErrors::CSystemExc) { int Value (SendInternalCommand (CreateRemoteHandlerCmd, RemoteHandlerTypeName)); if (Value) { std::auto_ptr Buffer (0); try{Buffer.reset (new char [Value + 1]);} catch (const std::bad_alloc& Exc) { throw nsErrors::CSystemExc (Exc.what(), nsErrors::OutOfMemory); } Buffer.get() [pSock->Read (Buffer.get(), Value)] = '\0'; pSock->Read (reinterpret_cast (&Value), sizeof (Value)); throw nsErrors::CSystemExc (std::string ("Can't create remote handler : ") + Buffer.get(), Value); } } // CreateRemoteHandler() void nsRoot::CSu::WriteString (const std::string& Str) throw (nsErrors::CSystemExc) { const int Size (Str.size()); pSock->Write (reinterpret_cast (&Size), sizeof (Size)); if (Size) pSock->Write (Str.data(), Size); } // WriteString() /* The main difference with Do() is the order on which fields are written : Size, Data, Code for Do(), then the same sequence of data (value may differ of course) is expected back. Code, Size, Data for this function, an int is expected to be sent back. That's why commands must be negatives (a size can't be negative) so the remote process can identify the data type. */ int nsRoot::CSu::SendInternalCommand (int Code, const std::string& Text) throw (nsErrors::CSystemExc) { pSock->Write (reinterpret_cast (&Code), sizeof (Code)); WriteString (Text); int ACK (nsErrors::InvalidData); pSock->Read (reinterpret_cast (&ACK), sizeof (ACK)); return ACK; } // SendInternalCommand() void nsRoot::CSu::SetRemoteHandler () throw (nsErrors::CException) { if (CurrentRemoteHandlerNumber != m_InstanceNumber) { int Value (SendInternalCommand (ChangeRemoteHandlerCmd, ToString (m_InstanceNumber))); if (Value) { std::string ErrorMsg ("Can't set remote handler."); if (Value > 0) try { char Buffer [Value + 1]; Buffer [pSock->Read (Buffer, Value)] = '\0'; ErrorMsg += '\n'; ErrorMsg += Buffer; pSock->Read (reinterpret_cast (&Value), sizeof (Value)); } catch (...) {Value = nsErrors::CodeNotTransmitted;} else Value = nsErrors::CodeNotTransmitted; throw nsErrors::CException (ErrorMsg, Value); } CurrentRemoteHandlerNumber = m_InstanceNumber; } } // SetRemoteHandler() nsRoot::CMsg nsRoot::CSu::Do (const CMsg& Msg) throw (nsErrors::CException, std::bad_alloc) { SetRemoteHandler(); WriteString (Msg.GetText()); int Code (Msg.GetCode()); pSock->Write (reinterpret_cast (&Code), sizeof (Code)); int Size (0); pSock->Read (reinterpret_cast (&Size), sizeof (Size)); std::auto_ptr Buffer (0); if (Size) { Buffer.reset (new char [Size]); Size = pSock->Read (Buffer.get(), Size); } pSock->Read (reinterpret_cast (&Code), sizeof (Code)); return Size ? CMsg (std::string (Buffer.get(), 0, Size), Code) : CMsg (std::string(), Code); } // Do() RutilTv0.18/lib/src/Module.cxx0000644000175000017500000001627310543033310015641 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Module.cxx \author Romain BONDUE \date 18/09/2005 \note The design is not the best, but there isn't many supported drivers so it suffices for now. I can always improve it later. :) */ #include #include #include #include // strcpy() extern "C"{ #include // SIOCGIFCONF } #include "Module.h" #include "Parameters.h" #include "CWE17Module.h" #include "RTModules.h" #include "ErrorsCode.h" #include "SystemTools.h" // Ioctl() namespace { const char* RT2400Name ("RT2400PCI"); const char* RT2500Name ("RT2500 Wireless"); const char* RT2570Name ("RT2500USB WLAN"); const char* RT61Name ("RT61 Wireless"); const char* RT73Name ("RT73 WLAN"); const std::string ProfileFilePrefix ("_profiles.xml"); } // anonymous namespace void nsCore::GetWirelessDevice (std::vector& NameVec) throw (nsErrors::CException) { std::ifstream Is ("/proc/net/dev"); if (!Is) { Is.clear(); Is.open ("/proc/net/wireless"); // Try the deprecated old file. } if (Is) try { Is.exceptions (std::ios_base::failbit | std::ios_base::badbit); Is.ignore (std::numeric_limits::max(), '\n'); Is.ignore (std::numeric_limits::max(), '\n'); // is included through WE17Driver.h (and is needed). ::iwreq Data; for (std::string Buffer ; Is >> Buffer ; ) { const std::string::size_type Pos = Buffer.rfind (':'); // Ignore ':'. if (Pos < Buffer.size()) Buffer.resize (Pos); else { char C; Is >> C; } // Check if it's a valid wireless device by getting the name. if (Buffer.size() < IFNAMSIZ - 1) { Buffer.copy (Data.ifr_ifrn.ifrn_name, IFNAMSIZ); Data.ifr_ifrn.ifrn_name [Buffer.size()] = '\0'; try { nsSystem::Ioctl (SIOCGIWNAME, &Data, ""); NameVec.push_back (nsWireless::CDeviceInfo (Buffer, Data.u.name)); } catch (const nsErrors::CSystemExc&) {} // Error ignored. Is.ignore (std::numeric_limits::max(), '\n'); } } } catch (const std::ios_base::failure& Exc) { // A failbit exception is thrown if Is.eof(). if (!Is.eof()) throw nsErrors::CException ("Error parsing /proc/net/dev" " (or /proc/net/wireless).", nsErrors::ProcParsing); } if (NameVec.empty()) // Ask the kernel directly, the downside of this, is { // that unconfigured interfaces are not reported. char Buffer [1024]; // Size from iwlib.c ::ifconf NetConf; NetConf.ifc_len = sizeof (Buffer); NetConf.ifc_buf = Buffer; nsSystem::Ioctl (SIOCGIFCONF, &NetConf, "Can't get interfaces through" " SIOCGIFCONF."); const ::ifreq* pNetFreq (NetConf.ifc_req); ::iwreq Data; for (size_t I (NetConf.ifc_len / sizeof (::ifreq)) ; I-- ; ++pNetFreq) { std::strcpy (Data.ifr_ifrn.ifrn_name, pNetFreq->ifr_name); try { nsSystem::Ioctl (SIOCGIWNAME, &Data, ""); NameVec.push_back (nsWireless::CDeviceInfo (pNetFreq->ifr_name, Data.u.name)); } catch (const nsErrors::CSystemExc&) {} // Error ignored. } } } // GetWirelessDevice() bool nsCore::IsSupported (const nsWireless::CDeviceInfo& Device) throw() { return Device.GetProtoName() == RT2400Name || Device.GetProtoName() == RT2500Name || Device.GetProtoName() == RT2570Name || Device.GetProtoName() == RT61Name || Device.GetProtoName() == RT73Name; } // IsSupported() nsCore::IModule* nsCore::MakeModule (const nsWireless::CDeviceInfo& Device, nsGUI::CGtkGUI* pUI) throw (nsErrors::CException, std::bad_alloc) { const std::string ProfilesFileName (Device.GetProtoName() + ProfileFilePrefix); if (Device.GetProtoName() == RT2400Name) return new CRT2400Module (Device.GetDeviceName(), ProfilesFileName); if (Device.GetProtoName() == RT2500Name) return new CRT2500Module (Device.GetDeviceName(), ProfilesFileName, pUI); if (Device.GetProtoName() == RT2570Name) return new CRT2570Module (Device.GetDeviceName(), ProfilesFileName, pUI); if (Device.GetProtoName() == RT61Name) return new CRT61Module (Device.GetDeviceName(), ProfilesFileName, pUI); if (Device.GetProtoName() == RT73Name) return new CRT73Module (Device.GetDeviceName(), ProfilesFileName, pUI); return new CWE17Module (Device.GetDeviceName(), ProfilesFileName); } // MakeModule() nsCore::ICLIModule* nsCore::MakeCLIModule (const nsWireless::CDeviceInfo& Device) throw (nsErrors::CException, std::bad_alloc) { const std::string ProfilesFileName (Device.GetProtoName() + ProfileFilePrefix); if (Device.GetProtoName() == RT2400Name) return new CRT2400CLIModule (Device.GetDeviceName(), ProfilesFileName); if (Device.GetProtoName() == RT2500Name) return new CRT2500CLIModule (Device.GetDeviceName(), ProfilesFileName); if (Device.GetProtoName() == RT2570Name) return new CRT2570CLIModule (Device.GetDeviceName(), ProfilesFileName); if (Device.GetProtoName() == RT61Name) return new CRT61CLIModule (Device.GetDeviceName(), ProfilesFileName); if (Device.GetProtoName() == RT73Name) return new CRT73CLIModule (Device.GetDeviceName(), ProfilesFileName); return new CWE17CLIModule (Device.GetDeviceName(), ProfilesFileName); } // MakeModule() RutilTv0.18/lib/src/CLinkStatusTab.cxx0000644000175000017500000001031510713131310017234 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CLinkStatusTab.cxx \author Romain BONDUE \date 28/07/2005 */ #include #include "CLinkStatusTab.h" namespace { inline void FillRow (const char* Label, ::GtkWidget* pWidget, ::GtkTable* pTable, unsigned Row) throw() { ::gtk_table_attach_defaults (pTable, ::gtk_label_new (Label), 0, 1, Row, Row + 1); ::gtk_table_attach_defaults (pTable, pWidget, 1, 2, Row, Row + 1); } // FillRow() } // anonymous namespace const char* const nsGUI::CLinkStatusTab::DisconnectLabel ("Disconnected"); nsGUI::CLinkStatusTab::CLinkStatusTab () throw() : m_pAlignment (::gtk_alignment_new (0.25, 0.5, 0.6, 0.3)), m_pLinkQualityBar (GTK_PROGRESS_BAR (::gtk_progress_bar_new())), m_pSignalLevelBar (GTK_PROGRESS_BAR (::gtk_progress_bar_new())), m_pNoiseLevelBar (GTK_PROGRESS_BAR (::gtk_progress_bar_new())), m_pStatusLabel (GTK_LABEL (::gtk_label_new (DisconnectLabel))), m_pModeLabel (GTK_LABEL (::gtk_label_new (0))), m_pChannelLabel (GTK_LABEL (::gtk_label_new (0))), m_pTxRateLabel (GTK_LABEL (::gtk_label_new (0))), m_pAddrLabel (GTK_LABEL (::gtk_label_new (0))) { ::GtkTable* const pTable (GTK_TABLE (::gtk_table_new (8, 2, false))); ::gtk_container_set_border_width (GTK_CONTAINER (pTable), 6); ::gtk_table_set_col_spacings (pTable, 12); ::gtk_table_set_row_spacings (pTable, 12); FillRow ("Status", GTK_WIDGET (m_pStatusLabel), pTable, 0); FillRow ("Mode", GTK_WIDGET (m_pModeLabel), pTable, 1); FillRow ("Channel", GTK_WIDGET (m_pChannelLabel), pTable, 2); FillRow ("Tx rate", GTK_WIDGET (m_pTxRateLabel), pTable, 3); FillRow ("Link quality", GTK_WIDGET (m_pLinkQualityBar), pTable, 4); FillRow ("Signal level", GTK_WIDGET (m_pSignalLevelBar), pTable, 5); FillRow ("Noise level", GTK_WIDGET (m_pNoiseLevelBar), pTable, 6); FillRow ("IP Address", GTK_WIDGET (m_pAddrLabel), pTable, 7); ::gtk_container_add (GTK_CONTAINER (m_pAlignment), GTK_WIDGET (pTable)); } // CLinkStatusTab() void nsGUI::CLinkStatusTab::SetBar (::GtkProgressBar* pBar, double BarPos, int Value, const char* Suffix, int UnknownValue) throw() { ::gtk_progress_bar_set_fraction (pBar, BarPos); if (Value != UnknownValue) { std::ostringstream Os; Os << Value << Suffix; ::gtk_progress_bar_set_text (pBar, Os.str().c_str()); } else ::gtk_progress_bar_set_text (pBar, "N/A"); } // SetBar() void nsGUI::CLinkStatusTab::Clear () throw() { SetLinkQuality (0); SetSignalLevel (-256); SetNoiseLevel (-256); ::gtk_label_set_text (m_pStatusLabel, DisconnectLabel); ::gtk_label_set_text (m_pTxRateLabel, "N/A"); } // Clear() void nsGUI::CLinkStatusTab::SetChannel (unsigned Channel, double Frequency) throw() { std::ostringstream Os; if (Channel) Os << Channel; else Os << "N/A"; if (Frequency) Os << " (" << Frequency << " GHz)"; ::gtk_label_set_text (m_pChannelLabel, Os.str().c_str()); } // SetChannel() void nsGUI::CLinkStatusTab::SetTxRate (unsigned TxRate) throw() { if (TxRate) { std::ostringstream Os; Os << TxRate / 1000.0 << " Mbps"; ::gtk_label_set_text (m_pTxRateLabel, Os.str().c_str()); } else ::gtk_label_set_text (m_pTxRateLabel, "Unknown"); } // SetTxRate() RutilTv0.18/lib/src/MsgHandlerFactory.cxx0000644000175000017500000000374010601026051017762 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file MsgHandlerFactory.cxx \author Romain BONDUE \date 17/02/2006 */ #include "MsgHandlerFactory.h" #include "CWirelessMsgHandler.h" #include "SuWProtocolCodes.h" #include "RTSuWProtocolCodes.h" #include "RTWMsgHandlers.h" #include "IfaceProtocolCodes.h" #include "IfaceMsgHandler.h" #include "ErrorsCode.h" nsRoot::IMsgHandler* nsRoot::MakeHandler (const std::string& HandlerName) throw (nsErrors::CException, std::bad_alloc) { if (HandlerName == nsWireless::WE17Handler) return new CWirelessMsgHandler; if (HandlerName == nsWireless::RT2400Handler) return new CRT2400MsgHandler; if (HandlerName == nsWireless::RT2500Handler) return new CRT2500MsgHandler; if (HandlerName == nsWireless::RT2570Handler) return new CRT2570MsgHandler; if (HandlerName == nsWireless::RT61Handler) return new CRT61MsgHandler; if (HandlerName == nsWireless::RT73Handler) return new CRT73MsgHandler; if (HandlerName == nsNet::IfaceHandler) return new CIfaceMsgHandler; throw nsErrors::CException (std::string ("Unknown handler : ") + HandlerName, nsErrors::UnknownHandler); } // MakeHandler() RutilTv0.18/lib/src/RTDrivers.cxx0000644000175000017500000014562110722350737016316 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTDrivers.cxx \author Romain BONDUE \date 30/08/2005 */ #include #include #include #include #ifndef NDEBUG #include #endif // NDEBUG extern "C"{ #include #include // SIOCDEVPRIVATE } #include "RTDrivers.h" #include "ErrorsCode.h" namespace { // FIXME The two wep ciphers are not differenciated. // WPA 1 parsing code can be simplified like WPA 2. // Both mode actually use the same constants (but a different // prefix section). // Parsing is quite alike in both case (same bit layout, mostly). // From wpa_supplicant wpa.c : const ::uint8_t WPA_OUI_TYPE[] = {0x00, 0x50, 0xf2, 1}; const ::uint8_t WPA_AUTH_KEY_MGMT_NONE[] = {0x00, 0x50, 0xf2, 0}; const ::uint8_t WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[] = {0x00, 0x50, 0xf2, 1}; const ::uint8_t WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = {0x00, 0x50, 0xf2, 2}; const ::uint8_t WPA_CIPHER_SUITE_NONE[] = {0x00, 0x50, 0xf2, 0}; const ::uint8_t WPA_CIPHER_SUITE_WEP40[] = {0x00, 0x50, 0xf2, 1}; const ::uint8_t WPA_CIPHER_SUITE_TKIP[] = {0x00, 0x50, 0xf2, 2}; const ::uint8_t WPA_CIPHER_SUITE_WRAP[] = {0x00, 0x50, 0xf2, 3}; const ::uint8_t WPA_CIPHER_SUITE_CCMP[] = {0x00, 0x50, 0xf2, 4}; const ::uint8_t WPA_CIPHER_SUITE_WEP104[] = {0x00, 0x50, 0xf2, 5}; // Adapted from wpa_supplicant wpa.c : const ::uint8_t RSN_SEQUENCE_SIZE (4U); const ::uint8_t RSN_PREFIX_SIZE (RSN_SEQUENCE_SIZE - 1U); const ::uint8_t RSN_PREFIX [RSN_SEQUENCE_SIZE - 1U] = {0U, 0xfU, 0xacU}; const ::uint8_t RSN_AUTH_UNSPEC_802_1X (1U); const ::uint8_t RSN_AUTH_PSK (2U); const ::uint8_t RSN_CIPHER_NONE (0U); const ::uint8_t RSN_CIPHER_WEP40 (1U); const ::uint8_t RSN_CIPHER_TKIP (2U); const ::uint8_t RSN_CIPHER_CCMP_WRAP (3U); const ::uint8_t RSN_CIPHER_CCMP (4U); const ::uint8_t RSN_CIPHER_WEP104 (5U); const ::uint8_t RSN_CIPHER_AES_CMAC (6U); // FIXME Unsupported currently. class CScanResult { protected : struct SSSid { unsigned Length; unsigned char Text [32]; }; // SSSid struct SConfigFH { unsigned m1; unsigned m2; unsigned m3; unsigned m4; }; // SConfigFH struct SConfig { unsigned m1; unsigned m2; unsigned m3; unsigned Frequency; SConfigFH m5; }; // SConfig struct SIE { typedef ::uint8_t DataType_t; static const unsigned DataSize = 32U; unsigned char Id; unsigned char Length; DataType_t Data [DataSize]; }; // SIE struct SFixedIE { unsigned char m1 [8]; unsigned short m2; unsigned short m3; }; // SFixedIE private : bool NextData (const SIE::DataType_t*& pData, int& LengthRemaining) const throw() { if (LengthRemaining > RSN_SEQUENCE_SIZE && !std::memcmp (pData, RSN_PREFIX, RSN_PREFIX_SIZE)) { pData += RSN_PREFIX_SIZE; LengthRemaining -= RSN_PREFIX_SIZE; return true; } return false; } // NextData() // ? FIXME ? A CIE class would be clean (it's not Ralink specific). // It would be more lisible with sub function : parse_cipher() ... void ParseIE (const SIE& IE, nsWireless::CEncryptionD& Descriptor) const throw() { int LengthRemaining (IE.Length); const SIE::DataType_t* pDataIter (IE.Data); if (IE.Id == 0xDDU && LengthRemaining >= int (sizeof (WPA_OUI_TYPE))) { const size_t VersionSize (2U); if (!std::memcmp(pDataIter, WPA_OUI_TYPE, sizeof (WPA_OUI_TYPE))) { int Offset (sizeof (WPA_OUI_TYPE) + VersionSize + sizeof (WPA_CIPHER_SUITE_TKIP)); LengthRemaining -= Offset; Descriptor.SetAuth (nsWireless::WPAPSK); Descriptor.SetEncrypt (nsWireless::TKIP); const int CipherCountSize (2U); if (LengthRemaining >= CipherCountSize) { LengthRemaining -= CipherCountSize; pDataIter += Offset; const SIE::DataType_t CipherCount (*pDataIter); Offset = CipherCount * sizeof (WPA_CIPHER_SUITE_TKIP); if (LengthRemaining >= Offset) { pDataIter += CipherCountSize; switch (CipherCount) { case 1 : if (!std::memcmp (pDataIter, WPA_CIPHER_SUITE_CCMP, sizeof (WPA_CIPHER_SUITE_CCMP))) Descriptor.SetEncrypt (nsWireless::AES); else if (!std::memcmp (pDataIter, WPA_CIPHER_SUITE_WEP40, sizeof (WPA_CIPHER_SUITE_WEP40)) || !std::memcmp (pDataIter, WPA_CIPHER_SUITE_WEP104, sizeof (WPA_CIPHER_SUITE_WEP104)) ) Descriptor.SetEncrypt (nsWireless::WEP); else if (std::memcmp (pDataIter, WPA_CIPHER_SUITE_TKIP, sizeof (WPA_CIPHER_SUITE_TKIP))) Descriptor.SetEncrypt (nsWireless::UnknownEnc); break; case 2 : { const SIE::DataType_t* const pSecondCipher (pDataIter + sizeof (WPA_CIPHER_SUITE_TKIP)); if (!memcmp (pDataIter, WPA_CIPHER_SUITE_TKIP, sizeof (WPA_CIPHER_SUITE_TKIP)) && !memcmp (pSecondCipher, WPA_CIPHER_SUITE_CCMP, sizeof (WPA_CIPHER_SUITE_CCMP)) || !memcmp (pDataIter, WPA_CIPHER_SUITE_CCMP, sizeof (WPA_CIPHER_SUITE_CCMP)) && !memcmp (pSecondCipher, WPA_CIPHER_SUITE_TKIP, sizeof (WPA_CIPHER_SUITE_TKIP))) Descriptor.SetEncrypt (nsWireless::TKIPAES); else // Not completely true, we may know one. Descriptor.SetEncrypt (nsWireless::UnknownEnc); } break; default : Descriptor.SetEncrypt (nsWireless::UnknownEnc); } LengthRemaining -= Offset; const int AuthCountSize (2U); bool AuthSet (false); if (LengthRemaining >= AuthCountSize) { pDataIter += Offset; const SIE::DataType_t AuthCount (*pDataIter); pDataIter += AuthCountSize; Offset = AuthCount * sizeof (WPA_AUTH_KEY_MGMT_UNSPEC_802_1X); if (LengthRemaining >= Offset) for (size_t Cnt (0) ; Cnt < AuthCount ; ++Cnt) { if (!std::memcmp (pDataIter, WPA_AUTH_KEY_MGMT_UNSPEC_802_1X, sizeof (WPA_AUTH_KEY_MGMT_UNSPEC_802_1X)) && /* NOTE : Legacy drivers stuff * here, we try to use WPAPSK * if possible because these * drivers only support this. */ !AuthSet) { Descriptor.SetAuth (nsWireless::WPA); AuthSet = true; } else if (!std::memcmp (pDataIter, WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X, sizeof (WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X))) { Descriptor.SetAuth (nsWireless::WPAPSK); AuthSet = true; } } } if (!AuthSet) Descriptor.SetAuth (nsWireless::UnknownAuth); } } } } else if (IE.Id == 0x30 && pDataIter [0U] == 1U || pDataIter [1U] == 1U) { const size_t VersionSize (2U); pDataIter += VersionSize; LengthRemaining -= VersionSize; Descriptor.SetAuth (nsWireless::WPA2); Descriptor.SetEncrypt (nsWireless::AES); const size_t CipherCountSize (2U); LengthRemaining -= CipherCountSize; // Trick, NextData() will if (NextData (pDataIter, LengthRemaining)) // check for it! { const size_t CipherCount (*++pDataIter); pDataIter += CipherCountSize; if (NextData (pDataIter, LengthRemaining)) { /* // FIXME Won't actually report several network. while (CipherCount && NextData (pDataIter, LengthRemaining)) { switch (*pDataIter) { Sort the cases by likeliness (arbitrary). case RSN_CIPHER_WEP40 : Do something ... break; etc ... } --CipherCount; ++pDataIter; // TODO Remove the incrementation in NextData() next call. } */ nsWireless::EncryptType_e Cipher (nsWireless::UnknownEnc); if (CipherCount == 1U) switch (*pDataIter) { case RSN_CIPHER_CCMP_WRAP : case RSN_CIPHER_CCMP : Cipher = nsWireless::AES; break; case RSN_CIPHER_TKIP : Cipher = nsWireless::TKIP; break; case RSN_CIPHER_WEP40 : case RSN_CIPHER_WEP104 : Cipher = nsWireless::WEP; break; case RSN_CIPHER_NONE : Cipher = nsWireless::None; //break; } // FIXME Assumption, no check : else if (CipherCount == 2U && NextData (++pDataIter, LengthRemaining)) Cipher = nsWireless::TKIPAES; Descriptor.SetEncrypt (Cipher); const size_t AuthCountSize (2U); LengthRemaining -= AuthCountSize; // Same trick. if (NextData (++pDataIter, LengthRemaining)) { size_t AuthCount (*++pDataIter); pDataIter += AuthCountSize; nsWireless::AuthType_e Auth (nsWireless::UnknownAuth); while (AuthCount && NextData (pDataIter, LengthRemaining)) { switch (*pDataIter) { case RSN_AUTH_PSK : Auth = nsWireless::WPA2PSK; break; case RSN_AUTH_UNSPEC_802_1X : /* NOTE : Legacy drivers stuff here, we favor * WPA2PSK because these drivers only support * this. */ if (Auth != nsWireless::WPA2PSK) Auth = nsWireless::WPA2; //break; } --AuthCount; ++pDataIter; } Descriptor.SetAuth (Auth); // There may be other stuff in the IE. We don't // currently need or use them. } } } } } // ParseIE() static const unsigned NbRates = 16; unsigned m_Length; char m_MacAddress [6]; unsigned char m_Reserved [2]; SSSid m_SSID; unsigned m_Privacy; int m_SignalStrength; int m_NetworkType; SConfig m_Config; int m_NetworkInfrastructureType; unsigned char m_SupportedRates [NbRates]; unsigned m_IELength; unsigned char m_pIEs [sizeof (SFixedIE) + sizeof (SIE) * 4]; public : CScanResult () throw() {memset (this, 0, sizeof (CScanResult));} unsigned GetLength () const throw() {return m_Length;} nsWireless::CMacAddress GetAPMacAddress () const throw (std::bad_alloc) { return nsWireless::CMacAddress (m_MacAddress); } // GetAPMacAddress() nsWireless::Mode_e GetMode () const throw() { switch (m_NetworkInfrastructureType) { case 0 : return nsWireless::AdHoc; case 1 : return nsWireless::Managed; default : return nsWireless::Auto; } } // GetMode() // Most things here are magic, ask Ralink... nsWireless::CEncryptionD GetEncryptionD () const throw() { nsWireless::CEncryptionD Descriptor; if (m_Privacy) { #ifndef NDEBUG std::cerr << "Ralink encryption, privacy enabled, essid : " << std::string (reinterpret_cast (m_SSID.Text), 0, m_SSID.Length) << std::endl; #endif // NDEBUG Descriptor.SetEncrypt (nsWireless::WEP); if (m_IELength > sizeof (SFixedIE)) { const SIE* pDescriptor (reinterpret_cast (m_pIEs + sizeof (SFixedIE))); for (size_t LengthRemaining (m_IELength - sizeof (SFixedIE)) ; LengthRemaining ; ) { #ifndef NDEBUG std::cerr << std::hex << "\tpDescriptor->Id : " << unsigned (pDescriptor->Id) << "\n\tpDescriptor->Length : " << unsigned (pDescriptor->Length) << std::endl; for (unsigned I (0U) ; I < pDescriptor->Length ; ++I) std::cerr << unsigned (pDescriptor->Data [I]) << ' '; std::cerr << std::dec << std::endl; #endif // NDEBUG ParseIE (*pDescriptor, Descriptor); LengthRemaining -= pDescriptor->Length + sizeof (SIE) - sizeof (SIE::DataType_t) * SIE::DataSize; pDescriptor = reinterpret_cast (reinterpret_cast (pDescriptor->Data) + pDescriptor->Length); } } } return Descriptor; } // GetEncryptionD() std::string GetSSID () const throw() { return std::string (reinterpret_cast (m_SSID.Text), 0, m_SSID.Length); } // GetSSID() double GetFrequency () const throw() { return m_Config.Frequency / 1000000.0; } // GetFrequency() nsWireless::CQuality GetQuality () const throw() { return nsWireless::CQuality (0, m_SignalStrength); } // GetQuality() unsigned GetTxRate () const throw() { return 0; } // GetTxRate() }; // CScanResult template class CScanResultsTab { public : CScanResultsTab () throw() : m_Size (MaxSize) { memset (m_Data, 0, sizeof (CScanResult) * MaxSize); } // CScanResulTab() const CScanResult* Get () const throw() { return m_Data; } // Get() unsigned Size () const throw() {return m_Size;} private : unsigned m_Size; CScanResult m_Data [MaxSize]; }; // CScanResultsTab struct SPrivateConfig { SPrivateConfig () throw() {memset (this, 0, sizeof (SPrivateConfig));} unsigned EnableTxBurst; unsigned EnableTurboRate; // Ralink : 0-AUTO, 1-always ON, 2-always OFF. unsigned UseBGProtection; // Ralink : 0-no use, 1-use 9-use short slot time when applicable. unsigned UseShortSlotTime; unsigned UseOfdmRatesIn11gAdhoc; unsigned RadioOn; unsigned m2; unsigned m3; }; // SPrivateConfig enum DriverWirelessMode_e {BGMixed, B, A, ABGMixed}; enum DriverEncrypt_e {WEP, TKIP = 4, AES = 6}; enum DriverAuth_e {Open, Shared, WPA = 3, WPAPSK, WPANone}; nsWireless::CEncryptionD ToEncryptionDRt73 (const char* Enc, const char* Auth) throw() { nsWireless::AuthType_e AuthType; if (!strcmp (Auth, "WPA-PSK")) AuthType = nsWireless::WPAPSK; else if (!strcmp (Auth, "WPA2-PSK")) AuthType = nsWireless::WPA2PSK; else AuthType = nsWireless::GetAuthFromName (Auth); return nsWireless::CEncryptionD (nsWireless::CHexaKey(), AuthType, nsWireless::GetEncryptFromName (Enc)); } // ToEncryptionDRt73() nsWireless::CEncryptionD ToEncryptionDRt61 (const char* Enc, const char* Auth) throw() { /* FIXME Are all these choices correct ? The most secure scheme is reported each time. */ nsWireless::AuthType_e AuthType; if (!strcmp (Auth, "WPA-PSK") || !strcmp (Auth, "WPA/WPA-PSK")) AuthType = nsWireless::WPAPSK; else if (!strcmp (Auth, "WPA2-PSK") || !strcmp (Auth, "WPA(2)-PSK") || !strcmp (Auth, "WPA2/WPA2-PSK") || !strcmp (Auth, "WPA(2)/WPA(2)-PSK")) AuthType = nsWireless::WPA2PSK; else AuthType = nsWireless::GetAuthFromName (Auth); return nsWireless::CEncryptionD (nsWireless::CHexaKey(), AuthType, nsWireless::GetEncryptFromName (Enc)); } // ToEncryptionDRt61() inline nsWireless::Mode_e ToMode (const char* Mode) throw() { if (!strcmp (Mode, "Adhoc")) return nsWireless::AdHoc; return nsWireless::Managed; } // ToMode() nsWireless::CQuality ToQuality (int Rssi) throw() { return nsWireless::CQuality (0, Rssi); } // ToQuality() // Assumes that BufSize is stricly superior to one, and Dest has, at // least, enough room for BufSize + 1 characters. void Extract (const char* Src, char* Dest, int BufSize) throw() { while (--BufSize >= 0 && Src [BufSize] == ' '); Dest [BufSize + 1] = '\0'; while (BufSize >= 0) { Dest[BufSize] = Src[BufSize]; --BufSize; } } // Extract() // 8 8 36 20 12 12 12 // Channel RSSI SSID Bssid WepStatus AuthMode NetworkType nsWireless::CCell ToCellRt73 (const char* Line) throw (nsErrors::CException) { // C style : unsigned Channel; int Rssi; if (sscanf (Line, "%u%d", &Channel, &Rssi) != 2) throw nsErrors::CException ("Data parsing error (1).", nsErrors::DataParsingError1); Line += 17; const int SsidSize (36); char Ssid [SsidSize + 1]; Extract(Line, Ssid, SsidSize); Line += SsidSize; char Bssid [21]; char Enc [13]; char Auth [13]; char NetworkType [13]; if (sscanf (Line, "%s%s%s%s", Bssid, Enc, Auth, NetworkType) != 4) throw nsErrors::CException ("Data parsing error (2).", nsErrors::DataParsingError2); #ifndef NDEBUG std::cerr << "Parsed data : " << Channel << ' ' << Rssi << " #" << Ssid << "# " << Bssid << ' ' << Enc << ' ' << Auth << ' ' << NetworkType << std::endl; #endif // NDEBUG return nsWireless::CCell (nsWireless::CMacAddress (std::string (Bssid)), ToMode (NetworkType), Ssid, ToEncryptionDRt73 (Enc, Auth), Channel, ToQuality (Rssi), 0); } // ToCellRt73() // 8 8 36 20 12 20 12 // Channel RSSI SSID Bssid WepStatus AuthMode NetworkType nsWireless::CCell ToCellRt61 (const char* Line) throw (nsErrors::CException) { // C style : unsigned Channel; int Rssi; if (sscanf (Line, "%u%d", &Channel, &Rssi) != 2) throw nsErrors::CException ("Data parsing error (1).", nsErrors::DataParsingError1); Line += 17; const int SsidSize (36); char Ssid [SsidSize + 1]; Extract(Line, Ssid, SsidSize); Line += SsidSize; const int BssidSize (20); char Bssid [BssidSize + 1]; if (sscanf (Line, "%s", Bssid) != 1) throw nsErrors::CException ("Data parsing error (2).", nsErrors::DataParsingError2); Line += BssidSize; const int EncSize (12); char Enc [EncSize + 1]; Extract(Line, Enc, EncSize); Line += EncSize; char Auth [21]; char NetworkType [13]; if (sscanf (Line, "%s%s", Auth, NetworkType) != 2) throw nsErrors::CException ("Data parsing error (3).", nsErrors::DataParsingError3); #ifndef NDEBUG std::cerr << "Parsed data : " << Channel << ' ' << Rssi << " #" << Ssid << "# " << Bssid << ' ' << Enc << ' ' << Auth << ' ' << NetworkType << std::endl; #endif // NDEBUG return nsWireless::CCell (nsWireless::CMacAddress (std::string (Bssid)), ToMode (NetworkType), Ssid, ToEncryptionDRt61 (Enc, Auth), Channel, ToQuality (Rssi), 0); } // ToCellRt61() } // anonymous namespace void nsWireless::CRTDriver::GetScanResult (int IoctlCode, u16 ListOid, std::vector& CellVec) const throw (nsErrors::CException, std::bad_alloc) { #ifndef NDEBUG std::cerr << "CRTDriver::GetScanResult()\n"; #endif // NDEBUG CScanResultsTab<64> Results; m_Data.data.pointer = reinterpret_cast< ::caddr_t> (&Results); m_Data.data.length = sizeof (Results); m_Data.data.flags = ListOid; Ioctl (IoctlCode, "Can't get scan results through special ioctl."); #ifndef NDEBUG std::cerr << "CRTDriver::GetScanResult() Results.size() : " << Results.Size() << std::endl; std::cerr << "\tRaw data :\n"; const unsigned char* p (reinterpret_cast (&Results)); for (unsigned i (0) ; i < m_Data.data.length ; ++i) std::cerr << unsigned (p [i]) << ' '; std::cerr << std::endl; #endif // NDEBUG const CScanResult* pResult (Results.Get()); for (unsigned i (0) ; i < Results.Size() ; ++i) { #ifndef NDEBUG std::cerr << "CRTDriver::GetScanResult() Results : " << i << std::endl; #endif // NDEBUG unsigned Channel (GetMatchingFreq (0, pResult->GetFrequency()).GetChannel()); CellVec.push_back (CCell (pResult->GetAPMacAddress(), pResult->GetMode(), pResult->GetSSID(), pResult->GetEncryptionD(), Channel, pResult->GetQuality(), pResult->GetTxRate())); pResult = reinterpret_cast (reinterpret_cast (pResult) + pResult->GetLength()); } } // GetScanResult() nsWireless::CRT2400Driver::CRT2400Driver (const std::string& DeviceName) throw (nsErrors::CException) : CRTDriver (DeviceName), m_PrivateIoctl (SIOCDEVPRIVATE) {} void nsWireless::CRT2400Driver::Scan () throw (nsErrors::CSystemExc) { m_Data.data.pointer = 0; m_Data.data.length = 0; m_Data.data.flags = 8002U; // RTLINUX_SET_OID_802_11_BSSID_LIST_SCAN Ioctl (m_PrivateIoctl, "Can't trigger scan through special ioctl."); } // Scan() void nsWireless::CRTAdvancedDriver::GetScanResult (u16 MagicNumber, std::vector& CellVec) const throw (nsErrors::CException, std::bad_alloc) { #ifndef NDEBUG std::cerr << "CRTAdvancedDriver::GetScanResult() Ralink scan" << std::endl; #endif // NDEBUG CRTDriver::GetScanResult (m_PrivateIoctl, MagicNumber, CellVec); #ifndef NDEBUG std::cerr << "CRTAdvancedDriver::GetScanResult() Ralink scan success, " << CellVec.size() << " cells." << std::endl; #endif // NDEBUG } // GetScanResult() nsWireless::CEncryptionD nsWireless::CRTAdvancedDriver::GetEncryption (u16 EncryptMagicNumber, u16 AuthMagicNumber) throw (nsErrors::CSystemExc, std::bad_alloc) { #ifndef NDEBUG std::cerr << "CRTAdvancedDriver::GetEncryption()" << std::endl; #endif // NDEBUG CEncryptionD Descriptor (CWE17Driver::GetEncryption()); if (Descriptor.GetEncrypt() != None) { // FIXME is this code really working? DriverEncrypt_e Encrypt (::WEP); m_Data.data.pointer = reinterpret_cast< ::caddr_t> (Encrypt); m_Data.data.length = sizeof (Encrypt); m_Data.data.flags = EncryptMagicNumber; Ioctl (m_PrivateIoctl, "Can't get cipher through special ioctl."); DriverAuth_e Auth (::Open); m_Data.data.pointer = reinterpret_cast< ::caddr_t> (Auth); m_Data.data.length = sizeof (Auth); m_Data.data.flags = AuthMagicNumber; Ioctl (m_PrivateIoctl, "Can't get authentication type through special ioctl."); switch (Encrypt) { case ::TKIP : Descriptor.SetEncrypt (nsWireless::TKIP); break; case ::AES : Descriptor.SetEncrypt (nsWireless::AES); //break; default : ; // To avoid warnings. } switch (Auth) { case ::WPANone : Descriptor.SetAuth (nsWireless::WPANONE); break; case ::WPAPSK : Descriptor.SetAuth (nsWireless::WPAPSK); //break; default : ; // To avoid warnings. } } return Descriptor; } // GetEncryption() void nsWireless::CRTAdvancedDriver::SetRfmontx (bool B) throw (nsErrors::CSystemExc) { char Buffer (B ? 1 : 0); m_Data.data.pointer = reinterpret_cast< ::caddr_t> (&Buffer); m_Data.data.length = sizeof (Buffer); m_Data.data.flags = 0; Ioctl (m_RfmontxIoctl, "Can't set injection mode."); m_Flags |= Rfmontx; } // SetRfmontx() nsWireless::CRT2500Driver::CRT2500Driver (const std::string& DeviceName) throw (nsErrors::CException, std::bad_alloc) /* RT_PRIV_IOCTL, RT_OID_802_11_STA_CONFIG, RT_OID_802_11_PREAMBLE and RT_OID_PHY_MODE */ : CRTAdvancedDriver (DeviceName, SIOCIWFIRSTPRIV + 1, 0x0217U, 0x0201U, 0x0212U, new IWPrivHandler) { // Backward compatibilty check. if (GetRfmontxIoctl() != InvalidIoctl && GetRfmontxIoctl() & 1) { #ifndef NDEBUG std::cerr << "CRT2500Driver::CRT2500Driver() GetRfmonTx backward" " compatibilty check." << std::endl; #endif // NDEBUG char Buffer ('0'); m_Data.data.pointer = reinterpret_cast< ::caddr_t> (&Buffer); m_Data.data.length = 0; // sizeof (Buffer) => EINVAL m_Data.data.flags = 0; Ioctl (GetRfmontxIoctl(), "Can't get injection mode through private" " ioctl."); SetFlag (Rfmontx, Buffer == '1'); #ifndef NDEBUG std::cerr << "CRT2500Driver::CRT2500Driver() GetRfmonTx backward" " compatibilty check : " << (Buffer == '1') << std::endl; #endif // NDEBUG } } // CRT2500Driver() void nsWireless::CRT2500Driver::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { if (Descriptor.GetAuth() == Open || Descriptor.GetAuth() == Shared) { #ifndef NDEBUG std::cerr << "CRT2500Driver::SetEncryption(), using standard ioctl." << std::endl; #endif // NDEBUG CWE17Driver::SetEncryption (Descriptor); } else { const char* const AuthName (GetAuthName (Descriptor.GetAuth()).c_str()); #ifndef NDEBUG std::cerr << "CRT2500Driver::SetEncryption(), using private ioctls.\n\t" "AuthName : " << AuthName << "\n\tEncryptName : " << GetEncryptName (Descriptor.GetEncrypt()) << "\n\tKey : " << std::string (Descriptor.GetKey().Get(), 0, Descriptor.GetKey().Size()) << std::endl; #endif // NDEBUG SetIoctl ("AuthMode", AuthName, "Can't set authentication mode : "); SetIoctl ("EncrypType", GetEncryptName (Descriptor.GetEncrypt()), "Can't set encryption type : "); SetIoctl (AuthName, std::string (Descriptor.GetKey().Get(), 0, Descriptor.GetKey().Size()), "Can't set key : "); } } // SetEncryption() nsWireless::CRTAdvancedDriver::CRTAdvancedDriver (const std::string& DeviceName, int PrivateIoctl, u16 StaConfigMagicNumber, u16 PreambleMagicNumber, u16 PhyModeMagicNumber, IWPrivHandler* pHandler) throw (nsErrors::CException, std::bad_alloc) : CRTDriver (DeviceName), m_PrivateIoctl (PrivateIoctl), m_SetIoctl (InvalidIoctl), m_RfmontxIoctl (InvalidIoctl), m_Flags (0), m_BGProtection (AutoProtection), m_TxPreamble (AutoPreamble) { int GetRfMontxIoctl (InvalidIoctl); try { const unsigned TabArgsSize (16); ::iw_priv_args TabArgs [TabArgsSize]; for (unsigned i (GetPrivateIoctls (TabArgs, TabArgsSize)) ; i ; ) if (!strcmp (TabArgs [--i].name, "set")) m_SetIoctl = TabArgs [i].cmd; else if (!strcmp (TabArgs [i].name, "rfmontx")) m_RfmontxIoctl = TabArgs [i].cmd; else if (!strcmp (TabArgs [i].name, "get_rfmontx")) GetRfMontxIoctl = TabArgs [i].cmd; else (*pHandler) (TabArgs [i]); } catch (...) { delete pHandler; throw; } delete pHandler; if (m_SetIoctl == InvalidIoctl) throw nsErrors::CException ("Can't find \"set\" private ioctl.", nsErrors::RTAdvancedSetIoctlNotFound); try { if (GetRfMontxIoctl != InvalidIoctl) { int* const pResult (reinterpret_cast (m_Data.name)); *pResult = 0; Ioctl (GetRfMontxIoctl, "Can't get rfmontx status."); if (*pResult) m_Flags |= Rfmontx; } SPrivateConfig PrivateConfig; m_Data.data.pointer = reinterpret_cast< ::caddr_t> (&PrivateConfig); m_Data.data.length = sizeof (PrivateConfig); m_Data.data.flags = StaConfigMagicNumber; Ioctl (m_PrivateIoctl, "Can't get STA config through special ioctl."); if (PrivateConfig.EnableTxBurst) m_Flags |= TxBurst; if (PrivateConfig.EnableTurboRate) m_Flags |= TurboRate; m_BGProtection = BGProtection_e (PrivateConfig.UseBGProtection); if (PrivateConfig.UseOfdmRatesIn11gAdhoc) m_Flags |= AdHocOFDM; m_Data.data.pointer = reinterpret_cast< ::caddr_t> (&m_TxPreamble); m_Data.data.length = sizeof (m_TxPreamble); m_Data.data.flags = PreambleMagicNumber; Ioctl (m_PrivateIoctl, "Can't get Tx Preamble through special ioctl."); DriverWirelessMode_e Mode; m_Data.data.pointer = reinterpret_cast< ::caddr_t> (&Mode); m_Data.data.length = sizeof (Mode); m_Data.data.flags = PhyModeMagicNumber; Ioctl (m_PrivateIoctl, "Cant get wireless mode through special ioctl."); if (Mode == B) m_Flags |= IsB_Only; } catch (const nsErrors::CSystemExc& Exc) { if (Exc.GetCode() != ENETDOWN) throw; } } // CRTAdvancedDriver() void nsWireless::CRTAdvancedDriver::SetIoctl (const char* Command, const std::string& Parameter, const std::string& ErrorMsg) const throw (nsErrors::CSystemExc) { const unsigned CstBufferSize (256); // Should be enough. char Buffer [CstBufferSize + 2]; // '=' and '\0'. m_Data.data.pointer = reinterpret_cast< ::caddr_t> (Buffer); m_Data.data.length = 0; m_Data.data.flags = 0; char* BufferIter (Buffer); while (m_Data.data.length < CstBufferSize && *Command) { *BufferIter++ = *Command++; ++m_Data.data.length; } *BufferIter = '='; ++m_Data.data.length; std::string::const_iterator ParameterIter (Parameter.begin()); while (m_Data.data.length < CstBufferSize && ParameterIter != Parameter.end()) { *++BufferIter = *ParameterIter++; ++m_Data.data.length; } *++BufferIter = '\0'; ++m_Data.data.length; #ifndef NDEBUG std::cerr << "CRTAdvancedDriver::SetIoctl() m_Data.data.pointer : " << reinterpret_cast (m_Data.data.pointer) << "\n\tm_Data.data.length : " << m_Data.data.length << std::endl; #endif // NDEBUG Ioctl (m_SetIoctl, ErrorMsg + Parameter); } // SetIoctl() void nsWireless::CRTAdvancedDriver::SetIoctl (const char* Command, int Value, const std::string& ErrorMsg) const throw (nsErrors::CSystemExc) { std::ostringstream Os; Os << Value; SetIoctl (Command, Os.str().c_str(), ErrorMsg); } // SetIoctl() nsWireless::CRT2570Driver::CRT2570Driver (const std::string& DeviceName) throw (nsErrors::CException) : CRTDriver (DeviceName), m_AuthIoctl (InvalidIoctl), m_EncIoctl (InvalidIoctl), m_KeyIoctl (InvalidIoctl), m_AdHocModeIoctl (InvalidIoctl), m_PrismHeaderIoctl (InvalidIoctl), m_RTPrivIoctl (InvalidIoctl), m_Flags (0), m_PrismMode (Default), m_AdHocMode (Std11) { const unsigned TabArgsSize (16); ::iw_priv_args TabArgs [TabArgsSize]; for (unsigned i (GetPrivateIoctls (TabArgs, TabArgsSize)) ; i ; ) if (!strcmp (TabArgs [--i].name, "auth")) m_AuthIoctl = TabArgs [i].cmd; else if (!strcmp (TabArgs [i].name, "enc")) m_EncIoctl = TabArgs [i].cmd; else if (!strcmp (TabArgs [i].name, "wpapsk")) m_KeyIoctl = TabArgs [i].cmd; else if (!strcmp (TabArgs [i].name, "adhocmode")) m_AdHocModeIoctl = TabArgs [i].cmd; else if (!strcmp (TabArgs [i].name, "rfmontx")) m_RfmontxIoctl = TabArgs [i].cmd; else if (!strcmp (TabArgs [i].name, "forceprismheader")) m_PrismHeaderIoctl = TabArgs [i].cmd; else if (!strcmp (TabArgs [i].name, "get_rtpriv")) m_RTPrivIoctl = TabArgs [i].cmd; else if (!strcmp (TabArgs [i].name, "get_rfmontx") && GetIntIoctl (TabArgs [i].cmd, "Can't get rfmontx status.")) m_Flags |= RfMontx; else if (!strcmp (TabArgs [i].name, "get_prismheader")) m_PrismMode = PrismMode_e (GetIntIoctl (TabArgs [i].cmd, "Can't get prism headers mode.")); else if (!strcmp (TabArgs [i].name, "get_adhocmode")) m_AdHocMode = AdHocMode_e (GetIntIoctl (TabArgs [i].cmd, "Can't get adhoc mode.")); if (m_EncIoctl == InvalidIoctl) throw nsErrors::CException ("Can't find \"enc\" private ioctl.", nsErrors::RT2570EncIoctlNotFound); if (m_AuthIoctl == InvalidIoctl) throw nsErrors::CException ("Can't find \"auth\" private ioctl.", nsErrors::RT2570AuthIoctlNotFound); if (m_KeyIoctl == InvalidIoctl) throw nsErrors::CException ("Can't find \"key\" private ioctl.", nsErrors::RT2570KeyIoctlNotFound); } // CRT2570Driver() void nsWireless::CRT2570Driver::GetScanResult (std::vector& CellVec) const throw (nsErrors::CException, std::bad_alloc) { #ifndef NDEBUG std::cerr << "CRT2570Driver::GetScanResult() Standard scan" << std::endl; #endif // NDEBUG CWE17Driver::GetScanResult (CellVec); #ifndef NDEBUG std::cerr << "CRT2570Driver::GetScanResult() Standard scan success, " << CellVec.size() << " cells." << std::endl; #endif // NDEBUG if (m_RTPrivIoctl != InvalidIoctl) // Backward compatibilty check. try { std::vector RalinkCellVec; #ifndef NDEBUG std::cerr << "CRT2570Driver::GetScanResult() Ralink scan" << std::endl; #endif // NDEBUG // OID_802_11_BSSID_LIST CRTDriver::GetScanResult (m_RTPrivIoctl, 0x0609U, RalinkCellVec); #ifndef NDEBUG std::cerr << "CRT2570Driver::GetScanResult() Ralink scan success, " << RalinkCellVec.size() << " cells." << std::endl; #endif // NDEBUG for (unsigned i (0) ; i < RalinkCellVec.size() && i < CellVec.size(); ++i) if (RalinkCellVec [i].GetEncryptionD().GetAuth() == WPAPSK || RalinkCellVec [i].GetEncryptionD().GetAuth() == WPANONE) // Both results seem to be always in the same order. CellVec [i].GetEncryptionD() = RalinkCellVec [i].GetEncryptionD(); } catch (const nsErrors::CException& Exc) { #ifndef NDEBUG std::cerr << "CRT2570Driver::GetScanResult() Ralink scan failed : " << Exc.GetMsg() << ' ' << Exc.GetCode() << std::endl; #endif // NDEBUG } // We have some results anyway. } // GetScanResult() void nsWireless::CRT2570Driver::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { if (Descriptor.GetAuth() == Open || Descriptor.GetAuth() == Shared) { #ifndef NDEBUG std::cerr << "CRT2570Driver::SetEncryption(), using standard ioctl." << std::endl; #endif // NDEBUG CWE17Driver::SetEncryption (Descriptor); } else { /* TODO Check if there's an order that works better, this is the same order as rt2500 currently. */ #ifndef NDEBUG std::cerr << "CRT2570Driver::SetEncryption(), using private ioctls.\n\t" "AuthName : " << GetAuthName (Descriptor.GetAuth()) << "\n\tEncryptName : " << GetEncryptName (Descriptor.GetEncrypt()) << "\n\tKey : " << std::string (Descriptor.GetKey().Get(), 0, Descriptor.GetKey().Size()) << std::endl; #endif // NDEBUG int Auth (3); // WPAPSK if (Descriptor.GetAuth() == WPA2PSK) Auth = 4; else if (Descriptor.GetAuth() == WPANONE) Auth = 5; PrivateIoctl (m_AuthIoctl, Auth, "Can't set wpa authentication."); PrivateIoctl (m_EncIoctl, Descriptor.GetEncrypt() == TKIP ? 3 : 4, "Can't set wpa encryption."); PrivateIoctl (m_KeyIoctl, std::string (Descriptor.GetKey().Get(), 0, Descriptor.GetKey().Size()), "Can't set wpa key."); } } // SetEncryption() void nsWireless::CRT2570Driver::PrivateIoctl (int IoctlCode, const std::string& Value, const std::string& ErrorMsg) throw (nsErrors::CSystemExc) { m_Data.data.pointer = reinterpret_cast< ::caddr_t> (const_cast (Value.c_str())); m_Data.data.length = Value.size(); m_Data.data.flags = 0; Ioctl (IoctlCode, ErrorMsg); } // PrivateIoctl() void nsWireless::CRT2570Driver::GetSupportedRates (std::vector& RatesVec) const throw() { CWE17Driver::GetSupportedRates (RatesVec); if (RatesVec.empty()) { // The driver doesn't report values but supports rate changing : RatesVec.push_back (54000); RatesVec.push_back (48000); RatesVec.push_back (36000); RatesVec.push_back (24000); RatesVec.push_back (18000); RatesVec.push_back (11000); RatesVec.push_back (2000); RatesVec.push_back (1000); } } // GetSupportedRates() int nsWireless::CRT2570Driver::GetIntIoctl (int Code, const std::string& ErrorMsg) throw (nsErrors::CSystemExc) { int* const pResult (reinterpret_cast (m_Data.name)); *pResult = 0; Ioctl (Code, ErrorMsg); return *pResult; } // GetIntIoctl() nsWireless::CRT61Driver::CRT61Driver (const std::string& DeviceName) throw (nsErrors::CException, std::bad_alloc) /* RT_PRIV_IOCTL, RT_OID_802_11_STA_CONFIG, RT_OID_802_11_PREAMBLE and RT_OID_PHY_MODE */ : CRTAdvancedDriver (DeviceName, SIOCIWFIRSTPRIV + 1, 0x050DU, 0x050FU, 0x050CU, new IWPrivHandlerRT61 (m_GetSiteSurveyIoctl)), m_LastScanTime (0) { } // CRT61Driver() void nsWireless::CRT61Driver::UpdateScanTime () throw() { const time_t NewTime (time (0)); if (NewTime != -1) // Ignore errors. m_LastScanTime = NewTime; } // UpdateScanTime() void nsWireless::CRT61Driver::GetScanResult (std::vector& CellVec) const throw (nsErrors::CException, std::bad_alloc) { // OID_802_11_BSSID_LIST //CRTAdvancedDriver::GetScanResult (0x0609U, CellVec); const time_t CurrentTime (time (0)); if (CurrentTime != -1 && CurrentTime - 4 < m_LastScanTime) { #ifndef NDEBUG std::cerr << "CRT61Driver::GetScanResult() Simulate EAGAIN.\n"; #endif // NDEBUG throw nsErrors::CException ("Simulate EAGAIN.", EAGAIN); } m_Data.data.length = 8192; char Buffer [m_Data.data.length]; m_Data.data.pointer = reinterpret_cast< ::caddr_t> (Buffer); m_Data.data.flags = 0; Ioctl (m_GetSiteSurveyIoctl, "Can't get scan result through private" " ioctl."); const char* const End (Buffer + m_Data.data.length - 1); #ifndef NDEBUG std::cerr << "CRT61Driver::GetScanResult() raw data : " << std::string (Buffer, 0, m_Data.data.length) << "\nSize : " << m_Data.data.length << std::endl; #endif // NDEBUG const size_t LineSize ((m_Data.data.length - 1) % 109 ? 117 : 109); for (const char* Iter (Buffer + LineSize) ; Iter < End ; Iter += LineSize) CellVec.push_back (ToCellRt61 (Iter)); #ifndef NDEBUG std::cerr << "Raw data successfully processed.\n"; #endif // NDEBUG } // GetScanResult() void nsWireless::CRT61Driver::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { if (Descriptor.GetAuth() == Open || Descriptor.GetAuth() == Shared) { #ifndef NDEBUG std::cerr << "CRT61Driver::SetEncryption(), using standard ioctl." << std::endl; #endif // NDEBUG CWE17Driver::SetEncryption (Descriptor); } else { #ifndef NDEBUG std::cerr << "CRT61Driver::SetEncryption(), using private ioctls.\n\t" "AuthName : " << GetAuthName (Descriptor.GetAuth()) << "\n\tEncryptName : " << GetEncryptName (Descriptor.GetEncrypt()) << "\n\tKey : " << std::string (Descriptor.GetKey().Get(), 0, Descriptor.GetKey().Size()) << std::endl; #endif // NDEBUG SetIoctl ("AuthMode", GetAuthName (Descriptor.GetAuth()), "Can't set authentication mode : "); SetIoctl ("EncrypType", GetEncryptName (Descriptor.GetEncrypt()), "Can't set encryption type : "); SetIoctl ("WPAPSK", std::string (Descriptor.GetKey().Get(), 0, Descriptor.GetKey().Size()), "Can't set key : "); } } // SetEncryption() void nsWireless::CRT61Driver::IWPrivHandlerRT61::operator () (const ::iw_priv_args& Arg) throw (nsErrors::CException) { if (!strcmp (Arg.name, "get_site_survey")) m_GetSiteSurveyIoctl = Arg.cmd; } // operator()() // FIXME Some code duplicated from RT61. void nsWireless::CRT73Driver::GetScanResult (std::vector& CellVec) const throw (nsErrors::CException, std::bad_alloc) { // OID_802_11_BSSID_LIST //CRTAdvancedDriver::GetScanResult (0x0609U, CellVec); const time_t CurrentTime (time (0)); if (CurrentTime != -1 && CurrentTime - 4 < GetLastScanTime()) { #ifndef NDEBUG std::cerr << "CRT73Driver::GetScanResult() Simulate EAGAIN.\n"; #endif // NDEBUG throw nsErrors::CException ("Simulate EAGAIN.", EAGAIN); } m_Data.data.length = 8192; char Buffer [m_Data.data.length]; m_Data.data.pointer = reinterpret_cast< ::caddr_t> (Buffer); m_Data.data.flags = 0; Ioctl (GetSiteSurveyIoctl(), "Can't get scan result through private" " ioctl."); const char* const End (Buffer + m_Data.data.length - 1); #ifndef NDEBUG std::cerr << "CRT73Driver::GetScanResult() raw data : " << std::string (Buffer, 0, m_Data.data.length) << "\nSize : " << m_Data.data.length << std::endl; #endif // NDEBUG const size_t LineSize (109); for (const char* Iter (Buffer + LineSize) ; Iter < End ; Iter += LineSize) CellVec.push_back (ToCellRt73 (Iter)); #ifndef NDEBUG std::cerr << "Raw data successfully processed.\n"; #endif // NDEBUG } // GetScanResult() void nsWireless::CRT73Driver::SetRfmontx (bool B) throw (nsErrors::CSystemExc) { char Buffer (B ? '1' : '0'); m_Data.data.pointer = reinterpret_cast< ::caddr_t> (&Buffer); m_Data.data.length = sizeof (Buffer); m_Data.data.flags = 0; Ioctl (GetRfmontxIoctl(), "Can't set injection mode."); SetFlag (Rfmontx, B); } // SetRfmontx() RutilTv0.18/lib/src/ProfileEditor.cxx0000644000175000017500000000622410705153462017171 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file ProfileEditor.cxx \author Romain BONDUE \date 02/04/2006 */ #include "ProfileEditor.h" #include "UserData.h" #include "GtkGUI.h" // NotifyError() #include "WWidgets.h" nsCore::CProfileEditor::~CProfileEditor () throw() {} bool nsCore::CProfileEditor::Edit (::GtkWindow* pMainWindow, nsUserData::CProfile& Profile) throw() { m_pDialog->SetConfigName (Profile.GetName()); m_pDialog->SetSSID (Profile.GetSSID()); m_pDialog->SetMode (Profile.GetMode()); m_pDialog->SetChannel (Profile.GetChannel()); m_pDialog->SetAuth (Profile.GetEncryptionD().GetAuth()); m_pDialog->SetEncrypt (Profile.GetEncryptionD().GetEncrypt()); m_pDialog->SetDefaultKey (Profile.GetEncryptionD().GetDefaultKey()); for (unsigned I (0) ; I < m_pDialog->GetNbKey() ; ++I) m_pDialog->SetKey (Profile.GetEncryptionD().GetKey (I), I); m_pDialog->SetIPSetting (Profile.GetIPSettings().GetSetting()); bool IsModified (false); while (m_pDialog->Run (pMainWindow)) { const std::string Name (m_pDialog->GetConfigName()); const std::string SSID (m_pDialog->GetSSID()); const nsWireless::Mode_e Mode (m_pDialog->GetMode()); if (Name.empty() || Mode != nsWireless::Monitor && SSID.empty()) nsGUI::NotifyError ("Empty profile name and/or SSID.", 0, GTK_WINDOW (m_pDialog->operator ::GtkDialog*())); else if (m_pDialog->GetEncrypt() != nsWireless::None && m_pDialog->GetKey (0).Empty()) nsGUI::NotifyError ("Empty key.", 0, GTK_WINDOW (m_pDialog->operator ::GtkDialog*())); else { Profile.GetEncryptionD().SetAuth (m_pDialog->GetAuth()); Profile.GetEncryptionD().SetEncrypt (m_pDialog->GetEncrypt()); for (unsigned I (0) ; I < m_pDialog->GetNbKey() ; ++I) Profile.GetEncryptionD().SetKey (m_pDialog->GetKey (I), I); Profile.GetEncryptionD().SetDefaultKey (m_pDialog->GetDefaultKey()); Profile.SetName (Name); Profile.SetSSID (SSID); Profile.SetMode (Mode); Profile.SetChannel (m_pDialog->GetChannel()); Profile.GetIPSettings().SetSetting (m_pDialog->GetIPSetting()); IsModified = true; break; } } m_pDialog->Hide(); return IsModified; } // Edit() RutilTv0.18/lib/src/CWE17Module.cxx0000644000175000017500000001273510722350737016365 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CWE17Module.cxx \author Romain BONDUE \date 21/08/2005 */ #include #include "CWE17Module.h" #include "WE17Driver.h" #include "WE17DriverRoot.h" #include "WWidgets.h" namespace { const unsigned TabModeSize (7); const nsWireless::Mode_e TabMode [TabModeSize] = {nsWireless::Auto, nsWireless::AdHoc, nsWireless::Managed, nsWireless::Master, nsWireless::Repeater, nsWireless::Secondary, nsWireless::Monitor}; const unsigned TabAuthSize (2); const nsWireless::AuthType_e TabAuth [TabAuthSize] = {nsWireless::Open, nsWireless::Shared}; const unsigned TabNoneEncryptSize (2); const nsWireless::EncryptType_e TabNoneEncrypt [TabNoneEncryptSize] = {nsWireless::None, nsWireless::WEP}; const unsigned TabSharedEncryptSize (1); const nsWireless::EncryptType_e TabSharedEncrypt [TabSharedEncryptSize] = {nsWireless::WEP}; void ApplyProfile (const nsUserData::CProfile& Profile, nsWireless::CWE17Driver& Driver, const nsWireless::CMacAddress* pAddress = 0) throw (nsErrors::CSystemExc) { Driver.SetSSID (Profile.GetSSID()); nsWireless::Mode_e CurrentMode (nsWireless::Unknown); try{CurrentMode = Driver.GetMode();} catch (...) {} // Ignore everything. if (CurrentMode != Profile.GetMode()) Driver.SetMode (Profile.GetMode()); try{Driver.SetChannel (Profile.GetChannel());} catch (const nsErrors::CSystemExc&) { // May be fine in managed mode. if (Profile.GetMode() != nsWireless::Managed) throw; } Driver.SetEncryption (Profile.GetEncryptionD()); if (pAddress) try{Driver.SetAPMacAddr (*pAddress);} catch (const nsErrors::CSystemExc&) {} // May fail. try{Driver.Commit();} // May fail because it's not always a necessity. catch (const nsErrors::CSystemExc&) {} } // ApplyProfile() } // anonymous namespace const char* const nsCore::CWE17Module::NewProfileDefaultName ("New profile"); nsCore::CWE17Module::~CWE17Module () throw() {} void nsCore::CWE17Module::RecordProfiles () throw (nsErrors::CException) { m_ProfilesFile.Record(); } // RecordProfiles() void nsCore::CWE17CLIModule::ApplyProfile (unsigned Pos) throw (nsErrors::CSystemExc) { ::ApplyProfile (m_ProfilesFile.GetProfile (Pos), m_Driver); } // ApplyProfile() nsCore::CWE17Module::CWE17Module (const std::string& DeviceName, const std::string& Path) throw (nsErrors::CException, std::bad_alloc) : m_pDriver (new nsWireless::CWE17Driver (DeviceName)), m_Editor (new nsGUI::CSharedConfigDialog (TabMode, TabModeSize, m_pDriver->GetSupportedFreq(), TabAuth, TabAuthSize, TabNoneEncrypt, TabNoneEncryptSize, TabSharedEncrypt, TabSharedEncryptSize, 0, 0)) { m_ProfilesFile.Extract(); } // CWE17Module() nsUserData::CProfile* nsCore::CWE17Module::EditNewProfile (::GtkWindow* pMainWindow) throw() { nsUserData::CProfile* const pProfile (&m_ProfilesFile.GetProfile (m_ProfilesFile.Size() - 1U)); if (!m_Editor.Edit (pMainWindow, *pProfile)) { m_ProfilesFile.DeleteLastProfile(); return 0; } return pProfile; } // EditNewProfile() void nsCore::CWE17Module::ApplyProfile (unsigned Pos) throw (nsErrors::CSystemExc) { ::ApplyProfile (m_ProfilesFile.GetProfile (Pos), *m_pDriver); } // ApplyProfile() void nsCore::CWE17Module::ApplyProfile (unsigned Pos, const nsWireless::CMacAddress& Address) throw (nsErrors::CSystemExc) { ::ApplyProfile (m_ProfilesFile.GetProfile (Pos), *m_pDriver, &Address); } // ApplyProfile() void nsCore::CWE17Module::BecomeRoot () throw (nsErrors::CException, std::bad_alloc) { m_pDriver.reset (new nsWireless::CWE17DriverRoot (m_pDriver->GetDeviceName())); } // BecomeRoot() RutilTv0.18/lib/src/XMLParser.cxx0000644000175000017500000001466010705133614016237 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file XMLParser.cxx \author Romain BONDUE \date 03/08/2006 */ #include #include #include "XMLParser.h" #include "ErrorsCode.h" namespace { void MakeError (::GError** ppError, ::GMarkupParseContext* pContext, int Code, const std::string& Label) throw() { int LineNumber, CharacterPosition; ::g_markup_parse_context_get_position (pContext, &LineNumber, &CharacterPosition); std::ostringstream Os; Os << Label << '\n' << "Line : " << LineNumber << '\t' << "Column : " << CharacterPosition; *ppError = ::g_error_new_literal (G_MARKUP_ERROR, Code, Os.str().c_str()); } // MakeError() } // anonymous namespace const char* const nsUserData::XMLHeader (""); const char* const nsUserData::Markup2B ("\n"); void nsUserData::CXMLParser::Extract (const std::string& FileName) throw (nsErrors::CException) { std::ifstream Is (FileName.c_str()); if (!Is) return; // No file : nothing to load. const ::GMarkupParser Parser = { reinterpret_cast (&_StartElement), reinterpret_cast (&_EndElement), reinterpret_cast (&_Text), 0, // &Ignored reinterpret_cast (&_Error)}; ::GMarkupParseContext* const pContext (::g_markup_parse_context_new (&Parser, ::GMarkupParseFlags (0), this, 0)); ::GError* pError (0); try { Is.exceptions (std::ios_base::badbit); const unsigned BufferSize (256); char Buffer [BufferSize]; while (Is) { Is.read (Buffer, BufferSize); if (!::g_markup_parse_context_parse (pContext, Buffer, Is.gcount(), &pError)) throw nsErrors::CException (pError->message, pError->code); } if (!::g_markup_parse_context_end_parse (pContext, &pError)) throw nsErrors::CException (pError->message, nsErrors::ProfilesExtractionExtraToken); ::g_markup_parse_context_free (pContext); } catch (const std::ios_base::failure& Exc) { ::g_markup_parse_context_free (pContext); throw nsErrors::CException (Exc.what(), nsErrors::ProfilesExtractionFailure); } catch (const nsErrors::CException&) { ::g_markup_parse_context_free (pContext); ::g_error_free (pError); throw; } } // Extract() void nsUserData::CXMLParser::_StartElement (::GMarkupParseContext* pContext, const char* ElementName, const char** AttributeNames, const char** AttributeValues, CXMLParser* This, ::GError** ppError) throw() { try{This->StartElement (ElementName, AttributeNames, AttributeValues);} catch (const nsErrors::CException& Exc) { MakeError (ppError, pContext, Exc.GetCode(), Exc.GetMsg()); } catch (const std::bad_alloc& Exc) { MakeError (ppError, pContext, nsErrors::OutOfMemory, Exc.what()); } } // _StartElement() void nsUserData::CXMLParser::_EndElement (::GMarkupParseContext* pContext, const char* ElementName, CXMLParser* This, ::GError** ppError) throw() { try{This->EndElement (ElementName);} catch (const nsErrors::CException& Exc) { MakeError (ppError, pContext, Exc.GetCode(), Exc.GetMsg()); } } // _EndElement() // Text is not null-terminated. void nsUserData::CXMLParser::_Text (::GMarkupParseContext* pContext, const char* Text, ::gsize Length, CXMLParser* This, ::GError** ppError) throw() { // This function is often called when we don't expect it. if (!Length) return; unsigned i (0); for ( ; i < Length ; ++i) // We ignore indentation and things like that. if (!isspace (static_cast (Text [i]))) break; if (i == Length) return; try{This->Text (::g_markup_parse_context_get_element (pContext), std::string (Text, 0, Length));} catch (const nsErrors::CException& Exc) { MakeError (ppError, pContext, Exc.GetCode(), Exc.GetMsg()); } } // _Text() // IgnoredText is not null-terminated. /*void nsUserData::CXMLParser::Ignored (::GMarkupParseContext* pContext, const char* IgnoredText, unsigned Length, CXMLParser*, ::GError** ppError) throw() { } // Ignored()*/ void nsUserData::CXMLParser::_Error (::GMarkupParseContext* pContext, ::GError* ppError, CXMLParser* This) throw() { This->Error(); } // Error() RutilTv0.18/lib/src/PrefsPage.cxx0000644000175000017500000002472711054622203016276 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file PrefsPage.cxx \author Romain BONDUE \date 19/07/2006 */ #include #include // strcmp() #include "PrefsPage.h" #include "StaticSettings.h" namespace { std::string ToMbpsStr (int Value) throw() { std::ostringstream Os; Os << Value / 1000.0 << " Mbps"; return Os.str(); } // ToMbpsStr() const unsigned NbDelay (7); unsigned TabDelay [NbDelay] = {1, 3, 5, 10, 15, 30, 60}; void DeleteCallback (::GtkWidget* pWidget, ::gint, void*) throw() { ::gtk_widget_destroy (pWidget); } // DeleteCallback() } // anonymous namespace nsGUI::CPrefsPage::CPrefsPage (bool IsRoot) throw() : m_pTable (GTK_TABLE (::gtk_table_new (6, 2, true))), m_pStartMinimizedButton (GTK_CHECK_BUTTON (::gtk_check_button_new_with_label ("Start hidden in tray"))), m_pAboutButton (GTK_BUTTON (::gtk_button_new_from_stock (GTK_STOCK_ABOUT))), m_pChangeInterface (GTK_BUTTON (::gtk_button_new_with_label ("Change interface"))), m_pRootModeButton (GTK_TOGGLE_BUTTON (::gtk_toggle_button_new_with_label ("Priviliged mode"))), m_pLeaveRootModeBox (GTK_COMBO_BOX (::gtk_combo_box_new_text())), m_pRatesLabel (::gtk_label_new ("Maximum Tx rate")), m_NbRate (0), m_pRatesBox (GTK_COMBO_BOX (::gtk_combo_box_new_text())), m_pTrayIconButton (GTK_CHECK_BUTTON (::gtk_check_button_new_with_label ("Display tray icon"))), m_pIfaceStatusButton (GTK_TOGGLE_BUTTON (::gtk_toggle_button_new())), m_pIfaceLabel (GTK_LABEL (::gtk_label_new (0))) { BuildUI (IsRoot); } // CPrefsPage() void nsGUI::CPrefsPage::BuildUI (bool IsRoot) throw() { ::gtk_container_set_border_width (GTK_CONTAINER (m_pTable), 6); ::gtk_table_set_col_spacings (m_pTable, 12); ::gtk_table_set_row_spacings (m_pTable, 8); ::gtk_container_add (GTK_CONTAINER (m_pIfaceStatusButton), GTK_WIDGET (m_pIfaceLabel)); ::gtk_table_attach_defaults (m_pTable, ::gtk_label_new ("The interface is" " currently : "), 0, 1, 0, 1); ::gtk_table_attach (m_pTable, GTK_WIDGET (m_pIfaceStatusButton), 1, 2, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); ::gtk_table_attach_defaults (m_pTable, m_pRatesLabel, 0, 1, 1, 2); ::gtk_table_attach (m_pTable, GTK_WIDGET (m_pRatesBox), 1, 2, 1, 2, GTK_FILL, GTK_SHRINK, 0, 0); ::gtk_table_attach (m_pTable, GTK_WIDGET (m_pTrayIconButton), 0, 1, 2, 3, GTK_EXPAND, GTK_EXPAND, 0, 0); ::gtk_table_attach (m_pTable, GTK_WIDGET (m_pStartMinimizedButton), 1, 2, 2, 3, GTK_EXPAND, GTK_EXPAND, 0, 0); ::gtk_table_attach (m_pTable, GTK_WIDGET (m_pChangeInterface), 0, 1, 3, 4, GTK_EXPAND, GTK_EXPAND, 0, 0); ::gtk_table_attach (m_pTable, GTK_WIDGET (m_pRootModeButton), 1, 2, 3, 4, GTK_EXPAND, GTK_EXPAND, 0, 0); ::GtkWidget* const pLabel (::gtk_label_new ("Leave priviliged mode after")); ::gtk_table_attach_defaults (m_pTable, pLabel, 0, 1, 4, 5); ::gtk_table_attach (m_pTable, GTK_WIDGET (m_pLeaveRootModeBox), 1, 2, 4, 5, GTK_FILL, GTK_SHRINK, 0, 0); ::gtk_combo_box_append_text (m_pLeaveRootModeBox, "Disabled"); for (unsigned i (0) ; i < NbDelay ; ++i) { std::ostringstream Os; Os << TabDelay [i] << " minute" << (TabDelay [i] > 1 ? 's' : '\0'); ::gtk_combo_box_append_text (m_pLeaveRootModeBox, Os.str().c_str()); } ::gtk_table_attach (m_pTable, GTK_WIDGET (m_pAboutButton), 0, 2, 5, 6, GTK_EXPAND, GTK_EXPAND, 0, 0); ::g_signal_connect (G_OBJECT (m_pAboutButton), "clicked", G_CALLBACK (AboutButtonClicked), this); ::g_signal_connect (G_OBJECT (m_pTrayIconButton), "clicked", G_CALLBACK (TrayIconButtonClicked), this); if (IsRoot) { ::gtk_widget_set_sensitive (GTK_WIDGET (m_pRootModeButton), false); ::gtk_widget_set_sensitive (pLabel, false); ::gtk_widget_set_sensitive (GTK_WIDGET (m_pLeaveRootModeBox), false); } ::gtk_widget_set_sensitive (GTK_WIDGET (m_pStartMinimizedButton), false); } // BuildUI() void nsGUI::CPrefsPage::AboutButtonClicked (::GtkButton*, CPrefsPage* This) throw() { ::GtkAboutDialog* const m_pAboutDialog (GTK_ABOUT_DIALOG (::gtk_about_dialog_new())); ::gtk_window_set_transient_for (GTK_WINDOW (m_pAboutDialog), GTK_WINDOW (::gtk_widget_get_toplevel (GTK_WIDGET (This->m_pTable)))); ::gtk_about_dialog_set_name (m_pAboutDialog, "RutilT"); ::gtk_about_dialog_set_version (m_pAboutDialog, nsCore::VersionLabel.c_str()); ::gtk_about_dialog_set_copyright (m_pAboutDialog, "Copyright © 2005-2008 Romain BONDUE"); ::gtk_about_dialog_set_comments (m_pAboutDialog, "Wireless devices" " configuration tool\n with extra support for Ralink devices."); ::gtk_about_dialog_set_license (m_pAboutDialog, "This program is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation; either version 2 of the License, or\n" "(at your option) any later version.\n" "\n" "This program is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n" "\n" "You should have received a copy of the GNU General Public License\n" "along with this program; if not, write to the Free Software\n" "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"); ::gtk_about_dialog_set_website (m_pAboutDialog, "http://cbbk.free.fr/bonrom/"); const char* Authors [] = {"Romain BONDUE ", "", "Contributors :", "Neil Armstrong", "Nicolas Favre-Félix", "Szymon Dziok", "Vincent Stehlé", "Kirk Williams", "Alessandro Grechi - AleXit", "Cesare Tirabassi", "Misha Aizatulin", "Ben Hutchings", "", "And thanks to the people who sent feedbacks,", "bug reports and/or helped testing.", 0}; ::gtk_about_dialog_set_authors (m_pAboutDialog, Authors); const char* Artists [] = {"Cyril BONDUE", 0}; ::gtk_about_dialog_set_artists (m_pAboutDialog, Artists); ::gtk_about_dialog_set_documenters (m_pAboutDialog, 0); ::gtk_about_dialog_set_translator_credits (m_pAboutDialog, 0); ::g_signal_connect (G_OBJECT (m_pAboutDialog), "response", G_CALLBACK (DeleteCallback), 0); ::gtk_widget_show_all (GTK_WIDGET (m_pAboutDialog)); } // AboutButtonClicked() void nsGUI::CPrefsPage::SetRates (const std::vector& RatesVec) throw() { for ( ; m_NbRate ; --m_NbRate) ::gtk_combo_box_remove_text (m_pRatesBox, 0); if (RatesVec.empty()) { ::gtk_widget_set_sensitive (GTK_WIDGET (m_pRatesLabel), false); ::gtk_widget_set_sensitive (GTK_WIDGET (m_pRatesBox), false); } else { ::gtk_widget_set_sensitive (GTK_WIDGET (m_pRatesLabel), true); ::gtk_widget_set_sensitive (GTK_WIDGET (m_pRatesBox), true); for (std::vector::size_type i (0) ; i < RatesVec.size() ; ++i) ::gtk_combo_box_append_text (m_pRatesBox, ToMbpsStr (RatesVec [i]).c_str()); m_NbRate = RatesVec.size(); } } // SetRates() void nsGUI::CPrefsPage::TrayIconButtonClicked (::GtkToggleButton* pButton, CPrefsPage* This) throw() { if (::gtk_toggle_button_get_active (pButton)) ::gtk_widget_set_sensitive (GTK_WIDGET (This->m_pStartMinimizedButton), true); else { ::gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (This->m_pStartMinimizedButton), false); ::gtk_widget_set_sensitive (GTK_WIDGET (This->m_pStartMinimizedButton), false); } } // TrayIconButtonClicked() unsigned nsGUI::CPrefsPage::GetAutoLeaveRootDelay () const throw() { const char* const DelayStr (::gtk_combo_box_get_active_text (m_pLeaveRootModeBox)); unsigned Delay (0); if (DelayStr) { std::istringstream Is (DelayStr); Is >> Delay; } return Delay * 60; } // GetAutoLeaveRootDelay() void nsGUI::CPrefsPage::SetAutoLeaveRootDelay (unsigned Delay) throw() { Delay /= 60; for (unsigned i (0) ; i < NbDelay ; ++i) if (Delay == TabDelay [i]) { ::gtk_combo_box_set_active (m_pLeaveRootModeBox, i + 1); return; } ::gtk_combo_box_set_active (m_pLeaveRootModeBox, 0); } // SetAutoLeaveRootDelay() int nsGUI::CPrefsPage::GetSelectedRate () const throw() { float Rate (0.F); const char* const Text (::gtk_combo_box_get_active_text (m_pRatesBox)); if (Text) { std::istringstream Is (Text); Is >> Rate; } return int (Rate * 1000); } // GetSelectedRate() RutilTv0.18/lib/src/CSelectableRowList.cxx0000644000175000017500000002133710722350737020121 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CSelectableRowList.cxx \author Romain BONDUE \date 28/07/2005 */ #include // atoi() #include // memset() #include "CSelectableRowList.h" #include "GtkGUI.h" nsGUI::CSelectableRowList::CSelectableRowList (unsigned NbColumn, const ::GType* TabType, const char** TabTitle, CGtkGUI* pUI, GUICallBack pGUICB) throw() : m_pListStore (GTK_LIST_STORE (::gtk_list_store_newv (NbColumn, const_cast< ::GType*> (TabType)))), m_pListView (GTK_TREE_VIEW (::gtk_tree_view_new_with_model (GTK_TREE_MODEL (m_pListStore)))), m_pScrollWindow (::gtk_scrolled_window_new (0, 0)), m_pButtonRenderer (GTK_CELL_RENDERER_TOGGLE (::gtk_cell_renderer_toggle_new())), m_SelectedRow (None), m_pUI (pUI), m_pGUICallBack (pGUICB) { // Add the radio buttons column : ::gtk_cell_renderer_toggle_set_radio (GTK_CELL_RENDERER_TOGGLE (m_pButtonRenderer), true); ::gtk_tree_view_append_column (m_pListView, ::gtk_tree_view_column_new_with_attributes (0, GTK_CELL_RENDERER (m_pButtonRenderer), "active", 0, reinterpret_cast (0))); // Set the signals : ::gtk_tree_selection_set_select_function ( ::gtk_tree_view_get_selection (m_pListView), reinterpret_cast< ::GtkTreeSelectionFunc> (_RowSelectedCallBack), this, 0); ::g_signal_connect (G_OBJECT (m_pButtonRenderer), "toggled", G_CALLBACK (ToggledCallBack), this); ::g_signal_connect (G_OBJECT (m_pListView), "row-activated", G_CALLBACK (DoubleClickCallBack), this); // Now the user data columns : GtkCellRenderer* const pRenderer (::gtk_cell_renderer_text_new()); // I could easily make the column sortable, but it's a bit pointless. for (unsigned i (1) ; i < NbColumn ; ++i) ::gtk_tree_view_append_column (m_pListView, ::gtk_tree_view_column_new_with_attributes (TabTitle [i], pRenderer, "text", i, reinterpret_cast (0))); ::gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (m_pScrollWindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); ::gtk_container_add (GTK_CONTAINER (m_pScrollWindow), GTK_WIDGET (m_pListView)); ::gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (m_pScrollWindow), GTK_SHADOW_IN); } // CSelectableRowList() void nsGUI::CSelectableRowList::SetData (unsigned Row, unsigned Column, bool UserVal) throw() { ::GValue Value; memset (&Value, 0, sizeof (::GValue)); ::g_value_init (&Value, G_TYPE_BOOLEAN); ::g_value_set_boolean (&Value, UserVal); SetData (Row, Column, &Value); } // SetData() void nsGUI::CSelectableRowList::SetData (unsigned Row, unsigned Column, unsigned UserVal) throw() { ::GValue Value; memset (&Value, 0, sizeof (::GValue)); ::g_value_init (&Value, G_TYPE_UINT); ::g_value_set_uint (&Value, UserVal); SetData (Row, Column, &Value); } // SetData() void nsGUI::CSelectableRowList::SetData (unsigned Row, unsigned Column, int UserVal) throw() { ::GValue Value; memset (&Value, 0, sizeof (::GValue)); ::g_value_init (&Value, G_TYPE_INT); ::g_value_set_int (&Value, UserVal); SetData (Row, Column, &Value); } // SetData() void nsGUI::CSelectableRowList::SetData (unsigned Row, unsigned Column, float UserVal) throw() { ::GValue Value; memset (&Value, 0, sizeof (::GValue)); ::g_value_init (&Value, G_TYPE_FLOAT); ::g_value_set_float (&Value, UserVal); SetData (Row, Column, &Value); } // SetData() void nsGUI::CSelectableRowList::SetData (unsigned Row, unsigned Column, const std::string& UserVal) throw() { ::GValue Value; memset (&Value, 0, sizeof (::GValue)); ::g_value_init (&Value, G_TYPE_STRING); ::g_value_set_string (&Value, UserVal.c_str()); SetData (Row, Column, &Value); } // SetData() void nsGUI::CSelectableRowList::SetData (unsigned Row, unsigned Column, ::GValue* pValue) throw() { if (Row >= m_IterVec.size()) // Make the row if needed. { Row = m_IterVec.size(); m_IterVec.push_back (::GtkTreeIter()); ::gtk_list_store_insert (m_pListStore, &m_IterVec.back(), Row); } ::gtk_list_store_set_value (m_pListStore, &m_IterVec [Row], Column, pValue); } // SetData() void nsGUI::CSelectableRowList::DeleteRow (unsigned Row) throw() { if (int (Row) == m_SelectedRow) ::gtk_tree_selection_unselect_iter (::gtk_tree_view_get_selection (m_pListView), &m_IterVec [Row]); ::gtk_list_store_remove (m_pListStore, &m_IterVec [Row]); m_IterVec.erase (m_IterVec.begin() + Row); } // DeleteRow() void nsGUI::CSelectableRowList::DoubleClickCallBack (::GtkTreeView*, ::GtkTreePath*, ::GtkTreeViewColumn*, CSelectableRowList* This) throw() { // Trigger the row only if the button is not already selected. if (!::gtk_cell_renderer_toggle_get_active (This->m_pButtonRenderer)) This->RowTriggered(); } // DoubleClickCallBack() void nsGUI::CSelectableRowList::ToggledCallBack (::GtkCellRendererToggle* pRenderer, const char* Path, CSelectableRowList* This) throw() { // Trigger the row only if the button is not already selected. if (!::gtk_cell_renderer_toggle_get_active (pRenderer)) { ::gtk_tree_selection_select_iter (::gtk_tree_view_get_selection (This->m_pListView), &This->m_IterVec [atoi(Path)]); This->RowTriggered(); } } // ToggledCallBack() bool nsGUI::CSelectableRowList::_RowSelectedCallBack (::GtkTreeSelection*, ::GtkTreeModel*, ::GtkTreePath* pTreePath, bool IsCurrentlySelected, CSelectableRowList* This) throw() { const int Row (::gtk_tree_path_get_indices (pTreePath) [0]); if (IsCurrentlySelected) { This->m_SelectedRow = None; This->RowUnselectedCallBack(); } // We need this check because this callback is called twice on select. else if (Row != This->m_SelectedRow) { This->m_SelectedRow = Row; This->RowSelectedCallBack(); } return true; // The selection is accepted. } // RowSelectedCallBack() void nsGUI::CSelectableRowList::RowTriggered () throw() { if (m_pUI && m_pGUICallBack && (m_pUI->*m_pGUICallBack) (m_SelectedRow)) for (unsigned i (0) ; i < m_IterVec.size() ; ++i) SetData (i, 0, int (i) == m_SelectedRow); } // RowTriggered() RutilTv0.18/lib/src/CProfileTab.cxx0000644000175000017500000001274210722350737016561 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CProfileTab.cxx \author Romain BONDUE \date 05/08/2005 */ #include "CProfileTab.h" #include "GtkGUI.h" #include "Parameters.h" #include "UserData.h" namespace { inline void PrepareButton (::GtkWidget* pButton, void (*CallBack) (::GtkButton*, nsGUI::CProfileTab*), nsGUI::CProfileTab* This) throw() { ::gtk_widget_set_sensitive (pButton, false); ::g_signal_connect (G_OBJECT (pButton), "clicked", G_CALLBACK (CallBack), This); } // PrepareButton() } // anonymous namespace const char* nsGUI::CProfileTab::ColumnTitle [NbColumn] = {"", "Profile", "SSID","Mode", "Channel", "Encryption", "Authentication"}; const ::GType nsGUI::CProfileTab::TabType [NbColumn] = { G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING}; nsGUI::CProfileTab::CProfileTab (CGtkGUI* pUI) throw() : CSelectableRowList (NbColumn, TabType, ColumnTitle, pUI, &CGtkGUI::ApplyProfile), m_pHBox (GTK_BOX (::gtk_hbox_new (false, 4))), m_pDeleteButton (::gtk_button_new_from_stock (GTK_STOCK_DELETE)), m_pEditButton (::gtk_button_new_from_stock (GTK_STOCK_EDIT)), m_pApplyButton (::gtk_button_new_from_stock (GTK_STOCK_APPLY)) { PrepareButton (m_pDeleteButton, DeleteButtonCallBack, this); PrepareButton (m_pEditButton, EditButtonCallBack, this); PrepareButton (m_pApplyButton, ApplyButtonCallBack, this); ::GtkWidget* const pNewProfileButton (::gtk_button_new_from_stock (GTK_STOCK_NEW)); ::g_signal_connect (G_OBJECT (pNewProfileButton), "clicked", G_CALLBACK (NewProfileButtonCallBack), this); ::GtkBox* const pVBox (GTK_BOX (::gtk_vbutton_box_new())); ::gtk_button_box_set_layout (GTK_BUTTON_BOX (pVBox), GTK_BUTTONBOX_SPREAD); ::gtk_container_add (GTK_CONTAINER (pVBox), pNewProfileButton); ::gtk_container_add (GTK_CONTAINER (pVBox), m_pApplyButton); ::gtk_container_add (GTK_CONTAINER (pVBox), m_pEditButton); ::gtk_container_add (GTK_CONTAINER (pVBox), m_pDeleteButton); ::gtk_container_set_border_width (GTK_CONTAINER (m_pHBox), 6); ::gtk_box_pack_start_defaults (m_pHBox, CSelectableRowList::operator ::GtkWidget*()); ::gtk_box_pack_start_defaults (m_pHBox, GTK_WIDGET (pVBox)); } // CProfileTab() void nsGUI::CProfileTab::SetProfile (unsigned Row, const nsUserData::CProfile& Profile) throw() { SetData (Row, NamePos, Profile.GetName()); SetData (Row, SSIDPos, Profile.GetSSID()); SetData (Row, ModePos, nsWireless::GetModeName (Profile.GetMode())); SetData (Row, ChannelPos, Profile.GetChannel()); SetData (Row, EncryptPos, nsWireless::GetEncryptName (Profile.GetEncryptionD().GetEncrypt())); SetData (Row, AuthPos, nsWireless::GetAuthName (Profile.GetEncryptionD().GetAuth())); } // SetProfile() void nsGUI::CProfileTab::DeleteButtonCallBack (::GtkButton*, CProfileTab* This) throw() { const unsigned SelectedRow (This->GetSelectedRow()); if (This->GetUI()->DeleteProfile (SelectedRow)) This->DeleteRow (SelectedRow); } // DeleteButtonCallBack() void nsGUI::CProfileTab::EditButtonCallBack (::GtkButton*, CProfileTab* This) throw() { const nsUserData::CProfile* const pProfile (This->GetUI()->EditProfile()); if (pProfile) { This->SetSelected (This->GetSelectedRow(), false); This->SetProfile (This->GetSelectedRow(), *pProfile); } } // EditButtonCallBack() void nsGUI::CProfileTab::ApplyButtonCallBack (::GtkButton*, CProfileTab* This) throw() { This->RowTriggered(); } // ApplyButtonCallBack() void nsGUI::CProfileTab::NewProfileButtonCallBack (::GtkButton*, CProfileTab* This) throw() { const nsUserData::CProfile* const pProfile (This->GetUI()->NewProfile()); if (pProfile) This->AddProfile (*pProfile); } // NewProfileButtonCallBack() RutilTv0.18/lib/src/RutilT.cxx0000644000175000017500000001334011054622761015643 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RutilT.cxx \author Romain BONDUE \date 05/07/2005 */ #include #include #include #include extern "C"{ #include } #include "Exceptions.h" #include "ErrorsCode.h" #include "CLIOpt.h" #include "GtkGUI.h" #include "Module.h" #include "NetTools.h" #include "UserData.h" #include "IDriver.h" #include "StaticSettings.h" namespace { void ApplyProfile (nsCore::ICLIModule& Module, const std::string& ProfileName) throw (nsErrors::CException) { unsigned I (0); for ( ; I < Module.GetNbProfile() && Module.GetProfile (I).GetName() != ProfileName ; ++I); if (I == Module.GetNbProfile()) throw (nsErrors::CException (std::string ("Profile not found : ") + ProfileName, nsErrors::ProfileNotFound)); Module.ApplyProfile (I); } // ApplyProfile() inline void UseDhcp (const nsCore::ICLIModule& Module, const std::string& IfaceName) throw (nsErrors::CException) { nsNet::CInterface Iface (IfaceName); Iface.SetIPFromDHCP (Module.GetDriver().GetSSID()); } // UseDhcp() void CLICore (const nsCore::CCLIOpt Opt) throw (nsErrors::CException, std::bad_alloc) { if (Opt.Profile() || Opt.Dhcp()) { if (Opt.IfaceName().empty()) throw (nsErrors::CException ("Iface name missing.", nsErrors::InvalidArguments)); std::vector DeviceVec; nsCore::GetWirelessDevice (DeviceVec); unsigned I (0); for ( ; I < DeviceVec.size() && DeviceVec [I].GetDeviceName() != Opt.IfaceName(); ++I); if (I == DeviceVec.size()) throw nsErrors::CException (std::string ("Can't find interface" " : ") + Opt.IfaceName(), nsErrors::NoDeviceFound); std::auto_ptr pModule (nsCore::MakeCLIModule (DeviceVec [I])); if (Opt.Profile()) ApplyProfile (*pModule, Opt.ProfileName()); if (Opt.Dhcp()) UseDhcp (*pModule, Opt.IfaceName()); } } // CLICore() } // anonymous namespace int main (int argc, char* argv []) { try { nsCore::CCLIOpt Opt (argc, argv); if (Opt.Help()) std::cout << "Usage :\n rutilt [IFACE_NAME] [OPTIONS...]\n" "Short options can be combined, options with an argument must appear last in" " this\ncase. Mandatory arguments to long options are mandatory for short" " options too.\nIf IFACE_NAME is specified, rutilt will try to use this network" " interface and\nwill not prompt the interface chooser.\nOptions :\n" " -h, --help\n display this help and exit\n-v, --version\n" " output version information and exit\n -t, --hide\n" " force to start hidden in tray\n-p, --profile PROFILE_NAME\n" " apply PROFILE_NAME on start (quote PROFILE_NAME if it contains" " spaces),\n the IP settings of that profile will not be applied.\n" " Note that profiles will be looked-up in the _current_ user's home\n" " directory.\n" "-d, --dhcp\n use dhcp (run the set_ip.sh script) on start\n-e, --exit\n" " exit after processing the command line options (do not start the" " gui)\n IFACE_NAME must be specified when using this options with" " --dhcp or\n --profile and the application executed as root.\n" "All Gtk+ specific options are also supported, see the Gtk+ documentation." << std::endl; else if (Opt.Version()) std::cout << "RutilT " << nsCore::VersionLabel << "\nCopyright (C) 2005-2008 Romain BONDUE\n" "This is free software. You may redistribute copies of it under the terms of\n" "the GNU General Public License .\n" "There is NO WARRANTY, to the extent permitted by law.\n\n" "Written by Romain BONDUE, see the AUTHORS file or the about dialog for all\n" "contributors." << std::endl; else if (Opt.Exit()) CLICore (Opt); else { ::gtk_init (&argc, &argv); nsGUI::CGtkGUI UI; UI.Run (Opt); } } catch (const nsErrors::CException& Exc) // Handle CSystemExc too. { std::cerr << Exc.GetMsg() << "\nCode : " << Exc.GetCode() << std::endl; return Exc.GetCode(); } catch (const std::exception& Exc) { std::cerr << "Exception : " << Exc.what() << std::endl; return nsErrors::UnknownExc; } catch (...) { std::cerr << "Unknown exception." << std::endl; return nsErrors::UnknownExc; } return 0; } // main() RutilTv0.18/lib/src/Helper.cxx0000644000175000017500000002626610636002145015643 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Helper.cxx \author Romain BONDUE \date 04/01/2006 */ #include #include #include #include #include #include #include // strtol(), strtoul() #include // strncmp(), strcmp(), memset() extern "C"{ #include // ::getspnam() #include // ::crypt() #include // ::sleep(), ::read(), ::write(), ::setuid() } #include "MsgHandlerFactory.h" #include "SystemTools.h" #include "Msg.h" #include "IMsgHandler.h" #include "Exceptions.h" #include "StaticSettings.h" #include "ErrorsCode.h" namespace { typedef std::map pMsgHandlersMap_t; class CFormattedSocket : public nsSystem::CLocalSocket { public : bool ReadIntOrStop (int& Buffer) throw (nsErrors::CException) { const unsigned NbByteRead (Read (reinterpret_cast (&Buffer), sizeof (Buffer))); if (NbByteRead) { if (NbByteRead != sizeof (Buffer)) throw nsErrors::CException ("Invalid data read, integer" " expected.", nsErrors::InvalidData); return false; } return true; } // ReadIntOrStop() int ReadInt () throw (nsErrors::CException) { int Buffer; if (ReadIntOrStop (Buffer)) throw nsErrors::CException ("Unexpected end of stream.", nsErrors::UnexpectedStreamEnd); return Buffer; } // ReadInt() unsigned long ReadULong () throw (nsErrors::CException) { unsigned long Buffer; if (Read (reinterpret_cast (&Buffer), sizeof (Buffer)) != sizeof (Buffer)) throw nsErrors::CException ("Invalid data read, unsigned long" " expected.", nsErrors::InvalidData); return Buffer; } // ReadULong() void Write (int Value) throw (nsErrors::CSystemExc) { CLocalSocket::Write (reinterpret_cast (&Value), sizeof (Value)); } // Write() std::string ReadString (unsigned Size) throw (nsErrors::CException, std::bad_alloc) { std::auto_ptr Buffer (new char [Size]); if (Read (Buffer.get(), Size) != Size) throw nsErrors::CException ("Invalid data read.", nsErrors::InvalidData); return std::string (Buffer.get(), 0, Size); } // ReadString() void Write (const std::string& Str) throw (nsErrors::CSystemExc) { Write (Str.size()); CLocalSocket::Write (Str.data(), Str.size()); } // Write() void Write (const nsRoot::CMsg& Msg) throw (nsErrors::CSystemExc) { Write (Msg.GetText()); Write (Msg.GetCode()); } // Write() }; // CFormattedSocket unsigned long ParseULong (const std::string& Str) throw (nsErrors::CException) { char* pEnd; const unsigned long Num (strtoul (Str.c_str(), &pEnd, 10)); if (*pEnd) throw nsErrors::CException ("Invalid data read.", nsErrors::InvalidData); return Num; } // ParseULong() unsigned long ParseLong (const std::string& Str) throw (nsErrors::CException) { char* pEnd; const long Num (strtol (Str.c_str(), &pEnd, 10)); if (*pEnd) throw nsErrors::CException ("Invalid data read.", nsErrors::InvalidData); return Num; } // ParseLong() bool IsRootPasswd (const std::string& Password) throw (nsErrors::CException) { const ::spwd* const pShadow (::getspnam ("root")); if (!pShadow) throw nsErrors::CSystemExc ("Can't check root password."); const unsigned CstSaltMaxSize (64); // Should be enough... char Salt [CstSaltMaxSize + 1]; // + 1 : '\0' if (pShadow->sp_pwdp [0] == '$') // MD5, Blowfish (other?) { unsigned i (0); for (unsigned Cpt (0) ; Cpt < 3 ; ++i) { if (i >= CstSaltMaxSize) throw nsErrors::CException ("Salt buffer overflow.", nsErrors::SaltBufferOverflow); Salt [i] = pShadow->sp_pwdp [i]; if (Salt [i] == '$') ++Cpt; } Salt [i] = '\0'; } else // DES { Salt [0] = pShadow->sp_pwdp [0]; Salt [1] = pShadow->sp_pwdp [1]; Salt [2] = '\0'; } const char* const CryptedPassword (::crypt (Password.c_str(), Salt)); if (!CryptedPassword) throw nsErrors::CSystemExc ("Cannot encrypt password."); if (!std::strcmp (CryptedPassword, pShadow->sp_pwdp)) return true; else { ::sleep (3); // For security reasons. return false; } } // IsRootPasswd() } // anonymous namespace int main (int argc, char* argv []) { try { if (::geteuid()) throw nsErrors::CException ("Must be executed as root.", nsErrors::HelperNotRoot); if (::setuid (0)) std::cerr << "Helper : Warning, cannot set user id. errno : " << errno << std::endl; if (argc != 2) throw nsErrors::CException ("Invalid number of arguments.", nsErrors::InvalidArguments); const ::pid_t RutilTPid (ParseLong (argv [1])); CFormattedSocket Sock; std::ostringstream OsAddr; OsAddr << nsRoot::ServerAddr << RutilTPid; Sock.Connect (OsAddr.str()); Sock.SendCredential(); if (!Sock.CheckCredentialPID (RutilTPid)) throw nsErrors::CException ("RutilT authentication failed.", nsErrors::RutilTAuthenticationFailed); #ifndef NOROOTPASSCHECK // Check root password : if (Sock.ReadInt() != nsRoot::CheckRootPassword) throw nsErrors::CException ("Invalid command, password check" " expected.", nsErrors::InvalidData); if (!IsRootPasswd (Sock.ReadString (Sock.ReadInt()))) { Sock.Write (nsErrors::InvalidRootPassword); std::cerr << "Helper : exiting, invalid root password." << std::endl; return nsErrors::InvalidRootPassword; } Sock.Write (0); #endif // NOROOTPASSCHECK nsRoot::IMsgHandler* pCurrentMsgHandler (0); unsigned long InstanceCounter (Sock.ReadULong()); pMsgHandlersMap_t MsgHandlersMap; for ( ; ; ) { int Value; #ifndef NDEBUG std::cerr << "Helper : waiting for command.\n"; #endif // NDEBUG if (Sock.ReadIntOrStop (Value)) break; #ifndef NDEBUG std::cerr << "Helper : command received : " << Value << std::endl; #endif // NDEBUG if (Value < 0) // Internal command. { const unsigned Size (Sock.ReadInt()); const std::string Data (Sock.ReadString (Size)); switch (Value) { case nsRoot::CreateRemoteHandlerCmd : MsgHandlersMap [InstanceCounter] = nsRoot::MakeHandler (Data); ++InstanceCounter; break; case nsRoot::ChangeRemoteHandlerCmd : pCurrentMsgHandler = MsgHandlersMap [ParseULong (Data)]; if (!pCurrentMsgHandler) throw nsErrors::CException ("Invalid instance number.", nsErrors::InvalidInstanceNum); break; case nsRoot::DeleteRemoteHandlerCmd : { const pMsgHandlersMap_t::iterator Iter (MsgHandlersMap.find (ParseULong (Data))); if (Iter != MsgHandlersMap.end()) { delete Iter->second; MsgHandlersMap.erase (Iter); } } break; default : throw nsErrors::CException ("Invalid command.", nsErrors::InvalidCommand); } Sock.Write (0); // Everything is ok. } else // CMsg { const std::string Data (Sock.ReadString (Value)); if (pCurrentMsgHandler) Sock.Write ((*pCurrentMsgHandler) (nsRoot::CMsg (Data, Sock.ReadInt()))); else throw nsErrors::CException ("No handler defined.", nsErrors::NoHandlerDefined); } } for (std::map::iterator Iter (MsgHandlersMap.begin()) ; Iter != MsgHandlersMap.end() ; ++Iter) delete Iter->second; } catch (const std::bad_alloc& Exc) { std::cerr << "Helper : " << Exc.what() << std::endl; return nsErrors::OutOfMemory; } catch (const nsErrors::CException& Exc) // Handle CSystemExc too. { std::cerr << "Helper : " << Exc.GetMsg() << "\nCode : " << Exc.GetCode() << std::endl; return Exc.GetCode(); } catch (const std::exception& Exc) { std::cerr << "Helper : exception : " << Exc.what() << std::endl; return nsErrors::UnknownExc; } catch (...) { std::cerr << "Helper : unknown execption." << std::endl; return nsErrors::UnknownExc; } } // main() RutilTv0.18/lib/src/CSiteSurveyTab.cxx0000644000175000017500000001632710543251476017307 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CSiteSurveyTab.cxx \author Romain BONDUE \date 28/07/2005 */ #include #include "GtkGUI.h" #include "Parameters.h" // CCell #include "CSiteSurveyTab.h" namespace { std::string MakeTxRateLabel (float TxRate) throw() { std::ostringstream Os; if (TxRate) Os << TxRate / 1000.0; else Os << "N/A"; return Os.str(); } // MakeTxRateLabel() } // anonymous namespace const char* const nsGUI::CSiteSurveyTab::ScanButtonLabel ("Scan"); const char* nsGUI::CSiteSurveyTab::ColumnTitle [NbColumn] = {0, "SSID", "AP Mac Address", "Mode", "Link", "Signal", "Noise", "Channel", "Rate", "Cipher","Auth"}; const ::GType nsGUI::CSiteSurveyTab::TabType [NbColumn] = { G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING}; nsGUI::CSiteSurveyTab::CSiteSurveyTab (CGtkGUI* pUI) throw() : CSelectableRowList (NbColumn, TabType, ColumnTitle, pUI, &CGtkGUI::Connect), m_pVBox (GTK_BOX (::gtk_vbox_new (false, 8))), m_pScanButton (::gtk_button_new_with_label (ScanButtonLabel)), m_pAddProfileButton (::gtk_button_new()), #if GTK_CHECK_VERSION (2, 10, 0) /* Should work with gtk+2.6 too, but it doesn't : an ugly "gtk-connect" * is displayed instead. Ditto with gtk+2.8 on some distribution... */ m_pConnectButton (::gtk_button_new_from_stock (GTK_STOCK_CONNECT)), #else m_pConnectButton (::gtk_button_new_with_label ("Connect")), #endif m_IsScanning (false) { ::GtkBox* pHBox (GTK_BOX (::gtk_hbox_new (false, 2))); ::gtk_box_pack_start_defaults (pHBox, ::gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_SMALL_TOOLBAR)); ::gtk_box_pack_start_defaults (pHBox, ::gtk_label_new ("Add profile")); ::gtk_container_add (GTK_CONTAINER (m_pAddProfileButton), GTK_WIDGET (pHBox)); ::gtk_widget_set_sensitive (m_pAddProfileButton, false); ::g_signal_connect (m_pAddProfileButton, "clicked", G_CALLBACK (AddProfileButtonCallBack), this); ::g_signal_connect (m_pScanButton, "clicked", G_CALLBACK (ScanButtonCallBack), this); ::gtk_container_set_border_width (GTK_CONTAINER (m_pVBox), 6); ::gtk_box_pack_start_defaults (m_pVBox, CSelectableRowList::operator ::GtkWidget* ()); ::g_signal_connect (m_pConnectButton, "clicked", G_CALLBACK (ConnectButtonCallBack), this); ::gtk_widget_set_sensitive (m_pConnectButton, false); pHBox = GTK_BOX (::gtk_hbutton_box_new()); // I reuse the pointer. ::gtk_box_set_spacing (pHBox, 4); ::gtk_button_box_set_layout (GTK_BUTTON_BOX (pHBox), GTK_BUTTONBOX_END); ::gtk_container_add (GTK_CONTAINER (pHBox), m_pAddProfileButton); ::gtk_container_add (GTK_CONTAINER (pHBox), m_pConnectButton); ::gtk_container_add (GTK_CONTAINER (pHBox), m_pScanButton); ::gtk_box_pack_start (m_pVBox, GTK_WIDGET (pHBox), false, false, 0); } // CSiteSurveyTab() const nsWireless::CCell* nsGUI::CSiteSurveyTab::AddCells (const CellVec_t& CellVec, const nsWireless::CMacAddress& CurrentAPMacAddr) throw() { const nsWireless::CCell* pCurrentCell (0); for (unsigned i (0) ; i < CellVec.size() ; ++i) { if (!pCurrentCell && CellVec [i].GetAPMacAddress() == CurrentAPMacAddr) { pCurrentCell = &CellVec [i]; SetData (i, ButtonPos, true); } else SetData (i, ButtonPos, false); SetData (i, SSIDPos, CellVec [i].GetSSID()); SetData (i, APMacPos, CellVec [i].GetAPMacAddress().GetStr()); SetData (i, ModePos, nsWireless::GetModeName (CellVec [i].GetMode())); SetData (i, LinkQPos, CellVec [i].GetQuality().GetLinkQuality()); SetData (i, SignalLPos, CellVec [i].GetQuality().GetSignalLevel()); SetData (i, NoiseLPos, CellVec [i].GetQuality().GetNoiseLevel()); SetData (i, ChannelPos, CellVec [i].GetChannel()); SetData (i, RatePos, MakeTxRateLabel (CellVec [i].GetTxRate())); SetData (i, EncryptPos, nsWireless::GetEncryptName (CellVec [i].GetEncryptionD().GetEncrypt())); SetData (i, AuthPos, nsWireless::GetAuthName (CellVec [i].GetEncryptionD().GetAuth())); } return pCurrentCell; } // Refresh() void nsGUI::CSiteSurveyTab::ScanButtonCallBack (GtkButton* pButton, CSiteSurveyTab* This) throw() { if (!This->m_IsScanning) This->GetUI()->Scan(); else This->GetUI()->StopScanning(); } // ScanButtonCallBack() void nsGUI::CSiteSurveyTab::ScanningStarted () throw() { m_IsScanning = true; ::gtk_widget_set_sensitive (m_pAddProfileButton, false); ::gtk_widget_set_sensitive (m_pConnectButton, false); Clear(); ::gtk_button_set_label (GTK_BUTTON (m_pScanButton), "Stop"); } // ScanningStarted() void nsGUI::CSiteSurveyTab::RowSelectedCallBack () throw() { ::gtk_widget_set_sensitive (m_pAddProfileButton, true); ::gtk_widget_set_sensitive (m_pConnectButton, true); } // RowSelectedCallBack() void nsGUI::CSiteSurveyTab::RowUnselectedCallBack () throw() { ::gtk_widget_set_sensitive (m_pAddProfileButton, false); ::gtk_widget_set_sensitive (m_pConnectButton, false); } // RowUnselectedCallBack() void nsGUI::CSiteSurveyTab::AddProfileButtonCallBack (::GtkButton*, CSiteSurveyTab* This) throw() { This->GetUI()->NewProfile (This->GetSelectedRow()); } // AddProfileButtonCallBack() void nsGUI::CSiteSurveyTab::ConnectButtonCallBack (::GtkButton*, CSiteSurveyTab* This) throw() { This->RowTriggered(); } // ConnectButtonCallBack() RutilTv0.18/lib/src/RTModules.cxx0000644000175000017500000006330210722350737016303 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTModules.cxx \author Romain BONDUE \date 21/08/2005 */ #include #include "RTModules.h" #include "GtkGUI.h" #include "RTDrivers.h" #include "RTDriversRoot.h" #include "ErrorsCode.h" namespace { ::GtkWidget* LabelWidget (::GtkWidget* pWidget, const char* Label) throw() { ::GtkBox* const pHBox (GTK_BOX (::gtk_hbox_new (false, 2))); ::gtk_box_pack_start_defaults (pHBox, ::gtk_label_new (Label)); ::gtk_box_pack_start_defaults (pHBox, pWidget); return GTK_WIDGET (pHBox); } // LabelWidget() const unsigned TabAuthAdHocRTxxSize (3); const nsWireless::AuthType_e TabAuthAdHocRTxx [TabAuthAdHocRTxxSize] = {nsWireless::Open, nsWireless::Shared, nsWireless::WPANONE}; const unsigned TabNoneEncryptSize (2); const nsWireless::EncryptType_e TabNoneEncrypt [TabNoneEncryptSize] = {nsWireless::None, nsWireless::WEP}; const unsigned TabSharedEncryptSize (1); const nsWireless::EncryptType_e TabSharedEncrypt [TabSharedEncryptSize] = {nsWireless::WEP}; const unsigned TabWPAPSKEncryptSize (2); const nsWireless::EncryptType_e TabWPAPSKEncrypt [TabWPAPSKEncryptSize] = {nsWireless::TKIP, nsWireless::AES}; const unsigned TabAuthRT2500Size (3); const unsigned TabAuthRT2400Size (2); const unsigned TabAuthRTxxSize (4); const nsWireless::AuthType_e TabAuthRTxx [TabAuthRTxxSize] = {nsWireless::Open, nsWireless::Shared, nsWireless::WPAPSK, nsWireless::WPA2PSK}; const unsigned TabModeRTxxSize (3); const nsWireless::Mode_e TabModeRTxx [TabModeRTxxSize] = {nsWireless::Managed, nsWireless::AdHoc, nsWireless::Monitor}; void ApplyRT2400Profile (const nsUserData::CProfile& Profile, nsWireless::CRT2400Driver& Driver) throw (nsErrors::CSystemExc) { Driver.SetChannel (Profile.GetChannel()); Driver.SetMode (Profile.GetMode()); Driver.SetEncryption (Profile.GetEncryptionD()); Driver.SetSSID (Profile.GetSSID()); } // ApplyRT2400Profile() void ApplyRTxxProfile (const nsUserData::CProfile& Profile, nsWireless::IDriver& Driver) throw (nsErrors::CSystemExc) { Driver.SetMode (Profile.GetMode()); Driver.SetChannel (Profile.GetChannel()); Driver.SetSSID (Profile.GetSSID()); Driver.SetEncryption (Profile.GetEncryptionD()); Driver.SetSSID (Profile.GetSSID()); } // ApplyRTxxProfile() void DisplayDriverLimitations (const nsWireless::AuthType_e* Auths, unsigned NAuth, const nsWireless::CCell& Cell, ::GtkWindow* pWindow) throw() { const nsWireless::AuthType_e DesiredAuth (Cell.GetEncryptionD().GetAuth()); while (NAuth) if (Auths[--NAuth] == DesiredAuth) return; ::GtkWidget* const pDialog (::gtk_message_dialog_new (pWindow, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "The device cannot be configured " " for this network because %s is unsupported, this" " could be a driver limitation .", nsWireless::GetAuthName (DesiredAuth).c_str())); ::gtk_dialog_run (GTK_DIALOG (pDialog)); ::gtk_widget_destroy (pDialog); } // DisplayDriverLimitations() } // anonymous namespace const char* const nsCore::CRT2400Module::NewProfileDefaultName ("New profile"); const char* const nsCore::CRTAdvancedModule::NewProfileDefaultName ("New profile"); const char* const nsCore::CRT2570Module::NewProfileDefaultName ("New profile"); void nsCore::CRT2400CLIModule::ApplyProfile (unsigned Pos) throw (nsErrors::CSystemExc) { ApplyRT2400Profile (m_ProfilesFile.GetProfile (Pos), m_Driver); } // ApplyProfile() nsGUI::CRT2500ConfigDialog::CRT2500ConfigDialog () throw() : CSharedConfigDialog (TabModeRTxx, TabModeRTxxSize, TabAuthRTxx, TabAuthRT2500Size, TabNoneEncrypt, TabNoneEncryptSize, TabSharedEncrypt, TabSharedEncryptSize, TabWPAPSKEncrypt, TabWPAPSKEncryptSize) { ::g_signal_connect (G_OBJECT (GetModeBox().operator ::GtkWidget*()), "changed", G_CALLBACK (ModeChangedCallBack), this); } // CRT2500ConfigDialog void nsGUI::CRT2500ConfigDialog::ModeChangedCallBack (::GtkToggleButton*, CRT2500ConfigDialog* This) throw() { if (This->GetModeBox().GetActive() == nsWireless::AdHoc) { This->GetAuthBox().SetElem (TabAuthAdHocRTxx, TabAuthAdHocRTxxSize); This->GetAuthBox().SetActive (TabAuthAdHocRTxx [0]); } else { This->GetAuthBox().SetElem (TabAuthRTxx, TabAuthRT2500Size); This->GetAuthBox().SetActive (TabAuthRTxx [0]); } } // ModeChangedCallBack() nsGUI::CRTxxConfigDialog::CRTxxConfigDialog () throw() : CSharedConfigDialog (TabModeRTxx, TabModeRTxxSize, TabAuthRTxx, TabAuthRTxxSize, TabNoneEncrypt, TabNoneEncryptSize, TabSharedEncrypt, TabSharedEncryptSize, TabWPAPSKEncrypt, TabWPAPSKEncryptSize) { ::g_signal_connect (G_OBJECT (GetModeBox().operator ::GtkWidget*()), "changed", G_CALLBACK (ModeChangedCallBack), this); } // CRTxxConfigDialog void nsGUI::CRTxxConfigDialog::ModeChangedCallBack (::GtkToggleButton*, CRTxxConfigDialog* This) throw() { if (This->GetModeBox().GetActive() == nsWireless::AdHoc) { This->GetAuthBox().SetElem (TabAuthAdHocRTxx, TabAuthAdHocRTxxSize); This->GetAuthBox().SetActive (TabAuthAdHocRTxx [0]); } else { This->GetAuthBox().SetElem (TabAuthRTxx, TabAuthRTxxSize); This->GetAuthBox().SetActive (TabAuthRTxx [0]); } } // ModeChangedCallBack() nsCore::CRT2400Module::CRT2400Module (const std::string& DeviceName, const std::string& Path) throw (nsErrors::CException, std::bad_alloc) : m_pDriver (new nsWireless::CRT2400Driver (DeviceName)), m_ProfileEditor (new nsGUI::CSharedConfigDialog (TabModeRTxx, TabModeRTxxSize, m_pDriver->GetSupportedFreq(), TabAuthRTxx, TabAuthRT2400Size, TabNoneEncrypt, TabNoneEncryptSize, TabSharedEncrypt, TabSharedEncryptSize, 0, 0)) { m_ProfilesFile.Extract(); } // CRT2400Module() nsUserData::CProfile* nsCore::CRT2400Module::NewProfile (::GtkWindow* pMainWindow, const nsWireless::CCell& Cell) throw() { DisplayDriverLimitations (TabAuthRTxx, TabAuthRT2400Size, Cell, pMainWindow); m_ProfilesFile.NewProfile (NewProfileDefaultName, Cell); return EditNewProfile (pMainWindow); } // NewProfile() void nsCore::CRT2400Module::BecomeRoot () throw (nsErrors::CException, std::bad_alloc) { m_pDriver.reset (new nsWireless::CRT2400DriverRoot (m_pDriver->GetDeviceName())); } // BecomeRoot() void nsCore::CRT2400Module::RecordProfiles () throw (nsErrors::CException) { m_ProfilesFile.Record(); } // RecordProfiles() void nsCore::CRT2400Module::ApplyProfile (unsigned Pos) throw (nsErrors::CSystemExc) { ApplyRT2400Profile (m_ProfilesFile.GetProfile (Pos), *m_pDriver); } // ApplyProfile() void nsCore::CRT2400Module::ApplyProfile (unsigned Pos, const nsWireless::CMacAddress& Address) throw (nsErrors::CSystemExc) { ApplyRT2400Profile (m_ProfilesFile.GetProfile (Pos), *m_pDriver); try {m_pDriver->SetAPMacAddr (Address);} catch (const nsErrors::CSystemExc&) {} // May fail. } // ApplyProfile() nsUserData::CProfile* nsCore::CRT2400Module::EditNewProfile (::GtkWindow* pMainWindow) throw() { nsUserData::CProfile* const pProfile (&m_ProfilesFile.GetProfile (m_ProfilesFile.Size() - 1U)); if (!m_ProfileEditor.Edit (pMainWindow, *pProfile)) { m_ProfilesFile.DeleteLastProfile(); return 0; } return pProfile; } // EditNewProfile() void nsCore::CRTAdvancedCLIModule::ApplyProfile (unsigned Pos) throw (nsErrors::CSystemExc) { ApplyRTxxProfile (m_ProfilesFile.GetProfile (Pos), *m_pDriver); } // ApplyProfile() nsCore::CRTAdvancedModule::CRTAdvancedModule (nsWireless::CRTAdvancedDriver* pDriver, nsGUI::CConfigDialog* pDialog, const std::string& Path, nsGUI::CGtkGUI* pUI, bool AdHofdmSupport) throw (nsErrors::CException, std::bad_alloc) : m_pDriver (pDriver), m_ProfileEditor (pDialog), m_pTable (GTK_TABLE (::gtk_table_new (5, 2, true))), m_pUI (pUI), m_CurrentActiveBoxItem (0), m_IsSkipped (false) { m_ProfilesFile.Extract(); // Build the private tab : ::gtk_container_set_border_width (GTK_CONTAINER (m_pTable), 6); ::gtk_table_set_col_spacings (m_pTable, 12); ::gtk_table_set_row_spacings (m_pTable, 8); const unsigned NbMode (2); const char* ModeNames [NbMode] = {"Mixed", "B Only"}; CreateCBox (ModeNames, NbMode, m_pDriver->GetWirelessMode(), "Wireless Mode", 0, &ModeCallBack); const unsigned NbProtectionMode (3); const char* ProtectionModeNames [NbProtectionMode] = {"Auto", "On", "Off"}; CreateCBox (ProtectionModeNames, NbProtectionMode, m_pDriver->GetBGProtection(), "B/G Protection", 1, &BGProtectionCallBack); const unsigned NbTxPreamble (3); const char* TxPreambleNames [NbTxPreamble] = {"Long", "Short", "Auto"}; CreateCBox (TxPreambleNames, NbTxPreamble, m_pDriver->GetTxPreamble(), "Tx Preamble", 2, &TxPreambleCallBack); CreateCheckButton ("Tx burst", 3, 0, m_pDriver->GetTxBurst(), &TxBurstCallBack); CreateCheckButton ("Turbo rate", 3, 1, m_pDriver->GetTurboRate(), &TurboRateCallBack); CreateCheckButton ("Injection in monitor mode", 4, 0, m_pDriver->GetRfmontx(), &RfmontxCallBack); if (AdHofdmSupport) CreateCheckButton ("OFDM in ad-hoc mode", 4, 1, m_pDriver->GetAdHocOFDM(), &AdHocOFDMCallBack); } // CRTAdvancedModule() nsUserData::CProfile* nsCore::CRTAdvancedModule::NewProfile (::GtkWindow* pMainWindow, const nsWireless::CCell& Cell) throw() { DisplayDriverLimitations (TabAuthRTxx, TabAuthRTxxSize, Cell, pMainWindow); m_ProfilesFile.NewProfile (NewProfileDefaultName, Cell); return EditNewProfile (pMainWindow); } // NewProfile() void nsCore::CRTAdvancedModule::RecordProfiles () throw (nsErrors::CException) { m_ProfilesFile.Record(); } // RecordProfiles() void nsCore::CRTAdvancedModule::CreateCBox (const char* TabName [], unsigned TabSize, int CurrentActive, const char* Label, unsigned Row, void (*CallBack) (::GtkComboBox*, CRTAdvancedModule*)) throw() { ::GtkComboBox* const pCBox (GTK_COMBO_BOX (::gtk_combo_box_new_text())); for (unsigned i (0) ; i < TabSize ; ++i) ::gtk_combo_box_append_text (pCBox, TabName [i]); ::gtk_combo_box_set_active (pCBox, CurrentActive); ::g_signal_connect (G_OBJECT (pCBox), "changed", G_CALLBACK (CallBack), this); ::g_signal_connect (G_OBJECT (pCBox), "set-focus-child", G_CALLBACK (CBoxFocusCallBack), this); ::GtkWidget* const pLabel (::gtk_label_new (Label)); ::gtk_table_attach_defaults (m_pTable, pLabel, 0, 1, Row, Row + 1); ::gtk_table_attach (m_pTable, GTK_WIDGET (pCBox), 1, 2, Row, Row + 1, GTK_FILL, GTK_SHRINK, 0, 0); } // CreateCBox() void nsCore::CRTAdvancedModule::CreateCheckButton ( const char* Label, unsigned Row, unsigned Column, bool CurrentState, void (*CallBack) (::GtkToggleButton*, CRTAdvancedModule*)) throw() { ::GtkWidget* const pButton (::gtk_check_button_new_with_label (Label)); ::gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pButton), CurrentState); ::g_signal_connect (G_OBJECT (pButton), "toggled", G_CALLBACK (CallBack), this); ::gtk_table_attach_defaults (m_pTable, pButton, Column, Column + 1, Row, Row + 1); } // CreateCheckButton() nsUserData::CProfile* nsCore::CRTAdvancedModule::EditNewProfile (::GtkWindow* pMainWindow) throw() { nsUserData::CProfile* const pProfile (&m_ProfilesFile.GetProfile (m_ProfilesFile.Size() - 1U)); if (!m_ProfileEditor.Edit (pMainWindow, *pProfile)) { m_ProfilesFile.DeleteLastProfile(); return 0; } return pProfile; } // EditNewProfile() void nsCore::CRTAdvancedModule::ApplyProfile (unsigned Pos) throw (nsErrors::CSystemExc) { ApplyRTxxProfile (m_ProfilesFile.GetProfile (Pos), *m_pDriver); } // ApplyProfile() void nsCore::CRTAdvancedModule::ApplyProfile (unsigned Pos, const nsWireless::CMacAddress& Address) throw (nsErrors::CSystemExc) { ApplyRTxxProfile (m_ProfilesFile.GetProfile (Pos), *m_pDriver); try {m_pDriver->SetAPMacAddr (Address);} catch (const nsErrors::CSystemExc&) {} // May fail. } // ApplyProfile() void nsCore::CRTAdvancedModule::ModeCallBack (::GtkComboBox* pCBox, CRTAdvancedModule* This) throw() { This->CommonCBoxCallBack (reinterpret_cast (&nsWireless::CRTAdvancedDriver::SetWirelessMode), pCBox); This->m_pUI->RefreshRates(); } // ModeCallBack() void nsCore::CRT2500Module::BecomeRoot () throw (nsErrors::CException, std::bad_alloc) { SetDriver (new nsWireless::CRT2500DriverRoot (GetDriver().GetDeviceName())); } // BecomeRoot() void nsCore::CRT61Module::BecomeRoot () throw (nsErrors::CException, std::bad_alloc) { SetDriver (new nsWireless::CRT61DriverRoot (GetDriver().GetDeviceName())); } // BecomeRoot() void nsCore::CRT73Module::BecomeRoot () throw (nsErrors::CException, std::bad_alloc) { SetDriver (new nsWireless::CRT73DriverRoot (GetDriver().GetDeviceName())); } // BecomeRoot() void nsCore::CRTAdvancedModule::CommonCBoxCallBack (DriverCBoxMember_t Member, ::GtkComboBox* pCBox) throw() { try { if (!m_IsSkipped) { if (m_pUI->BecomeRoot()) { const unsigned CurrentActive (::gtk_combo_box_get_active (pCBox)); (m_pDriver.get()->*Member) (CurrentActive); m_CurrentActiveBoxItem = CurrentActive; } else ResumePreviousState (pCBox); } } catch (const nsErrors::CException& Exc) { ResumePreviousState (pCBox); m_pUI->ProcessError (Exc); } } // CommonCBoxCallBack() void nsCore::CRTAdvancedModule::CommonCButtonCallBack (DriverButtonMember_t Member, ::GtkToggleButton* pButton) throw() { try { const bool NewState (::gtk_toggle_button_get_active (pButton)); if (!m_IsSkipped) { if (m_pUI->BecomeRoot()) (m_pDriver.get()->*Member) (NewState); else { m_IsSkipped = true; ::gtk_toggle_button_set_active (pButton, !NewState); m_IsSkipped = false; } } } catch (const nsErrors::CException& Exc) { m_pUI->ProcessError (Exc); } } // CommonCButtonCallBack() void nsCore::CRT2570CLIModule::ApplyProfile (unsigned Pos) throw (nsErrors::CSystemExc) { ApplyRTxxProfile (m_ProfilesFile.GetProfile (Pos), m_Driver); } // ApplyProfile() nsCore::CRT2570Module::CRT2570Module (const std::string& DeviceName, const std::string& Path, nsGUI::CGtkGUI* pUI) throw (nsErrors::CException, std::bad_alloc) : m_pDriver (new nsWireless::CRT2570Driver (DeviceName)), m_ProfileEditor (new nsGUI::CRTxxConfigDialog()), m_pUI (pUI), m_pBox (GTK_BOX (::gtk_vbox_new (true, 2))), m_CurrentActiveBoxItem (0), m_IsSkipped (false) { m_ProfileEditor.GetDialog()->SetAvailableChannel (m_pDriver->GetSupportedFreq()); m_ProfilesFile.Extract(); BuildPrivateTab(); } // CRT2570Module() nsUserData::CProfile* nsCore::CRT2570Module::NewProfile (::GtkWindow* pMainWindow, const nsWireless::CCell& Cell) throw() { DisplayDriverLimitations (TabAuthRTxx, TabAuthRTxxSize, Cell, pMainWindow); m_ProfilesFile.NewProfile (NewProfileDefaultName, Cell); return EditNewProfile (pMainWindow); } // NewProfile() void nsCore::CRT2570Module::RecordProfiles () throw (nsErrors::CException) { m_ProfilesFile.Record(); } // RecordProfiles() void nsCore::CRT2570Module::BecomeRoot () throw (nsErrors::CException, std::bad_alloc) { m_pDriver.reset (new nsWireless::CRT2570DriverRoot (m_pDriver->GetDeviceName())); } // BecomeRoot() void nsCore::CRT2570Module::ApplyProfile (unsigned Pos) throw (nsErrors::CSystemExc) { ApplyRTxxProfile (m_ProfilesFile.GetProfile (Pos), *m_pDriver); } // ApplyProfile() void nsCore::CRT2570Module::ApplyProfile (unsigned Pos, const nsWireless::CMacAddress& Address) throw (nsErrors::CSystemExc) { ApplyRTxxProfile (m_ProfilesFile.GetProfile (Pos), *m_pDriver); try {m_pDriver->SetAPMacAddr (Address);} catch (const nsErrors::CSystemExc&) {} // May fail. } // ApplyProfile() nsUserData::CProfile* nsCore::CRT2570Module::EditNewProfile (::GtkWindow* pMainWindow) throw() { nsUserData::CProfile* const pProfile (&m_ProfilesFile.GetProfile (m_ProfilesFile.Size() - 1U)); if (!m_ProfileEditor.Edit (pMainWindow, *pProfile)) { m_ProfilesFile.DeleteLastProfile(); return 0; } return pProfile; } // EditNewProfile() void nsCore::CRT2570Module::CommonCButtonCallBack (DriverButtonMember_t pMember, ::GtkToggleButton* pButton) throw() { try { const bool NewState (::gtk_toggle_button_get_active (pButton)); if (!m_IsSkipped) { if (m_pUI->BecomeRoot()) (m_pDriver.get()->*pMember) (NewState); else { m_IsSkipped = true; ::gtk_toggle_button_set_active (pButton, !NewState); m_IsSkipped = false; } } } catch (const nsErrors::CException& Exc) { m_pUI->ProcessError (Exc); } } // CommonCButtonCallBack() void nsCore::CRT2570Module::CommonCBoxCallBack (DriverBoxMember_t pMember, ::GtkComboBox* pCBox) throw() { try { if (!m_IsSkipped) { if (m_pUI->BecomeRoot()) { const int CurrentActive (::gtk_combo_box_get_active (pCBox)); (m_pDriver.get()->*pMember) (CurrentActive); m_CurrentActiveBoxItem = CurrentActive; } else ResumePreviousState (pCBox); } } catch (const nsErrors::CException& Exc) { ResumePreviousState (pCBox); m_pUI->ProcessError (Exc); } } // AdhocModeCallBack() void nsCore::CRT2570Module::BuildPrivateTab () throw() { ::GtkComboBox* pCBox (GTK_COMBO_BOX (::gtk_combo_box_new_text())); ::gtk_combo_box_append_text (pCBox, "Standard 11Mpbs"); ::gtk_combo_box_append_text (pCBox, "Auto"); ::gtk_combo_box_append_text (pCBox, "54Mbps only"); // Warning : works because of the numeric values, can easily break. ::gtk_combo_box_set_active (pCBox, m_pDriver->GetAdHocMode()); ::g_signal_connect (G_OBJECT (pCBox), "changed", G_CALLBACK (AdhocModeCallBack), this); ::g_signal_connect (G_OBJECT (pCBox), "set-focus-child", G_CALLBACK (CBoxFocusCallBack), this); ::GtkBox* pHbox (GTK_BOX (::gtk_hbox_new (true, 2))); ::gtk_box_pack_start_defaults (pHbox, ::gtk_label_new ("Ad-hoc mode")); ::gtk_box_pack_start_defaults (pHbox, GTK_WIDGET (pCBox)); ::gtk_box_pack_start_defaults (m_pBox, GTK_WIDGET (pHbox)); ::GtkWidget* const pButton (::gtk_toggle_button_new_with_label ("Injection in monitor mode")); ::gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pButton), m_pDriver->GetRfmontx()); ::g_signal_connect (G_OBJECT (pButton), "toggled", G_CALLBACK (RfmontxCallBack), this); ::gtk_box_pack_start_defaults (m_pBox, pButton); pCBox = GTK_COMBO_BOX (::gtk_combo_box_new_text()); ::gtk_combo_box_append_text (pCBox, "Default (auto)"); ::gtk_combo_box_append_text (pCBox, "Force"); ::gtk_combo_box_append_text (pCBox, "Force no"); // Warning : works because of the numeric values, can easily break. ::gtk_combo_box_set_active (pCBox, m_pDriver->GetPrismHeader()); ::g_signal_connect (G_OBJECT (pCBox), "changed", G_CALLBACK (PrismHeaderCallBack), this); ::g_signal_connect (G_OBJECT (pCBox), "set-focus-child", G_CALLBACK (CBoxFocusCallBack), this); pHbox = GTK_BOX (::gtk_hbox_new (true, 2)); ::gtk_box_pack_start_defaults (pHbox, ::gtk_label_new ("Prism header")); ::gtk_box_pack_start_defaults (pHbox, GTK_WIDGET (pCBox)); ::gtk_box_pack_start_defaults (m_pBox, GTK_WIDGET (pHbox)); } // BuildPrivateTab() nsCore::CRT2500Module::CRT2500Module (const std::string& DeviceName, const std::string& ProfilePath, nsGUI::CGtkGUI* pUI) throw (nsErrors::CException, std::bad_alloc) : CRTAdvancedModule (new nsWireless::CRT2500Driver (DeviceName), new nsGUI::CRT2500ConfigDialog(), ProfilePath, pUI, true) { GetProfileEditor().GetDialog()->SetAvailableChannel (GetDriver().GetSupportedFreq()); } // CRT2500Module() nsUserData::CProfile* nsCore::CRT2500Module::NewProfile (::GtkWindow* pMainWindow, const nsWireless::CCell& Cell) throw() { DisplayDriverLimitations (TabAuthRTxx, TabAuthRT2500Size, Cell, pMainWindow); GetProfilesFile().NewProfile (NewProfileDefaultName, Cell); return EditNewProfile (pMainWindow); } // NewProfile() nsCore::CRT61Module::CRT61Module (const std::string& DeviceName, const std::string& ProfilePath, nsGUI::CGtkGUI* pUI) throw (nsErrors::CException, std::bad_alloc) : CRTAdvancedModule (new nsWireless::CRT61Driver (DeviceName), new nsGUI::CRTxxConfigDialog, ProfilePath, pUI, false) { GetProfileEditor().GetDialog()->SetAvailableChannel (GetDriver().GetSupportedFreq()); } // CRT61Module() nsCore::CRT73Module::CRT73Module (const std::string& DeviceName, const std::string& ProfilePath, nsGUI::CGtkGUI* pUI) throw (nsErrors::CException, std::bad_alloc) : CRTAdvancedModule (new nsWireless::CRT73Driver (DeviceName), new nsGUI::CRTxxConfigDialog, ProfilePath, pUI, true) { GetProfileEditor().GetDialog()->SetAvailableChannel (GetDriver().GetSupportedFreq()); } // CRT73Module() RutilTv0.18/lib/src/eggtrayicon.c0000644000175000017500000003414310705133111016343 0ustar romainromain/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* eggtrayicon.c * Copyright (C) 2002 Anders Carlsson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* #include */ #include /* #include FIXME */ #include "eggtrayicon.h" #include #if defined (GDK_WINDOWING_X11) #include #include #elif defined (GDK_WINDOWING_WIN32) #include #endif /* FIXME #ifndef EGG_COMPILATION #ifndef _ #define _(x) dgettext (GETTEXT_PACKAGE, x) #define N_(x) x #endif #else #define _(x) x #define N_(x) x #endif */ #define SYSTEM_TRAY_REQUEST_DOCK 0 #define SYSTEM_TRAY_BEGIN_MESSAGE 1 #define SYSTEM_TRAY_CANCEL_MESSAGE 2 #define SYSTEM_TRAY_ORIENTATION_HORZ 0 #define SYSTEM_TRAY_ORIENTATION_VERT 1 enum { PROP_0, PROP_ORIENTATION }; static GtkPlugClass *parent_class = NULL; static void egg_tray_icon_init (EggTrayIcon *icon); static void egg_tray_icon_class_init (EggTrayIconClass *klass); static void egg_tray_icon_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void egg_tray_icon_realize (GtkWidget *widget); static void egg_tray_icon_unrealize (GtkWidget *widget); static void egg_tray_icon_add (GtkContainer *container, GtkWidget *widget); #ifdef GDK_WINDOWING_X11 static void egg_tray_icon_update_manager_window (EggTrayIcon *icon, gboolean dock_if_realized); static void egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon); #endif GType egg_tray_icon_get_type (void) { static GType our_type = 0; if (our_type == 0) { static const GTypeInfo our_info = { sizeof (EggTrayIconClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) egg_tray_icon_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (EggTrayIcon), 0, /* n_preallocs */ (GInstanceInitFunc) egg_tray_icon_init }; our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0); } return our_type; } static void egg_tray_icon_init (EggTrayIcon *icon) { icon->stamp = 1; icon->orientation = GTK_ORIENTATION_HORIZONTAL; gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK); } static void egg_tray_icon_class_init (EggTrayIconClass *klass) { GObjectClass *gobject_class = (GObjectClass *)klass; GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; GtkContainerClass *container_class = (GtkContainerClass *)klass; parent_class = g_type_class_peek_parent (klass); gobject_class->get_property = egg_tray_icon_get_property; widget_class->realize = egg_tray_icon_realize; widget_class->unrealize = egg_tray_icon_unrealize; container_class->add = egg_tray_icon_add; g_object_class_install_property (gobject_class, PROP_ORIENTATION, g_param_spec_enum ("orientation", /*_("Orientation"), FIXME _("The orientation of the tray."),*/ "Orientation", "The orientation of the tray.", GTK_TYPE_ORIENTATION, GTK_ORIENTATION_HORIZONTAL, G_PARAM_READABLE)); #if defined (GDK_WINDOWING_X11) /* Nothing */ #elif defined (GDK_WINDOWING_WIN32) g_warning ("Port eggtrayicon to Win32"); #else g_warning ("Port eggtrayicon to this GTK+ backend"); #endif } static void egg_tray_icon_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { EggTrayIcon *icon = EGG_TRAY_ICON (object); switch (prop_id) { case PROP_ORIENTATION: g_value_set_enum (value, icon->orientation); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } #ifdef GDK_WINDOWING_X11 static void egg_tray_icon_get_orientation_property (EggTrayIcon *icon) { Display *xdisplay; Atom type; int format; union { gulong *prop; guchar *prop_ch; } prop = { NULL }; gulong nitems; gulong bytes_after; int error, result; g_assert (icon->manager_window != None); xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); gdk_error_trap_push (); type = None; result = XGetWindowProperty (xdisplay, icon->manager_window, icon->orientation_atom, 0, G_MAXLONG, FALSE, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &(prop.prop_ch)); error = gdk_error_trap_pop (); if (error || result != Success) return; if (type == XA_CARDINAL) { GtkOrientation orientation; orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; if (icon->orientation != orientation) { icon->orientation = orientation; g_object_notify (G_OBJECT (icon), "orientation"); } } if (prop.prop) XFree (prop.prop); } static GdkFilterReturn egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data) { EggTrayIcon *icon = user_data; XEvent *xev = (XEvent *)xevent; if (xev->xany.type == ClientMessage && xev->xclient.message_type == icon->manager_atom && xev->xclient.data.l[1] == icon->selection_atom) { egg_tray_icon_update_manager_window (icon, TRUE); } else if (xev->xany.window == icon->manager_window) { if (xev->xany.type == PropertyNotify && xev->xproperty.atom == icon->orientation_atom) { egg_tray_icon_get_orientation_property (icon); } if (xev->xany.type == DestroyNotify) { egg_tray_icon_manager_window_destroyed (icon); } } return GDK_FILTER_CONTINUE; } #endif static void egg_tray_icon_unrealize (GtkWidget *widget) { #ifdef GDK_WINDOWING_X11 EggTrayIcon *icon = EGG_TRAY_ICON (widget); GdkWindow *root_window; if (icon->manager_window != None) { GdkWindow *gdkwin; gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget), icon->manager_window); gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); } root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget)); gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon); if (GTK_WIDGET_CLASS (parent_class)->unrealize) (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); #endif } #ifdef GDK_WINDOWING_X11 static void egg_tray_icon_send_manager_message (EggTrayIcon *icon, long message, Window window, long data1, long data2, long data3) { XClientMessageEvent ev; Display *display; ev.type = ClientMessage; ev.window = window; ev.message_type = icon->system_tray_opcode_atom; ev.format = 32; ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window); ev.data.l[1] = message; ev.data.l[2] = data1; ev.data.l[3] = data2; ev.data.l[4] = data3; display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); gdk_error_trap_push (); XSendEvent (display, icon->manager_window, False, NoEventMask, (XEvent *)&ev); XSync (display, False); gdk_error_trap_pop (); } static void egg_tray_icon_send_dock_request (EggTrayIcon *icon) { egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_REQUEST_DOCK, icon->manager_window, gtk_plug_get_id (GTK_PLUG (icon)), 0, 0); } static void egg_tray_icon_update_manager_window (EggTrayIcon *icon, gboolean dock_if_realized) { Display *xdisplay; if (icon->manager_window != None) return; xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); XGrabServer (xdisplay); icon->manager_window = XGetSelectionOwner (xdisplay, icon->selection_atom); if (icon->manager_window != None) XSelectInput (xdisplay, icon->manager_window, StructureNotifyMask|PropertyChangeMask); XUngrabServer (xdisplay); XFlush (xdisplay); if (icon->manager_window != None) { GdkWindow *gdkwin; gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), icon->manager_window); gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon); if (dock_if_realized && GTK_WIDGET_REALIZED (icon)) egg_tray_icon_send_dock_request (icon); egg_tray_icon_get_orientation_property (icon); } } static void egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon) { GdkWindow *gdkwin; g_return_if_fail (icon->manager_window != None); gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), icon->manager_window); gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); icon->manager_window = None; egg_tray_icon_update_manager_window (icon, TRUE); } #endif static gboolean transparent_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { gdk_window_clear_area (widget->window, event->area.x, event->area.y, event->area.width, event->area.height); return FALSE; } static void make_transparent_again (GtkWidget *widget, GtkStyle *previous_style, gpointer user_data) { gdk_window_set_back_pixmap (widget->window, NULL, TRUE); } static void make_transparent (GtkWidget *widget, gpointer user_data) { if (GTK_WIDGET_NO_WINDOW (widget) || GTK_WIDGET_APP_PAINTABLE (widget)) return; gtk_widget_set_app_paintable (widget, TRUE); gtk_widget_set_double_buffered (widget, FALSE); gdk_window_set_back_pixmap (widget->window, NULL, TRUE); g_signal_connect (widget, "expose_event", G_CALLBACK (transparent_expose_event), NULL); g_signal_connect_after (widget, "style_set", G_CALLBACK (make_transparent_again), NULL); } static void egg_tray_icon_realize (GtkWidget *widget) { #ifdef GDK_WINDOWING_X11 EggTrayIcon *icon = EGG_TRAY_ICON (widget); GdkScreen *screen; GdkDisplay *display; Display *xdisplay; char buffer[256]; GdkWindow *root_window; if (GTK_WIDGET_CLASS (parent_class)->realize) GTK_WIDGET_CLASS (parent_class)->realize (widget); make_transparent (widget, NULL); screen = gtk_widget_get_screen (widget); display = gdk_screen_get_display (screen); xdisplay = gdk_x11_display_get_xdisplay (display); /* Now see if there's a manager window around */ g_snprintf (buffer, sizeof (buffer), "_NET_SYSTEM_TRAY_S%d", gdk_screen_get_number (screen)); icon->selection_atom = XInternAtom (xdisplay, buffer, False); icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False); icon->system_tray_opcode_atom = XInternAtom (xdisplay, "_NET_SYSTEM_TRAY_OPCODE", False); icon->orientation_atom = XInternAtom (xdisplay, "_NET_SYSTEM_TRAY_ORIENTATION", False); egg_tray_icon_update_manager_window (icon, FALSE); egg_tray_icon_send_dock_request (icon); root_window = gdk_screen_get_root_window (screen); /* Add a root window filter so that we get changes on MANAGER */ gdk_window_add_filter (root_window, egg_tray_icon_manager_filter, icon); #endif } static void egg_tray_icon_add (GtkContainer *container, GtkWidget *widget) { g_signal_connect (widget, "realize", G_CALLBACK (make_transparent), NULL); GTK_CONTAINER_CLASS (parent_class)->add (container, widget); } EggTrayIcon * egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name) { g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL); } EggTrayIcon* egg_tray_icon_new (const gchar *name) { return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL); } guint egg_tray_icon_send_message (EggTrayIcon *icon, gint timeout, const gchar *message, gint len) { guint stamp; g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0); g_return_val_if_fail (timeout >= 0, 0); g_return_val_if_fail (message != NULL, 0); #ifdef GDK_WINDOWING_X11 if (icon->manager_window == None) return 0; #endif if (len < 0) len = strlen (message); stamp = icon->stamp++; #ifdef GDK_WINDOWING_X11 /* Get ready to send the message */ egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE, icon->manager_window, timeout, len, stamp); /* Now to send the actual message */ gdk_error_trap_push (); while (len > 0) { XClientMessageEvent ev; Display *xdisplay; xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); ev.type = ClientMessage; ev.window = icon->manager_window; ev.format = 8; ev.message_type = XInternAtom (xdisplay, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False); if (len > 20) { memcpy (&ev.data, message, 20); len -= 20; message += 20; } else { memcpy (&ev.data, message, len); len = 0; } XSendEvent (xdisplay, icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev); XSync (xdisplay, False); } gdk_error_trap_pop (); #endif return stamp; } void egg_tray_icon_cancel_message (EggTrayIcon *icon, guint id) { g_return_if_fail (EGG_IS_TRAY_ICON (icon)); g_return_if_fail (id > 0); #ifdef GDK_WINDOWING_X11 egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE, (Window)gtk_plug_get_id (GTK_PLUG (icon)), id, 0, 0); #endif } GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon) { g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL); return icon->orientation; } RutilTv0.18/lib/src/OptionsFile.cxx0000644000175000017500000000724211054617535016662 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file OptionsFile.cxx \author Romain BONDUE \date 03/08/2006 */ #ifndef NDEBUG #include #endif // NDEBUG #include #include #include // getenv() #include // strcmp() #include "OptionsFile.h" #include "StaticSettings.h" #include "ErrorsCode.h" #include "UserData.h" namespace { const char* const DisplayTrayIconLabel ("DisplayTrayIcon"); const char* const StartMinimizedLabel ("StartMinimized"); const char* const LeaveRootDelayLabel ("LeaveRootDelay"); const char* const RootMarkupLabel ("Options"); const char* const Indentation (" "); } // anonymous namespace void nsUserData::COptionsFile::Record () throw (nsErrors::CException) { #ifndef NDEBUG std::cerr << "Recording options in : " << AppDirectory << '/' << nsCore::OptionsFileName << std::endl; #endif // NDEBUG std::ofstream Os ((AppDirectory + '/' + nsCore::OptionsFileName).c_str(), std::ios_base::trunc); try { Os.exceptions (std::ios_base::badbit | std::ios_base::failbit); Os << XMLHeader << '\n' << Markup1B << RootMarkupLabel << Markup2E; RecordFields (Os); Os << Markup2B << RootMarkupLabel << Markup2E; } catch (const std::ios_base::failure& Exc) { throw nsErrors::CException (Exc.what(), nsErrors::OptionsRecordFailure); } } // Record() void nsUserData::COptionsFile::Extract () throw (nsErrors::CException) { CXMLParser::Extract (AppDirectory + '/' + nsCore::OptionsFileName); } // Extract() void nsUserData::COptionsFile::Text (const char* QName, const std::string& Text) throw (nsErrors::CException) { std::istringstream Is (Text); Is.exceptions (std::ios_base::badbit); try { if (!strcmp (QName, DisplayTrayIconLabel)) Is >> m_DisplayTrayIcon; else if (!strcmp (QName, StartMinimizedLabel)) Is >> m_StartMinimized; else if (!strcmp (QName, LeaveRootDelayLabel)) Is >> m_LeaveRootDelay; } catch (const std::ios_base::failure& Exc) { throw nsErrors::CException (Exc.what(), nsErrors::OptionsExtractionInvalidValue); } } // Text() void nsUserData::COptionsFile::RecordFields (std::ostream& Os) throw (std::ios_base::failure) { Os << Indentation << Markup1B << DisplayTrayIconLabel << Markup1E << m_DisplayTrayIcon << Markup2B << DisplayTrayIconLabel << Markup2E << Indentation << Markup1B << StartMinimizedLabel << Markup1E << m_StartMinimized << Markup2B << StartMinimizedLabel << Markup2E << Indentation << Markup1B << LeaveRootDelayLabel << Markup1E << m_LeaveRootDelay << Markup2B << LeaveRootDelayLabel << Markup2E; } // RecordFields() RutilTv0.18/lib/src/IfaceRoot.cxx0000644000175000017500000000460210543033310016260 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file IfaceRoot.cxx \author Romain BONDUE \date 09/06/2006 */ #include "IfaceRoot.h" #include "IfaceProtocolCodes.h" #include "Msg.h" #include "ErrorsCode.h" nsNet::CInterfaceRoot::CInterfaceRoot (const CInterface& Iface) throw (nsErrors::CSystemExc) : CInterface (Iface), m_Su (IfaceHandler) { SuDo (Iface.GetName(), DeviceNameC); } // CInterfaceRoot() void nsNet::CInterfaceRoot::SetIP (const CIPAddress& Addr) throw (nsErrors::CSystemExc) { // TODO } // SetIP() void nsNet::CInterfaceRoot::SetIPFromDHCP (const std::string& Data) throw (nsErrors::CException) { SuDo (Data, DhcpC); } // SetIPFromDHCP() void nsNet::CInterfaceRoot::Up () throw (nsErrors::CSystemExc) { SuDo ("", UpC); } // Up() void nsNet::CInterfaceRoot::Down () throw (nsErrors::CSystemExc) { SuDo ("", DownC); } // Down() void nsNet::CInterfaceRoot::SuDo (const std::string& Text, int Code) throw (nsErrors::CSystemExc) { try { const nsRoot::CMsg ReturnedMsg (m_Su.Do (nsRoot::CMsg (Text, Code))); if (ReturnedMsg.GetCode()) throw nsErrors::CSystemExc (ReturnedMsg.GetText(), ReturnedMsg.GetCode()); } catch (const nsErrors::CException& Exc) { throw nsErrors::CSystemExc (Exc.GetMsg(), Exc.GetCode()); } catch (const std::bad_alloc& Exc) { throw nsErrors::CSystemExc (Exc.what(), nsErrors::OutOfMemory); } } // SuDo() RutilTv0.18/lib/src/SystemTools.cxx0000644000175000017500000002646310705136646016743 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file SystemTools.cxx \author Romain BONDUE \date 20/12/2005 */ #include #include // std::memset() #include #include #ifndef NDEBUG #include #include #endif // NDEBUG extern "C"{ #include #include #include #include // ::wait() #include } #include "SystemTools.h" namespace { inline void Sigaction (int Signum, const struct sigaction& NewSettings, struct sigaction* OldSettings = 0) throw (nsErrors::CSystemExc) { if (::sigaction (Signum, &NewSettings, OldSettings)) throw nsErrors::CSystemExc ("::sigaction() failed."); } // Sigaction() void ZombieCleaner (int) throw() {::wait (0);} // Set up things when RutilT starts. struct SInitializer { public : const int Sd; SInitializer () throw (nsErrors::CSystemExc) : Sd (::socket (PF_INET, SOCK_DGRAM, 0)) { if (Sd == -1) throw nsErrors::CSystemExc ("Can't create socket."); IgnoreSignals(); } // SInitializer() ~SInitializer () throw() {::close (Sd);} void IgnoreSignals () throw (nsErrors::CSystemExc) { struct sigaction Settings; std::memset (&Settings, 0, sizeof (struct sigaction)); Settings.sa_handler = SIG_IGN; Sigaction (SIGPIPE, Settings); Settings.sa_flags = SA_NOCLDSTOP; Settings.sa_handler = ZombieCleaner; Sigaction (SIGCHLD, Settings); } // IgnoreSignals() void RestoreSignals () throw (nsErrors::CSystemExc) { struct sigaction Settings; std::memset (&Settings, 0, sizeof (struct sigaction)); Settings.sa_handler = SIG_DFL; Sigaction (SIGPIPE, Settings); Sigaction (SIGCHLD, Settings); /* !! UGLY !! They are modified in GtkGUI.cxx They have not been modified here because this code is linked with the helper, and it's not linked with gtk. */ Sigaction (SIGINT, Settings); Sigaction (SIGTERM, Settings); } // RestoreSignals() } Data; inline void Close (int FD) throw (nsErrors::CSystemExc) { if (::close (FD)) throw nsErrors::CSystemExc ("Can't close file descriptor."); } // Close() void InitSockaddrUn (const std::string& addr_name, ::sockaddr_un& addr) throw() { std::memset(&addr, 0, sizeof (addr)); const size_t UNIX_PATH_MAX (108U); addr.sun_family = AF_UNIX; addr_name.copy (addr.sun_path + 1, UNIX_PATH_MAX - 1); } // InitSockaddrUn() ::ucred* GetCredential (int Sd, unsigned char* Buffer, unsigned BufferSize) throw (nsErrors::CSystemExc) { std::memset (Buffer, 0, BufferSize); ::msghdr Msg; std::memset (&Msg, 0, sizeof (Msg)); Msg.msg_control = Buffer; Msg.msg_controllen = BufferSize; ::cmsghdr* const pCMsgHeader (CMSG_FIRSTHDR (&Msg)); ::ucred* const pUCred (reinterpret_cast< ::ucred*> (CMSG_DATA (pCMsgHeader))); pCMsgHeader->cmsg_len = CMSG_LEN (sizeof (::ucred)); pCMsgHeader->cmsg_level = SOCK_STREAM; pCMsgHeader->cmsg_type = SCM_CREDENTIALS; Msg.msg_controllen = pCMsgHeader->cmsg_len; ::iovec DataVec; std::memset (&DataVec, 0, sizeof (DataVec)); char MsgData; DataVec.iov_base = &MsgData; DataVec.iov_len = sizeof (MsgData); Msg.msg_iov = &DataVec; Msg.msg_iovlen = 1; int BoolValue (1); if (::setsockopt (Sd, SOL_SOCKET, SO_PASSCRED, &BoolValue, sizeof (BoolValue))) throw nsErrors::CSystemExc ("Can't enable credential reception on" " socket."); const int NbRead (::recvmsg (Sd, &Msg, MSG_WAITALL)); BoolValue = 0; if (::setsockopt (Sd, SOL_SOCKET, SO_PASSCRED, &BoolValue, sizeof (BoolValue))) throw nsErrors::CSystemExc ("Can't enable credential reception on" " socket."); if (NbRead == -1) throw nsErrors::CSystemExc ("Can't get credential information."); if (size_t (NbRead) < sizeof (MsgData)) throw nsErrors::CSystemExc ("Can't get credential on socket."); return pUCred; } // GetCredential() } // anonymous namespace void nsSystem::Ioctl (int Request, void* pData, const std::string& ErrorMsg) throw (nsErrors::CSystemExc) { if (::ioctl (Data.Sd, Request, pData) < 0) { #ifndef NDEBUG perror ("::ioctl() failed"); std::cerr << "\tRequest : " << std::hex << Request << std::dec << ' ' << ErrorMsg << std::endl; #endif // NDEBUG throw nsErrors::CSystemExc (ErrorMsg); } } // Ioctl() nsSystem::CLocalSocket::CLocalSocket () throw (nsErrors::CSystemExc) : m_Sd (::socket (PF_UNIX, SOCK_STREAM, 0)) { if (m_Sd == -1) throw nsErrors::CSystemExc ("Can't create socket."); } // CLocalSocket() void nsSystem::CLocalSocket::Close () throw (nsErrors::CSystemExc) { if (m_Sd != InvalidSocket); { ::Close (m_Sd); m_Sd = InvalidSocket; } } // Close() void nsSystem::CLocalSocket::Write (const char* Data, size_t Size) throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "Writing " << Size << " byte(s) in socket." << std::endl; #endif // NDEBUG if (::write (m_Sd, Data, Size) != ssize_t (Size)) throw nsErrors::CSystemExc ("Can't write in socket or short write."); } // Write() size_t nsSystem::CLocalSocket::Read (char* Buffer, size_t Size) throw (nsErrors::CSystemExc) { #ifndef NDEBUG std::cerr << "Trying to read up to " << Size << " bytes in socket." << std::endl; #endif // NDEBUG const ssize_t ByteRead (::read (m_Sd, Buffer, Size)); if (ByteRead < 0) { if (errno == ECONNRESET) return 0; throw nsErrors::CSystemExc ("Can't read in socket."); } #ifndef NDEBUG std::cerr << "\tRead " << ByteRead << " byte(s)" << std::endl; #endif // NDEBUG return ByteRead; } // Read() void nsSystem::CLocalSocket::Bind (const std::string& addr_name) throw (nsErrors::CSystemExc) { ::sockaddr_un addr; InitSockaddrUn (addr_name, addr); if (::bind (m_Sd, reinterpret_cast< ::sockaddr*> (&addr), sizeof (addr))) throw nsErrors::CSystemExc ("Can't bind socket."); } // Bind() void nsSystem::CLocalSocket::Connect (const std::string& addr_name) throw (nsErrors::CSystemExc) { ::sockaddr_un addr; InitSockaddrUn (addr_name, addr); if (::connect (m_Sd, reinterpret_cast< ::sockaddr*> (&addr), sizeof (addr))) throw nsErrors::CSystemExc ("Can't connect socket."); } // Connect() void nsSystem::CLocalSocket::Listen (unsigned Backlog) throw (nsErrors::CSystemExc) { if (::listen (m_Sd, Backlog)) throw nsErrors::CSystemExc ("Can't listen on socket."); } // Listen() nsSystem::CLocalSocket* nsSystem::CLocalSocket::Accept () throw (nsErrors::CSystemExc, std::bad_alloc) { const int NewSd (::accept (m_Sd, 0, 0)); if (NewSd == -1) throw nsErrors::CSystemExc ("Can't accept connection on socket."); return new CLocalSocket (NewSd); } // Accept() void nsSystem::CLocalSocket::SendCredential () throw (nsErrors::CSystemExc) { // Linux specific. const unsigned BufferSize (256); unsigned char Buffer [BufferSize]; std::memset (Buffer, 0, BufferSize); ::msghdr Msg; std::memset (&Msg, 0, sizeof (Msg)); Msg.msg_control = Buffer; Msg.msg_controllen = BufferSize; ::cmsghdr* const pCMsgHeader (CMSG_FIRSTHDR (&Msg)); ::ucred* const pUCred (reinterpret_cast< ::ucred*> (CMSG_DATA (pCMsgHeader))); pCMsgHeader->cmsg_len = CMSG_LEN (sizeof (::ucred)); pCMsgHeader->cmsg_level = SOCK_STREAM; pCMsgHeader->cmsg_type = SCM_CREDENTIALS; pUCred->pid = ::getpid(); const ::uid_t Euid (::geteuid()); pUCred->uid = Euid ? ::getuid() : Euid; pUCred->gid = ::getgid(); Msg.msg_controllen = pCMsgHeader->cmsg_len; ::iovec DataVec; std::memset (&DataVec, 0, sizeof (DataVec)); char MsgData (65); DataVec.iov_base = &MsgData; DataVec.iov_len = sizeof (MsgData); Msg.msg_iov = &DataVec; Msg.msg_iovlen = 1; const ssize_t NbSent (::sendmsg (m_Sd, &Msg, 0)); if (NbSent == -1) throw nsErrors::CSystemExc ("Can't send credential on socket."); if (size_t (NbSent) != DataVec.iov_len) throw nsErrors::CSystemExc ("Can't send credential on socket (Short" " write)."); } // SendCredential() bool nsSystem::CLocalSocket::CheckCredentialUID (::uid_t uid) throw (nsErrors::CSystemExc) { // Linux specific. const unsigned BufferSize (256); unsigned char Buffer [BufferSize]; return GetCredential (m_Sd, Buffer, BufferSize)->uid == uid; } // CheckCredentialUID() bool nsSystem::CLocalSocket::CheckCredentialPID (::pid_t pid) throw (nsErrors::CSystemExc) { // Linux specific. const unsigned BufferSize (256); unsigned char Buffer [BufferSize]; return GetCredential (m_Sd, Buffer, BufferSize)->pid == pid; } // CheckCredentialPID() bool nsSystem::Fork () throw (nsErrors::CSystemExc) { const ::pid_t Pid (::fork()); if (Pid == -1) throw nsErrors::CSystemExc ("Can't create sub-process."); return Pid; } // Fork() void nsSystem::Exec (const char* Argv []) throw (nsErrors::CSystemExc) { Data.RestoreSignals(); ::execv (Argv [0], const_cast (Argv)); throw nsErrors::CSystemExc (std::string ("Can't execute file : ") + Argv [0] + '.'); } // Exec() RutilTv0.18/lib/src/NetTools.cxx0000644000175000017500000001343610662032770016174 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file NetTools.cxx \author Romain BONDUE \date 08/05/2006 */ #include #include // abort() #include #include #include #include // memset() extern "C"{ #include #include #include #include } #include "NetTools.h" #include "SystemTools.h" #include "ErrorsCode.h" #include "StaticSettings.h" namespace { void GetInterfaceFlags (::ifreq& Req, const std::string& IfName) throw (nsErrors::CSystemExc) { IfName.copy (Req.ifr_name, IFNAMSIZ - 1); Req.ifr_name [IfName.size() > IFNAMSIZ - 1 ? IFNAMSIZ - 1 : IfName.size()] = '\0'; nsSystem::Ioctl (SIOCGIFFLAGS, &Req, "Can't get interface state."); } // GetInterfaceFlags() } // anonymous namespace std::string nsNet::CIPAddress::GetStr () const throw() { ::in_addr Addr = {m_Addr}; return ::inet_ntoa (Addr); } // GetStr() nsNet::CInterface::CInterface (const std::string& IfName) throw() : m_IfName (IfName), m_RXBytes (0), m_RXPackets (0), m_RXErrors (0), m_RXDropped (0), m_RXFifo (0), m_RXFrame (0), m_RXCompressed (0), m_Multicast (0), m_TXBytes (0), m_TXPackets (0), m_TXErrors (0), m_TXDropped (0), m_TXFifo (0), m_Collisions (0), m_Carrier (0), m_TXCompressed (0) {} void nsNet::CInterface::RefreshStats () throw (nsErrors::CException) { try { std::ifstream Is ("/proc/net/dev"); Is.exceptions (std::ios_base::failbit | std::ios_base::badbit); Is.ignore (std::numeric_limits::max(), '\n'); Is.ignore (std::numeric_limits::max(), '\n'); while (Is) { std::string Buffer; for (char C ; ; ) { Is >> C; if (C == ':') break; Buffer += C; } if (Buffer == m_IfName) { Is >> m_RXBytes >> m_RXPackets >> m_RXErrors >> m_RXDropped >> m_RXFifo >> m_RXFrame >> m_RXCompressed >> m_Multicast >> m_TXBytes >> m_TXPackets >> m_TXErrors >> m_TXDropped >> m_TXFifo >> m_Collisions >> m_Carrier >> m_TXCompressed; return; } Is.ignore (std::numeric_limits::max(), '\n'); } } catch (...) {} throw nsErrors::CException ("Can't parse /proc/net/dev", nsErrors::StatsParsing); } // RefreshStats() nsNet::CIPAddress nsNet::CInterface::GetIP () const throw (nsErrors::CSystemExc) { ::ifreq Req; std::memset (&Req, 0, sizeof (Req)); ::sockaddr_in* const pIn (reinterpret_cast< ::sockaddr_in*> (&Req.ifr_addr)); pIn->sin_family = AF_INET; m_IfName.copy (Req.ifr_name, IFNAMSIZ - 1); Req.ifr_name [m_IfName.size() > IFNAMSIZ - 1 ? IFNAMSIZ - 1 : m_IfName.size()] = '\0'; nsSystem::Ioctl (SIOCGIFADDR, &Req, "Can't get IP address."); return pIn->sin_addr.s_addr; } // GetIP() void nsNet::CInterface::SetIPFromDHCP (const std::string& Data) throw (nsErrors::CException) { if (nsSystem::Fork()) { const std::string Path (nsCore::DhcpScriptPrefix + nsCore::DhcpScriptName); const char* Argv [5] = {Path.c_str(), m_IfName.c_str(), Data.c_str(), 0}; try {nsSystem::Exec (Argv);} catch (const nsErrors::CException& Exc) { std::cerr << "Error : " << Exc.GetMsg() << '\t' << Exc.GetCode() << std::endl; } abort(); } } // SetIPFromDHCP() void nsNet::CInterface::ClearStats () throw() { m_RXBytes = 0; m_RXPackets = 0; m_RXErrors = 0; m_RXDropped = 0; m_RXFifo = 0; m_RXFrame = 0; m_RXCompressed = 0; m_Multicast = 0; m_TXBytes = 0; m_TXPackets = 0; m_TXErrors = 0; m_TXDropped = 0; m_TXFifo = 0; m_Collisions = 0; m_Carrier = 0; m_TXCompressed = 0; } // ClearStats() bool nsNet::CInterface::IsUp () throw (nsErrors::CSystemExc) { ::ifreq Req; GetInterfaceFlags (Req, m_IfName); return Req.ifr_flags & IFF_UP; } // IsUp() void nsNet::CInterface::Up () throw (nsErrors::CSystemExc) { ::ifreq Req; GetInterfaceFlags (Req, m_IfName); if (!(Req.ifr_flags & IFF_UP)) { Req.ifr_flags |= IFF_UP | IFF_RUNNING; nsSystem::Ioctl (SIOCSIFFLAGS, &Req, "Can't bring interface up."); } } // Up() void nsNet::CInterface::Down () throw (nsErrors::CSystemExc) { ::ifreq Req; GetInterfaceFlags (Req, m_IfName); if (Req.ifr_flags & IFF_UP) { Req.ifr_flags &= ~(IFF_UP | IFF_RUNNING); nsSystem::Ioctl (SIOCSIFFLAGS, &Req, "Can't bring interface down."); } } // Down() RutilTv0.18/lib/src/RTWMsgHandlers.cxx0000644000175000017500000000771010705134325017224 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTWMsgHandlers.cxx \author Romain BONDUE \date 21/02/2005 */ #include #include "RTWMsgHandlers.h" #include "RTDrivers.h" #include "RTSuWProtocolCodes.h" #include "ErrorsCode.h" namespace { template T Extract (const std::string& Str) throw (nsErrors::CException) { std::istringstream Is (Str); T Value; Is >> Value; if (Is) return Value; throw nsErrors::CException ("Invalid data read (from helper).", nsErrors::InvalidDataFromHelper); } // Extract() } // anonymous namespace void nsRoot::CRT2400MsgHandler::SetDriver (const std::string& DeviceName) throw (std::bad_alloc, nsErrors::CException) { CWirelessMsgHandler::SetDriver (new nsWireless::CRT2400Driver (DeviceName)); } // SetDriver() void nsRoot::CRT2500MsgHandler::SetDriver (const std::string& DeviceName) throw (std::bad_alloc, nsErrors::CException) { CWirelessMsgHandler::SetDriver (new nsWireless::CRT2500Driver (DeviceName)); } // SetDriver() void nsRoot::CRT2570MsgHandler::SetDriver (const std::string& DeviceName) throw (std::bad_alloc, nsErrors::CException) { CWirelessMsgHandler::SetDriver (new nsWireless::CRT2570Driver (DeviceName)); } // SetDriver() void nsRoot::CRT61MsgHandler::SetDriver (const std::string& DeviceName) throw (std::bad_alloc, nsErrors::CException) { CWirelessMsgHandler::SetDriver (new nsWireless::CRT61Driver (DeviceName)); } // SetDriver() void nsRoot::CRT73MsgHandler::SetDriver (const std::string& DeviceName) throw (std::bad_alloc, nsErrors::CException) { CWirelessMsgHandler::SetDriver (new nsWireless::CRT73Driver (DeviceName)); } // SetDriver() nsRoot::CMsg nsRoot::CRTAdvancedMsgHandler::operator () (const CMsg& Msg) throw (nsErrors::CException, std::bad_alloc) { switch (Msg.GetCode()) { case nsWireless::WModeC : GetDriver()->SetWirelessMode (nsWireless::WirelessMode_e (Extract (Msg.GetText()))); break; case nsWireless::TxBurstC : GetDriver()->SetTxBurst (Extract (Msg.GetText())); break; case nsWireless::BGProtectionC : GetDriver()->SetBGProtection (nsWireless::BGProtection_e (Extract (Msg.GetText()))); break; case nsWireless::TxPreambleC : GetDriver()->SetTxPreamble (nsWireless::TxPreamble_e (Extract (Msg.GetText()))); break; case nsWireless::TurboRateC : GetDriver()->SetTurboRate (Extract (Msg.GetText())); break; case nsWireless::AdHocOFDMC : GetDriver()->SetAdHocOFDM (Extract (Msg.GetText())); break; case nsWireless::RfmontxC : GetDriver()->SetRfmontx (Extract (Msg.GetText())); break; default : return CWirelessMsgHandler::operator () (Msg); } return CMsg(); } // operator() () RutilTv0.18/COPYING0000644000175000017500000004313310357221665013400 0ustar romainromain GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 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. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program 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. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public 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. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. RutilTv0.18/README0000644000175000017500000002550711054622761013227 0ustar romainromainThis utility is no longer in active development, but if you notice a bug or would like to see a feature implemented, feel free to contact me. RutilT should work with any, Linux wireless extensions compliant, kernel module, and using it with any of these drivers is supported. It also features special, extra support for rt2400, rt2500, rt2570, rt61 and rt73 devices used along the rt2x00 project's legacy drivers (original Ralink's drivers may work too, but using RutilT with them is unsupported). The new rt2x00 driver itself will be supported in a future release, please use the standard tools ("iwconfig", "iwlist" etc...) with this driver at this stage. Comments of all kind are welcomed, to contact me : - spy84464@hotmail.com or, - through the rt2x00-dev or rt2x00-general mailing list or, - on the forum : http://rt2x00.serialmonkey.com/phpBB2/ Running the program as root is no longer needed : RutilT includes an "helper", it is a privileged program that allows underprivileged users to manage wireless devices if they are authorized to. The helper is launched if root privileges are needed, when a profile is applied for instance. By default, the helper is installed setuid (Notice : Like all other setuid programs and while care has been taken, a potential security risk might exists.) and launched if the user type in the root password. This does not require any external software. This behavior can be changed, you can compile RutilT to use an external program like gksu or kdesu to launch the helper, which does not need to be setuid anymore. Since v0.14, a script is used as a proxy for external launchers. By default, gksu is used, the script falls back on kdesu if it cannot find gksu. This means that, when root privileges are required, the script is executed and expected to launch the helper with root privileges. Of course, you are welcome to tune this script, you may want to use an external launcher if root's account is disabled on your distribution (like Ubuntu), if you do not want the helper to be setuid, and/or as a kind of better desktop integration. If none of these options suit you, the helper can be completely disabled, RutilT will have to be run as root directly to change anything. See the INSTALL file (in the "Compilation options" section) for instructions. Since v0.09, RutilT can use the dhcp protocol to set your wireless interface IP address. It can do when clicking on the "Connect" button in the "Site Survey" tab, or if it has been enabled when applying a profile. If you are upgrading from a previous version and want to enable dhcp with your old profiles, just edit them. By default, RutilT uses the "dhclient" program (and fall back to "dhcpd" if unavailable) which comes with many distribution and launches it in the background, but this behavior can be changed, in fact, the script "set_ip.sh" is executed, feel free to customize it to match your needs, do not forget that it is executed with root privileges, so beware! Once RutilT installed, you can find the script in the "/usr/local/share/rutilt/" directory (default installation path), it also contains some useful piece of information to tune it. Static IP settings might be supported in a future release, until then, "set_ip.sh" can also be modified to set those settings, the script contains some examples on how to do (Note : those examples may be inaccurate for your distribution). Since v0.13, RutilT comes with some command line interface support, mainly to apply a profile, this can be handy within startup scripts for instance. Usage : rutilt [IFACE_NAME] [OPTIONS...] Short options can be combined, options with an argument must appear last in this case. Mandatory arguments to long options are mandatory for short options too. If IFACE_NAME is specified, rutilt will try to use this network interface and will not prompt the interface chooser. Options : -h, --help display some help and exit -v, --version output version information and exit -t, --hide force to start hidden in tray -p, --profile PROFILE_NAME apply PROFILE_NAME on start (quote PROFILE_NAME if it contains spaces), the IP settings of that profile will not be applied. Note that profiles will be looked-up in the _current_ user's home directory. -d, --dhcp use dhcp (run the set_ip.sh script) on start -e, --exit exit after processing the command line options (do not start the gui) IFACE_NAME must be specified when using this options with --dhcp or --profile and the application executed as root. All Gtk+ specific options are also supported, see the Gtk+ documentation. Example : $ rutilt wlan0 -dep "Home network" This will apply the profile "Home network" on interface wlan0, then launch dhclient and exit. == Troubleshooting == If you updated your kernel, make sure you recompiled RutilT and try again before reporting any problem. If you contact me, thanks to generate a debug trace and join it to the e-mail, do _not_ truncate any part, send it as a whole. To generate a trace, run these commands in RutilT sources directory : ./configure.sh --debug make make install (as root) rutilt &> debug.log == Known issues == The helper does not work on OpenSuse10.2 (and possibly other) by default. An external launcher should be used. Technically, this is because I did not manage to encrypt the password using the blowfish algorithm (I have tried with the crypt() function.). If you can shed some lights on this problem, I would be glad if you could contact me. == Changelog == v0.18, Profiles and options are now recorded on the disc upon every modification, and not only when the application exits. If RutilT cannot locate the user's home directory, it will use "/root/" by default, this can help when it is run from an init script. Fix some bug. v0.17, fix compilation with recent gcc releases. v0.16, add a button to toggle the interface state (up/down) and make it possible to use RutilT with down interfaces. "dhcpcd" is now handled in the set_ip.sh script. It has become possible to select a profile when connecting through the site survey tab, and this is compulsory actually : any connection to any network now requires a profile. The number of transmitted and received bytes is now also displayed in mega bytes. A manual page for the helper has been added, and the installation procedure has been updated to be more Debian and freedesktop.org friendly. Greatly increase network encryption and authentication identification with rt2500, rt2570 (and rt2400?). Add a tray icon menu. Usual bug fixes and code cleaning. v0.15, fix a lot of bug and potential crash. Update support for rt61, rt2570 and recent kernels. RutilT can now be compile to generate a debug trace. v0.14, improve the installation/uninstallation process. Add full support for rt61 and rt73. rt2570 support has been enhanced, mainly to display WPA encrypted networks properly in scan results. Lot of small tweak to improve stability and error tolerance have been rolled in. The privileged session internal has been revamped and a script is now used to switch to root if an external launcher should be used. Improve WEP support. Fix compilation towards 2.6.19 kernel sources, as well as several bugs. v0.13, add command line support, a Unix manual page and a desktop menu configuration file. As usual, some bugs have been fixed. v0.12, fix a bug which prevented to set the Tx rate (or set it with an incorrect value). v0.11, the current IP address is now displayed in the Link Status tab. The generic driver for unknown devices have been enhanced, ditto for rt2500. The user is now asked if dhcp should be used when connecting to a network through the Site Survey tab. rt2570 support is finally stabilized and has been enhanced (thanks to Kirk Williams). A tray icon has been added. Support for WPANONE with rt2500 and rt2570 has been implemented. An option page has been added to tune RutilT behavior and to set the maximum tx rate. RutilT can now be compiled to allow everyone to use it as root without the root password. The wireless extensions dependency has been reduced from v17 to v16. The profiles are now recorded properly if the application is shutdown with a signal. The application now has its icons. And, as usual, many bugs have been fixed. v0.10, fix compilation errors with g++-3.3. v0.09, rt2400 support has been slightly improved again, this change follow a big code cleaning. rt2570 support has been completely rewritten and should be nearly working, however it is still experimental because of the lack of testing. RutilT now let you set several keys for WEP encrypted network. A statistics tab has been added to monitor network activity. There is no more need to enable/disable injection support at compile-time, it is now dynamically detected. Dhcp support has been integrated. The built-in helper launcher can now be changed to an external program like gksudo to integrate better with some distribution, it also removes the need of another setuid program. Finally, a lot of bugs have been fixed and stability has been improved. v0.08, injection support is disabled by default again. rt2400 support has been tweaked, thanks again to Szymon Dziok, and several small bugs have been fixed, as well as some code cleaning and better WPA support for rt2500. v0.07, rt2400 support has been fixed, thanks to Szymon Dziok. Among all the usual tweaks and fixes, the main new feature is privileged mode handling. This is also the first release since the code has been uploaded on rt2x00 CVS. v0.06, like with each new version, many tweaks and improvements have been done. The new major feature is special support for rt2500, it has been tested and should work well. Special support for rt2400 and rt2570 have also been implemented but is completely untested and considered experimental. v0.05, fix compilation bugs on gcc3.3, thanks to Nicolas Favre-Félix, and improve network interface selection. v0.04, no new features but a lot of improvements, corrections and rework, most of the code should be stable now. This version is suitable for module that do not need special support (compliant to WE 17). Of course, it still requires wide testing to validate it. v0.03, almost all files have been modified! The code has been cleaned or reworked in many place and the application should be more stable and less buggy. Profiles support has also been added, it is possible to set the connection parameters with them. v0.02, the code has been cleaned and a lot of bugs fixed. Errors are also better handled (they are not print on stderr anymore) but it still incomplete. I have also had static checks on the wireless extensions headers and gtk one. v0.01, first release, provide a link and site survey monitor. It is possible to connect to a network through the site survey tab. Every things need polish and many bugs are present. It must be considered as an alpha release. RutilTv0.18/include/0000755000175000017500000000000011054676047013767 5ustar romainromainRutilTv0.18/include/IMsgHandler.h0000644000175000017500000000230410372634634016272 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file IMsgHandler.h \author Romain BONDUE \date 20/02/2006 */ #ifndef __IMSGHANDLER_H__ #define __IMSGHANDLER_H__ #include #include "Msg.h" namespace nsRoot { class IMsgHandler : public std::unary_function { public : virtual ~IMsgHandler () throw() {} virtual CMsg operator () (const CMsg&) = 0; }; // IMsgHandler } // namespace nsRoot #endif // __IMSGHANDLER_H__ RutilTv0.18/include/RTWMsgHandlers.h0000644000175000017500000000623410636002145016734 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTWMsgHandlers.h \author Romain BONDUE \date 21/02/06 */ #ifndef __RTWMSGHANDLERS_H__ #define __RTWMSGHANDLERS_H__ #include "CWirelessMsgHandler.h" namespace nsWireless { class CRT2400Driver; class CRTAdvancedDriver; class CRT2570Driver; } // namespace nsWireless namespace nsRoot { class CRT2400MsgHandler : public CWirelessMsgHandler { protected : nsWireless::CRT2400Driver* GetDriver () throw(); const nsWireless::CRT2400Driver* GetDriver () const throw(); void SetDriver (const std::string&) throw (std::bad_alloc, nsErrors::CException); }; // CRT2400MsgHandler // Not always the best way to share code (but the most compact). class CRTAdvancedMsgHandler : public CWirelessMsgHandler { public: CMsg operator () (const CMsg&) throw (nsErrors::CException, std::bad_alloc); protected : nsWireless::CRTAdvancedDriver* GetDriver () throw(); const nsWireless::CRTAdvancedDriver* GetDriver () const throw(); }; // CRTAdvancedMsgHandler class CRT2500MsgHandler : public CRTAdvancedMsgHandler { protected : void SetDriver (const std::string&) throw (std::bad_alloc, nsErrors::CException); }; // CRT500MsgHandler class CRT61MsgHandler : public CRTAdvancedMsgHandler { protected : void SetDriver (const std::string&) throw (std::bad_alloc, nsErrors::CException); }; // CRT61MsgHandler class CRT73MsgHandler : public CRTAdvancedMsgHandler { protected : void SetDriver (const std::string&) throw (std::bad_alloc, nsErrors::CException); }; // CRT73MsgHandler class CRT2570MsgHandler : public CWirelessMsgHandler { public: CMsg operator () (const CMsg&) throw (nsErrors::CException, std::bad_alloc); protected : nsWireless::CRT2570Driver* GetDriver () throw(); const nsWireless::CRT2570Driver* GetDriver () const throw(); void SetDriver (const std::string&) throw (std::bad_alloc, nsErrors::CException); }; // CRT2570MsgHandler } // namespace nsRoot #include "private/RTWMsgHandlers.hxx" #endif // __RTWMSGHANDLERS_H__ RutilTv0.18/include/CLinkStatusTab.h0000644000175000017500000000501710702224517016764 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CLinkStatusTab.h \author Romain BONDUE \date 29/07/2005 */ #ifndef __CLINKSTATUSTAB_H__ #define __CLINKSTATUSTAB_H__ extern "C"{ #include } #include "Exceptions.h" namespace nsGUI { class CLinkStatusTab { public : CLinkStatusTab () throw(); operator ::GtkWidget* () throw(); operator const ::GtkWidget* () const throw(); void Clear () throw(); void SetLinkQuality (unsigned short) throw(); void SetSignalLevel (short) throw(); void SetNoiseLevel (short) throw(); void SetStatus (std::string SSID, const std::string& Addr) throw(); void SetMode (const std::string&) throw(); void SetChannel (unsigned, double) throw(); void SetTxRate (unsigned) throw(); void SetAddr (const std::string&) throw(); protected : void SetBar (::GtkProgressBar*, double Pos, int Value, const char* Suffix, int UnknownValue) throw(); /** \return A number between 0.0 and 1.0, inclusive. */ double dBmToPercent (short) throw(); static const char* const DisconnectLabel; private : CLinkStatusTab& operator = (const CLinkStatusTab&); CLinkStatusTab (const CLinkStatusTab&); ::GtkWidget* const m_pAlignment; ::GtkProgressBar* const m_pLinkQualityBar; ::GtkProgressBar* const m_pSignalLevelBar; ::GtkProgressBar* const m_pNoiseLevelBar; ::GtkLabel* const m_pStatusLabel; ::GtkLabel* const m_pModeLabel; ::GtkLabel* const m_pChannelLabel; ::GtkLabel* const m_pTxRateLabel; ::GtkLabel* const m_pAddrLabel; }; // CLinkStatusTab } // namespace nsGUI #include "private/CLinkStatusTab.hxx" #endif // __CLINKSTATUSTAB_H__ RutilTv0.18/include/CWE17Module.h0000644000175000017500000000700410722350737016071 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CWE17Module.h \author Romain BONDUE \date 21/08/2005 */ #ifndef __CWE17MODULE_H__ #define __CWE17MODULE_H__ #include #include #include // std::auto_ptr<> #include "Module.h" #include "UserData.h" #include "ProfileEditor.h" #include "WE17Driver.h" namespace nsCore { class CWE17CLIModule : public ICLIModule { public : CWE17CLIModule (const std::string&, const std::string&) throw (nsErrors::CException, std::bad_alloc); ~CWE17CLIModule () throw(); const nsUserData::CProfile& GetProfile (unsigned) const throw(); void ApplyProfile (unsigned) throw (nsErrors::CSystemExc); unsigned GetNbProfile () const throw(); nsWireless::IDriver& GetDriver () throw(); const nsWireless::IDriver& GetDriver () const throw(); private : CWE17CLIModule (const CWE17CLIModule&); CWE17CLIModule& operator = (const CWE17CLIModule&); nsWireless::CWE17Driver m_Driver; nsUserData::CProfilesFile m_ProfilesFile; }; // CWE17CLIModule class CWE17Module : public IModule { public : CWE17Module (const std::string&, const std::string&) throw (nsErrors::CException, std::bad_alloc); ~CWE17Module () throw(); nsWireless::IDriver& GetDriver () throw(); const nsWireless::IDriver& GetDriver () const throw(); nsUserData::CProfile* NewProfile (::GtkWindow*) throw(); nsUserData::CProfile* NewProfile (::GtkWindow*, const nsWireless::CCell&) throw(); bool EditProfile (::GtkWindow*, unsigned) throw(); void DeleteProfile (unsigned) throw(); void ApplyProfile (unsigned) throw (nsErrors::CSystemExc); void ApplyProfile (unsigned, const nsWireless::CMacAddress&) throw (nsErrors::CSystemExc); /** \warning No bound check! */ nsUserData::CProfile& GetProfile (unsigned) throw(); unsigned GetNbProfile () const throw(); void RecordProfiles () throw (nsErrors::CException); ::GtkWidget* GetPrivateTab () throw(); void BecomeRoot () throw (nsErrors::CException, std::bad_alloc); protected : nsUserData::CProfile* EditNewProfile (::GtkWindow*) throw(); static const char* const NewProfileDefaultName; private : CWE17Module (const CWE17Module&); CWE17Module& operator = (const CWE17Module&); std::auto_ptr m_pDriver; nsCore::CProfileEditor m_Editor; nsUserData::CProfilesFile m_ProfilesFile; }; // CWE17Module } // namespace nsCore #include "private/CWE17Module.hxx" #endif // __CWE17MODULE_H__ RutilTv0.18/include/Msg.h0000644000175000017500000000336410601026050014650 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file 04/01/2006 \author Romain BONDUE \date Msg.h */ #ifndef __MSG_H__ #define __MSG_H__ #include namespace nsRoot { // FIXME Improve this class (mainly data storage). class CMsg { public : CMsg (const std::string& Text = "", int Code = 0) throw(); int GetCode () const throw(); const std::string& GetText () const throw(); void SetCode (int) throw(); void SetText (const std::string&) throw(); private : std::string m_Text; int m_Code; }; // CMsg const int CheckRootPassword = -1; // MUST be negative. const int CreateRemoteHandlerCmd = -2; // MUST be negative. const int ChangeRemoteHandlerCmd = -3; // MUST be negative. const int DeleteRemoteHandlerCmd = -4; // MUST be negative. const int IsAliveCmd = -5; const std::string ServerAddr ("RutilT - Helper IPC Socket "); } // namespace nsRoot #include "private/Msg.hxx" #endif // __MSG_H__ RutilTv0.18/include/ErrorsCode.h0000644000175000017500000000560010712363523016200 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file ErrorsCode.h \author Romain BONDUE \date 05/07/2005 */ #ifndef __ERRORSCODE_H__ #define __ERRORSCODE_H__ namespace nsErrors { enum ErrorsCode_t {InvalidArguments = -1, ProcParsing = -2, NoDeviceFound = -3, OutOfMemory = -4, GtkInitFailure = -5, ProfilesRecordFailure = -6, ProfilesExtractionFailure = -7, ProfilesExtractionMissingName = -8, ProfilesExtractionMissingSSID = -9, ProfilesExtractionMissingMode = -10, ProfilesExtractionMissingChannel = -11, ProfilesExtractionInvalidMode = -12, ProfilesExtractionInvalidChannel = -13, ProfilesExtractionInvalidKey = -14, ProfilesExtractionExtraToken = -15, HelperAuthenticationFailed = -16, ProfileNotFound = -17, ScanningTimeOut = -18, RTAdvancedSetIoctlNotFound = -19, InvalidCommand = -20, UnknownHandler = -21, InvalidData = -22, UnknownExc = -23, NoDriverSet = -24, NoHandlerDefined = -25, InvalidRootPassword = -26, InvalidDataFromHelper = -27, UnexpectedStreamEnd = -28, // FIXME Error -29 available StatsParsing = -30, RT2570EncIoctlNotFound = -31, RT2570AuthIoctlNotFound = -32, RT2570KeyIoctlNotFound = -33, InvalidInstanceNum = -34, CodeNotTransmitted = -35, OptionsExtractionInvalidValue = -36, OptionsRecordFailure = -37, SaltBufferOverflow = - 38, HelperNotRoot = -39, RutilTAuthenticationFailed = -40, DataParsingError1 = -41, DataParsingError2 = -42, DataParsingError3 = -43, CannotSendRootPasswd = -44, CannotExecuteHelper = -45}; } // namespace nsErrors #endif // __ERRORSCODE_H__ RutilTv0.18/include/CProfileTab.h0000644000175000017500000000507210462717161016271 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CProfileTab.h \author Romain BONDUE \date 05/08/2005 */ #ifndef __CPROFILETAB_H__ #define __CPROFILETAB_H__ #include "CSelectableRowList.h" namespace nsUserData{class CProfile;} namespace nsWireless {class CCell;} namespace nsGUI { class CProfileTab : protected CSelectableRowList { public : CProfileTab (CGtkGUI*) throw(); operator ::GtkWidget* () throw(); void AddProfile (const nsUserData::CProfile&) throw(); int GetSelectedRow () const throw(); void SetSelected (unsigned, bool) throw(); using CSelectableRowList::Clear; protected : enum {ButtonPos, NamePos, SSIDPos, ModePos, ChannelPos, EncryptPos, AuthPos}; void SetProfile (unsigned, const nsUserData::CProfile&) throw(); void RowSelectedCallBack () throw(); void RowUnselectedCallBack () throw(); /** \return true if the profile has been modified. */ bool Edit (nsUserData::CProfile&) const throw(); private : ::GtkBox* const m_pHBox; ::GtkWidget* const m_pDeleteButton; ::GtkWidget* const m_pEditButton; ::GtkWidget* const m_pApplyButton; static const unsigned NbColumn = 7; static const char* ColumnTitle [NbColumn]; static const ::GType TabType [NbColumn]; static void DeleteButtonCallBack (::GtkButton*, CProfileTab*) throw(); static void EditButtonCallBack (::GtkButton*, CProfileTab*) throw(); static void ApplyButtonCallBack (::GtkButton*, CProfileTab*) throw(); static void NewProfileButtonCallBack (::GtkButton*, CProfileTab*) throw(); }; // CProfileTab } // namespace nsGUI #include "private/CProfileTab.hxx" #endif // __CPROFILETAB_H__ RutilTv0.18/include/SystemTools.h0000644000175000017500000000464210637260644016451 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file SystemTools.h \author Romain BONDUE \date 20/12/2005 */ #ifndef __SYSTEMTOOLS_H__ #define __SYSTEMTOOLS_H__ #include extern"C"{ #include } #include "Exceptions.h" namespace nsSystem { void Ioctl (int, void*, const std::string&) throw (nsErrors::CSystemExc); /** \return True in the child process. */ bool Fork () throw (nsErrors::CSystemExc); /** \warning The array is not checked, it must respect execv() conventions. */ void Exec (const char* []) throw (nsErrors::CSystemExc); class CLocalSocket { public : CLocalSocket () throw (nsErrors::CSystemExc); ~CLocalSocket () throw (nsErrors::CSystemExc); void Close () throw (nsErrors::CSystemExc); void Connect (const std::string&) throw (nsErrors::CSystemExc); void Bind (const std::string&) throw (nsErrors::CSystemExc); void Listen (unsigned = 0) throw (nsErrors::CSystemExc); // The socket returned must be deleted by the callder. CLocalSocket* Accept () throw (nsErrors::CSystemExc, std::bad_alloc); void Write (const char*, size_t) throw (nsErrors::CSystemExc); size_t Read (char*, size_t) throw (nsErrors::CSystemExc); void SendCredential () throw (nsErrors::CSystemExc); bool CheckCredentialUID (::uid_t) throw (nsErrors::CSystemExc); bool CheckCredentialPID (::pid_t) throw (nsErrors::CSystemExc); private : static const int InvalidSocket = -1; CLocalSocket (int) throw(); int m_Sd; }; // CLocalSocket } // namespace nsSystem #include "private/SystemTools.hxx" #endif // __SYSTEMTOOLS_H__ RutilTv0.18/include/UserData.h0000644000175000017500000001041710722350737015647 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file UserData.h \author Romain BONDUE \date 03/08/2005 */ #ifndef __USERDATA_H__ #define __USERDATA_H__ #include #include #include #include #include "XMLParser.h" #include "Parameters.h" #include "Exceptions.h" namespace nsUserData { extern const std::string AppDirectory; void MakeAppDirectory () throw (nsErrors::CSystemExc); // Could have been more beautiful... enum IPSetting_e {None, Dhcp, Static}; class CIPSettings { public : CIPSettings (IPSetting_e = None) throw(); IPSetting_e GetSetting () const throw(); void SetSetting (IPSetting_e) throw(); private : IPSetting_e m_Setting; }; // CIPSettings class CProfile { public : CProfile (const std::string& = std::string()) throw(); CProfile (const std::string&, const nsWireless::CCell&) throw (std::bad_alloc); ~CProfile () throw(); const std::string& GetName () const throw(); const std::string& GetSSID () const throw(); nsWireless::Mode_e GetMode () const throw(); unsigned GetChannel () const throw(); const nsWireless::CEncryptionD& GetEncryptionD () const throw(); nsWireless::CEncryptionD& GetEncryptionD () throw(); CIPSettings& GetIPSettings () throw(); const CIPSettings& GetIPSettings () const throw(); void SetName (const std::string&) throw(); void SetSSID (const std::string&) throw(); void SetMode (nsWireless::Mode_e) throw(); void SetChannel (unsigned) throw(); void SetEncryptionD (const nsWireless::CEncryptionD&); bool Match (const nsWireless::CCell&) const throw(); private : std::string m_Name; std::string m_SSID; nsWireless::Mode_e m_Mode; unsigned m_Channel; nsWireless::CEncryptionD m_EncryptionD; CIPSettings m_IPSettings; }; // CProfile class CProfilesFile : private CXMLParser { public : CProfilesFile () throw (nsErrors::CSystemExc); ~CProfilesFile () throw(); void Extract () throw (nsErrors::CException); void Record () throw (nsErrors::CException); void NewProfile (const char*) throw(); void NewProfile (const char*, const nsWireless::CCell&) throw(); void DeleteLastProfile () throw(); /** \warning No bound check! */ void DeleteProfile (unsigned Pos) throw(); /** \warning No bound check! */ CProfile& GetProfile (unsigned) throw(); const CProfile& GetProfile (unsigned) const throw(); unsigned Size () const throw(); private : // For extracting : void StartElement (const char*, const char**, const char**) throw (std::bad_alloc, nsErrors::CException); void EndElement (const char*) throw (nsErrors::CException); void Text (const char*, const std::string&) throw (nsErrors::CException); void Error () throw(); // For recording : const char* GetRootMarkupLabel () const throw(); void RecordFields (std::ostream&, unsigned) throw (std::ios_base::failure); static const char* const Indentation; std::vector m_Profiles; }; // CProfilesFile } // namespace nsUserData #include "private/UserData.hxx" #endif // __USERDATA_H__ RutilTv0.18/include/XMLParser.h0000644000175000017500000000531610464416054015754 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file XMLParser.h \author Romain BONDUE \date 03/08/2006 */ #ifndef __XMLPARSER_H__ #define __XMLPARSER_H__ #include extern "C"{ #include } #include "Exceptions.h" namespace nsUserData { extern const char* const XMLHeader; const char Markup1B = '<'; // B for Begin. const char Markup1E = '>'; // E for End; extern const char* const Markup2B; extern const char* const Markup2E; class CXMLParser { public : virtual ~CXMLParser () throw(); /* If the file doesn't exist, it's not considered as an error. Nothing is done. */ void Extract (const std::string&) throw (nsErrors::CException); protected : virtual void StartElement (const char*, const char**, const char**) throw (std::bad_alloc, nsErrors::CException); virtual void EndElement (const char*) throw (nsErrors::CException); virtual void Text (const char*, const std::string&) throw (nsErrors::CException); virtual void Error () throw(); private : static void _StartElement (::GMarkupParseContext*, const char*, const char**, const char**, CXMLParser*, ::GError**) throw(); static void _EndElement (::GMarkupParseContext*, const char*, CXMLParser*, ::GError**) throw(); static void _Text (::GMarkupParseContext*, const char*, ::gsize, CXMLParser*, ::GError**) throw(); /*static void Ignored (::GMarkupParseContext*, const char*, unsigned, CXMLParser*, ::GError**) throw();*/ static void _Error (::GMarkupParseContext*, ::GError*, CXMLParser*) throw(); }; // CXMLParser } // namespace nsUserData #include "private/XMLParser.hxx" #endif // __XMLPARSER_H__ RutilTv0.18/include/private/0000755000175000017500000000000011054676047015441 5ustar romainromainRutilTv0.18/include/private/Su.hxx0000644000175000017500000000240610636002145016546 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Su.hxx \author Romain BONDUE \date 29/11/2005 \warning This file should only be included from Su.h */ inline nsRoot::CSu::CSu (const std::string& RemoteHandlerTypeName) throw (nsErrors::CSystemExc) : m_InstanceNumber (InstanceCounter) { CreateRemoteHandler (RemoteHandlerTypeName); ++InstanceCounter; } // CSu() inline void nsRoot::CSu::Close () throw (nsErrors::CSystemExc) { delete pSock; pSock = 0; } // Close() RutilTv0.18/include/private/CWE17Module.hxx0000644000175000017500000000677710722350737020143 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CWE17Module.hxx \author Romain BONDUE \date 21/08/2005 \warning This file should only be included from CWE17Module.h */ inline nsCore::CWE17CLIModule::~CWE17CLIModule () throw() {} inline nsCore::CWE17CLIModule::CWE17CLIModule (const std::string& DeviceName, const std::string& Path) throw (nsErrors::CException, std::bad_alloc) : m_Driver (DeviceName) { m_ProfilesFile.Extract(); } // CWE17CLIModule() inline const nsUserData::CProfile& nsCore::CWE17CLIModule::GetProfile (unsigned Pos) const throw() { return m_ProfilesFile.GetProfile (Pos); } // GetProfile() inline unsigned nsCore::CWE17CLIModule::GetNbProfile () const throw() { return m_ProfilesFile.Size(); } // GetNbProfile() inline nsWireless::IDriver& nsCore::CWE17CLIModule::GetDriver () throw() { return m_Driver; } // GetDriver() inline const nsWireless::IDriver& nsCore::CWE17CLIModule::GetDriver () const throw() { return m_Driver; } // GetDriver() inline nsWireless::IDriver& nsCore::CWE17Module::GetDriver () throw() { return *m_pDriver; } // GetDriver() inline const nsWireless::IDriver& nsCore::CWE17Module::GetDriver () const throw() { return *m_pDriver; } // GetDriver() inline void nsCore::CWE17Module::DeleteProfile (unsigned Pos) throw() { m_ProfilesFile.DeleteProfile (Pos); } // DeleteProfile() inline nsUserData::CProfile& nsCore::CWE17Module::GetProfile (unsigned Pos) throw() { return m_ProfilesFile.GetProfile (Pos); } // GetProfile() inline unsigned nsCore::CWE17Module::GetNbProfile () const throw() { return m_ProfilesFile.Size(); } // GetNbProfile() inline ::GtkWidget* nsCore::CWE17Module::GetPrivateTab () throw() {return 0;} inline nsUserData::CProfile* nsCore::CWE17Module::NewProfile (::GtkWindow* pMainWindow) throw() { m_ProfilesFile.NewProfile (NewProfileDefaultName); return EditNewProfile (pMainWindow); } // NewProfile() inline nsUserData::CProfile* nsCore::CWE17Module::NewProfile (::GtkWindow* pMainWindow, const nsWireless::CCell& Cell) throw() { m_ProfilesFile.NewProfile (NewProfileDefaultName, Cell); return EditNewProfile (pMainWindow); } // NewProfile() inline bool nsCore::CWE17Module::EditProfile (::GtkWindow* pMainWindow, unsigned Pos) throw() { return m_Editor.Edit (pMainWindow, m_ProfilesFile.GetProfile (Pos)); } // EditProfile() RutilTv0.18/include/private/WWidgets.hxx0000644000175000017500000003754010705153462017731 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file WWidgets.hxx \author Romain BONDUE \date 31/03/2006 \warning This file should only be included from WWidgets.h */ #include template std::string nsGUI::CConvert::operator () (const T& Object) throw() { std::ostringstream Os; Os << Object; return Os.str(); } // ToStr() inline std::string nsGUI::CModeConvert::operator () (const nsWireless::Mode_e& Mode) throw() { return nsWireless::GetModeName (Mode); } // operator ()() inline std::string nsGUI::CAuthConvert::operator () (const nsWireless::AuthType_e& Auth) throw() { return nsWireless::GetAuthName (Auth); } // operator ()() inline std::string nsGUI::CEncryptConvert::operator () (const nsWireless::EncryptType_e& Encrypt) throw() { return nsWireless::GetEncryptName (Encrypt); } // operator ()() template inline nsGUI::CComboBox::CComboBox () throw() : m_pBox (GTK_COMBO_BOX (::gtk_combo_box_new_text())), m_TabSize (0), m_Tab (0) {} template inline nsGUI::CComboBox::CComboBox (const T* Tab, unsigned TabSize) throw() : m_pBox (GTK_COMBO_BOX (::gtk_combo_box_new_text())), m_TabSize (0), m_Tab (0) { SetElem (Tab, TabSize); } // CComboBox() template void nsGUI::CComboBox::SetElem (const T* Tab, unsigned TabSize) throw() { while (m_TabSize) ::gtk_combo_box_remove_text (m_pBox, --m_TabSize); C Convertor; for (unsigned I (0) ; I < TabSize ; ++I) ::gtk_combo_box_append_text (m_pBox, Convertor (Tab [I]).c_str()); m_Tab = Tab; m_TabSize = TabSize; } // SetElem() template void nsGUI::CComboBox::SetActive (const T& Item) throw() { for (unsigned I (0) ; I < m_TabSize ; ++I) if (Item == m_Tab [I]) { ::gtk_combo_box_set_active (m_pBox, I); return; } ::gtk_combo_box_set_active (m_pBox, 0); } // SetActive() template inline const T& nsGUI::CComboBox::GetActive () const throw() { return m_Tab [::gtk_combo_box_get_active (m_pBox)]; } // GetActive() template inline unsigned nsGUI::CComboBox::GetActiveRow () const throw() { return ::gtk_combo_box_get_active (m_pBox); } // GetActive() template inline nsGUI::CComboBox::operator ::GtkWidget* () throw() { return GTK_WIDGET (m_pBox); } // operator ::GtkWidget*() template inline nsGUI::CComboBox::operator const ::GtkWidget* () const throw() { return GTK_WIDGET (m_pBox); } // operator const ::GtkWidget*() inline void nsGUI::CKeyEntry::ASCIIOnly (bool State) throw() { ::gtk_toggle_button_set_active (m_pIsASCIIButton, State); ::gtk_widget_set_sensitive (GTK_WIDGET (m_pIsASCIIButton), !State); } // ASCIIOnly() inline bool nsGUI::CKeyEntry::ASCIIOnly () const throw() { return ::gtk_toggle_button_get_active (m_pIsASCIIButton); } // ASCIIOnly() inline nsGUI::CKeyEntry::operator ::GtkWidget* () throw() { return GTK_WIDGET (m_pBox); } // operator ::GtkWidget*() inline nsGUI::CKeyEntry::operator const ::GtkWidget* () const throw() { return GTK_WIDGET (m_pBox); } // operator const ::GtkWidget*() inline void nsGUI::CKeyEntry::Clear () throw() { ::gtk_entry_set_text (m_pEntry, ""); } // Clear() inline nsGUI::CKeyEntry::operator ::GtkEntry* () throw() { return GTK_ENTRY (m_pEntry); } // operator ::GtkEntry*() inline nsGUI::CKeyEntry::operator const ::GtkEntry* () const throw() { return GTK_ENTRY (m_pEntry); } // operator const ::GtkEntry*() template inline nsGUI::CMultiKey::CMultiKey () throw() : m_pBox (GTK_VBOX (::gtk_vbox_new (false, 2))), m_pKeysExpander (GTK_EXPANDER (::gtk_expander_new ("More key"))), m_pDefaultKeyBox (GTK_COMBO_BOX (::gtk_combo_box_new_text())) { BuildUI(); } // CMultiKey() template inline nsGUI::CMultiKey::operator ::GtkWidget* () throw() { return GTK_WIDGET (m_pBox); } // operator ::GtkWidget*() template inline nsGUI::CMultiKey::operator const ::GtkWidget* () const throw() { return GTK_WIDGET (m_pBox); } // operator const ::GtkWidget*() template inline nsWireless::CHexaKey nsGUI::CMultiKey::Get (unsigned Pos) const throw() { return m_KeyEntryTab [Pos].Get(); } // Get() template inline void nsGUI::CMultiKey::Set (const nsWireless::CHexaKey& Key, unsigned Pos) throw() { m_KeyEntryTab [Pos].Set (Key); } // Set() template inline void nsGUI::CMultiKey::AdditionnalKeyAvailable (bool State) throw() { ::gtk_widget_set_sensitive (GTK_WIDGET (m_pKeysExpander), State); if (!State) ::gtk_combo_box_set_active (m_pDefaultKeyBox, 0); } // AdditionnalKeyAvailable() template inline unsigned nsGUI::CMultiKey::GetNbKey () const throw() {return N;} template void nsGUI::CMultiKey::BuildUI () throw() { ::GtkBox* pHBox (GTK_BOX (::gtk_hbox_new (false, 2))); ::gtk_box_pack_start_defaults (pHBox, ::gtk_label_new ("Key")); ::gtk_box_pack_start_defaults (pHBox, m_KeyEntryTab [0]); ::gtk_box_pack_start_defaults (GTK_BOX (m_pBox), GTK_WIDGET (pHBox)); if (N > 1) { ::GtkWidget* const pVBox (::gtk_vbox_new (true, 2)); for (unsigned I (1) ; I < N ; ++I) ::gtk_box_pack_start_defaults (GTK_BOX (pVBox), m_KeyEntryTab [I]); for (unsigned I (1) ; I < N + 1 ; ++I) { std::ostringstream Os; Os << I; ::gtk_combo_box_append_text (m_pDefaultKeyBox, Os.str().c_str()); } pHBox = GTK_BOX (::gtk_hbox_new (false, 2)); ::gtk_box_pack_start_defaults (pHBox, ::gtk_label_new ("Default key")); ::gtk_box_pack_start_defaults (pHBox, GTK_WIDGET (m_pDefaultKeyBox)); ::gtk_box_pack_start_defaults (GTK_BOX (pVBox), GTK_WIDGET (pHBox)); ::gtk_container_add (GTK_CONTAINER (m_pKeysExpander), pVBox); ::gtk_box_pack_start_defaults (GTK_BOX (m_pBox), GTK_WIDGET (m_pKeysExpander)); } else ::gtk_combo_box_append_text (m_pDefaultKeyBox, "1"); ::gtk_combo_box_set_active (m_pDefaultKeyBox, 0); } // BuildUI() template void nsGUI::CMultiKey::Clear () throw() { for (unsigned I (0) ; I < N ; ++I) m_KeyEntryTab [I].Clear(); } // Clear() template inline nsGUI::CKeyEntry& nsGUI::CMultiKey::GetKeyEntry (unsigned Pos) throw() { return m_KeyEntryTab [Pos]; } // GetKeyEntry() template inline const nsGUI::CKeyEntry& nsGUI::CMultiKey::GetKeyEntry (unsigned Pos) const throw() { return m_KeyEntryTab [Pos]; } // GetKeyEntry() template inline unsigned nsGUI::CMultiKey::GetDefaultKey () const throw() { return ::gtk_combo_box_get_active (m_pDefaultKeyBox); } // GetDefaultKey() template inline void nsGUI::CMultiKey::SetDefaultKey (unsigned DefaultKey) throw() { ::gtk_combo_box_set_active (m_pDefaultKeyBox, DefaultKey); } // SetDefaultKey() inline bool nsGUI::CConfigDialog::Run (::GtkWindow* pMainWindow) throw() { if (pMainWindow) ::gtk_window_set_transient_for (GTK_WINDOW (m_pDialog), pMainWindow); ::gtk_widget_show_all (m_pDialog->vbox); return ::gtk_dialog_run (m_pDialog) == GTK_RESPONSE_OK; } // Run() inline void nsGUI::CConfigDialog::Hide () throw() { ::gtk_widget_hide (GTK_WIDGET (m_pDialog)); } // Hide() inline std::string nsGUI::CConfigDialog::GetConfigName () const throw() { return ::gtk_entry_get_text (m_pNameEntry); } // GetConfigName() inline std::string nsGUI::CConfigDialog::GetSSID () const throw() { return ::gtk_entry_get_text (m_pSSIDEntry); } // GetSSID() inline nsWireless::Mode_e nsGUI::CConfigDialog::GetMode () const throw() { return m_ModeBox.GetActive(); } // GetMode() inline unsigned nsGUI::CConfigDialog::GetChannel () const throw() { return m_ChannelBox.GetActive(); } // GetChannel() inline nsWireless::EncryptType_e nsGUI::CConfigDialog::GetEncrypt () const throw() { return m_EncryptBox.GetActive(); } // GetEncrypt() inline nsWireless::AuthType_e nsGUI::CConfigDialog::GetAuth () const throw() { return m_AuthBox.GetActive(); } // GetAuth() inline unsigned nsGUI::CConfigDialog::GetNbKey () const throw() { return nsWireless::CEncryptionD::MaxNbKey; } // GetNbKey() inline nsWireless::CHexaKey nsGUI::CConfigDialog::GetKey (unsigned Pos) const throw() { return m_MultiKey.Get (Pos); } // GetKey() inline nsGUI::CConfigDialog::operator ::GtkDialog* () throw() { return m_pDialog; } // operator ::GtkDialog*() inline nsGUI::CConfigDialog::operator const ::GtkDialog* () const throw() { return m_pDialog; } // operator const ::GtkDialog*() inline nsGUI::CModeComboBox& nsGUI::CConfigDialog::GetModeBox () throw() { return m_ModeBox; } // GetModeBox() inline const nsGUI::CModeComboBox& nsGUI::CConfigDialog::GetModeBox () const throw() { return m_ModeBox; } // GetModeBox() inline const nsGUI::CChannelComboBox& nsGUI::CConfigDialog::GetChannelBox () const throw() { return m_ChannelBox; } // GetChannelBox() inline nsGUI::CEncryptComboBox& nsGUI::CConfigDialog::GetEncryptBox () throw() { return m_EncryptBox; } // GetEncryptBox() inline const nsGUI::CEncryptComboBox& nsGUI::CConfigDialog::GetEncryptBox () const throw() { return m_EncryptBox; } // GetEncryptBox() inline nsGUI::CAuthComboBox& nsGUI::CConfigDialog::GetAuthBox () throw() { return m_AuthBox; } // GetAuthBox() inline const nsGUI::CAuthComboBox& nsGUI::CConfigDialog::GetAuthBox () const throw() { return m_AuthBox; } // GetAuthBox() inline ::GtkEntry* nsGUI::CConfigDialog::GetNameEntry () throw() { return m_pNameEntry; } // GetNameEntry() inline const ::GtkEntry* nsGUI::CConfigDialog::GetNameEntry () const throw() { return m_pNameEntry; } // GetNameEntry() inline ::GtkEntry* nsGUI::CConfigDialog::GetSSIDEntry () throw() { return m_pSSIDEntry; } // GetSSIDEntry() inline const ::GtkEntry* nsGUI::CConfigDialog::GetSSIDEntry () const throw() { return m_pSSIDEntry; } // GetSSIDEntry() inline ::GtkBox* nsGUI::CConfigDialog::GetBox () throw() { return GTK_BOX (m_pDialog->vbox); } // GetBox() inline const ::GtkBox* nsGUI::CConfigDialog::GetBox () const throw() { return GTK_BOX (m_pDialog->vbox); } // GetBox() inline nsGUI::CMultiKey<4>& nsGUI::CConfigDialog::GetMultiKey () throw() { return m_MultiKey; } // GetMultiKey() inline const nsGUI::CMultiKey<4>& nsGUI::CConfigDialog::GetMultiKey () const throw() { return m_MultiKey; } // GetMultiKey() inline void nsGUI::CConfigDialog::SetConfigName (const std::string& Name) throw() { ::gtk_entry_set_text (m_pNameEntry, Name.c_str()); ::gtk_window_set_title (GTK_WINDOW (m_pDialog), Name.c_str()); } // SetConfigName() inline void nsGUI::CConfigDialog::SetSSID (const std::string& SSID) throw() { ::gtk_entry_set_text (m_pSSIDEntry, SSID.c_str()); } // SetConfigName() inline void nsGUI::CConfigDialog::SetMode (nsWireless::Mode_e Mode) throw() { m_ModeBox.SetActive (Mode); } // SetMode() inline void nsGUI::CConfigDialog::SetChannel (unsigned Channel) throw() { m_ChannelBox.SetActive (Channel); } // SetChannel() inline void nsGUI::CConfigDialog::SetEncrypt (nsWireless::EncryptType_e Enc) throw() { m_EncryptBox.SetActive (Enc); } // SetEncrypt() inline void nsGUI::CConfigDialog::SetAuth (nsWireless::AuthType_e Auth) throw() { m_AuthBox.SetActive (Auth); } // SetAuth() inline void nsGUI::CConfigDialog::SetKey (const nsWireless::CHexaKey& Key, unsigned Pos) throw() { m_MultiKey.Set (Key, Pos); } // SetKey() inline ::GtkRadioButton* nsGUI::CConfigDialog::GetIPNoneButton () throw() { return m_pIPNoneButton; } // GetIPNoneButton() inline const ::GtkRadioButton* nsGUI::CConfigDialog::GetIPNoneButton () const throw() { return m_pIPNoneButton; } // GetIPNoneButton() inline ::GtkRadioButton* nsGUI::CConfigDialog::GetIPDhcpButton () throw() { return m_pIPDhcpButton; } // GetIPDhcpButton() inline const ::GtkRadioButton* nsGUI::CConfigDialog::GetIPDhcpButton () const throw() { return m_pIPDhcpButton; } // GetIPDhcpButton() inline ::GtkRadioButton* nsGUI::CConfigDialog::GetIPStaticButton () throw() { return m_pIPStaticButton; } // GetIPStaticButton() inline const ::GtkRadioButton* nsGUI::CConfigDialog::GetIPStaticButton () const throw() { return m_pIPStaticButton; } // GetIPStaticButton() inline nsUserData::IPSetting_e nsGUI::CConfigDialog::GetIPSetting () const throw() { return (::gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GetIPDhcpButton())) ? nsUserData::Dhcp : nsUserData::None); } // GetIPSetting() inline void nsGUI::CConfigDialog::SetIPSetting (nsUserData::IPSetting_e Setting) throw() { if (Setting == nsUserData::None) ::gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_pIPNoneButton), true); else ::gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_pIPDhcpButton), true); } // SetIPSetting() inline unsigned nsGUI::CConfigDialog::GetDefaultKey () const throw() { return m_MultiKey.GetDefaultKey(); } // GetDefaultKey() inline void nsGUI::CConfigDialog::SetDefaultKey (unsigned DefaultKey) throw() { m_MultiKey.SetDefaultKey (DefaultKey); } // SetDefaultKey() inline void nsGUI::CSharedConfigDialog::ClearKeyEntry () throw() { GetMultiKey().Clear(); } // ClearKeyEntry() inline void nsGUI::CSharedConfigDialog::SetEncryptBox (const nsWireless::EncryptType_e* TabEncrypt, unsigned TabEncryptSize) throw() { GetEncryptBox().SetElem (TabEncrypt, TabEncryptSize); GetEncryptBox().SetActive (TabEncrypt [0]); } // SetEncryptBox() RutilTv0.18/include/private/ProfileEditor.hxx0000644000175000017500000000264210543033310020723 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file ProfileEditor.hxx \author Romain BONDUE \date 18/04/2006 \warning This file should only be included from ProfileEditor.h */ inline nsCore::CProfileEditor::CProfileEditor (nsGUI::CConfigDialog* pDialog) throw() : m_pDialog (pDialog) {} inline nsGUI::CConfigDialog* nsCore::CProfileEditor::GetDialog () throw() { return m_pDialog.get(); } // GetDialog() inline const nsGUI::CConfigDialog* nsCore::CProfileEditor::GetDialog () const throw() { return m_pDialog.get(); } // GetDialog() RutilTv0.18/include/private/Msg.hxx0000644000175000017500000000252310360151760016707 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Msg.hxx \author Romain BONDUE \date 04/01/2006 \warning This file should only be included from Msg.h */ inline nsRoot::CMsg::CMsg (const std::string& Text, int Code) throw() : m_Text (Text), m_Code (Code) {} inline int nsRoot::CMsg::GetCode () const throw() {return m_Code;} inline const std::string& nsRoot::CMsg::GetText () const throw() { return m_Text; } // GetText() inline void nsRoot::CMsg::SetCode (int Code) throw() {m_Code = Code;} inline void nsRoot::CMsg::SetText (const std::string& Text) throw() { m_Text = Text; } // SetText() RutilTv0.18/include/private/CLIOpt.hxx0000644000175000017500000000342710543033310017250 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CLIOpt.hxx \author Romain BONDUE \date 29/10/2006 \warning This file should only be included from CLIOpt.h */ inline bool nsCore::CCLIOpt::Help () const throw() {return m_Flags & HelpFlag;} inline bool nsCore::CCLIOpt::Version () const throw() { return m_Flags & VersionFlag; } // Version() inline bool nsCore::CCLIOpt::Hidden () const throw() { return m_Flags & HiddenFlag; } // Hidden() inline bool nsCore::CCLIOpt::Exit () const throw() {return m_Flags & ExitFlag;} inline bool nsCore::CCLIOpt::Dhcp () const throw() {return m_Flags & DhcpFlag;} inline const std::string& nsCore::CCLIOpt::ProfileName () const throw() { return m_ProfileName; } // ProfileName() inline const std::string& nsCore::CCLIOpt::IfaceName () const throw() { return m_IfaceName; } // IfaceName() inline bool nsCore::CCLIOpt::Profile () const throw() { return m_Flags & ProfileFlag; } // Profile() inline bool nsCore::CCLIOpt::Iface () const throw() { return !m_IfaceName.empty(); } // Iface() RutilTv0.18/include/private/RTDrivers.hxx0000644000175000017500000002223211037203750020043 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTDrivers.hxx \author Romain BONDUE \date 30/08/2005 \warning This file should only be included from RTDrivers.h */ #include // memcpy() inline nsWireless::CRTDriver::CRTDriver (const std::string& DeviceName) throw (nsErrors::CSystemExc) : CWE17Driver (DeviceName) {} inline void nsWireless::CRT2400Driver::GetScanResult (std::vector& CellVec) const throw (nsErrors::CException, std::bad_alloc) { /* Don't call CWE17Driver::GetScanResult() because it's not supported by rt2400. RTLINUX_GET_OID_802_11_BSSID_LIST */ CRTDriver::GetScanResult (m_PrivateIoctl, 8001, CellVec); } // GetScanResult() inline void nsWireless::CRTAdvancedDriver::SetFlag (int Flag, bool B) throw() { if (B) m_Flags |= Flag; else m_Flags &= ~Flag; } // SetFlag() inline bool nsWireless::CRTAdvancedDriver::GetFlag (int Flag) const throw() { return m_Flags & Flag; } // GetFlag() inline int nsWireless::CRTAdvancedDriver::GetRfmontxIoctl () const throw() { return m_RfmontxIoctl; } // GetRfmontxIoctl() inline void nsWireless::CRTAdvancedDriver::SetWirelessMode (WirelessMode_e WMode) throw (nsErrors::CSystemExc) { SetIoctl ("WirelessMode", WMode, "Can't set the wireless mode."); SetFlag (IsB_Only, WMode == B_Only); } // SetWirelessMode() inline void nsWireless::CRTAdvancedDriver::SetTxBurst (bool B) throw (nsErrors::CSystemExc) { SetIoctl ("TxBurst", B ? 1 : 0, "Can't set TxBurst."); SetFlag (TxBurst, B); } // SetTxBurst() inline void nsWireless::CRTAdvancedDriver::SetBGProtection (BGProtection_e Protection) throw (nsErrors::CSystemExc) { SetIoctl ("BGProtection", Protection, "Can't set B/G protection."); m_BGProtection = Protection; } // SetBGProtection() inline void nsWireless::CRTAdvancedDriver::SetTxPreamble (TxPreamble_e Preamble) throw (nsErrors::CSystemExc) { SetIoctl ("TxPreamble", Preamble, "Can't set TxPreamble."); m_TxPreamble = Preamble; } // SetTxPreamble() inline void nsWireless::CRTAdvancedDriver::SetTurboRate (bool B) throw (nsErrors::CSystemExc) { SetIoctl ("TurboRate", B ? 1 : 0, "Can't set turbo rate."); SetFlag (TurboRate, B); } // SetTurboRate() inline void nsWireless::CRTAdvancedDriver::SetAdHocOFDM (bool B) throw (nsErrors::CSystemExc) { SetIoctl ("AdhocOfdm", B ? 1 : 0, "Can't set OFDM mode."); SetFlag (AdHocOFDM, B); } // SetAdHocOFDM() inline void nsWireless::CRTAdvancedDriver::IWPrivHandler::operator () (const ::iw_priv_args&) throw (nsErrors::CException) { } // operator ()() inline nsWireless::CRTAdvancedDriver::IWPrivHandler::~IWPrivHandler () throw() { } // ~IWPrivHandler() inline nsWireless::WirelessMode_e nsWireless::CRTAdvancedDriver::GetWirelessMode () const throw() { return m_Flags & IsB_Only ? B_Only : Mixed; } // GetWirelessMode() inline bool nsWireless::CRTAdvancedDriver::GetTxBurst () const throw() { return m_Flags & TxBurst; } // GetTxBurst() inline nsWireless::BGProtection_e nsWireless::CRTAdvancedDriver::GetBGProtection () const throw() { return m_BGProtection; } // GetBGProtection() inline nsWireless::TxPreamble_e nsWireless::CRTAdvancedDriver::GetTxPreamble () const throw() { return m_TxPreamble; } // GetTxPreamble() inline bool nsWireless::CRTAdvancedDriver::GetTurboRate () const throw() { return m_Flags & TurboRate; } // GetTurboRate() inline bool nsWireless::CRTAdvancedDriver::GetAdHocOFDM () const throw() { return m_Flags & AdHocOFDM; } // GetAdHocOFDM() inline bool nsWireless::CRTAdvancedDriver::GetRfmontx () const throw() { return m_Flags & Rfmontx; } // GetRfmontx() inline int nsWireless::CRTAdvancedDriver::GetTxRate () const throw (nsErrors::CSystemExc) { const int Rate (CWE17Driver::GetTxRate()); return Rate == 5000 ? 5500 : Rate; } // GetTxRate() inline void nsWireless::CRTAdvancedDriver::SetTxRate (int Rate) throw (nsErrors::CSystemExc) { CWE17Driver::SetTxRate (Rate == 5500 ? 5000 : Rate); } // SetTxRate() inline nsWireless::BGProtection_e nsWireless::CRTAdvancedDriver::GetBGProtectionFlag () const throw() { return m_BGProtection; } // GetBGProtectionFlag() inline void nsWireless::CRTAdvancedDriver::SetBGProtectionFlag (BGProtection_e Status) throw() { m_BGProtection = Status; } // SetBGProtectionFlag() inline nsWireless::TxPreamble_e nsWireless::CRTAdvancedDriver::GetTxPreambleFlag () const throw() { return m_TxPreamble; } // GetTxPreambleFlag() inline void nsWireless::CRTAdvancedDriver::SetTxPreambleFlag (TxPreamble_e Status) throw() { m_TxPreamble = Status; } // SetTxPreambleFlag() inline void nsWireless::CRT2500Driver::GetScanResult (std::vector& CellVec) const throw (nsErrors::CException, std::bad_alloc) { // OID_802_11_BSSID_LIST CRTAdvancedDriver::GetScanResult (0x0116U, CellVec); } // GetScanResult() inline nsWireless::CEncryptionD nsWireless::CRT2500Driver::GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) { // OID_802_11_WEP_STATUS and OID_802_11_AUTHENTICATION_MODE return CRTAdvancedDriver::GetEncryption (0x011AU, 0x0117U); } // GetEncryption() inline void nsWireless::CRT2570Driver::PrivateIoctl (int IoctlCode, int Value, const std::string& ErrorMsg) throw (nsErrors::CSystemExc) { std::memcpy (m_Data.name, &Value, sizeof (Value)); Ioctl (IoctlCode, ErrorMsg); } // PrivateIoctl() inline void nsWireless::CRT2570Driver::SetRfmontx (bool B) throw (nsErrors::CSystemExc) { PrivateIoctl (m_RfmontxIoctl, B ? 1 : 0, "Can't set rfmontx."); } // SetRfmontx() inline bool nsWireless::CRT2570Driver::GetRfmontx () const throw() { return m_Flags & RfMontx; } // GetRfmontx() inline void nsWireless::CRT2570Driver::SetPrismHeader (PrismMode_e PrismMode) throw (nsErrors::CSystemExc) { PrivateIoctl (m_PrismHeaderIoctl, int (PrismMode), "Can't force prism header."); } // SetPrismHeader() inline nsWireless::CRT2570Driver::PrismMode_e nsWireless::CRT2570Driver::GetPrismHeader () const throw() { return m_PrismMode; } // GetPrismHeader() inline nsWireless::CRT2570Driver::AdHocMode_e nsWireless::CRT2570Driver::GetAdHocMode () const throw() { return m_AdHocMode; } // GetAdHocMode() inline void nsWireless::CRT2570Driver::SetAdHocMode (AdHocMode_e Mode) throw (nsErrors::CSystemExc) { PrivateIoctl (m_AdHocModeIoctl, int (Mode), "Can't set adhoc mode."); } // SetAdHocMode() inline nsWireless::CEncryptionD nsWireless::CRT61Driver::GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) { // OID_802_11_WEP_STATUS and OID_802_11_AUTHENTICATION_MODE return CRTAdvancedDriver::GetEncryption (0x0510U, 0x0511U); } // GetEncryption() inline void nsWireless::CRT61Driver::Scan () throw (nsErrors::CSystemExc) { UpdateScanTime(); CRTAdvancedDriver::Scan(); } // Scan() inline nsWireless::CRT61Driver::IWPrivHandlerRT61::IWPrivHandlerRT61 (int& GetSiteSurveyIoctl) throw() : m_GetSiteSurveyIoctl (GetSiteSurveyIoctl) {} inline time_t nsWireless::CRT61Driver::GetLastScanTime () const throw() { return m_LastScanTime; } // GetLastScanTime() inline int nsWireless::CRT61Driver::GetSiteSurveyIoctl () const throw() { return m_GetSiteSurveyIoctl; } // GetSiteSurveyIoctl() inline nsWireless::CRT73Driver::CRT73Driver (const std::string& Ifname) throw (nsErrors::CException, std::bad_alloc) : CRT61Driver (Ifname) {} RutilTv0.18/include/private/RTDriversRoot.hxx0000644000175000017500000002540110636002145020707 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTDriversRoot.hxx \author Romain BONDUE \date 19/02/2006 \warning This file should only be included from RTDriversRoot.h */ inline nsWireless::CRT2400DriverRoot::~CRT2400DriverRoot () throw() {} inline void nsWireless::CRT2400DriverRoot::SetSSID (const std::string& SSID) throw (nsErrors::CSystemExc) { CSuWProtocol::SetSSID (SSID); } // SetSSID() inline void nsWireless::CRT2400DriverRoot::SetFrequency (double Frequency) throw (nsErrors::CSystemExc) { CSuWProtocol::SetFrequency (Frequency); } // SetFrequency() inline void nsWireless::CRT2400DriverRoot::SetChannel (unsigned Channel) throw (nsErrors::CSystemExc) { CSuWProtocol::SetChannel (Channel); } // SetChannel() inline nsWireless::CEncryptionD nsWireless::CRT2400DriverRoot::GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) { return CSuWProtocol::GetEncryption(); } // GetEncryption() inline void nsWireless::CRT2400DriverRoot::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { CSuWProtocol::SetEncryption (Descriptor); } // SetEncryption() inline void nsWireless::CRT2400DriverRoot::SetMode (Mode_e Mode) throw (nsErrors::CSystemExc) { CSuWProtocol::SetMode (Mode); } // SetMode() inline void nsWireless::CRT2400DriverRoot::SetTxRate (int TxRate) throw (nsErrors::CSystemExc) { CSuWProtocol::SetTxRate (TxRate); } // SetTxRate() inline void nsWireless::CRT2400DriverRoot::SetAPMacAddr (const CMacAddress& Addr) throw (std::bad_alloc, nsErrors::CSystemExc) { CSuWProtocol::SetAPMacAddr (Addr); } // SetAPMacAddr() inline void nsWireless::CRT2400DriverRoot::Scan () throw (nsErrors::CSystemExc) { CSuWProtocol::Scan(); } // Scan() inline nsWireless::CRT2500DriverRoot::~CRT2500DriverRoot () throw() {} inline void nsWireless::CRT2500DriverRoot::SetSSID (const std::string& SSID) throw (nsErrors::CSystemExc) { CSuWProtocol::SetSSID (SSID); } // SetSSID() inline void nsWireless::CRT2500DriverRoot::SetFrequency (double Frequency) throw (nsErrors::CSystemExc) { CSuWProtocol::SetFrequency (Frequency); } // SetFrequency() inline void nsWireless::CRT2500DriverRoot::SetChannel (unsigned Channel) throw (nsErrors::CSystemExc) { CSuWProtocol::SetChannel (Channel); } // SetChannel() inline nsWireless::CEncryptionD nsWireless::CRT2500DriverRoot::GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) { return CSuWProtocol::GetEncryption(); } // GetEncryption() inline void nsWireless::CRT2500DriverRoot::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { CSuWProtocol::SetEncryption (Descriptor); } // SetEncryption() inline void nsWireless::CRT2500DriverRoot::SetMode (Mode_e Mode) throw (nsErrors::CSystemExc) { CSuWProtocol::SetMode (Mode); } // SetMode() inline void nsWireless::CRT2500DriverRoot::SetTxRate (int TxRate) throw (nsErrors::CSystemExc) { CSuWProtocol::SetTxRate (TxRate); } // SetTxRate() inline void nsWireless::CRT2500DriverRoot::SetAPMacAddr (const CMacAddress& Addr) throw (std::bad_alloc, nsErrors::CSystemExc) { CSuWProtocol::SetAPMacAddr (Addr); } // SetAPMacAddr() inline void nsWireless::CRT2500DriverRoot::Scan () throw (nsErrors::CSystemExc) { CSuWProtocol::Scan(); } // Scan() inline nsWireless::CRT2570DriverRoot::~CRT2570DriverRoot () throw() {} inline void nsWireless::CRT2570DriverRoot::SetSSID (const std::string& SSID) throw (nsErrors::CSystemExc) { CSuWProtocol::SetSSID (SSID); } // SetSSID() inline void nsWireless::CRT2570DriverRoot::SetFrequency (double Frequency) throw (nsErrors::CSystemExc) { CSuWProtocol::SetFrequency (Frequency); } // SetFrequency() inline void nsWireless::CRT2570DriverRoot::SetChannel (unsigned Channel) throw (nsErrors::CSystemExc) { CSuWProtocol::SetChannel (Channel); } // SetChannel() inline nsWireless::CEncryptionD nsWireless::CRT2570DriverRoot::GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) { return CSuWProtocol::GetEncryption(); } // GetEncryption() inline void nsWireless::CRT2570DriverRoot::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { CSuWProtocol::SetEncryption (Descriptor); } // SetEncryption() inline void nsWireless::CRT2570DriverRoot::SetMode (Mode_e Mode) throw (nsErrors::CSystemExc) { CSuWProtocol::SetMode (Mode); } // SetMode() inline void nsWireless::CRT2570DriverRoot::SetTxRate (int TxRate) throw (nsErrors::CSystemExc) { CSuWProtocol::SetTxRate (TxRate); } // SetTxRate() inline void nsWireless::CRT2570DriverRoot::SetAPMacAddr (const CMacAddress& Addr) throw (std::bad_alloc, nsErrors::CSystemExc) { CSuWProtocol::SetAPMacAddr (Addr); } // SetAPMacAddr() inline void nsWireless::CRT2570DriverRoot::Scan () throw (nsErrors::CSystemExc) { CSuWProtocol::Scan(); } // Scan() inline nsWireless::CRT61DriverRoot::~CRT61DriverRoot () throw() {} inline void nsWireless::CRT61DriverRoot::SetSSID (const std::string& SSID) throw (nsErrors::CSystemExc) { CSuWProtocol::SetSSID (SSID); } // SetSSID() inline void nsWireless::CRT61DriverRoot::SetFrequency (double Frequency) throw (nsErrors::CSystemExc) { CSuWProtocol::SetFrequency (Frequency); } // SetFrequency() inline void nsWireless::CRT61DriverRoot::SetChannel (unsigned Channel) throw (nsErrors::CSystemExc) { CSuWProtocol::SetChannel (Channel); } // SetChannel() inline nsWireless::CEncryptionD nsWireless::CRT61DriverRoot::GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) { return CSuWProtocol::GetEncryption(); } // GetEncryption() inline void nsWireless::CRT61DriverRoot::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { CSuWProtocol::SetEncryption (Descriptor); } // SetEncryption() inline void nsWireless::CRT61DriverRoot::SetMode (Mode_e Mode) throw (nsErrors::CSystemExc) { CSuWProtocol::SetMode (Mode); } // SetMode() inline void nsWireless::CRT61DriverRoot::SetTxRate (int TxRate) throw (nsErrors::CSystemExc) { CSuWProtocol::SetTxRate (TxRate); } // SetTxRate() inline void nsWireless::CRT61DriverRoot::SetAPMacAddr (const CMacAddress& Addr) throw (std::bad_alloc, nsErrors::CSystemExc) { CSuWProtocol::SetAPMacAddr (Addr); } // SetAPMacAddr() inline void nsWireless::CRT61DriverRoot::Scan () throw (nsErrors::CSystemExc) { UpdateScanTime(); CSuWProtocol::Scan(); } // Scan() inline nsWireless::CRT73DriverRoot::~CRT73DriverRoot () throw() {} inline void nsWireless::CRT73DriverRoot::SetSSID (const std::string& SSID) throw (nsErrors::CSystemExc) { CSuWProtocol::SetSSID (SSID); } // SetSSID() inline void nsWireless::CRT73DriverRoot::SetFrequency (double Frequency) throw (nsErrors::CSystemExc) { CSuWProtocol::SetFrequency (Frequency); } // SetFrequency() inline void nsWireless::CRT73DriverRoot::SetChannel (unsigned Channel) throw (nsErrors::CSystemExc) { CSuWProtocol::SetChannel (Channel); } // SetChannel() inline nsWireless::CEncryptionD nsWireless::CRT73DriverRoot::GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) { return CSuWProtocol::GetEncryption(); } // GetEncryption() inline void nsWireless::CRT73DriverRoot::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { CSuWProtocol::SetEncryption (Descriptor); } // SetEncryption() inline void nsWireless::CRT73DriverRoot::SetMode (Mode_e Mode) throw (nsErrors::CSystemExc) { CSuWProtocol::SetMode (Mode); } // SetMode() inline void nsWireless::CRT73DriverRoot::SetTxRate (int TxRate) throw (nsErrors::CSystemExc) { CSuWProtocol::SetTxRate (TxRate); } // SetTxRate() inline void nsWireless::CRT73DriverRoot::SetAPMacAddr (const CMacAddress& Addr) throw (std::bad_alloc, nsErrors::CSystemExc) { CSuWProtocol::SetAPMacAddr (Addr); } // SetAPMacAddr() inline void nsWireless::CRT73DriverRoot::Scan () throw (nsErrors::CSystemExc) { UpdateScanTime(); CSuWProtocol::Scan(); } // Scan() RutilTv0.18/include/private/RTWMsgHandlers.hxx0000644000175000017500000000572610543033310020766 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTWMsgHandlers.hxx \author Romain BONDUE \date 21/02/2006 \warning This file should only be included from RTWMsgHandlers.h */ inline nsWireless::CRT2400Driver* nsRoot::CRT2400MsgHandler::GetDriver () throw() { return reinterpret_cast (CWirelessMsgHandler::GetDriver()); } // GetDriver() inline const nsWireless::CRT2400Driver* nsRoot::CRT2400MsgHandler::GetDriver () const throw() { return reinterpret_cast (CWirelessMsgHandler::GetDriver()); } // GetDriver() inline nsWireless::CRTAdvancedDriver* nsRoot::CRTAdvancedMsgHandler::GetDriver () throw() { return reinterpret_cast (CWirelessMsgHandler::GetDriver()); } // GetDriver() inline const nsWireless::CRTAdvancedDriver* nsRoot::CRTAdvancedMsgHandler::GetDriver () const throw() { return reinterpret_cast (CWirelessMsgHandler::GetDriver()); } // GetDriver() inline nsWireless::CRT2570Driver* nsRoot::CRT2570MsgHandler::GetDriver () throw() { return reinterpret_cast (CWirelessMsgHandler::GetDriver()); } // GetDriver() inline const nsWireless::CRT2570Driver* nsRoot::CRT2570MsgHandler::GetDriver () const throw() { return reinterpret_cast (CWirelessMsgHandler::GetDriver()); } // GetDriver() inline nsRoot::CMsg nsRoot::CRT2570MsgHandler::operator () (const CMsg& Msg) throw (nsErrors::CException, std::bad_alloc) { return CWirelessMsgHandler::operator () (Msg); } // operator() () RutilTv0.18/include/private/CWirelessMsgHandler.hxx0000644000175000017500000000311610375371353022035 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CWirelessMsgHandler.hxx \author Romain BONDUE \date 17/02/2006 \warning This file should only be included from CWirelessMsgHandler.h */ inline nsRoot::CWirelessMsgHandler::CWirelessMsgHandler () throw() : m_pDriver (0) {} inline nsRoot::CWirelessMsgHandler::~CWirelessMsgHandler () throw() {} inline nsWireless::IDriver* nsRoot::CWirelessMsgHandler::GetDriver () throw() { return m_pDriver.get(); } // GetDriver() inline const nsWireless::IDriver* nsRoot::CWirelessMsgHandler::GetDriver () const throw() { return m_pDriver.get(); } // GetDriver() inline void nsRoot::CWirelessMsgHandler::SetDriver (nsWireless::IDriver* pDriver) throw() { m_pDriver.reset (pDriver); } // SetDriver() RutilTv0.18/include/private/Parameters.hxx0000644000175000017500000002140310722350737020271 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Parameters.hxx \author Romain BONDUE \date 07/07/2005 \warning This file should only be included from Parameters.h */ inline nsWireless::Mode_e nsWireless::GetMatchingMode (Mode_e Mode) throw() { switch (Mode) { case Auto : return Auto; // Shouldn't happen. case AdHoc : return AdHoc; default : return Managed; } } // GetMatchingMode() inline nsWireless::CQuality::CQuality (unsigned short LinkQuality, short SignalLevel, short NoiseLevel) throw() : m_LinkQuality (LinkQuality), m_SignalLevel (SignalLevel), m_NoiseLevel (NoiseLevel) {} inline unsigned short nsWireless::CQuality::GetLinkQuality () const throw() { return m_LinkQuality; } // GetLinkQuality() inline short nsWireless::CQuality::GetSignalLevel () const throw() { return m_SignalLevel; } // GetSignalLevel() inline short nsWireless::CQuality::GetNoiseLevel () const throw() { return m_NoiseLevel; } // GetNoiseLevel() inline nsWireless::CDeviceInfo::CDeviceInfo (const std::string& DeviceName, const std::string& ProtoName) throw() : m_DeviceName (DeviceName), m_ProtoName (ProtoName) {} inline const std::string& nsWireless::CDeviceInfo::GetDeviceName () const throw() { return m_DeviceName; } // GetDeviceName() inline const std::string& nsWireless::CDeviceInfo::GetProtoName () const throw() { return m_ProtoName; } // GetProtoName() inline nsWireless::CHexaKey::CHexaKey () throw() : m_Size (0), m_Key (0) {} inline nsWireless::CHexaKey::CHexaKey (const char* Key, unsigned Size) throw (std::bad_alloc) : m_Size (0), m_Key (0) { Set (Key, Size); } // CHexaKey() inline nsWireless::CHexaKey::CHexaKey (const std::string& Str) throw (CBadFormatExc) : m_Size (0), m_Key (0) { Set (Str); } // CHexaKey() inline nsWireless::CHexaKey::CHexaKey (const CHexaKey& Key) throw (std::bad_alloc) : m_Size (0), m_Key (0) { operator = (Key); } // CHexaKey() inline nsWireless::CHexaKey::~CHexaKey () throw() {delete[] m_Key;} inline bool nsWireless::CHexaKey::Empty () const throw() { return !m_Size && m_StrKey.empty(); } // Empty() inline unsigned nsWireless::CHexaKey::Size () const throw() { // 1 hexadecimal digit (1 byte) represents 4 bits (1/2 byte). return m_Size ? m_Size : m_StrKey.size() / 2 + (m_StrKey.size() & 1 ? 1 : 0); } // Size() inline bool nsWireless::CHexaKey::operator != (const CHexaKey& Key) const throw() { return !operator == (Key); } // operator !=() inline nsWireless::CEncryptionD::CEncryptionD (const CHexaKey& Key, AuthType_e Auth, EncryptType_e Encrypt, unsigned DefaultKey) throw (std::bad_alloc) : m_Auth (Auth), m_Encrypt (Encrypt), m_DefaultKey (DefaultKey) { m_KeyTab [0] = Key; } // CEncryptionD() inline nsWireless::CEncryptionD::CEncryptionD (const CEncryptionD& Descriptor) throw (std::bad_alloc) { operator = (Descriptor); } // CEncryptionD() inline void nsWireless::CEncryptionD::SetDefaultKey (unsigned Value) throw() { m_DefaultKey = Value; } // SetDefaultKey() inline unsigned nsWireless::CEncryptionD::GetDefaultKey () const throw() { return m_DefaultKey; } // GetDefaultKey() inline nsWireless::EncryptType_e nsWireless::CEncryptionD::GetEncrypt () const throw() { return m_Encrypt; } // GetEncrypt() inline nsWireless::AuthType_e nsWireless::CEncryptionD::GetAuth () const throw() { return m_Auth; } // GetAuth() inline const nsWireless::CHexaKey& nsWireless::CEncryptionD::GetKey (unsigned Pos) const throw() { return m_KeyTab [Pos]; } // GetKey() inline void nsWireless::CEncryptionD::SetEncrypt (EncryptType_e Encrypt) throw() { m_Encrypt = Encrypt; } // SetEncrypt() inline void nsWireless::CEncryptionD::SetAuth (AuthType_e Auth) throw() { m_Auth = Auth; } // SetAuth() inline void nsWireless::CEncryptionD::SetKey (const CHexaKey& Key, unsigned Pos) throw (std::bad_alloc) { m_KeyTab [Pos] = Key; } // SetKey() inline nsWireless::CMacAddress::CMacAddress () throw() : CHexaKey() {} inline nsWireless::CMacAddress::CMacAddress (const char* Addr) throw (std::bad_alloc) : CHexaKey (Addr, Size) {} inline nsWireless::CMacAddress::CMacAddress (const std::string& Addr) throw (CBadFormatExc) : CHexaKey (Addr) {Check();} inline void nsWireless::CMacAddress::Set (const char* Addr) throw (std::bad_alloc) { Set (Addr, Size); } // Set() inline void nsWireless::CMacAddress::Set (const std::string& Addr) throw (CBadFormatExc) { CHexaKey::Set (Addr); Check(); } // Set() inline void nsWireless::CMacAddress::Check () throw (CBadFormatExc) { // One hexadecimal byte is stored with 2 caracters in a std::string. if (GetStr().size() < Size * 2) { Clear(); throw CBadFormatExc(); } } // Check() inline nsWireless::CCell::CCell () throw() : m_Mode (Unknown), m_Channel (0), m_Rate (0) {} inline const nsWireless::CMacAddress& nsWireless::CCell::GetAPMacAddress () const throw() { return m_APAddr; } // GetAPMacAddress() inline nsWireless::Mode_e nsWireless::CCell::GetMode () const throw() { return m_Mode; } // GetMode() inline const std::string& nsWireless::CCell::GetSSID () const throw() { return m_SSID; } // GetSSID() inline void nsWireless::CCell::SetSSID (const std::string& Str) throw() { m_SSID = Str; } // SetSSID() inline const nsWireless::CEncryptionD& nsWireless::CCell::GetEncryptionD () const throw() { return m_EncDescriptor; } // GetEncryptionD() inline nsWireless::CEncryptionD& nsWireless::CCell::GetEncryptionD () throw() { return m_EncDescriptor; } // GetEncryptionD() inline unsigned nsWireless::CCell::GetChannel () const throw() { return m_Channel; } // GetChannel() inline const nsWireless::CQuality& nsWireless::CCell::GetQuality () const throw() { return m_Quality; } // GetQuality() inline unsigned nsWireless::CCell::GetTxRate () const throw() {return m_Rate;} inline nsWireless::CCell::CCell (const CMacAddress& Addr) throw() : m_APAddr (Addr), m_Mode (Unknown), m_Channel (0), m_Rate (0) {} inline nsWireless::CFreq::CFreq (unsigned Channel, double Frequency) throw() : m_Channel (Channel), m_Frequency (Frequency) {} inline unsigned nsWireless::CFreq::GetChannel () const throw() { return m_Channel; } // GetChannel() inline double nsWireless::CFreq::GetFrequency () const throw() { return m_Frequency; } // GetFrequency() RutilTv0.18/include/private/PrefsPage.hxx0000644000175000017500000001217011054617534020043 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file PrefsPage.hxx \author Romain BONDUE \date 19/07/2006 \warning This file should only be included from PrefsPage.h */ inline nsGUI::CPrefsPage::operator ::GtkWidget* () throw() { return GTK_WIDGET (m_pTable); } // operator ::GtkWidget*() inline nsGUI::CPrefsPage::operator const ::GtkWidget* () const throw() { return GTK_WIDGET (m_pTable); } // operator ::GtkWidget*() inline bool nsGUI::CPrefsPage::StartMinimized () const throw() { return ::gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m_pStartMinimizedButton)); } // StartMinimized() inline void nsGUI::CPrefsPage::StartMinimized (bool B) throw() { ::gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_pStartMinimizedButton), B); } // StartMinimized() inline void nsGUI::CPrefsPage::AddChangeInterfaceCallBack (::GCallback CallBack, void* pData) throw() { ::g_signal_connect_swapped (G_OBJECT (m_pChangeInterface), "clicked", CallBack, pData); } // AddChangeInterfaceCallBack() inline void nsGUI::CPrefsPage::AddRootModeChangedCallBack (::GCallback CallBack, void* pData) throw() { ::g_signal_connect_swapped (G_OBJECT (m_pRootModeButton), "toggled", CallBack, pData); } // AddRootModeChanged() inline void nsGUI::CPrefsPage::SetRootMode (bool B) throw() { ::gtk_toggle_button_set_active (m_pRootModeButton, B); } // SetRootMode() inline void nsGUI::CPrefsPage::AddAutoLeaveRootModeCallBack (::GCallback CallBack, void* pData) throw() { ::g_signal_connect_swapped (G_OBJECT (m_pLeaveRootModeBox), "changed", CallBack, pData); } // AddAutoLeaveRootModeCallBack() inline void nsGUI::CPrefsPage::AddRateChangedCallBack (::GCallback CallBack, void* pData) throw() { ::g_signal_connect_swapped (G_OBJECT (m_pRatesBox), "changed", CallBack, pData); } // AddRateChangedCallBack() inline bool nsGUI::CPrefsPage::DisplayTrayIcon () const throw() { return ::gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m_pTrayIconButton)); } // DisplayTrayIcon() inline unsigned nsGUI::CPrefsPage::GetSelectedRateIndex () const throw() { return ::gtk_combo_box_get_active (m_pRatesBox); } // GetSelectedRateIndex() inline void nsGUI::CPrefsPage::SetRateIndex (unsigned Index) throw() { ::gtk_combo_box_set_active (m_pRatesBox, Index); } // SetRateIndex() inline void nsGUI::CPrefsPage::DisplayTrayIcon (bool B) throw() { ::gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_pTrayIconButton), B); } // DisplayTrayIcon() inline void nsGUI::CPrefsPage::AddTrayIconButtonCallBack (::GCallback CallBack, void* pData) throw() { ::g_signal_connect_swapped (G_OBJECT (m_pTrayIconButton), "clicked", CallBack, pData); } // AddTrayIconButtonCallBack() inline void nsGUI::CPrefsPage::AddStartMinimizedCallBack (::GCallback CallBack, void* pData) throw() { ::g_signal_connect_swapped (G_OBJECT (m_pStartMinimizedButton), "clicked", CallBack, pData); } // AddStartMinimizedCallBack() inline void nsGUI::CPrefsPage::AddIfaceStatusChangeCallBack (::GCallback CallBack, void* pData) throw() { ::g_signal_connect_swapped (G_OBJECT (m_pIfaceStatusButton), "toggled", CallBack, pData); } // AddIfaceStatusChangeCallBack() inline void nsGUI::CPrefsPage::IfaceStatus (bool Status) throw() { ::gtk_toggle_button_set_active (m_pIfaceStatusButton, Status); } // IfaceStatus() inline bool nsGUI::CPrefsPage::IfaceStatus () const throw() { return ::gtk_toggle_button_get_active (m_pIfaceStatusButton); } // IfaceStatus() inline void nsGUI::CPrefsPage::IfaceLabel (const std::string& Label) throw() { ::gtk_label_set_text (m_pIfaceLabel, Label.c_str()); } // IfaceLabel() inline std::string nsGUI::CPrefsPage::IfaceLabel () const throw() { return ::gtk_label_get_text (m_pIfaceLabel); } // IfaceLabel() RutilTv0.18/include/private/CStatsPage.hxx0000644000175000017500000000366110662041272020164 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CStatsPage.hxx \author Romain BONDUE \date 08/05/2005 \warning This file should only be included from CStatsPage.h */ inline nsGUI::CStatsPage::operator ::GtkWidget* () throw() { return GTK_WIDGET (m_pBox); } // operator ::GtkWidget*() inline nsGUI::CStatsPage::operator const ::GtkWidget* () const throw() { return GTK_WIDGET (m_pBox); } // operator const ::GtkWidget*() inline void nsGUI::CStatsPage::SetTXPackets (unsigned long NbPackets) throw() { SetLabel (m_pTXPackets, NbPackets); } // SetTXPackets() inline void nsGUI::CStatsPage::SetTXErrors (unsigned long NbErrors) throw() { SetLabel (m_pTXErrors, NbErrors); } // SetTXErrors() inline void nsGUI::CStatsPage::SetCollisions (unsigned long NbCollisions) throw() { SetLabel (m_pCollisions, NbCollisions); } // SetCollisions() inline void nsGUI::CStatsPage::SetRXPackets (unsigned long NbPackets) throw() { SetLabel (m_pRXPackets, NbPackets); } // SetRXPackets() inline void nsGUI::CStatsPage::SetRXErrors (unsigned long NbErrors) throw() { SetLabel (m_pRXErrors, NbErrors); } // SetRXErrors() RutilTv0.18/include/private/UserData.hxx0000644000175000017500000001307410722350737017703 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file UserData.hxx \author Romain BONDUE \date 05/07/2005 \warning This file should only be included from UserData.h */ #ifndef NDEBUG #include #endif // NDEBUG #include // EEXIST extern "C"{ #include // ::mkdir() } inline nsUserData::CProfile::CProfile (const std::string& Name) throw() : m_Name (Name), m_Mode (nsWireless::Managed), m_Channel (1), m_IPSettings (Dhcp) {} inline nsUserData::CProfile::~CProfile () throw() {} inline const std::string& nsUserData::CProfile::GetName () const throw() { return m_Name; } // GetName() inline const std::string& nsUserData::CProfile::GetSSID () const throw() { return m_SSID; } // GetSSID() inline nsWireless::Mode_e nsUserData::CProfile::GetMode () const throw() { return m_Mode; } // GetMode() inline unsigned nsUserData::CProfile::GetChannel () const throw() { return m_Channel; } // GetChannel() inline const nsWireless::CEncryptionD& nsUserData::CProfile::GetEncryptionD () const throw() { return m_EncryptionD; } // GetEncryptionD() inline nsWireless::CEncryptionD& nsUserData::CProfile::GetEncryptionD () throw() { return m_EncryptionD; } // GetEncryptionD() inline void nsUserData::CProfile::SetName (const std::string& Name) throw() { m_Name = Name; } // SetName() inline void nsUserData::CProfile::SetSSID (const std::string& SSID) throw() { m_SSID = SSID; } // SetSSID() inline void nsUserData::CProfile::SetMode (nsWireless::Mode_e Mode) throw() { m_Mode = Mode; } // SetMode() inline void nsUserData::CProfile::SetChannel (unsigned Channel) throw() { m_Channel = Channel; } // SetChannel() inline void nsUserData::CProfile::SetEncryptionD (const nsWireless::CEncryptionD& D) { m_EncryptionD = D; } // SetEncryptionD() inline nsUserData::CIPSettings& nsUserData::CProfile::GetIPSettings () throw() { return m_IPSettings; } // GetIPSettings() inline const nsUserData::CIPSettings& nsUserData::CProfile::GetIPSettings () const throw() { return m_IPSettings; } // GetIPSettings() inline nsUserData::CProfilesFile::~CProfilesFile () throw() {} inline void nsUserData::CProfilesFile::Error () throw() { // We remove the last CProfile as it may be invalid. DeleteLastProfile(); } // Error() inline nsUserData::CProfile& nsUserData::CProfilesFile::GetProfile (unsigned Pos) throw() { #ifndef NDEBUG try { return m_Profiles.at (Pos); } catch (const std::out_of_range& Exc) { std::cerr << Exc.what() << "\tAccessing profile index : " << Pos << ", but there are only " << m_Profiles.size() << " profiles." << std::endl; } #endif // NDEBUG return m_Profiles [Pos]; } // GetProfile() inline const nsUserData::CProfile& nsUserData::CProfilesFile::GetProfile (unsigned Pos) const throw() { #ifndef NDEBUG try { return m_Profiles.at (Pos); } catch (const std::out_of_range& Exc) { std::cerr << Exc.what() << "\tAccessing profile index : " << Pos << ", but there are only " << m_Profiles.size() << " profiles." << std::endl; } #endif // NDEBUG return m_Profiles [Pos]; } // GetProfile() inline unsigned nsUserData::CProfilesFile::Size () const throw() { return m_Profiles.size(); } // Size() inline void nsUserData::CProfilesFile::NewProfile (const char* Name) throw() { m_Profiles.push_back (CProfile (Name)); } // NewProfile() inline void nsUserData::CProfilesFile::NewProfile (const char* Name, const nsWireless::CCell& Cell) throw() { try{m_Profiles.push_back (CProfile (Name, Cell));} catch (std::bad_alloc) {m_Profiles.push_back (CProfile (Name));} } // NewProfile() inline void nsUserData::CProfilesFile::DeleteLastProfile () throw() { if (!m_Profiles.empty()) m_Profiles.erase (--m_Profiles.end()); } // DeleteLastProfile() inline void nsUserData::CProfilesFile::DeleteProfile (unsigned Pos) throw() { m_Profiles.erase (m_Profiles.begin() + Pos); } // DeleteProfile() inline nsUserData::CIPSettings::CIPSettings (IPSetting_e Setting) throw() : m_Setting (Setting) {} inline nsUserData::IPSetting_e nsUserData::CIPSettings::GetSetting () const throw() { return m_Setting; } // GetSetting() inline void nsUserData::CIPSettings::SetSetting (IPSetting_e Setting) throw() { m_Setting = Setting; } // SetSetting() RutilTv0.18/include/private/TrayIcon.hxx0000644000175000017500000000276710722350737017732 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file TrayIcon.hxx \author Romain BONDUE \date 08/07/2005 \warning This file should only be included from TrayIcon.h */ inline void nsGUI::CTrayIcon::SetIcon (const std::string& FileName) throw() { if (FileName != m_CurrentIconFileName) { if (m_pIcon) ::gtk_image_set_from_file (m_pIcon, FileName.c_str()); m_CurrentIconFileName = FileName; } } // SetIcon() inline void nsGUI::CTrayIcon::SetTooltip (const std::string& Text) throw() { if (m_pTrayIcon) ::gtk_tooltips_set_tip (m_pToolTipsGroup, m_pTrayIcon, Text.c_str(), 0); } // SetTooltip() inline bool nsGUI::CTrayIcon::IsVisible () const throw() { return m_pTrayIcon; } // IsVisible() RutilTv0.18/include/private/CSiteSurveyTab.hxx0000644000175000017500000000317010420722326021033 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CSiteSurveyTab.hxx \author Romain BONDUE \date 29/07/2005 \warning This file should only be included from CSiteSurveyTab.h */ inline nsGUI::CSiteSurveyTab::~CSiteSurveyTab () throw() {} inline nsGUI::CSiteSurveyTab::operator ::GtkWidget* () throw() { return GTK_WIDGET (m_pVBox); } // operator ::GtkWidget* () inline int nsGUI::CSiteSurveyTab::GetSelectedRow () const throw() { return CSelectableRowList::GetSelectedRow(); } // GetSelectedCell() inline void nsGUI::CSiteSurveyTab::SetSelected (unsigned Row, bool Value) throw() { SetData (Row, 0, Value); } // SetSelected() inline void nsGUI::CSiteSurveyTab::ScanningStopped () throw() { ::gtk_button_set_label (GTK_BUTTON (m_pScanButton), ScanButtonLabel); m_IsScanning = false; } // ScanningStopped() RutilTv0.18/include/private/SystemTools.hxx0000644000175000017500000000213310637260644020474 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file SystemTools.hxx \author Romain BONDUE \date 29/11/2005 \warning This file should only be included from SystemTools.h */ inline nsSystem::CLocalSocket::CLocalSocket (int Sd) throw() : m_Sd (Sd) {} inline nsSystem::CLocalSocket::~CLocalSocket () throw (nsErrors::CSystemExc) { Close(); } // ~CLocalSocket() RutilTv0.18/include/private/NetTools.hxx0000644000175000017500000000703610446611444017741 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file NetTools.hxx \author Romain BONDUE \date 08/05/2006 \warning This file should only be included from NetTools.h */ inline nsNet::CInterface::~CInterface () throw() {} inline unsigned long nsNet::CInterface::GetRXBytes () const throw() { return m_RXBytes; } // GetRXBytes() inline unsigned long nsNet::CInterface::GetRXPackets () const throw() { return m_RXPackets; } // GetRXPackets() inline unsigned long nsNet::CInterface::GetRXErrors () const throw() { return m_RXErrors; } // GetRXErrors() inline unsigned long nsNet::CInterface::GetRXDropped () const throw() { return m_RXDropped; } // GetRXDropped() inline unsigned long nsNet::CInterface::GetRXFifo () const throw() { return m_RXFifo; } // GetRXFifo() inline unsigned long nsNet::CInterface::GetRXFrame () const throw() { return m_RXFrame; } // GetRXFrame() inline unsigned long nsNet::CInterface::GetRXCompressed () const throw() { return m_RXCompressed; } // GetRXCompressed() inline unsigned long nsNet::CInterface::GetMulticast () const throw() { return m_Multicast; } // GetMulticast() inline unsigned long nsNet::CInterface::GetTXBytes () const throw() { return m_TXBytes; } // GetTXBytes() inline unsigned long nsNet::CInterface::GetTXPackets () const throw() { return m_TXPackets; } // GetTXPackets() inline unsigned long nsNet::CInterface::GetTXErrors () const throw() { return m_TXErrors; } // GetTXErrors() inline unsigned long nsNet::CInterface::GetTXDropped () const throw() { return m_TXDropped; } // GetTXDropped() inline unsigned long nsNet::CInterface::GetTXFifo () const throw() { return m_TXFifo; } // GetTXFifo() inline unsigned long nsNet::CInterface::GetCollisions () const throw() { return m_Collisions; } // GetCollisions() inline unsigned long nsNet::CInterface::GetCarrier () const throw() { return m_Carrier; } // GetCarrier() inline unsigned long nsNet::CInterface::GetTXCompressed () const throw() { return m_TXCompressed; } // GetTXCompressed() inline nsNet::CIPAddress::CIPAddress (uint32_t Addr) throw() : m_Addr (Addr) {} inline void nsNet::CIPAddress::Set (uint32_t Addr) throw() {m_Addr = Addr;} inline uint32_t nsNet::CIPAddress::Get () const throw() {return m_Addr;} inline uint8_t nsNet::CIPAddress::Get (unsigned Pos) const throw() { return reinterpret_cast (&m_Addr) [Pos]; } // Get() inline void nsNet::CIPAddress::Set (uint8_t Value, unsigned Pos) throw() { reinterpret_cast (&m_Addr) [Pos] = Value; } // Set() inline const std::string& nsNet::CInterface::GetName () const throw() { return m_IfName; } // GetName() inline void nsNet::CInterface::SetName (const std::string& IfName) throw() { m_IfName = IfName; ClearStats(); } // SetName() RutilTv0.18/include/private/Exceptions.hxx0000644000175000017500000000343110360147547020311 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Exceptions.hxx \author Romain BONDUE \date 05/07/2005 \warning This file should only be included from Exceptions.h */ #include inline nsErrors::CException::CException (const std::string& Msg, int Code) throw() : m_Msg (Msg), m_Code (Code) {} inline nsErrors::CException::~CException () throw() {} inline const std::string& nsErrors::CException::GetMsg () const throw() { return m_Msg; } // GetMsg() inline const char* nsErrors::CException::what () const throw() { return m_Msg.c_str(); } // what() inline int nsErrors::CException::GetCode () const throw() {return m_Code;} inline nsErrors::CSystemExc::CSystemExc (const std::string& Msg, int Code) throw() : CException (Msg, Code) {} template inline const char* nsErrors::CRTExc::what () const throw() { return typeid (CExcType).name(); } // what() RutilTv0.18/include/private/XMLParser.hxx0000644000175000017500000000302110464416054017775 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file XMLParser.hxx \author Romain BONDUE \date 03/08/2006 \warning This file should only be included from XMLParser.h */ inline nsUserData::CXMLParser::~CXMLParser () throw() {} inline void nsUserData::CXMLParser::StartElement (const char*, const char**, const char**) throw (std::bad_alloc, nsErrors::CException) {} inline void nsUserData::CXMLParser::EndElement (const char*) throw (nsErrors::CException) {} inline void nsUserData::CXMLParser::Text (const char*, const std::string&) throw (nsErrors::CException) {} inline void nsUserData::CXMLParser::Error () throw() {} RutilTv0.18/include/private/GtkGUI.hxx0000644000175000017500000000415111054617534017261 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file GtkGUI.hxx \author Romain BONDUE \date 21/07/2005 \warning This fils should only be included from GtkGUI.h */ #include "Module.h" inline void nsGUI::CGtkGUI::StopScanning () throw() { ::g_source_remove (m_SiteSurveyTabTimer); m_SiteSurveyTab.ScanningStopped(); m_SiteSurveyTabTimer = 0; } // StopScanning() inline nsGUI::CGtkGUI::operator const ::GtkWindow* () const throw() { return m_pWindow; } // operator const ::GtkWindow* () inline nsGUI::CGtkGUI::operator ::GtkWindow* () throw() { return m_pWindow; } // operator const ::GtkWindow* () inline bool nsGUI::CGtkGUI::IsRoot () const throw() { return m_Flags & IsRootF; } // IsRoot() inline void nsGUI::CGtkGUI::SetRoot () throw() { m_Flags |= IsRootF; } // SetRoot() inline bool nsGUI::CGtkGUI::IsIgnored () const throw() { return m_Flags & IsIgnoredF; } // IsIgnored() inline void nsGUI::CGtkGUI::IsIgnored (bool B) throw() { if (B) m_Flags |= IsIgnoredF; else m_Flags &= ~IsIgnoredF; } // IsIgnored() inline bool nsGUI::CGtkGUI::IsStatsAvailable () const throw() { return m_Flags & IsStatsAvailableF; } // IsStatsAvailable() inline void nsGUI::CGtkGUI::IsStatsAvailable (bool B) throw() { if (B) m_Flags |= IsStatsAvailableF; else m_Flags &= ~IsStatsAvailableF; } // IsStatsAvailable() RutilTv0.18/include/private/CSelectableRowList.hxx0000644000175000017500000000366510420722326021662 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CSelectableRowList.hxx \author Romain BONDUE \date 29/07/2005 \warning This file should only be included from CSelectableRowList.h */ inline nsGUI::CSelectableRowList::~CSelectableRowList () throw() { ::g_object_unref (m_pListStore); } // ~CSelectableRowList() inline nsGUI::CSelectableRowList::operator ::GtkWidget* () throw() { return m_pScrollWindow; } // operator ::GtkWidget* () inline void nsGUI::CSelectableRowList::Clear () throw() { ::gtk_list_store_clear (m_pListStore); m_IterVec.clear(); m_SelectedRow = None; } // Clear() inline nsGUI::CGtkGUI* nsGUI::CSelectableRowList::GetUI () throw() { return m_pUI; } // GetUI() inline const nsGUI::CGtkGUI* nsGUI::CSelectableRowList::GetUI () const throw() { return m_pUI; } // GetUI() inline int nsGUI::CSelectableRowList::GetSelectedRow () const throw() { return m_SelectedRow; } // GetSelectedRow() inline unsigned nsGUI::CSelectableRowList::GetNbRow () const throw() { return m_IterVec.size(); } // GetNbRow() inline void nsGUI::CSelectableRowList::RowSelectedCallBack () throw() {} inline void nsGUI::CSelectableRowList::RowUnselectedCallBack () throw() {} RutilTv0.18/include/private/SuWProtocol.hxx0000644000175000017500000000226610375371353020435 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file SuWProtocol.hxx \author Romain BONDUE \date 07/11/2006 \warning This file should only be included from SuWProtocol.h */ #include template void nsWireless::CSuWProtocol::SuDo (T MsgValue, int Code) throw (nsErrors::CSystemExc) { std::ostringstream Os; Os << MsgValue; SuDo (nsRoot::CMsg (Os.str(), Code)); } // SuDo() RutilTv0.18/include/private/WE17DriverRoot.hxx0000644000175000017500000000555610375602515020702 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file WE17DriverRoot.hxx \author Romain BONDUE \date 17/02/2006 \warning This file should only be included from WE17DriverRoot.h */ inline nsWireless::CWE17DriverRoot::~CWE17DriverRoot () throw() {} inline void nsWireless::CWE17DriverRoot::SetSSID (const std::string& SSID) throw (nsErrors::CSystemExc) { CSuWProtocol::SetSSID (SSID); } // SetSSID() inline void nsWireless::CWE17DriverRoot::SetFrequency (double Frequency) throw (nsErrors::CSystemExc) { CSuWProtocol::SetFrequency (Frequency); } // SetFrequency() inline void nsWireless::CWE17DriverRoot::SetChannel (unsigned Channel) throw (nsErrors::CSystemExc) { CSuWProtocol::SetChannel (Channel); } // SetChannel() inline nsWireless::CEncryptionD nsWireless::CWE17DriverRoot::GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) { return CSuWProtocol::GetEncryption(); } // GetEncryption() inline void nsWireless::CWE17DriverRoot::SetEncryption (const CEncryptionD& Descriptor) throw (nsErrors::CSystemExc, std::bad_alloc) { CSuWProtocol::SetEncryption (Descriptor); } // SetEncryption() inline void nsWireless::CWE17DriverRoot::SetMode (Mode_e Mode) throw (nsErrors::CSystemExc) { CSuWProtocol::SetMode (Mode); } // SetMode() inline void nsWireless::CWE17DriverRoot::SetTxRate (int TxRate) throw (nsErrors::CSystemExc) { CSuWProtocol::SetTxRate (TxRate); } // SetTxRate() inline void nsWireless::CWE17DriverRoot::SetAPMacAddr (const CMacAddress& Addr) throw (std::bad_alloc, nsErrors::CSystemExc) { CSuWProtocol::SetAPMacAddr (Addr); } // SetAPMacAddr() inline void nsWireless::CWE17DriverRoot::Scan () throw (nsErrors::CSystemExc) { CSuWProtocol::Scan(); } // Scan() RutilTv0.18/include/private/CLinkStatusTab.hxx0000644000175000017500000000463110702224517021017 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CLinkStatusTab.hxx \author Romain BONDUE \date 29/07/2005 \warning This file should only be included from CLinkStatusTab.h */ inline nsGUI::CLinkStatusTab::operator ::GtkWidget* () throw() { return m_pAlignment; } // operator ::GtkWidget*() inline nsGUI::CLinkStatusTab::operator const ::GtkWidget* () const throw() { return m_pAlignment; } // operator ::GtkWidget*() inline double nsGUI::CLinkStatusTab::dBmToPercent (short dBm) throw() { return dBm / 256.0 + 1; } // dBmToPercent() inline void nsGUI::CLinkStatusTab::SetLinkQuality (unsigned short Quality) throw() { SetBar (m_pLinkQualityBar, Quality / 100.0, Quality, " %", 0); } // SetLinkQuality() inline void nsGUI::CLinkStatusTab::SetSignalLevel (short Level) throw() { SetBar (m_pSignalLevelBar, dBmToPercent (Level), Level, " dBm", -256); } // SetSignalLevel() inline void nsGUI::CLinkStatusTab::SetNoiseLevel (short Level) throw() { SetBar (m_pNoiseLevelBar, dBmToPercent (Level), Level, " dBm", -256); } // SetSignalLevel() inline void nsGUI::CLinkStatusTab::SetStatus (std::string SSID, const std::string& Addr) throw() { SSID += " <---> "; SSID += Addr; ::gtk_label_set_text (m_pStatusLabel, SSID.c_str()); } // SetStatus() inline void nsGUI::CLinkStatusTab::SetMode (const std::string& Mode) throw() { ::gtk_label_set_text (m_pModeLabel, Mode.c_str()); } // SetMode() inline void nsGUI::CLinkStatusTab::SetAddr (const std::string& Addr) throw() { ::gtk_label_set_text (m_pAddrLabel, Addr.c_str()); } // SetAddr() RutilTv0.18/include/private/RTModules.hxx0000644000175000017500000003513010722350737020046 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE * if (pCBox == This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTModules.hxx \author Romain BONDUE \date 19/08/2005 \warning This file should only be included from RTModules.h */ inline nsCore::CRT2400CLIModule::CRT2400CLIModule (const std::string& DeviceName, const std::string& Path) throw (nsErrors::CException, std::bad_alloc) : m_Driver (DeviceName) { m_ProfilesFile.Extract(); } // CRT2400CLIModule() inline nsCore::CRT2400CLIModule::~CRT2400CLIModule () throw() {} inline const nsUserData::CProfile& nsCore::CRT2400CLIModule::GetProfile (unsigned Pos) const throw() { return m_ProfilesFile.GetProfile (Pos); } // GetProfile() inline unsigned nsCore::CRT2400CLIModule::GetNbProfile () const throw() { return m_ProfilesFile.Size(); } // GetNbProfile() inline nsWireless::IDriver& nsCore::CRT2400CLIModule::GetDriver () throw() { return m_Driver; } // GetDriver() inline const nsWireless::IDriver& nsCore::CRT2400CLIModule::GetDriver () const throw() { return m_Driver; } // GetDriver() inline nsWireless::IDriver& nsCore::CRT2400Module::GetDriver () throw() { return *m_pDriver; } // GetDriver() inline const nsWireless::IDriver& nsCore::CRT2400Module::GetDriver () const throw() { return *m_pDriver; } // GetDriver() inline void nsCore::CRT2400Module::DeleteProfile (unsigned Pos) throw() { m_ProfilesFile.DeleteProfile (Pos); } // DeleteProfile() inline nsUserData::CProfile& nsCore::CRT2400Module::GetProfile (unsigned Pos) throw() { return m_ProfilesFile.GetProfile (Pos); } // GetProfile() inline unsigned nsCore::CRT2400Module::GetNbProfile () const throw() { return m_ProfilesFile.Size(); } // GetNbProfile() inline ::GtkWidget* nsCore::CRT2400Module::GetPrivateTab () throw() {return 0;} inline nsUserData::CProfile* nsCore::CRT2400Module::NewProfile (::GtkWindow* pMainWindow) throw() { m_ProfilesFile.NewProfile (NewProfileDefaultName); return EditNewProfile (pMainWindow); } // NewProfile() inline bool nsCore::CRT2400Module::EditProfile (::GtkWindow* pMainWindow, unsigned Pos) throw() { return m_ProfileEditor.Edit (pMainWindow, m_ProfilesFile.GetProfile (Pos)); } // EditProfile() inline nsCore::CRT2400Module::~CRT2400Module () throw() {} inline nsCore::CRTAdvancedCLIModule::CRTAdvancedCLIModule (nsWireless::CRTAdvancedDriver* pDriver, const std::string& Path) throw (nsErrors::CException, std::bad_alloc) : m_pDriver (pDriver) { m_ProfilesFile.Extract(); } // CRTAdvancedCLIModule() inline nsCore::CRTAdvancedCLIModule::~CRTAdvancedCLIModule () throw() {} inline const nsUserData::CProfile& nsCore::CRTAdvancedCLIModule::GetProfile (unsigned Pos) const throw() { return m_ProfilesFile.GetProfile (Pos); } // GetProfile() inline unsigned nsCore::CRTAdvancedCLIModule::GetNbProfile () const throw() { return m_ProfilesFile.Size(); } // GetNbProfile() inline nsCore::CRTAdvancedModule::~CRTAdvancedModule () throw() {} inline nsWireless::IDriver& nsCore::CRTAdvancedCLIModule::GetDriver () throw() { return *m_pDriver; } // GetDriver() inline const nsWireless::IDriver& nsCore::CRTAdvancedCLIModule::GetDriver () const throw() { return *m_pDriver; } // GetDriver() inline nsUserData::CProfile* nsCore::CRTAdvancedModule::NewProfile (::GtkWindow* pMainWindow) throw() { m_ProfilesFile.NewProfile (NewProfileDefaultName); return EditNewProfile (pMainWindow); } // NewProfile() inline nsWireless::IDriver& nsCore::CRTAdvancedModule::GetDriver () throw() { return *m_pDriver; } // GetDriver() inline const nsWireless::IDriver& nsCore::CRTAdvancedModule::GetDriver () const throw() { return *m_pDriver; } // GetDriver() inline nsCore::CRT2500CLIModule::CRT2500CLIModule (const std::string& DeviceName, const std::string& Path) throw (nsErrors::CException, std::bad_alloc) : CRTAdvancedCLIModule (new nsWireless::CRT2500Driver (DeviceName), Path) {} inline nsCore::CRT61CLIModule::CRT61CLIModule (const std::string& DeviceName, const std::string& Path) throw (nsErrors::CException, std::bad_alloc) : CRTAdvancedCLIModule (new nsWireless::CRT61Driver (DeviceName), Path) {} inline nsCore::CRT73CLIModule::CRT73CLIModule (const std::string& DeviceName, const std::string& Path) throw (nsErrors::CException, std::bad_alloc) : CRTAdvancedCLIModule (new nsWireless::CRT73Driver (DeviceName), Path) {} inline bool nsCore::CRTAdvancedModule::EditProfile (::GtkWindow* pMainWindow, unsigned Pos) throw() { return m_ProfileEditor.Edit (pMainWindow, m_ProfilesFile.GetProfile (Pos)); } // EditProfile() inline void nsCore::CRTAdvancedModule::DeleteProfile (unsigned Pos) throw() { m_ProfilesFile.DeleteProfile (Pos); } // DeleteProfile() inline nsUserData::CProfile& nsCore::CRTAdvancedModule::GetProfile (unsigned Pos) throw() { return m_ProfilesFile.GetProfile (Pos); } // GetProfile() inline unsigned nsCore::CRTAdvancedModule::GetNbProfile () const throw() { return m_ProfilesFile.Size(); } // GetNbProfile() inline ::GtkWidget* nsCore::CRTAdvancedModule::GetPrivateTab () throw() { return GTK_WIDGET (m_pTable); } // GetPrivateTab() inline void nsCore::CRTAdvancedModule::ResumePreviousState (::GtkComboBox* pCBox) throw() { m_IsSkipped = true; ::gtk_combo_box_set_active (pCBox, m_CurrentActiveBoxItem); m_IsSkipped = false; } // ResumePreviousState() inline void nsCore::CRTAdvancedModule::SetDriver (nsWireless::CRTAdvancedDriver* pDriver) throw() { m_pDriver.reset (pDriver); } // SetDriver() inline void nsCore::CRTAdvancedModule::TxBurstCallBack (::GtkToggleButton* pButton, CRTAdvancedModule* This) throw() { This->CommonCButtonCallBack (&nsWireless::CRTAdvancedDriver::SetTxBurst, pButton); } // TxBurstCallBack() inline void nsCore::CRTAdvancedModule::TurboRateCallBack (::GtkToggleButton* pButton, CRTAdvancedModule* This) throw() { This->CommonCButtonCallBack (&nsWireless::CRTAdvancedDriver::SetTurboRate, pButton); } // TurboRateCallBack() inline void nsCore::CRTAdvancedModule::AdHocOFDMCallBack (::GtkToggleButton* pButton, CRTAdvancedModule* This) throw() { This->CommonCButtonCallBack (&nsWireless::CRTAdvancedDriver::SetAdHocOFDM, pButton); } // AdHocOFDMCallBack() inline void nsCore::CRTAdvancedModule::RfmontxCallBack (::GtkToggleButton* pButton, CRTAdvancedModule* This) throw() { This->CommonCButtonCallBack (&nsWireless::CRTAdvancedDriver::SetRfmontx, pButton); } // RfmontxCallBack() inline void nsCore::CRTAdvancedModule::BGProtectionCallBack (::GtkComboBox* pCBox, CRTAdvancedModule* This) throw() { This->CommonCBoxCallBack (reinterpret_cast (&nsWireless::CRTAdvancedDriver::SetBGProtection), pCBox); } // BGProtectionCallBack() inline void nsCore::CRTAdvancedModule::TxPreambleCallBack (::GtkComboBox* pCBox, CRTAdvancedModule* This) throw() { This->CommonCBoxCallBack (reinterpret_cast (&nsWireless::CRTAdvancedDriver::SetTxPreamble), pCBox); } // TxPreambleCallBack() inline void nsCore::CRTAdvancedModule::CBoxFocusCallBack (::GtkComboBox* pCBox, bool, nsCore::CRTAdvancedModule* This) throw() { This->m_CurrentActiveBoxItem = ::gtk_combo_box_get_active (pCBox); } // CBoxFocusCallBack() inline nsCore::CProfileEditor& nsCore::CRTAdvancedModule::GetProfileEditor () throw() { return m_ProfileEditor; } // GetProfileEditor() inline const nsCore::CProfileEditor& nsCore::CRTAdvancedModule::GetProfileEditor () const throw() { return m_ProfileEditor; } // GetProfileEditor() inline nsCore::CRT2570CLIModule::CRT2570CLIModule (const std::string& DeviceName, const std::string& Path) throw (nsErrors::CException, std::bad_alloc) : m_Driver (DeviceName) { m_ProfilesFile.Extract(); } // CRT2570CLIModule() inline nsCore::CRT2570CLIModule::~CRT2570CLIModule () throw() {} inline const nsUserData::CProfile& nsCore::CRT2570CLIModule::GetProfile (unsigned Pos) const throw() { return m_ProfilesFile.GetProfile (Pos); } // GetProfile() inline unsigned nsCore::CRT2570CLIModule::GetNbProfile () const throw() { return m_ProfilesFile.Size(); } // GetNbProfile() inline nsWireless::IDriver& nsCore::CRT2570CLIModule::GetDriver () throw() { return m_Driver; } // GetDriver() inline const nsWireless::IDriver& nsCore::CRT2570CLIModule::GetDriver () const throw() { return m_Driver; } // GetDriver() inline nsCore::CRT2570Module::~CRT2570Module () throw() {} inline void nsCore::CRT2570Module::CBoxFocusCallBack (::GtkComboBox* pCBox, bool, nsCore::CRT2570Module* This) throw() { This->m_CurrentActiveBoxItem = ::gtk_combo_box_get_active (pCBox); } // CBoxFocusCallBack() inline nsWireless::IDriver& nsCore::CRT2570Module::GetDriver () throw() { return *m_pDriver; } // GetDriver() inline const nsWireless::IDriver& nsCore::CRT2570Module::GetDriver () const throw() { return *m_pDriver; } // GetDriver() inline void nsCore::CRT2570Module::RfmontxCallBack (::GtkToggleButton* pButton, CRT2570Module* This) throw() { This->CommonCButtonCallBack (&nsWireless::CRT2570Driver::SetRfmontx, pButton); } // RfmontxCallBack() inline void nsCore::CRT2570Module::PrismHeaderCallBack (::GtkComboBox* pCBox, CRT2570Module* This) throw() { This->CommonCBoxCallBack (reinterpret_cast (&nsWireless::CRT2570Driver::SetPrismHeader), pCBox); } // PrismHeaderCallBack() inline void nsCore::CRT2570Module::AdhocModeCallBack (::GtkComboBox* pCBox, CRT2570Module* This) throw() { This->CommonCBoxCallBack (reinterpret_cast (&nsWireless::CRT2570Driver::SetAdHocMode), pCBox); } // AdhocModeCallBack() inline nsUserData::CProfile* nsCore::CRT2570Module::NewProfile (::GtkWindow* pMainWindow) throw() { m_ProfilesFile.NewProfile (NewProfileDefaultName); return EditNewProfile (pMainWindow); } // NewProfile() inline bool nsCore::CRT2570Module::EditProfile (::GtkWindow* pMainWindow, unsigned Pos) throw() { return m_ProfileEditor.Edit (pMainWindow, m_ProfilesFile.GetProfile (Pos)); } // EditProfile() inline void nsCore::CRT2570Module::DeleteProfile (unsigned Pos) throw() { m_ProfilesFile.DeleteProfile (Pos); } // DeleteProfile() inline nsUserData::CProfile& nsCore::CRT2570Module::GetProfile (unsigned Pos) throw() { return m_ProfilesFile.GetProfile (Pos); } // GetProfile() inline unsigned nsCore::CRT2570Module::GetNbProfile () const throw() { return m_ProfilesFile.Size(); } // GetNbProfile() inline ::GtkWidget* nsCore::CRT2570Module::GetPrivateTab () throw() { return GTK_WIDGET (m_pBox); } // GetPrivateTab() inline void nsCore::CRT2570Module::ResumePreviousState (::GtkComboBox* pCBox) throw() { m_IsSkipped = true; ::gtk_combo_box_set_active (pCBox, m_CurrentActiveBoxItem); m_IsSkipped = false; } // ResumePreviousState() inline nsUserData::CProfilesFile& nsCore::CRTAdvancedModule::GetProfilesFile () throw() { return m_ProfilesFile; } // GetProfilesFile() inline const nsUserData::CProfilesFile& nsCore::CRTAdvancedModule::GetProfilesFile () const throw() { return m_ProfilesFile; } // GetProfilesFile() inline nsUserData::CProfilesFile& nsCore::CRTAdvancedCLIModule::GetProfilesFile () throw() { return m_ProfilesFile; } // GetProfilesFile() inline const nsUserData::CProfilesFile& nsCore::CRTAdvancedCLIModule::GetProfilesFile () const throw() { return m_ProfilesFile; } // GetProfilesFile() RutilTv0.18/include/private/WE17Driver.hxx0000644000175000017500000000445710702162053020025 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file WE17Driver.hxx \author Romain BONDUE \date 05/07/2005 \warning This file should only be included from WE17Driver.h */ #include "SystemTools.h" // Not a big problem, but... inline void nsWireless::CWE17Driver::Ioctl (int Request, const std::string& ErrorMsg) const throw (nsErrors::CSystemExc) { nsSystem::Ioctl (Request, &m_Req, ErrorMsg); } // Ioctl() inline nsWireless::CWE17Driver::~CWE17Driver () throw() {} inline const std::string& nsWireless::CWE17Driver::GetProtoName () const throw() { return m_ProtoName; } // GetProtoName() inline unsigned nsWireless::CWE17Driver::GetMaxSSIDSize () const throw() { return IW_ESSID_MAX_SIZE; } // GetMaxSSIDSize() inline unsigned nsWireless::CWE17Driver::GetMaxKeySize () const throw() { return IW_ENCODING_TOKEN_MAX; } // GetMaxKeySize() inline const std::vector& nsWireless::CWE17Driver::GetSupportedFreq () const throw() { return m_SupportedFreqVec; } // GetSupportedFrequency() inline void nsWireless::CWE17Driver::AddSupportedFreq (unsigned Channel, double Frequency) throw() { m_SupportedFreqVec.push_back (CFreq (Channel, Frequency)); } // AddSupportedFrequency() inline std::string nsWireless::CWE17Driver::GetDeviceName () const throw() { return m_Req.ifr_ifrn.ifrn_name; } // GetDeviceName() RutilTv0.18/include/private/OptionsFile.hxx0000644000175000017500000000405110464416054020417 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file OptionsFile.hxx \author Romain BONDUE \date 03/08/2006 \warning This file should only be included from OptionsFile.h */ inline nsUserData::COptionsFile::COptionsFile (bool DisplayTrayIcon, bool StartMinimized, unsigned LeaveRootDelay) throw() : m_DisplayTrayIcon (DisplayTrayIcon), m_StartMinimized (StartMinimized), m_LeaveRootDelay (LeaveRootDelay) {} inline bool nsUserData::COptionsFile::DisplayTrayIcon () const throw() { return m_DisplayTrayIcon; } // DisplayTrayIcon() inline void nsUserData::COptionsFile::DisplayTrayIcon (bool B) throw() { m_DisplayTrayIcon = B; } // DisplayTrayIcon() inline bool nsUserData::COptionsFile::StartMinimized () const throw() { return m_StartMinimized; } // StartMinimized() inline void nsUserData::COptionsFile::StartMinimized (bool B) throw() { m_StartMinimized = B; } // StartMinimized() inline unsigned nsUserData::COptionsFile::LeaveRootDelay () const throw() { return m_LeaveRootDelay; } // LeaveRootDelay() inline void nsUserData::COptionsFile::LeaveRootDelay (unsigned Delay) throw() { m_LeaveRootDelay = Delay; } // LeaveRootDelay() inline nsUserData::COptionsFile::~COptionsFile () throw() {} RutilTv0.18/include/private/CProfileTab.hxx0000644000175000017500000000377110420722326020320 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CProfileTab.hxx \author Romain BONDUE \date 05/08/2005 \warning This file should only be included from CProfileTab.h */ inline nsGUI::CProfileTab::operator ::GtkWidget* () throw() { return GTK_WIDGET (m_pHBox); } // operator ::GTkWidget* () inline void nsGUI::CProfileTab::AddProfile (const nsUserData::CProfile& Profile) throw() { SetProfile (CSelectableRowList::GetNbRow(), Profile); } // AddProfile() inline int nsGUI::CProfileTab::GetSelectedRow () const throw() { return CSelectableRowList::GetSelectedRow(); } // GetProfile() inline void nsGUI::CProfileTab::RowSelectedCallBack () throw() { ::gtk_widget_set_sensitive (m_pDeleteButton, true); ::gtk_widget_set_sensitive (m_pEditButton, true); ::gtk_widget_set_sensitive (m_pApplyButton, true); } // RowSelectedCallBack() inline void nsGUI::CProfileTab::RowUnselectedCallBack () throw() { ::gtk_widget_set_sensitive (m_pDeleteButton, false); ::gtk_widget_set_sensitive (m_pEditButton, false); ::gtk_widget_set_sensitive (m_pApplyButton, false); } // RowUnselectedCallBack() inline void nsGUI::CProfileTab::SetSelected (unsigned Pos, bool Value) throw() { SetData (Pos, 0, Value); } // SetSelected() RutilTv0.18/include/eggtrayicon.h0000644000175000017500000000503610705133111016435 0ustar romainromain/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* eggtrayicon.h * Copyright (C) 2002 Anders Carlsson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef __EGG_TRAY_ICON_H__ #define __EGG_TRAY_ICON_H__ #include #ifdef GDK_WINDOWING_X11 #include #endif G_BEGIN_DECLS #define EGG_TYPE_TRAY_ICON (egg_tray_icon_get_type ()) #define EGG_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TRAY_ICON, EggTrayIcon)) #define EGG_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TRAY_ICON, EggTrayIconClass)) #define EGG_IS_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TRAY_ICON)) #define EGG_IS_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TRAY_ICON)) #define EGG_TRAY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TRAY_ICON, EggTrayIconClass)) typedef struct _EggTrayIcon EggTrayIcon; typedef struct _EggTrayIconClass EggTrayIconClass; struct _EggTrayIcon { GtkPlug parent_instance; guint stamp; #ifdef GDK_WINDOWING_X11 Atom selection_atom; Atom manager_atom; Atom system_tray_opcode_atom; Atom orientation_atom; Window manager_window; #endif GtkOrientation orientation; }; struct _EggTrayIconClass { GtkPlugClass parent_class; }; GType egg_tray_icon_get_type (void); EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen *screen, const gchar *name); EggTrayIcon *egg_tray_icon_new (const gchar *name); guint egg_tray_icon_send_message (EggTrayIcon *icon, gint timeout, const char *message, gint len); void egg_tray_icon_cancel_message (EggTrayIcon *icon, guint id); GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon); G_END_DECLS #endif /* __EGG_TRAY_ICON_H__ */ RutilTv0.18/include/TrayIcon.h0000644000175000017500000000330710705146212015657 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file TrayIcon.h \author Romain BONDUE \date 08/07/2006 */ #ifndef __TRAYICON_H__ #define __TRAYICON_H__ #include extern "C"{ #include } namespace nsGUI { class CTrayIcon { public : // Callback : void (*) (void*, ::GdkEventButton*) throw(); CTrayIcon (const std::string&, ::GCallback, void*) throw(); ~CTrayIcon () throw(); void SetIcon (const std::string&) throw(); void SetTooltip (const std::string&) throw(); void Show () throw(); void Hide () throw(); bool IsVisible () const throw(); private : ::GtkWidget* m_pTrayIcon; ::GtkImage* m_pIcon; ::GtkTooltips* const m_pToolTipsGroup; std::string m_CurrentIconFileName; ::GCallback const m_CallBack; void* const m_pCallBackData; }; // CTrayIcon } // namespace nsGUI #include "private/TrayIcon.hxx" #endif // __TRAYICON_H__ RutilTv0.18/include/CLIOpt.h0000644000175000017500000000355310543033307015224 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CLIOpt.h * \author Romain BONDUE * \date 28/10/2006 */ #ifndef __CLIOPT_H__ #define __CLIOPT_H__ #include #include "Exceptions.h" namespace nsCore { class CCLIOpt { public : CCLIOpt (int, char* []) throw (nsErrors::CException); bool Help () const throw(); bool Version () const throw(); bool Hidden () const throw(); bool Exit () const throw(); bool Dhcp () const throw(); bool Profile () const throw(); bool Iface () const throw(); const std::string& ProfileName () const throw(); const std::string& IfaceName () const throw(); private : enum {None, HelpFlag, VersionFlag, HiddenFlag = 4, ExitFlag = 8, DhcpFlag = 16, ProfileFlag = 32}; int ParseShortOption (const char*) throw (nsErrors::CException); int ParseLongOption (const char*) throw (nsErrors::CException); int m_Flags; std::string m_ProfileName; std::string m_IfaceName; }; // CCLIOpt } // namespace nsCore #include "private/CLIOpt.hxx" #endif // __CLIOPT_H__ RutilTv0.18/include/IfaceProtocolCodes.h0000644000175000017500000000215510543033307017636 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file IfaceProtocolCodes.h \author Romain BONDUE \date 09/06/2006 */ #ifndef __IFACEPROTOCOLCODES_H__ #define __IFACEPROTOCOLCODES_H__ namespace nsNet { enum IfaceProtocolCodes_e {DeviceNameC, DhcpC, StaticIpC, UpC, DownC}; const char* const IfaceHandler ("IfaceHandler"); } // namespace nsNet #endif // __IFACEPROTOCOLCODES_H__ RutilTv0.18/include/MsgHandlerFactory.h0000644000175000017500000000242110446611443017504 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file MsgHandlerFactory.h \author Romain BONDUE \date 17/02/2006 */ #ifndef __MSGHANDLERFACTORY_H__ #define __MSGHANDLERFACTORY_H__ #include // bad_alloc #include "Exceptions.h" namespace nsRoot { class IMsgHandler; /** \warning The object returned be manually free. */ IMsgHandler* MakeHandler (const std::string&) throw (nsErrors::CException, std::bad_alloc); } // namespace nsRoot #endif // __MSGHANDLERFACTORY_H__ RutilTv0.18/include/GtkGUI.h0000644000175000017500000001556711054617533015243 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file GtkGUI.h \author Romain BONDUE \date 21/07/2005 */ #ifndef __GTKGUI_H__ #define __GTKGUI_H__ #include #include #include // auto_ptr<> extern "C"{ #include } #if !GTK_CHECK_VERSION (2, 6, 0) #error Invalid GTK+ headers, require at least version 2.6. #endif #include "Exceptions.h" #include "CLinkStatusTab.h" #include "CSiteSurveyTab.h" #include "CStatsPage.h" #include "CProfileTab.h" #include "TrayIcon.h" #include "PrefsPage.h" #include "CLIOpt.h" namespace nsWireless { class CEncryptionD; class CDeviceInfo; class CQuality; class CMacAddress; } // namespace nsWireless namespace nsCore{class IModule;} namespace nsNet{class CInterface;} namespace nsGUI { class CStatsPage; void NotifyError (const std::string&, int, ::GtkWindow*) throw(); bool AskUser (const std::string&, ::GtkWindow*) throw(); class CGtkGUI { public : CGtkGUI () throw (nsErrors::CException); ~CGtkGUI () throw(); void Run (const nsCore::CCLIOpt&) throw (nsErrors::CException); bool Connect (unsigned) throw(); void Scan () throw(); void StopScanning () throw(); bool ApplyProfile (unsigned) throw(); bool DeleteProfile (unsigned) throw(); const nsUserData::CProfile* EditProfile () throw(); const nsUserData::CProfile* NewProfile () throw(); bool NewProfile (unsigned) throw(); void RefreshRates () throw(); bool BecomeRoot () throw (nsErrors::CException); bool IsRoot () const throw(); /** \return "true" means that the calling function should clean * everything and return. */ bool ProcessError (const nsErrors::CException&) throw(); operator const ::GtkWindow* () const throw(); operator ::GtkWindow* () throw(); private : CGtkGUI& operator= (const CGtkGUI&); CGtkGUI (const CGtkGUI&); void SetNoRoot () throw(); void SetRoot () throw(); void SetWindowIcons () throw(); unsigned CreateProfile (unsigned CellNum) throw(); void SelectMatchingProfile (const nsWireless::CCell&) throw(); void SelectMatchingProfile (unsigned ProfileI) throw(); bool ChangeModule (const std::string& = std::string()) throw (nsErrors::CException); void SelectCurrentCell () throw (nsErrors::CSystemExc); void SelectCurrentCell (const nsWireless::CMacAddress&) throw(); void SetIPFromProfile (unsigned ProfileI) throw (nsErrors::CException); void RefreshLinkStatus () throw (nsErrors::CException); /** \param unsigned The TX rate in Mbps. */ void RefreshLinkStatus (const nsWireless::CQuality&, unsigned, const nsWireless::CMacAddress&) throw (nsErrors::CException); bool RefreshStats () throw(); /** \param unsigned The TX rate in Mbps. */ void RefreshTray (const nsWireless::CQuality&, unsigned) throw(); void LoadOptions () throw(); void StoreProfiles () throw(); void StoreOptions () throw(); bool IsIgnored () const throw(); void IsIgnored (bool) throw(); bool IsStatsAvailable () const throw(); void IsStatsAvailable (bool) throw(); bool BringIfaceUp () throw(); void IfaceIsDown () throw(); void TrayIconMenu (::GdkEventButton&) throw(); ::GtkWidget* MakeMenuVisibilityItem () throw(); ::GtkWidget* MakeMenuProfileItem() throw(); ::GtkWidget* MakeMenuExitItem() throw(); enum PageNum_e {LinkStatus, Stats, Profiles, SiteSurvey, Preferences, Private}; enum {IsRootF = 1, IsIgnoredF = 2, IsStatsAvailableF = 4}; std::auto_ptr m_pModule; ::GtkWindow* const m_pWindow; ::GtkNotebook* const m_pNoteBook; // I use this because C++ exception can't go through gtk. nsErrors::CException m_Exc; CLinkStatusTab m_LinkStatusTab; unsigned m_GlobalTimer; CStatsPage m_StatsPage; std::auto_ptr m_pIface; CSiteSurveyTab m_SiteSurveyTab; CellVec_t m_CellVec; unsigned m_SiteSurveyTabTimer; unsigned m_TimeRemaining; CProfileTab m_ProfileTab; CTrayIcon m_TrayIcon; std::string m_ToolTipHeader; unsigned char m_Flags; CPrefsPage m_PrefsPage; unsigned m_LeaveRootModeTimer; unsigned m_CurrentRateIndex; ::GtkMenuShell* m_pTrayMenu; ::gulong m_ExitHandlerID; static int DeleteCallBack (::GtkWidget*, ::GdkEvent*, void*) throw(); static void PageSwitchCallBack (::GtkNotebook*, ::GtkNotebookPage*, PageNum_e, CGtkGUI*) throw(); static bool GlobalTimerWithTrayCallBack (CGtkGUI*) throw(); static bool GlobalTimerWithoutTrayCallBack (CGtkGUI*) throw(); static bool RefreshCellListCallBack (CGtkGUI*) throw(); static void TrayIconClickedCallBack (CGtkGUI*, ::GdkEventButton*) throw(); static void ChangeInterfaceCallBack (CGtkGUI*) throw(); static void AutoLeaveRootModeCallBack (CGtkGUI*) throw(); static bool LeaveRootModeTimerCallBack (CGtkGUI*) throw(); static void RootModeChangedCallBack (CGtkGUI*) throw(); static void RateChangedCallBack (CGtkGUI*) throw(); static bool RefreshRateDelayedCallBack (CGtkGUI*) throw(); static void DisplayTrayIconButtonCallBack (CGtkGUI*) throw(); static void StartMinimizedButtonCallBack (CGtkGUI*) throw(); static void IfaceStatusChangedCallBack (CGtkGUI*) throw(); static void HideCallBack (CGtkGUI*) throw(); static void ShowCallBack (CGtkGUI*) throw(); static void CreateProfileAndApplyCallBack (CGtkGUI*) throw(); static void ApplyProfileTrayCallBack (::gpointer) throw(); }; // CGtkGUI } // namespace nsGUI #include "private/GtkGUI.hxx" #endif // __GTKGUI_H__ RutilTv0.18/include/RTModules.h0000644000175000017500000003525610722350737016025 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTModules.h \author Romain BONDUE \date 19/08/2005 */ #ifndef __RTMODULES_H__ #define __RTMODULES_H__ #include #include #include // std::auto_ptr<> #include "Module.h" #include "UserData.h" #include "CWE17Module.h" #include "ProfileEditor.h" #include "WWidgets.h" #include "RTDrivers.h" namespace nsGUI { class CGtkGUI; class CRT2500ConfigDialog : public CSharedConfigDialog { public : CRT2500ConfigDialog () throw(); private : static void ModeChangedCallBack (::GtkToggleButton*, CRT2500ConfigDialog*) throw(); }; // CRT2500ConfigDialog class CRTxxConfigDialog : public CSharedConfigDialog { public : CRTxxConfigDialog () throw(); private : static void ModeChangedCallBack (::GtkToggleButton*, CRTxxConfigDialog*) throw(); }; // CRTxxConfigDialog } // namespace nsGUI namespace nsCore { class CRT2400CLIModule : public ICLIModule { public : CRT2400CLIModule (const std::string&, const std::string&) throw (nsErrors::CException, std::bad_alloc); ~CRT2400CLIModule () throw(); const nsUserData::CProfile& GetProfile (unsigned) const throw(); void ApplyProfile (unsigned) throw (nsErrors::CSystemExc); unsigned GetNbProfile () const throw(); nsWireless::IDriver& GetDriver () throw(); const nsWireless::IDriver& GetDriver () const throw(); private : CRT2400CLIModule (const CRT2400CLIModule&); CRT2400CLIModule& operator = (const CRT2400CLIModule&); nsWireless::CRT2400Driver m_Driver; nsUserData::CProfilesFile m_ProfilesFile; }; // CRT2400CLIModule class CRT2400Module : public IModule { public : CRT2400Module (const std::string&, const std::string&) throw (nsErrors::CException, std::bad_alloc); ~CRT2400Module () throw(); void BecomeRoot () throw (nsErrors::CException, std::bad_alloc); nsWireless::IDriver& GetDriver () throw(); const nsWireless::IDriver& GetDriver () const throw(); nsUserData::CProfile* NewProfile (::GtkWindow*) throw(); nsUserData::CProfile* NewProfile (::GtkWindow*, const nsWireless::CCell&) throw(); bool EditProfile (::GtkWindow*, unsigned) throw(); void DeleteProfile (unsigned) throw(); void ApplyProfile (unsigned) throw (nsErrors::CSystemExc); void ApplyProfile (unsigned, const nsWireless::CMacAddress&) throw (nsErrors::CSystemExc); nsUserData::CProfile& GetProfile (unsigned) throw(); unsigned GetNbProfile () const throw(); void RecordProfiles () throw (nsErrors::CException); ::GtkWidget* GetPrivateTab () throw(); protected : static const char* const NewProfileDefaultName; private : CRT2400Module (const CRT2400Module&); CRT2400Module& operator= (const CRT2400Module&); nsUserData::CProfile* EditNewProfile (::GtkWindow*) throw(); std::auto_ptr m_pDriver; CProfileEditor m_ProfileEditor; nsUserData::CProfilesFile m_ProfilesFile; }; // CRT2400Module class CRTAdvancedCLIModule : public ICLIModule { public : ~CRTAdvancedCLIModule () throw(); const nsUserData::CProfile& GetProfile (unsigned) const throw(); void ApplyProfile (unsigned) throw (nsErrors::CSystemExc); unsigned GetNbProfile () const throw(); nsWireless::IDriver& GetDriver () throw(); const nsWireless::IDriver& GetDriver () const throw(); protected : CRTAdvancedCLIModule (nsWireless::CRTAdvancedDriver*, const std::string&) throw (nsErrors::CException, std::bad_alloc); nsUserData::CProfilesFile& GetProfilesFile () throw(); const nsUserData::CProfilesFile& GetProfilesFile () const throw(); private : CRTAdvancedCLIModule (const CRTAdvancedCLIModule&); CRTAdvancedCLIModule& operator = (const CRTAdvancedCLIModule&); std::auto_ptr m_pDriver; nsUserData::CProfilesFile m_ProfilesFile; }; // CRTAdvancedCLIModule class CRTAdvancedModule : public IModule { public : ~CRTAdvancedModule () throw(); nsWireless::IDriver& GetDriver () throw(); const nsWireless::IDriver& GetDriver () const throw(); nsUserData::CProfile* NewProfile (::GtkWindow*) throw(); nsUserData::CProfile* NewProfile (::GtkWindow*, const nsWireless::CCell&) throw(); bool EditProfile (::GtkWindow*, unsigned) throw(); void DeleteProfile (unsigned) throw(); void ApplyProfile (unsigned) throw (nsErrors::CSystemExc); void ApplyProfile (unsigned, const nsWireless::CMacAddress&) throw (nsErrors::CSystemExc); nsUserData::CProfile& GetProfile (unsigned) throw(); unsigned GetNbProfile () const throw(); void RecordProfiles () throw (nsErrors::CException); ::GtkWidget* GetPrivateTab () throw(); protected : CRTAdvancedModule (nsWireless::CRTAdvancedDriver*, nsGUI::CConfigDialog*, const std::string&, nsGUI::CGtkGUI*, bool AdHofdmSupport) throw (nsErrors::CException, std::bad_alloc); void CreateCBox (const char* [], unsigned, int, const char*, unsigned, void (*) (::GtkComboBox*, CRTAdvancedModule*)) throw(); void CreateCheckButton (const char*, unsigned, unsigned, bool, void (*) (::GtkToggleButton*, CRTAdvancedModule*)) throw(); void SetDriver (nsWireless::CRTAdvancedDriver*) throw(); nsUserData::CProfilesFile& GetProfilesFile () throw(); const nsUserData::CProfilesFile& GetProfilesFile () const throw(); static const char* const NewProfileDefaultName; CProfileEditor& GetProfileEditor () throw(); const CProfileEditor& GetProfileEditor () const throw(); nsUserData::CProfile* EditNewProfile (::GtkWindow*) throw(); private : CRTAdvancedModule (const CRTAdvancedModule&); CRTAdvancedModule& operator= (const CRTAdvancedModule&); std::auto_ptr m_pDriver; CProfileEditor m_ProfileEditor; nsUserData::CProfilesFile m_ProfilesFile; // Private tab : ::GtkTable* const m_pTable; nsGUI::CGtkGUI* const m_pUI; unsigned m_CurrentActiveBoxItem; bool m_IsSkipped; typedef void (nsWireless::CRTAdvancedDriver::*DriverCBoxMember_t) (int); void CommonCBoxCallBack (DriverCBoxMember_t, ::GtkComboBox*) throw(); typedef void (nsWireless::CRTAdvancedDriver::*DriverButtonMember_t) (bool); void CommonCButtonCallBack (DriverButtonMember_t, ::GtkToggleButton*) throw(); void ResumePreviousState (::GtkComboBox*) throw(); static void ModeCallBack (::GtkComboBox*, CRTAdvancedModule*) throw(); static void BGProtectionCallBack (::GtkComboBox*, CRTAdvancedModule*) throw(); static void TxPreambleCallBack (::GtkComboBox*, CRTAdvancedModule*) throw(); static void TxBurstCallBack (::GtkToggleButton*, CRTAdvancedModule*) throw(); static void TurboRateCallBack (::GtkToggleButton*, CRTAdvancedModule*) throw(); static void AdHocOFDMCallBack (::GtkToggleButton*, CRTAdvancedModule*) throw(); static void RfmontxCallBack (::GtkToggleButton*, CRTAdvancedModule*) throw(); static void CBoxFocusCallBack (::GtkComboBox*, bool, CRTAdvancedModule*) throw(); }; // CRTAdvancedModule class CRT2500CLIModule : public CRTAdvancedCLIModule { public : CRT2500CLIModule (const std::string&, const std::string&) throw (nsErrors::CException, std::bad_alloc); }; // CRT2500CLIModule class CRT2500Module : public CRTAdvancedModule { public : CRT2500Module (const std::string&, const std::string&, nsGUI::CGtkGUI*) throw (nsErrors::CException, std::bad_alloc); void BecomeRoot () throw (nsErrors::CException, std::bad_alloc); nsUserData::CProfile* NewProfile (::GtkWindow*, const nsWireless::CCell&) throw(); }; // CRT2500Module class CRT61CLIModule : public CRTAdvancedCLIModule { public : CRT61CLIModule (const std::string&, const std::string&) throw (nsErrors::CException, std::bad_alloc); }; // CRT61LIModule class CRT61Module : public CRTAdvancedModule { public : CRT61Module (const std::string&, const std::string&, nsGUI::CGtkGUI*) throw (nsErrors::CException, std::bad_alloc); void BecomeRoot () throw (nsErrors::CException, std::bad_alloc); }; // CRT61Module class CRT73Module : public CRTAdvancedModule { public : CRT73Module (const std::string&, const std::string&, nsGUI::CGtkGUI*) throw (nsErrors::CException, std::bad_alloc); void BecomeRoot () throw (nsErrors::CException, std::bad_alloc); }; // CRT73Module class CRT73CLIModule : public CRTAdvancedCLIModule { public : CRT73CLIModule (const std::string&, const std::string&) throw (nsErrors::CException, std::bad_alloc); }; // CRT73LIModule class CRT2570CLIModule : public ICLIModule { public : CRT2570CLIModule (const std::string&, const std::string&) throw (nsErrors::CException, std::bad_alloc); ~CRT2570CLIModule () throw(); const nsUserData::CProfile& GetProfile (unsigned) const throw(); void ApplyProfile (unsigned) throw (nsErrors::CSystemExc); unsigned GetNbProfile () const throw(); nsWireless::IDriver& GetDriver () throw(); const nsWireless::IDriver& GetDriver () const throw(); private : CRT2570CLIModule (const CRT2570CLIModule&); CRT2570CLIModule& operator = (const CRT2570CLIModule&); nsWireless::CRT2570Driver m_Driver; nsUserData::CProfilesFile m_ProfilesFile; }; // CRT2570CLIModule class CRT2570Module : public IModule { public : CRT2570Module (const std::string&, const std::string&, nsGUI::CGtkGUI*) throw (nsErrors::CException, std::bad_alloc); ~CRT2570Module () throw(); void BecomeRoot () throw (nsErrors::CException, std::bad_alloc); nsWireless::IDriver& GetDriver () throw(); const nsWireless::IDriver& GetDriver () const throw(); nsUserData::CProfile* NewProfile (::GtkWindow*) throw(); nsUserData::CProfile* NewProfile (::GtkWindow*, const nsWireless::CCell&) throw(); bool EditProfile (::GtkWindow*, unsigned) throw(); void DeleteProfile (unsigned) throw(); void ApplyProfile (unsigned) throw (nsErrors::CSystemExc); void ApplyProfile (unsigned, const nsWireless::CMacAddress&) throw (nsErrors::CSystemExc); nsUserData::CProfile& GetProfile (unsigned) throw(); unsigned GetNbProfile () const throw(); void RecordProfiles () throw (nsErrors::CException); ::GtkWidget* GetPrivateTab () throw(); protected : static const char* const NewProfileDefaultName; void BuildPrivateTab () throw(); private : CRT2570Module (const CRT2570Module&); CRT2570Module& operator= (const CRT2570Module&); nsUserData::CProfile* EditNewProfile (::GtkWindow*) throw(); std::auto_ptr m_pDriver; CProfileEditor m_ProfileEditor; nsUserData::CProfilesFile m_ProfilesFile; nsGUI::CGtkGUI* const m_pUI; // Private tab : ::GtkBox* const m_pBox; unsigned m_CurrentActiveBoxItem; bool m_IsSkipped; typedef void (nsWireless::CRT2570Driver::*DriverButtonMember_t) (bool); void CommonCButtonCallBack (DriverButtonMember_t, ::GtkToggleButton*) throw(); typedef void (nsWireless::CRT2570Driver::*DriverBoxMember_t) (int); void CommonCBoxCallBack (DriverBoxMember_t, ::GtkComboBox*) throw(); void ResumePreviousState (::GtkComboBox*) throw(); static void AdhocModeCallBack (::GtkComboBox*, CRT2570Module*) throw(); static void PrismHeaderCallBack (::GtkComboBox*, CRT2570Module*) throw(); static void RfmontxCallBack (::GtkToggleButton*, CRT2570Module*) throw(); static void CBoxFocusCallBack (::GtkComboBox*, bool, CRT2570Module*) throw(); }; // CRT2570Module } // namespace nsCore #include "private/RTModules.hxx" #endif // __RTMODULES_H__ RutilTv0.18/include/WE17Driver.h0000644000175000017500000001133510543033307015766 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file WE17Driver.h \author Romain BONDUE \date 05/07/2005 */ #ifndef __WE17DRIVER_H__ #define __WE17DRIVER_H__ #include extern "C"{ // Compilation problems if socket.h is not included (or after wireless.h). #include // Those 3 headers were included by wireless.h until WE21. #include /* for "caddr_t" et al */ #include /* for "struct sockaddr" et al */ #include /* for IFNAMSIZ and co... */ #include } #if WIRELESS_EXT < 16 #error Invalid wireless extension version : require at least version 16. #endif #include "IDriver.h" namespace nsWireless { class CWE17Driver : public IDriver { public : CWE17Driver (const std::string&) throw (nsErrors::CSystemExc); ~CWE17Driver () throw(); std::string GetDeviceName () const throw(); std::string GetSSID () const throw (nsErrors::CSystemExc); void SetSSID (const std::string&) throw (nsErrors::CSystemExc); double GetFrequency () const throw (nsErrors::CException); void SetFrequency (double) throw (nsErrors::CSystemExc); unsigned GetChannel () const throw (nsErrors::CException); void SetChannel (unsigned) throw (nsErrors::CSystemExc); CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); Mode_e GetMode () const throw (nsErrors::CSystemExc); void SetMode (Mode_e) throw (nsErrors::CSystemExc); CQuality GetQuality () const throw (nsErrors::CSystemExc); int GetTxRate () const throw (nsErrors::CSystemExc); void SetTxRate (int) throw (nsErrors::CSystemExc); CMacAddress GetAPMacAddr () const throw (nsErrors::CSystemExc); void SetAPMacAddr (const CMacAddress&) throw (std::bad_alloc, nsErrors::CSystemExc); /* Don't use Scan() too often : * - The driver may not be ready (EAGAIN). * - "The scanning operation disable normal network traffic" * (Jean Tourrilhes). It has also some others side effects, * see the comments in iwlib.c . */ void Scan () throw (nsErrors::CSystemExc); void GetScanResult (std::vector&) const throw (nsErrors::CException, std::bad_alloc); unsigned GetMaxSSIDSize () const throw(); unsigned GetMaxKeySize () const throw(); const std::vector& GetSupportedFreq () const throw(); void GetSupportedRates (std::vector&) const throw (nsErrors::CSystemExc); const std::string& GetProtoName () const throw(); void Commit () throw (nsErrors::CSystemExc); protected : void Ioctl (int, const std::string&) const throw (nsErrors::CSystemExc); void AddSupportedFreq (unsigned, double) throw(); unsigned GetPrivateIoctls (::iw_priv_args*, unsigned) throw (nsErrors::CSystemExc); CFreq GetMatchingFreq (unsigned, double = 0) const throw(); mutable ::iwreq_data& m_Data; private : /** \return A negative value for a channel, a positive for a * frequency. */ double GetDriverFreqValue () const throw (nsErrors::CSystemExc); unsigned FillCellVec (const ::iw_event*, std::vector&) const throw (nsErrors::CException); std::string m_ProtoName; mutable ::iwreq m_Req; std::vector m_SupportedFreqVec; }; // CWE17Driver } // namespace nsWireless #include "private/WE17Driver.hxx" #endif // __WE17DRIVER_H__ RutilTv0.18/include/Module.h0000644000175000017500000000707010712363523015361 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Module.h \author Romain BONDUE \date 18/08/2005 */ #ifndef __MODULE_H__ #define __MODULE_H__ #include #include extern "C"{ #include } #include "Parameters.h" #include "Exceptions.h" namespace nsWireless { class IDriver; class CCell; class CDeviceInfo; class CMacAddress; } // namespace nsWireless namespace nsUserData{class CProfile;} namespace nsGUI{class CGtkGUI;} namespace nsCore { class ICLIModule { public : virtual ~ICLIModule () throw() {} virtual const nsUserData::CProfile& GetProfile (unsigned) const throw() = 0; virtual void ApplyProfile (unsigned) throw (nsErrors::CSystemExc) = 0; virtual unsigned GetNbProfile () const throw() = 0; virtual nsWireless::IDriver& GetDriver () throw() = 0; virtual const nsWireless::IDriver& GetDriver () const throw() = 0; }; // ICLIModule class IModule { public : virtual ~IModule () throw() {} virtual nsWireless::IDriver& GetDriver () throw() = 0; virtual const nsWireless::IDriver& GetDriver () const throw() = 0; virtual nsUserData::CProfile* NewProfile (::GtkWindow*) throw() = 0; virtual nsUserData::CProfile* NewProfile (::GtkWindow*, const nsWireless::CCell&) throw() = 0; virtual bool EditProfile (::GtkWindow*, unsigned) throw() = 0; virtual void DeleteProfile (unsigned) throw() = 0; virtual void ApplyProfile (unsigned) throw (nsErrors::CSystemExc) = 0; virtual void ApplyProfile (unsigned, const nsWireless::CMacAddress&) throw (nsErrors::CSystemExc) = 0; virtual nsUserData::CProfile& GetProfile (unsigned) throw() = 0; virtual unsigned GetNbProfile () const throw() = 0; virtual void RecordProfiles () throw (nsErrors::CException) = 0; /** \return A GUI component to set driver specific parameters (may * return 0 if none). */ virtual ::GtkWidget* GetPrivateTab () throw() = 0; virtual void BecomeRoot () throw (nsErrors::CException, std::bad_alloc) = 0; }; // IModule void GetWirelessDevice (std::vector&) throw (nsErrors::CException); bool IsSupported (const nsWireless::CDeviceInfo&) throw(); IModule* MakeModule (const nsWireless::CDeviceInfo&, nsGUI::CGtkGUI*) throw (nsErrors::CException, std::bad_alloc); ICLIModule* MakeCLIModule (const nsWireless::CDeviceInfo&) throw (nsErrors::CException, std::bad_alloc); } // namespace nsCore #endif // __MODULE_H__ RutilTv0.18/include/IfaceMsgHandler.h0000644000175000017500000000261310446611443017107 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file IfaceMsgHandler.h \author Romain BONDUE \date 09/06/06 */ #ifndef __IFACEMSGHANDLER_H__ #define __IFACEMSGHANDLER_H__ #include #include // std::bad_alloc #include "IMsgHandler.h" #include "NetTools.h" #include "Msg.h" #include "Exceptions.h" namespace nsRoot { class CIfaceMsgHandler : public IMsgHandler { public : CMsg operator () (const CMsg&) throw (nsErrors::CException, std::bad_alloc); private : nsNet::CInterface m_Iface; }; // CIfaceMsgHandler } // namespace nsRoot #endif // __IFACEMSGHANDLER_H__ RutilTv0.18/include/RTDriversRoot.h0000644000175000017500000002065710636002145016665 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTDriversRoot.h \author Romain BONDUE \date 19/02/2006 */ #ifndef __RTDRIVERSROOT_H__ #define __RTDRIVERSROOT_H__ #include "RTDrivers.h" #include "SuWProtocol.h" namespace nsWireless { class CRT2400DriverRoot : public CRT2400Driver, protected CSuWProtocol { public : CRT2400DriverRoot (const std::string&) throw (nsErrors::CException, std::bad_alloc); ~CRT2400DriverRoot () throw(); void SetSSID (const std::string&) throw (nsErrors::CSystemExc); /** \param The unit is the GHz (2.462 for instance). */ void SetFrequency (double) throw (nsErrors::CSystemExc); void SetChannel (unsigned) throw (nsErrors::CSystemExc); CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); void SetMode (Mode_e) throw (nsErrors::CSystemExc); /** \param The unit is the Kbps. */ void SetTxRate (int) throw (nsErrors::CSystemExc); void SetAPMacAddr (const CMacAddress&) throw (std::bad_alloc, nsErrors::CSystemExc); void Scan () throw (nsErrors::CSystemExc); }; // CRT2400DriverRoot // FIXME Lazely copy/paste this class. class CRT2500DriverRoot : public CRT2500Driver, protected CSuWProtocol { public : CRT2500DriverRoot (const std::string&) throw (nsErrors::CException, std::bad_alloc); ~CRT2500DriverRoot () throw(); void SetSSID (const std::string&) throw (nsErrors::CSystemExc); /** \param The unit is the GHz (2.462 for instance). */ void SetFrequency (double) throw (nsErrors::CSystemExc); void SetChannel (unsigned) throw (nsErrors::CSystemExc); CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); void SetMode (Mode_e) throw (nsErrors::CSystemExc); /** \param The unit is the Kbps. */ void SetTxRate (int) throw (nsErrors::CSystemExc); void SetAPMacAddr (const CMacAddress&) throw (std::bad_alloc, nsErrors::CSystemExc); void Scan () throw (nsErrors::CSystemExc); void SetWirelessMode (WirelessMode_e) throw (nsErrors::CSystemExc); void SetTxBurst (bool) throw (nsErrors::CSystemExc); void SetBGProtection (BGProtection_e) throw (nsErrors::CSystemExc); void SetTxPreamble (TxPreamble_e) throw (nsErrors::CSystemExc); void SetTurboRate (bool) throw (nsErrors::CSystemExc); void SetAdHocOFDM (bool) throw (nsErrors::CSystemExc); void SetRfmontx (bool) throw (nsErrors::CSystemExc); }; // CRT2500DriverRoot class CRT2570DriverRoot : public CRT2570Driver, protected CSuWProtocol { public : CRT2570DriverRoot (const std::string&) throw (nsErrors::CException, std::bad_alloc); ~CRT2570DriverRoot () throw(); void SetSSID (const std::string&) throw (nsErrors::CSystemExc); /** \param The unit is the GHz (2.462 for instance). */ void SetFrequency (double) throw (nsErrors::CSystemExc); void SetChannel (unsigned) throw (nsErrors::CSystemExc); CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); void SetMode (Mode_e) throw (nsErrors::CSystemExc); /** \param The unit is the Kbps. */ void SetTxRate (int) throw (nsErrors::CSystemExc); void SetAPMacAddr (const CMacAddress&) throw (std::bad_alloc, nsErrors::CSystemExc); void Scan () throw (nsErrors::CSystemExc); }; // CRT2570DriverRoot class CRT61DriverRoot : public CRT61Driver, protected CSuWProtocol { public : CRT61DriverRoot (const std::string&) throw (nsErrors::CException, std::bad_alloc); ~CRT61DriverRoot () throw(); void SetSSID (const std::string&) throw (nsErrors::CSystemExc); /** \param The unit is the GHz (2.462 for instance). */ void SetFrequency (double) throw (nsErrors::CSystemExc); void SetChannel (unsigned) throw (nsErrors::CSystemExc); CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); void SetMode (Mode_e) throw (nsErrors::CSystemExc); /** \param The unit is the Kbps. */ void SetTxRate (int) throw (nsErrors::CSystemExc); void SetAPMacAddr (const CMacAddress&) throw (std::bad_alloc, nsErrors::CSystemExc); void Scan () throw (nsErrors::CSystemExc); void SetWirelessMode (WirelessMode_e) throw (nsErrors::CSystemExc); void SetTxBurst (bool) throw (nsErrors::CSystemExc); void SetBGProtection (BGProtection_e) throw (nsErrors::CSystemExc); void SetTxPreamble (TxPreamble_e) throw (nsErrors::CSystemExc); void SetTurboRate (bool) throw (nsErrors::CSystemExc); void SetAdHocOFDM (bool) throw (nsErrors::CSystemExc); void SetRfmontx (bool) throw (nsErrors::CSystemExc); }; // CRT61DriverRoot class CRT73DriverRoot : public CRT73Driver, protected CSuWProtocol { public : CRT73DriverRoot (const std::string&) throw (nsErrors::CException, std::bad_alloc); ~CRT73DriverRoot () throw(); void SetSSID (const std::string&) throw (nsErrors::CSystemExc); /** \param The unit is the GHz (2.462 for instance). */ void SetFrequency (double) throw (nsErrors::CSystemExc); void SetChannel (unsigned) throw (nsErrors::CSystemExc); CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); void SetMode (Mode_e) throw (nsErrors::CSystemExc); /** \param The unit is the Kbps. */ void SetTxRate (int) throw (nsErrors::CSystemExc); void SetAPMacAddr (const CMacAddress&) throw (std::bad_alloc, nsErrors::CSystemExc); void Scan () throw (nsErrors::CSystemExc); void SetWirelessMode (WirelessMode_e) throw (nsErrors::CSystemExc); void SetTxBurst (bool) throw (nsErrors::CSystemExc); void SetBGProtection (BGProtection_e) throw (nsErrors::CSystemExc); void SetTxPreamble (TxPreamble_e) throw (nsErrors::CSystemExc); void SetTurboRate (bool) throw (nsErrors::CSystemExc); void SetAdHocOFDM (bool) throw (nsErrors::CSystemExc); void SetRfmontx (bool) throw (nsErrors::CSystemExc); }; // CRT73DriverRoot } // namespace nsWireless #include "private/RTDriversRoot.hxx" #endif // __RTDRIVERSROOT_H__ RutilTv0.18/include/IDriver.h0000644000175000017500000000764210712363523015505 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file IDriver.h \author Romain BONDUE \date 30/11/05 */ #ifndef __IDRIVER_H__ #define __IDRIVER_H__ #include #include #include // std::bad_alloc #include "Exceptions.h" #include "Parameters.h" namespace nsWireless { class IDriver { public : virtual ~IDriver () throw() {} virtual const std::string& GetProtoName () const throw() = 0; virtual std::string GetDeviceName () const throw() = 0; virtual std::string GetSSID () const throw (nsErrors::CSystemExc) = 0; virtual void SetSSID (const std::string&) throw (nsErrors::CSystemExc) = 0; // FIXME The exception profile. /** \return The unit is the GHz (2.462 for instance). */ virtual double GetFrequency () const throw (nsErrors::CException) = 0; /** \param The unit is the GHz (2.462 for instance). */ virtual void SetFrequency (double) throw (nsErrors::CSystemExc) = 0; // FIXME The exception profile. virtual unsigned GetChannel () const throw (nsErrors::CException) = 0; virtual void SetChannel (unsigned) throw (nsErrors::CSystemExc) = 0; // Unlike others GetXXX() members, this one requires root privileges. virtual CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc) = 0; virtual void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc) = 0; virtual Mode_e GetMode () const throw (nsErrors::CSystemExc) = 0; virtual void SetMode (Mode_e) throw (nsErrors::CSystemExc) = 0; virtual CQuality GetQuality () const throw (nsErrors::CSystemExc) = 0; /** \return The unit is the Kbps. */ virtual int GetTxRate () const throw (nsErrors::CSystemExc) = 0; /** \param The unit is the Kbps. */ virtual void SetTxRate (int) throw (nsErrors::CSystemExc) = 0; virtual CMacAddress GetAPMacAddr () const throw (nsErrors::CSystemExc) = 0; virtual void SetAPMacAddr (const CMacAddress&) throw (std::bad_alloc, nsErrors::CSystemExc) = 0; virtual void Scan () throw (nsErrors::CSystemExc) = 0; virtual void GetScanResult (std::vector&) const throw (nsErrors::CException, std::bad_alloc) = 0; /** \return The maximum SSID size in byte. */ virtual unsigned GetMaxSSIDSize () const throw() = 0; /** \return The maximum key size in byte. */ virtual unsigned GetMaxKeySize () const throw() = 0; virtual const std::vector& GetSupportedFreq () const throw() = 0; // FIXME ? "auto" mode possible too. // May don't fill the vector if the driver doesn't support this. virtual void GetSupportedRates (std::vector&) const throw (nsErrors::CSystemExc) = 0; virtual void Commit () throw (nsErrors::CSystemExc) = 0; }; // IDriver } // namespace nsWireless #endif // __IDRIVER_H__ RutilTv0.18/include/Parameters.h0000644000175000017500000002142710722350737016245 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Parameters.h \author Romain BONDUE \date 07/07/2005 */ #ifndef __PARAMETERS_H__ #define __PARAMETERS_H__ #include #include // std::bad_alloc extern "C"{ // Compilation problems if socket.h is not included (or after wireless.h) #include // Those 3 headers were included by wireless.h until WE21. #include /* for "caddr_t" et al */ #include /* for "struct sockaddr" et al */ #include /* for IFNAMSIZ and co... */ #include // IW_MODE_AUTO, IW_MODE_ADHOC etc... } #include "Exceptions.h" // CRTExc namespace nsWireless { enum Mode_e {Auto = IW_MODE_AUTO, AdHoc = IW_MODE_ADHOC, Managed = IW_MODE_INFRA, Master = IW_MODE_MASTER, Repeater = IW_MODE_REPEAT, Secondary = IW_MODE_SECOND, Monitor = IW_MODE_MONITOR, Unknown}; const std::string& GetModeName (Mode_e) throw(); Mode_e GetModeFromName (const std::string&) throw(); Mode_e GetMatchingMode (Mode_e) throw(); class CQuality { public : /** \param LinkQuality in pourcentage * \param SignalLevel in dBm * \param NoiseLevel in dBm */ CQuality (unsigned short LinkQuality = 0, short SignalLevel = -256, short NoiseLevel = -256) throw(); unsigned short GetLinkQuality() const throw(); short GetSignalLevel () const throw(); short GetNoiseLevel () const throw(); private : unsigned short m_LinkQuality; short m_SignalLevel; short m_NoiseLevel; }; // CQuality class CDeviceInfo { public : CDeviceInfo (const std::string& DeviceName, const std::string&) throw(); const std::string& GetDeviceName () const throw(); const std::string& GetProtoName () const throw(); private : std::string m_DeviceName; std::string m_ProtoName; }; // CDeviceInfo class CHexaKey { public : class CBadFormatExc : public nsErrors::CRTExc {}; CHexaKey () throw(); CHexaKey (const char*, unsigned Size) throw (std::bad_alloc); /** \param Str Must only be composed of hexadecimal caracters. It can * also contain these separators : ' ', ':' and '-'. */ explicit CHexaKey (const std::string& Str) throw (CBadFormatExc); CHexaKey (const CHexaKey&) throw (std::bad_alloc); ~CHexaKey () throw(); CHexaKey& operator = (const CHexaKey&) throw (std::bad_alloc); bool Empty () const throw(); void Clear () throw(); const char* Get () const throw (std::bad_alloc); unsigned Size () const throw(); const std::string& GetStr () const throw(); void Set (const char*, unsigned) throw (std::bad_alloc); /** \param Str Must only be composed of hexadecimal caracters. It can * also contain these separators : ' ', ':' and '-'. */ void Set (std::string) throw (CBadFormatExc); void SetFromASCII (const std::string&) throw (std::bad_alloc); bool operator == (const CHexaKey&) const throw(); bool operator != (const CHexaKey&) const throw(); private : mutable unsigned m_Size; mutable char* m_Key; mutable std::string m_StrKey; }; // CHexaKey // Only for implementation purpose, there's no useful abstraction here. class CMacAddress : public CHexaKey { public : CMacAddress () throw(); /** \param Address Must be at least 6 bytes long, everything after the * 6th byte will be ignored. */ // explicit to don't mess with NTCTS, use a string instead. explicit CMacAddress (const char* Address) throw (std::bad_alloc); /** \param Address Must be at least 12 hexadecimal caracters long, It can also contain these separators : ' ', ':' and '-'. */ CMacAddress (const std::string& Address) throw (CBadFormatExc); /** \param Address Must be at least 6 bytes long, everything after the * 6th byte will be ignored. */ void Set (const char* Address) throw (std::bad_alloc); /** \param Address Must be at least 12 hexadecimal caracters long, It can also contain these separators : ' ', ':' and '-'. */ void Set (const std::string& Address) throw (CBadFormatExc); bool Empty () const throw(); static const unsigned Size = 6; private : void Set (const char*, unsigned) throw (std::bad_alloc); void SetFromASCII (const std::string&) throw (std::bad_alloc); void Check () throw (CBadFormatExc); }; // CMacAddress enum EncryptType_e {None, WEP, AES, TKIP, TKIPAES, UnknownEnc}; enum AuthType_e {Open, Shared, WPAPSK, WPANONE, WPA2PSK, WPA, WPA2, UnknownAuth}; const std::string& GetEncryptName (EncryptType_e) throw(); EncryptType_e GetEncryptFromName (const std::string&) throw(); const std::string& GetAuthName (AuthType_e) throw(); AuthType_e GetAuthFromName (const std::string&) throw(); class CEncryptionD // D for "Descriptor" { public : CEncryptionD (const CHexaKey& = CHexaKey(), AuthType_e = Open, EncryptType_e = None, unsigned DefaultKey = 0) throw (std::bad_alloc); CEncryptionD (const CEncryptionD&) throw (std::bad_alloc); CEncryptionD& operator = (const CEncryptionD&) throw (std::bad_alloc); EncryptType_e GetEncrypt () const throw(); AuthType_e GetAuth () const throw(); /** \warning No bound check! */ const CHexaKey& GetKey (unsigned = 0) const throw(); void SetEncrypt (EncryptType_e) throw(); void SetAuth (AuthType_e) throw(); /** \warning No bound check! */ void SetKey (const CHexaKey&, unsigned = 0) throw (std::bad_alloc); // Should be between 0 and MaxNbKey, UNCHECKED. void SetDefaultKey (unsigned) throw(); unsigned GetDefaultKey () const throw(); bool operator == (const CEncryptionD&) const throw(); static const unsigned MaxNbKey = 4; private : AuthType_e m_Auth; EncryptType_e m_Encrypt; CHexaKey m_KeyTab [MaxNbKey]; unsigned m_DefaultKey; }; // CEncryptionD class CCell { public : CCell () throw(); CCell (const CMacAddress&, Mode_e, const std::string&, const CEncryptionD&, unsigned, const CQuality&, unsigned) throw (std::bad_alloc); /* If the fields are empty or equal to 0 (except the Mode), * they haven't been set, I'm not sure there is any guaranty. */ const CMacAddress& GetAPMacAddress () const throw(); Mode_e GetMode () const throw(); const std::string& GetSSID () const throw(); void SetSSID (const std::string&) throw(); const CEncryptionD& GetEncryptionD () const throw(); CEncryptionD& GetEncryptionD () throw(); unsigned GetChannel () const throw(); const CQuality& GetQuality () const throw(); unsigned GetTxRate () const throw(); private : // FIXME ** AWFUL ** friend class CWE17Driver; // To set the fields efficiently. CCell (const CMacAddress&) throw(); // Used by IDriver. CMacAddress m_APAddr; Mode_e m_Mode; std::string m_SSID; CEncryptionD m_EncDescriptor; unsigned m_Channel; CQuality m_Quality; unsigned m_Rate; }; // CCell class CFreq { public : CFreq (unsigned, double) throw(); unsigned GetChannel () const throw(); double GetFrequency () const throw(); private : unsigned m_Channel; double m_Frequency; }; // CFreq } // namespace nsWireless #include "private/Parameters.hxx" #endif // __PARAMETERS_H__ RutilTv0.18/include/Exceptions.h0000644000175000017500000000334210360147547016260 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Exceptions.h \author Romain BONDUE \date 05/07/2005 */ #ifndef __EXCEPTIONS_H__ #define __EXCEPTIONS_H__ #include #include #include namespace nsErrors { class CException : public std::exception { public : CException (const std::string&, int) throw(); ~CException () throw(); const char* what () const throw(); const std::string& GetMsg () const throw(); int GetCode () const throw(); private : std::string m_Msg; int m_Code; }; // CException class CSystemExc : public CException { public : CSystemExc (const std::string&, int = errno) throw(); }; // CSystemExc template class CRTExc : public std::exception // RT for RunTime { public : const char* what () const throw(); }; // CRTExc } // namespace nsErrors #include "private/Exceptions.hxx" #endif // __EXCEPTIONS_H__ RutilTv0.18/include/CStatsPage.h0000644000175000017500000000374710436326255016145 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CStatsPage.h \author Romain BONDUE \date 08/05/2006 */ #ifndef __CSTATSPAGE_H__ #define __CSTATSPAGE_H__ extern "C"{ #include } namespace nsGUI { class CStatsPage { public : CStatsPage () throw(); void SetTXBytes (unsigned long) throw(); void SetTXPackets (unsigned long) throw(); void SetTXErrors (unsigned long) throw(); void SetCollisions (unsigned long) throw(); void SetRXBytes (unsigned long) throw(); void SetRXPackets (unsigned long) throw(); void SetRXErrors (unsigned long) throw(); operator ::GtkWidget* () throw(); operator const ::GtkWidget* () const throw(); protected : void BuildUI () throw(); void SetLabel (::GtkLabel*, unsigned long) throw(); private : ::GtkBox* const m_pBox; ::GtkLabel* const m_pTXBytes; ::GtkLabel* const m_pTXPackets; ::GtkLabel* const m_pTXErrors; ::GtkLabel* const m_pCollisions; ::GtkLabel* const m_pRXBytes; ::GtkLabel* const m_pRXPackets; ::GtkLabel* const m_pRXErrors; }; // CStatsPage } // namespace nsGUI #include "private/CStatsPage.hxx" #endif // __CSTATSPAGE_H__ RutilTv0.18/include/CSiteSurveyTab.h0000644000175000017500000000567010420722326017010 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CSiteSurveyTab.h \author Romain BONDUE \date 29/07/2005 */ #ifndef __CSITESURVEYTAB_H__ #define __CSITESURVEYTAB_H__ #include #include #include extern "C"{ #include } #include "CSelectableRowList.h" #include "Exceptions.h" namespace nsWireless { class CCell; class CMacAddress; } // namespace nsWireless namespace nsGUI { class CGtkGUI; typedef std::vector CellVec_t; class CSiteSurveyTab : protected CSelectableRowList { public : CSiteSurveyTab (CGtkGUI*) throw(); ~CSiteSurveyTab () throw(); operator ::GtkWidget* () throw(); /** \return The current associated cell, 0 if none.*/ const nsWireless::CCell* AddCells (const CellVec_t&, const nsWireless::CMacAddress&) throw(); void SetSelected (unsigned, bool) throw(); int GetSelectedRow () const throw(); void ScanningStarted () throw(); void ScanningStopped () throw(); protected : static const unsigned NbColumn = 11; enum {ButtonPos, SSIDPos, APMacPos, ModePos, LinkQPos, SignalLPos, NoiseLPos, ChannelPos, RatePos, EncryptPos, AuthPos}; void RowSelectedCallBack () throw(); void RowUnselectedCallBack () throw(); static const char* const ScanButtonLabel; private : ::GtkBox* const m_pVBox; ::GtkWidget* const m_pScanButton; ::GtkWidget* const m_pAddProfileButton; ::GtkWidget* const m_pConnectButton; bool m_IsScanning; static const char* ColumnTitle [NbColumn]; static const ::GType TabType [NbColumn]; static void ScanButtonCallBack (::GtkButton*, CSiteSurveyTab*) throw(); static void AddProfileButtonCallBack (::GtkButton*, CSiteSurveyTab*) throw(); static void ConnectButtonCallBack (::GtkButton*, CSiteSurveyTab*) throw(); }; // CSiteSurveyTab } // namespace nsGUI #include "private/CSiteSurveyTab.hxx" #endif // __CSITESURVEYTAB_H__ RutilTv0.18/include/CWirelessMsgHandler.h0000644000175000017500000000377111037203750020001 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CWirelessMsgHandler.h \author Romain BONDUE \date 17/02/06 */ #ifndef __CWIRELESSMSGHANDLER_H__ #define __CWIRELESSMSGHANDLER_H__ #include #include // std::bad_alloc #include #include "IMsgHandler.h" #include "IDriver.h" #include "Exceptions.h" namespace nsRoot { class CWirelessMsgHandler : public IMsgHandler { public : CWirelessMsgHandler () throw(); ~CWirelessMsgHandler () throw(); CMsg operator () (const CMsg&) throw (nsErrors::CException, std::bad_alloc); protected : nsWireless::IDriver* GetDriver () throw(); const nsWireless::IDriver* GetDriver () const throw(); virtual void SetDriver (const std::string&) throw (std::bad_alloc, nsErrors::CException); /* It hold the driver, meaning it will delete it. This function is * designed to help implemented the former. */ void SetDriver (nsWireless::IDriver*) throw(); private : std::auto_ptr m_pDriver; }; // CWirelessMsgHandler } // namespace nsRoot #include "private/CWirelessMsgHandler.hxx" #endif // __CWIRELESSMSGHANDLER_H__ RutilTv0.18/include/WE17DriverRoot.h0000644000175000017500000000436510375377200016645 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file WE17DriverRoot.h \author Romain BONDUE \date 17/02/2006 */ #ifndef __WE17DRIVERROOT_H__ #define __WE17DRIVERROOT_H__ #include "WE17Driver.h" #include "SuWProtocol.h" namespace nsWireless { class CWE17DriverRoot : public CWE17Driver, protected CSuWProtocol { public : CWE17DriverRoot (const std::string&) throw (nsErrors::CSystemExc, std::bad_alloc); ~CWE17DriverRoot () throw(); void SetSSID (const std::string&) throw (nsErrors::CSystemExc); /** \param The unit is the GHz (2.462 for instance). */ void SetFrequency (double) throw (nsErrors::CSystemExc); void SetChannel (unsigned) throw (nsErrors::CSystemExc); CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); void SetMode (Mode_e) throw (nsErrors::CSystemExc); /** \param The unit is the Kbps. */ void SetTxRate (int) throw (nsErrors::CSystemExc); void SetAPMacAddr (const CMacAddress&) throw (std::bad_alloc, nsErrors::CSystemExc); void Scan () throw (nsErrors::CSystemExc); }; // CWE17DriverRoot } // namespace nsWireless #include "private/WE17DriverRoot.hxx" #endif // __WE17DRIVERROOT_H__ RutilTv0.18/include/PrefsPage.h0000644000175000017500000000747111054617533016020 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file PrefsPage.h \author Romain BONDUE \date 19/07/2006 */ #ifndef __PREFSPAGE_H__ #define __PREFSPAGE_H__ #include #include extern "C"{ #include } namespace nsGUI { class CPrefsPage { public : CPrefsPage (bool) throw(); operator ::GtkWidget* () throw(); operator const ::GtkWidget* () const throw(); bool StartMinimized () const throw(); void StartMinimized (bool) throw(); // CallBack : void (*) (void*) void AddChangeInterfaceCallBack (::GCallback, void*) throw(); // CallBack : void (*) (void*) void AddRootModeChangedCallBack (::GCallback, void*) throw(); // Don't forget that this function will call the previous handlers. void SetRootMode (bool) throw(); // CallBack : void (*) (void*) void AddAutoLeaveRootModeCallBack (::GCallback, void*) throw(); /** \return 0 if disabled. The delay in second otherwise. */ unsigned GetAutoLeaveRootDelay () const throw(); /** \param 0 to disable. Must be a valid delay in second. */ void SetAutoLeaveRootDelay (unsigned) throw(); void SetRates (const std::vector&) throw(); int GetSelectedRate () const throw(); unsigned GetSelectedRateIndex () const throw(); void SetRateIndex (unsigned) throw(); // CallBack : void (*) (::GtkComboBox*, void*) void AddRateChangedCallBack (::GCallback, void*) throw(); bool DisplayTrayIcon () const throw(); void DisplayTrayIcon (bool) throw(); // CallBack : void (*) (void*) void AddTrayIconButtonCallBack (::GCallback, void*) throw(); // CallBack : void (*) (void*) void AddStartMinimizedCallBack (::GCallback, void*) throw(); // CallBack : void (*) (void*) void AddIfaceStatusChangeCallBack (::GCallback, void*) throw(); // false : down void IfaceStatus (bool) throw(); bool IfaceStatus () const throw(); void IfaceLabel (const std::string&) throw(); std::string IfaceLabel () const throw(); protected : void BuildUI (bool) throw(); private : ::GtkTable* const m_pTable; ::GtkCheckButton* const m_pStartMinimizedButton; ::GtkButton* const m_pAboutButton; ::GtkButton* const m_pChangeInterface; ::GtkToggleButton* const m_pRootModeButton; ::GtkComboBox* const m_pLeaveRootModeBox; ::GtkWidget* const m_pRatesLabel; unsigned m_NbRate; ::GtkComboBox* const m_pRatesBox; ::GtkCheckButton* const m_pTrayIconButton; ::GtkToggleButton* const m_pIfaceStatusButton; ::GtkLabel* m_pIfaceLabel; static void AboutButtonClicked (::GtkButton*, CPrefsPage*) throw(); static void TrayIconButtonClicked (::GtkToggleButton*, CPrefsPage*) throw(); }; // CPrefsPage } // namespace nsGUI #include "private/PrefsPage.hxx" #endif // __PREFSPAGE_H__ RutilTv0.18/include/WWidgets.h0000644000175000017500000002640510705153462015675 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file WWidgets.h \author Romain BONDUE \date 31/03/06 \warning GtkWidget are allocated and expected to be used, the wrapping object will NOT try to free it. */ #ifndef __WWIDGETS_H__ #define __WWIDGETS_H__ #include #include #include #include extern "C"{ #include } #include "Parameters.h" #include "UserData.h" // Only because of IPSetting_e. namespace nsGUI { template class CConvert : public std::unary_function { public : std::string operator () (const T&) throw(); }; // Convert template > class CComboBox { public : CComboBox () throw(); /** \warning Both parameters must not be null (0). */ CComboBox (const T*, unsigned) throw(); const T& GetActive () const throw(); unsigned GetActiveRow () const throw(); void SetActive (const T&) throw(); void SetElem (const T*, unsigned) throw(); operator ::GtkWidget* () throw(); operator const ::GtkWidget* () const throw(); private : CComboBox& operator = (const CComboBox&) throw(); CComboBox (const CComboBox&) throw(); ::GtkComboBox* const m_pBox; unsigned m_TabSize; const T* m_Tab; }; // CComboBox class CModeConvert : public CConvert { public : std::string operator () (const nsWireless::Mode_e&) throw(); }; // CModeConvert typedef CComboBox CModeComboBox; typedef CComboBox CChannelComboBox; class CEncryptConvert : public CConvert { public : std::string operator () (const nsWireless::EncryptType_e&) throw(); }; // CEncryptConvert typedef CComboBox CEncryptComboBox; class CAuthConvert : public CConvert { public : std::string operator () (const nsWireless::AuthType_e&) throw(); }; // CAuthConvert typedef CComboBox CAuthComboBox; class CKeyEntry { public : CKeyEntry () throw(); nsWireless::CHexaKey Get () const throw(); void Set (const nsWireless::CHexaKey&) throw(); void Clear () throw(); void ASCIIOnly (bool) throw(); bool ASCIIOnly () const throw(); operator ::GtkWidget* () throw(); operator const ::GtkWidget* () const throw(); operator ::GtkEntry* () throw(); operator const ::GtkEntry* () const throw(); private : CKeyEntry& operator = (const CKeyEntry&) throw(); CKeyEntry (const CKeyEntry&) throw(); static void NewTextTyped (::GtkEditable*, char*, int, int*, CKeyEntry*) throw(); static void ASCIIButtonToggled (::GtkToggleButton*, CKeyEntry*) throw(); ::GtkEntry* const m_pEntry; ::GtkToggleButton* const m_pIsASCIIButton; ::GtkBox* const m_pBox; }; // CKeyEntry template // N Must be at least 1. class CMultiKey { public : CMultiKey () throw(); operator ::GtkWidget* () throw(); operator const ::GtkWidget* () const throw(); // Value between 0 and N - 1, it is *not* checked. nsWireless::CHexaKey Get (unsigned) const throw(); void Set (const nsWireless::CHexaKey&, unsigned) throw(); void AdditionnalKeyAvailable (bool) throw(); unsigned GetNbKey () const throw(); void Clear () throw(); // Value between 0 and N - 1, it is *not* checked. CKeyEntry& GetKeyEntry (unsigned) throw(); // Value between 0 and N - 1, it is *not* checked. const CKeyEntry& GetKeyEntry (unsigned) const throw(); unsigned GetDefaultKey () const throw(); // Value between 0 and N - 1, it is *not* checked. void SetDefaultKey (unsigned) throw(); protected : void BuildUI () throw(); private : CMultiKey (const CMultiKey&); CMultiKey& operator = (const CMultiKey&); ::GtkVBox* const m_pBox; ::GtkExpander* const m_pKeysExpander; ::GtkComboBox* const m_pDefaultKeyBox; CKeyEntry m_KeyEntryTab [N]; }; // CMultiKey class CConfigDialog { public : CConfigDialog (const nsWireless::Mode_e*, unsigned, const std::vector&, const nsWireless::EncryptType_e*, unsigned, const nsWireless::AuthType_e*, unsigned) throw (std::bad_alloc); CConfigDialog (const nsWireless::Mode_e*, unsigned, const nsWireless::EncryptType_e*, unsigned, const nsWireless::AuthType_e*, unsigned) throw (std::bad_alloc); virtual ~CConfigDialog () throw(); bool Run (::GtkWindow*) throw(); void Hide () throw(); std::string GetConfigName () const throw(); void SetConfigName (const std::string&) throw(); std::string GetSSID () const throw(); void SetSSID (const std::string&) throw(); nsWireless::Mode_e GetMode () const throw(); void SetMode (nsWireless::Mode_e) throw(); unsigned GetChannel () const throw(); void SetChannel (unsigned) throw(); void SetAvailableChannel (const std::vector&) throw (std::bad_alloc); nsWireless::EncryptType_e GetEncrypt () const throw(); void SetEncrypt (nsWireless::EncryptType_e) throw(); nsWireless::AuthType_e GetAuth () const throw(); void SetAuth (nsWireless::AuthType_e) throw(); unsigned GetNbKey () const throw(); unsigned GetDefaultKey () const throw(); void SetDefaultKey (unsigned) throw(); /** \warning No bound check. */ nsWireless::CHexaKey GetKey (unsigned) const throw(); /** \warning No bound check. */ void SetKey (const nsWireless::CHexaKey&, unsigned) throw(); nsUserData::IPSetting_e GetIPSetting () const throw(); void SetIPSetting (nsUserData::IPSetting_e) throw(); operator ::GtkDialog* () throw(); operator const ::GtkDialog* () const throw(); protected : void BuildUI () throw(); CModeComboBox& GetModeBox () throw(); const CModeComboBox& GetModeBox () const throw(); const CChannelComboBox& GetChannelBox () const throw(); CEncryptComboBox& GetEncryptBox () throw(); const CEncryptComboBox& GetEncryptBox () const throw(); CAuthComboBox& GetAuthBox () throw(); const CAuthComboBox& GetAuthBox () const throw(); ::GtkEntry* GetNameEntry () throw(); const ::GtkEntry* GetNameEntry () const throw(); ::GtkEntry* GetSSIDEntry () throw(); const ::GtkEntry* GetSSIDEntry () const throw(); ::GtkBox* GetBox () throw(); const ::GtkBox* GetBox () const throw(); CMultiKey<4>& GetMultiKey () throw(); const CMultiKey<4>& GetMultiKey () const throw(); ::GtkRadioButton* GetIPNoneButton () throw(); const ::GtkRadioButton* GetIPNoneButton () const throw(); ::GtkRadioButton* GetIPDhcpButton () throw(); const ::GtkRadioButton* GetIPDhcpButton () const throw(); ::GtkRadioButton* GetIPStaticButton () throw(); const ::GtkRadioButton* GetIPStaticButton () const throw(); private : unsigned* m_ChannelTab; unsigned m_ChannelTabSize; ::GtkDialog* const m_pDialog; ::GtkEntry* const m_pNameEntry; ::GtkEntry* const m_pSSIDEntry; CModeComboBox m_ModeBox; CChannelComboBox m_ChannelBox; CEncryptComboBox m_EncryptBox; CAuthComboBox m_AuthBox; CMultiKey<4> m_MultiKey; ::GtkRadioButton* const m_pIPNoneButton; ::GtkRadioButton* const m_pIPDhcpButton; ::GtkRadioButton* const m_pIPStaticButton; }; // CConfigDialog // ? TODO ? Disable the channel box with some mode? class CSharedConfigDialog : public CConfigDialog { public : /* Auth [0] matches Enc1, Auth [1] matches Enc2 etc... TabAuthSize must be equal to the number of EncryptTab passed, which must be superior or equal to 1. */ CSharedConfigDialog (const nsWireless::Mode_e*, unsigned, const std::vector&, const nsWireless::AuthType_e*, unsigned, const nsWireless::EncryptType_e*, unsigned, const nsWireless::EncryptType_e*, unsigned, const nsWireless::EncryptType_e*, unsigned) throw (std::bad_alloc); CSharedConfigDialog (const nsWireless::Mode_e*, unsigned, const nsWireless::AuthType_e*, unsigned, const nsWireless::EncryptType_e*, unsigned, const nsWireless::EncryptType_e*, unsigned, const nsWireless::EncryptType_e*, unsigned) throw (std::bad_alloc); protected : void ClearKeyEntry () throw(); private : const unsigned m_AuthTabSize; const nsWireless::AuthType_e* const m_AuthTab; const unsigned m_EncryptTabSize1; const nsWireless::EncryptType_e* const m_EncTab1; const unsigned m_EncryptTabSize2; const nsWireless::EncryptType_e* const m_EncTab2; const unsigned m_EncryptTabSize3; const nsWireless::EncryptType_e* const m_EncTab3; void SetEncryptBox (const nsWireless::EncryptType_e*, unsigned) throw(); static void EncryptButtonCallBack (::GtkToggleButton*, CSharedConfigDialog*) throw(); static void AuthButtonCallBack (::GtkToggleButton*, CSharedConfigDialog*) throw(); }; // CSharedConfigDialog } // namespace nsGUI #include "private/WWidgets.hxx" #endif // __WWIDGETS_H__ RutilTv0.18/include/RTDrivers.h0000644000175000017500000002173110636013651016017 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTDrivers.h \author Romain BONDUE \date 30/08/2005 */ #ifndef __RTDRIVERS_H__ #define __RTDRIVERS_H__ #include #include "WE17Driver.h" namespace nsWireless { typedef unsigned short u16; class CRTDriver : public CWE17Driver { public : CRTDriver (const std::string&) throw (nsErrors::CSystemExc); protected : void GetScanResult (int, u16, std::vector&) const throw (nsErrors::CException, std::bad_alloc); }; // CRTDriver class CRT2400Driver : public CRTDriver { public : CRT2400Driver (const std::string&) throw (nsErrors::CException); void Scan () throw (nsErrors::CSystemExc); void GetScanResult (std::vector&) const throw (nsErrors::CException, std::bad_alloc); private : const int m_PrivateIoctl; }; // CRT2400Driver enum WirelessMode_e {Mixed, B_Only}; enum BGProtection_e {AutoProtection, On, Off}; enum TxPreamble_e {Long, Short, AutoPreamble}; class CRTAdvancedDriver : public CRTDriver { public : void GetScanResult (u16, std::vector&) const throw (nsErrors::CException, std::bad_alloc); int GetTxRate () const throw (nsErrors::CSystemExc); void SetTxRate (int) throw (nsErrors::CSystemExc); // TODO CountryRegion (has an influence on GetSupportedFreq()). virtual WirelessMode_e GetWirelessMode () const throw(); virtual void SetWirelessMode (WirelessMode_e) throw (nsErrors::CSystemExc); virtual bool GetTxBurst () const throw(); virtual void SetTxBurst (bool) throw (nsErrors::CSystemExc); virtual BGProtection_e GetBGProtection () const throw(); virtual void SetBGProtection (BGProtection_e) throw (nsErrors::CSystemExc); virtual TxPreamble_e GetTxPreamble () const throw(); virtual void SetTxPreamble (TxPreamble_e) throw (nsErrors::CSystemExc); virtual bool GetTurboRate () const throw(); virtual void SetTurboRate (bool) throw (nsErrors::CSystemExc); virtual bool GetAdHocOFDM () const throw(); virtual void SetAdHocOFDM (bool) throw (nsErrors::CSystemExc); virtual bool GetRfmontx () const throw(); virtual void SetRfmontx (bool) throw (nsErrors::CSystemExc); protected : class IWPrivHandler { public : virtual void operator () (const ::iw_priv_args&) throw (nsErrors::CException); virtual ~IWPrivHandler () throw(); }; // IWPrivHandler CRTAdvancedDriver (const std::string&, int, u16, u16, u16, IWPrivHandler*) throw (nsErrors::CException, std::bad_alloc); CEncryptionD GetEncryption (u16, u16) throw (nsErrors::CSystemExc, std::bad_alloc); void SetIoctl (const char*, const std::string&, const std::string&) const throw (nsErrors::CSystemExc); void SetIoctl (const char*, int, const std::string&) const throw (nsErrors::CSystemExc); enum {IsB_Only = 1, TxBurst = 2, TurboRate = 4, AdHocOFDM = 8, Rfmontx = 16}; void SetFlag (int, bool) throw(); bool GetFlag (int) const throw(); BGProtection_e GetBGProtectionFlag () const throw(); void SetBGProtectionFlag (BGProtection_e) throw(); TxPreamble_e GetTxPreambleFlag () const throw(); void SetTxPreambleFlag (TxPreamble_e) throw(); int GetRfmontxIoctl () const throw(); static const int InvalidIoctl = -1; private : const int m_PrivateIoctl; int m_SetIoctl; int m_RfmontxIoctl; char m_Flags; BGProtection_e m_BGProtection; TxPreamble_e m_TxPreamble; }; // CRTAdvancedDriver class CRT2500Driver : public CRTAdvancedDriver { public : CRT2500Driver (const std::string&) throw (nsErrors::CException, std::bad_alloc); CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); void GetScanResult (std::vector&) const throw (nsErrors::CException, std::bad_alloc); }; // CRT2500Driver class CRT2570Driver : public CRTDriver { public : CRT2570Driver (const std::string&) throw (nsErrors::CException); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); void GetScanResult (std::vector&) const throw (nsErrors::CException, std::bad_alloc); void GetSupportedRates (std::vector&) const throw(); virtual bool GetRfmontx () const throw(); virtual void SetRfmontx (bool) throw (nsErrors::CSystemExc); enum PrismMode_e {Default = 0, Force = 1, ForceNo = 2}; virtual PrismMode_e GetPrismHeader () const throw(); virtual void SetPrismHeader (PrismMode_e) throw (nsErrors::CSystemExc); enum AdHocMode_e {Std11 = 0, Auto = 1, Only54 = 2}; virtual AdHocMode_e GetAdHocMode () const throw(); virtual void SetAdHocMode (AdHocMode_e) throw (nsErrors::CSystemExc); protected : void PrivateIoctl (int, int, const std::string&) throw (nsErrors::CSystemExc); void PrivateIoctl (int, const std::string&, const std::string&) throw (nsErrors::CSystemExc); int GetIntIoctl (int, const std::string&) throw (nsErrors::CSystemExc); static const int InvalidIoctl = -1; private : int m_AuthIoctl; int m_EncIoctl; int m_KeyIoctl; int m_AdHocModeIoctl; int m_RfmontxIoctl; int m_PrismHeaderIoctl; int m_RTPrivIoctl; enum {RfMontx = 1}; char m_Flags; PrismMode_e m_PrismMode; AdHocMode_e m_AdHocMode; }; // CRT2570Driver class CRT61Driver : public CRTAdvancedDriver { public : CRT61Driver (const std::string&) throw (nsErrors::CException, std::bad_alloc); void Scan () throw (nsErrors::CSystemExc); void GetScanResult (std::vector&) const throw (nsErrors::CException, std::bad_alloc); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc); protected : class IWPrivHandlerRT61 : public IWPrivHandler { public : IWPrivHandlerRT61 (int&) throw(); void operator () (const ::iw_priv_args&) throw (nsErrors::CException); private : int& m_GetSiteSurveyIoctl; }; // IWPrivHandler void UpdateScanTime () throw(); time_t GetLastScanTime () const throw(); int GetSiteSurveyIoctl () const throw(); private : int m_GetSiteSurveyIoctl; time_t m_LastScanTime; }; // CRT61Driver // Maximize shared code (could more elegant though). class CRT73Driver : public CRT61Driver { public : CRT73Driver (const std::string&) throw (nsErrors::CException, std::bad_alloc); void GetScanResult (std::vector&) const throw (nsErrors::CException, std::bad_alloc); void SetRfmontx (bool) throw (nsErrors::CSystemExc); }; // CRT73Driver } // namespace nsWireless #include "private/RTDrivers.hxx" #endif // __RTDRIVERS_H__ RutilTv0.18/include/SuWProtocolCodes.h0000644000175000017500000000243310453256101017343 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file SuWProtocolCodes.h \author Romain BONDUE \date 07/01/2006 */ #ifndef __SUWPROTOCOLCODES__ #define __SUWPROTOCOLCODES__ namespace nsWireless { // NextC is designed to extend the protocol. enum SuWProtocolCodes_e {DeviceNameC, SSIDC, FrequencyC, ChannelC, GEncryptionC, SEncryptionC, ModeC, TxRateC, ApMacAddrC, ScanC, CommitC, NextC}; const char* const WE17Handler ("WE17"); } // namespace nsWireless #endif // __SUWPROTOCOLCODES__ RutilTv0.18/include/RTSuWProtocolCodes.h0000644000175000017500000000275510636002145017620 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file RTSuWProtocolCodes.h \author Romain BONDUE \date 21/02/2006 */ #ifndef __RTSUWPROTOCOLCODES__ #define __RTSUWPROTOCOLCODES__ #include "SuWProtocolCodes.h" namespace nsWireless { // NextRTC is designed to extend the protocol. enum RTSuWProtocolCodes_e {WModeC = NextC, TxBurstC, BGProtectionC, TxPreambleC, TurboRateC, AdHocOFDMC, RfmontxC, NextRTC}; const char* const RT2400Handler ("RT2400"); const char* const RT2500Handler ("RT2500"); const char* const RT2570Handler ("RT2570"); const char* const RT61Handler ("RT61"); const char* const RT73Handler ("RT73"); } // namespace nsWireless #endif // __RTSUWPROTOCOLCODES__ RutilTv0.18/include/CSelectableRowList.h0000644000175000017500000000707410722350737017636 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file CSelectableRowList.h \author Romain BONDUE \date 29/07/2005 */ #ifndef __CSELECTABLEROWLIST_H__ #define __CSELECTABLEROWLIST_H__ #include #include extern "C"{ #include } namespace nsGUI { class CGtkGUI; typedef bool (CGtkGUI::*GUICallBack) (unsigned); // A graphic component, the first column is always a button. class CSelectableRowList { public : // Only basic ::GType are allowed. CSelectableRowList (unsigned, const ::GType*, const char**, CGtkGUI*, GUICallBack) throw(); virtual ~CSelectableRowList () throw(); operator ::GtkWidget* () throw(); void SetData (unsigned Row, unsigned Column, bool) throw(); void SetData (unsigned Row, unsigned Column, unsigned) throw(); void SetData (unsigned Row, unsigned Column, int) throw(); void SetData (unsigned Row, unsigned Column, float) throw(); void SetData (unsigned Row, unsigned Column, const std::string&) throw(); void Clear () throw(); void DeleteRow (unsigned) throw(); /** \return The selected row, 'None' if none. */ int GetSelectedRow () const throw(); unsigned GetNbRow () const throw(); static const int None = -1; protected : CGtkGUI* GetUI () throw(); const CGtkGUI* GetUI () const throw(); void RowTriggered () throw(); virtual void RowSelectedCallBack () throw(); virtual void RowUnselectedCallBack () throw(); private : CSelectableRowList& operator = (const CSelectableRowList&); CSelectableRowList (const CSelectableRowList&); void SetData (unsigned Row, unsigned Column, ::GValue*) throw(); ::GtkListStore* const m_pListStore; ::GtkTreeView* const m_pListView; ::GtkWidget* const m_pScrollWindow; ::GtkCellRendererToggle* m_pButtonRenderer; std::vector< ::GtkTreeIter> m_IterVec; int m_SelectedRow; CGtkGUI* const m_pUI; GUICallBack m_pGUICallBack; static void DoubleClickCallBack (::GtkTreeView*, ::GtkTreePath*, ::GtkTreeViewColumn*, CSelectableRowList*) throw(); static void ToggledCallBack (::GtkCellRendererToggle*, const char*, CSelectableRowList*) throw(); static bool _RowSelectedCallBack (::GtkTreeSelection*, ::GtkTreeModel*, ::GtkTreePath*, bool, CSelectableRowList*) throw(); }; // CSelectableRowList } // namespace nsGUI #include "private/CSelectableRowList.hxx" #endif // __CSELECTABLEROWLIST_H__ RutilTv0.18/include/NetTools.h0000644000175000017500000001014310543033307015672 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file NetTools.h \author Romain BONDUE \date 08/05/2006 */ #ifndef __NETTOOLS_H__ #define __NETTOOLS_H__ #include extern "C"{ #include } #include "Exceptions.h" namespace nsNet { class CIPAddress { public : CIPAddress (uint32_t) throw(); void Set (uint32_t) throw(); uint32_t Get () const throw(); /** \warning Pos must be between 0 and 3. */ uint8_t Get (unsigned) const throw(); /** \warning Pos must be between 0 and 3. */ void Set (uint8_t, unsigned) throw(); std::string GetStr () const throw(); private : uint32_t m_Addr; }; // CIPAddress() class CInterface { public : CInterface (const std::string& = "IfaceName not set") throw(); virtual ~CInterface () throw(); const std::string& GetName () const throw(); void SetName (const std::string&) throw(); void RefreshStats () throw (nsErrors::CException); unsigned long GetRXBytes () const throw(); unsigned long GetRXPackets () const throw(); unsigned long GetRXErrors () const throw(); unsigned long GetRXDropped () const throw(); /// The number of FIFO buffer errors. unsigned long GetRXFifo () const throw(); /// The number of packet framing errors. unsigned long GetRXFrame () const throw(); unsigned long GetRXCompressed () const throw(); /** The number of multicast frames transmitted or received by the device driver. */ unsigned long GetMulticast () const throw(); unsigned long GetTXBytes () const throw(); unsigned long GetTXPackets () const throw(); unsigned long GetTXErrors () const throw(); unsigned long GetTXDropped () const throw(); /// The number of FIFO buffer errors. unsigned long GetTXFifo () const throw(); unsigned long GetCollisions () const throw(); /// The number of carrier losses detected by the device driver. unsigned long GetCarrier () const throw(); unsigned long GetTXCompressed () const throw(); /* Comments above from : http://www.linuxdevcenter.com/pub/a/linux/2000/11/16/LinuxAdmin.html */ CIPAddress GetIP () const throw (nsErrors::CSystemExc); virtual void SetIPFromDHCP (const std::string&) throw (nsErrors::CException); bool IsUp () throw (nsErrors::CSystemExc); virtual void Up () throw (nsErrors::CSystemExc); virtual void Down () throw (nsErrors::CSystemExc); protected : void ClearStats () throw(); private : std::string m_IfName; unsigned long m_RXBytes; unsigned long m_RXPackets; unsigned long m_RXErrors; unsigned long m_RXDropped; unsigned long m_RXFifo; unsigned long m_RXFrame; unsigned long m_RXCompressed; unsigned long m_Multicast; unsigned long m_TXBytes; unsigned long m_TXPackets; unsigned long m_TXErrors; unsigned long m_TXDropped; unsigned long m_TXFifo; unsigned long m_Collisions; unsigned long m_Carrier; unsigned long m_TXCompressed; }; // CInterface } // namespace nsNet #include "private/NetTools.hxx" #endif // __NETTOOLS_H__ RutilTv0.18/include/OptionsFile.h0000644000175000017500000000433510464416054016372 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file OptionsFile.h \author Romain BONDUE \date 03/08/2006 */ #ifndef __OPTIONSFILE_H__ #define __OPTIONSFILE_H__ #include #include #include "XMLParser.h" #include "Exceptions.h" namespace nsUserData { class COptionsFile : public CXMLParser { public : COptionsFile (bool DisplayTrayIcon, bool StartMinimized, unsigned LeaveRootDelay) throw(); ~COptionsFile () throw(); void Record () throw (nsErrors::CException); /* If the file doesn't exist, it's not considered as an error. Nothing is done. */ void Extract () throw (nsErrors::CException); bool DisplayTrayIcon () const throw(); void DisplayTrayIcon (bool) throw(); bool StartMinimized () const throw(); void StartMinimized (bool) throw(); unsigned LeaveRootDelay () const throw(); void LeaveRootDelay (unsigned) throw(); protected : // For extracting : void Text (const char*, const std::string&) throw (nsErrors::CException); // For recording : (*not* virtual) void RecordFields (std::ostream&) throw (std::ios_base::failure); private : bool m_DisplayTrayIcon; bool m_StartMinimized; unsigned m_LeaveRootDelay; }; // COptionsFile } // namespace nsUserData #include "private/OptionsFile.hxx" #endif // __OPTIONSFILE_H__ RutilTv0.18/include/Su.h0000644000175000017500000000452010636002145014513 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file Su.h \author Romain BONDUE \date 29/11/2005 */ #ifndef __SU_H__ #define __SU_H__ #include #include #include "Exceptions.h" #include "SystemTools.h" namespace nsRoot { class CMsg; class CSu { public : CSu (const std::string&) throw (nsErrors::CSystemExc); ~CSu () throw(); CMsg Do (const CMsg&) throw (nsErrors::CException, std::bad_alloc); /* No CSu object is usable until this function has been called. Don't forget to monitor SIGPIPE and eventually SIGCHLD. */ static bool Init (const std::string&) throw (nsErrors::CException, std::bad_alloc); static void Close () throw (nsErrors::CSystemExc); protected : // This is *not* Do(). static int SendInternalCommand (int, const std::string&) throw (nsErrors::CSystemExc); private : static nsSystem::CLocalSocket* pSock; static unsigned long CurrentRemoteHandlerNumber; static unsigned long InstanceCounter; void SetRemoteHandler () throw (nsErrors::CException); void CreateRemoteHandler (const std::string&) throw (nsErrors::CSystemExc); static void WriteString (const std::string&) throw (nsErrors::CSystemExc); const unsigned long m_InstanceNumber; }; // CSu } // namespace nsRoot #include "private/Su.hxx" #endif // __SU_H__ RutilTv0.18/include/SuWProtocol.h0000644000175000017500000000455210453256101016371 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file SuWProtocol.h \author Romain BONDUE \date 07/01/2006 */ #ifndef __SUWPROTOCOL_H__ #define __SUWPROTOCOL_H__ #include #include "Exceptions.h" #include "Su.h" #include "Parameters.h" #include "Msg.h" namespace nsWireless { class CSuWProtocol { public : CSuWProtocol (const std::string&, const std::string&) throw (nsErrors::CSystemExc, std::bad_alloc); void SetSSID (const std::string&) throw (nsErrors::CSystemExc); void SetFrequency (double) throw (nsErrors::CSystemExc); void SetChannel (unsigned) throw (nsErrors::CSystemExc); CEncryptionD GetEncryption () throw (nsErrors::CSystemExc, std::bad_alloc); void SetEncryption (const CEncryptionD&) throw (nsErrors::CSystemExc, std::bad_alloc); void SetMode (Mode_e) throw (nsErrors::CSystemExc); void SetTxRate (int) throw (nsErrors::CSystemExc); void SetAPMacAddr (const CMacAddress&) throw (std::bad_alloc, nsErrors::CSystemExc); void Scan () throw (nsErrors::CSystemExc); void Commit () throw (nsErrors::CSystemExc); protected : nsRoot::CMsg SuDo (const nsRoot::CMsg&) throw (nsErrors::CSystemExc); template void SuDo (T, int) throw (nsErrors::CSystemExc); private : nsRoot::CSu m_Su; }; // CSuWProtocol } // namespace nsWireless #include "private/SuWProtocol.hxx" #endif // __SUWPROTOCOL_H__ RutilTv0.18/include/ProfileEditor.h0000644000175000017500000000327110705153462016703 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file ProfileEditor.h \author Romain BONDUE \date 02/04/2006 */ #ifndef __PROFILEEDITOR_H__ #define __PROFILEEDITOR_H__ #include // auto_ptr<> #include namespace nsUserData {class CProfile;} namespace nsGUI {class CConfigDialog;} namespace nsCore { // See this class as an interface between the UI and the Profile. class CProfileEditor { public : // Own the pointer, which mustn't be null. CProfileEditor (nsGUI::CConfigDialog* pDialog) throw(); ~CProfileEditor () throw(); nsGUI::CConfigDialog* GetDialog () throw(); const nsGUI::CConfigDialog* GetDialog () const throw(); bool Edit (::GtkWindow*, nsUserData::CProfile&) throw(); private : std::auto_ptr m_pDialog; }; // CProfileEditor } // namespace nsCore #include "private/ProfileEditor.hxx" #endif // __PROFILEEDITOR_H__ RutilTv0.18/include/IfaceRoot.h0000644000175000017500000000304710543033307016003 0ustar romainromain/* Copyright (c) 2005 Romain BONDUE This file is part of RutilT. RutilT 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. RutilT 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 RutilT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** \file IfaceRoot.h \author Romain BONDUE \date 09/06/2006 */ #ifndef __IFACEROOT_H__ #define __IFACEROOT_H__ #include #include "Su.h" #include "NetTools.h" namespace nsNet { class CInterfaceRoot : public CInterface { public : CInterfaceRoot (const CInterface&) throw (nsErrors::CSystemExc); void SetIP (const CIPAddress&) throw (nsErrors::CSystemExc); void SetIPFromDHCP (const std::string&) throw (nsErrors::CException); void Up () throw (nsErrors::CSystemExc); void Down () throw (nsErrors::CSystemExc); protected : void SuDo (const std::string&, int) throw (nsErrors::CSystemExc); private : nsRoot::CSu m_Su; }; // CRootInterface } // namespace nsNet #endif // __IFACEROOT_H__