From 4aed5e3d6ac6c4e71fbbe97f8c6c953a4072e717 Mon Sep 17 00:00:00 2001 From: Szymon Tomasz Stefanek Date: Sun, 26 Dec 2010 18:29:52 +0000 Subject: More renaming & cleanup. git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5233 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/kvilib/CMakeLists.txt | 76 +- src/kvilib/ext/KviXlib.h | 52 + src/kvilib/ext/kvi_xlib.h | 52 - src/kvilib/irc/KviIrcServerDataBase.cpp | 2 +- src/kvilib/net/KviDnsResolver.cpp | 445 ++++++ src/kvilib/net/KviDnsResolver.h | 142 ++ src/kvilib/net/KviHttpRequest.cpp | 1432 ++++++++++++++++++++ src/kvilib/net/KviHttpRequest.h | 225 +++ src/kvilib/net/KviNetUtils.cpp | 797 +++++++++++ src/kvilib/net/KviNetUtils.h | 99 ++ src/kvilib/net/KviSASL.cpp | 198 +++ src/kvilib/net/KviSASL.h | 61 + src/kvilib/net/KviSSL.cpp | 866 ++++++++++++ src/kvilib/net/KviSSL.h | 196 +++ src/kvilib/net/KviUrl.cpp | 93 ++ src/kvilib/net/KviUrl.h | 65 + src/kvilib/net/kvi_dns.cpp | 445 ------ src/kvilib/net/kvi_dns.h | 142 -- src/kvilib/net/kvi_http.cpp | 1432 -------------------- src/kvilib/net/kvi_http.h | 225 --- src/kvilib/net/kvi_netutils.cpp | 797 ----------- src/kvilib/net/kvi_netutils.h | 99 -- src/kvilib/net/kvi_sasl.cpp | 198 --- src/kvilib/net/kvi_sasl.h | 61 - src/kvilib/net/kvi_ssl.cpp | 866 ------------ src/kvilib/net/kvi_ssl.h | 196 --- src/kvilib/net/kvi_url.cpp | 93 -- src/kvilib/net/kvi_url.h | 65 - src/kvilib/tal/KviTalApplication.cpp | 56 + src/kvilib/tal/KviTalApplication.h | 83 ++ src/kvilib/tal/KviTalFileDialog.cpp | 112 ++ src/kvilib/tal/KviTalFileDialog.h | 118 ++ src/kvilib/tal/KviTalGroupBox.cpp | 140 ++ src/kvilib/tal/KviTalGroupBox.h | 149 ++ src/kvilib/tal/KviTalHBox.cpp | 128 ++ src/kvilib/tal/KviTalHBox.h | 118 ++ .../tal/KviTalIconAndRichTextItemDelegate.cpp | 93 ++ src/kvilib/tal/KviTalIconAndRichTextItemDelegate.h | 95 ++ src/kvilib/tal/KviTalListWidget.cpp | 189 +++ src/kvilib/tal/KviTalListWidget.h | 113 ++ src/kvilib/tal/KviTalMainWindow.cpp | 65 + src/kvilib/tal/KviTalMainWindow.h | 85 ++ src/kvilib/tal/KviTalMenuBar.cpp | 51 + src/kvilib/tal/KviTalMenuBar.h | 71 + src/kvilib/tal/KviTalPopupMenu.cpp | 215 +++ src/kvilib/tal/KviTalPopupMenu.h | 68 + src/kvilib/tal/KviTalSplitter.cpp | 25 + src/kvilib/tal/KviTalSplitter.h | 37 + src/kvilib/tal/KviTalTabDialog.cpp | 82 ++ src/kvilib/tal/KviTalTabDialog.h | 57 + src/kvilib/tal/KviTalTableWidget.cpp | 101 ++ src/kvilib/tal/KviTalTableWidget.h | 81 ++ src/kvilib/tal/KviTalToolBar.cpp | 86 ++ src/kvilib/tal/KviTalToolBar.h | 112 ++ src/kvilib/tal/KviTalToolTip.cpp | 112 ++ src/kvilib/tal/KviTalToolTip.h | 70 + src/kvilib/tal/KviTalVBox.cpp | 98 ++ src/kvilib/tal/KviTalVBox.h | 110 ++ src/kvilib/tal/KviTalWizard.cpp | 540 ++++++++ src/kvilib/tal/KviTalWizard.h | 168 +++ src/kvilib/tal/kvi_tal_application.cpp | 56 - src/kvilib/tal/kvi_tal_application.h | 83 -- src/kvilib/tal/kvi_tal_filedialog.cpp | 112 -- src/kvilib/tal/kvi_tal_filedialog.h | 118 -- src/kvilib/tal/kvi_tal_groupbox.cpp | 140 -- src/kvilib/tal/kvi_tal_groupbox.h | 149 -- src/kvilib/tal/kvi_tal_hbox.cpp | 128 -- src/kvilib/tal/kvi_tal_hbox.h | 118 -- src/kvilib/tal/kvi_tal_itemdelegates.cpp | 93 -- src/kvilib/tal/kvi_tal_itemdelegates.h | 95 -- src/kvilib/tal/kvi_tal_listwidget.cpp | 189 --- src/kvilib/tal/kvi_tal_listwidget.h | 113 -- src/kvilib/tal/kvi_tal_mainwindow.cpp | 65 - src/kvilib/tal/kvi_tal_mainwindow.h | 85 -- src/kvilib/tal/kvi_tal_menubar.cpp | 51 - src/kvilib/tal/kvi_tal_menubar.h | 71 - src/kvilib/tal/kvi_tal_popupmenu.cpp | 215 --- src/kvilib/tal/kvi_tal_popupmenu.h | 68 - src/kvilib/tal/kvi_tal_splitter.cpp | 25 - src/kvilib/tal/kvi_tal_splitter.h | 37 - src/kvilib/tal/kvi_tal_tabdialog.cpp | 82 -- src/kvilib/tal/kvi_tal_tabdialog.h | 57 - src/kvilib/tal/kvi_tal_tablewidget.cpp | 101 -- src/kvilib/tal/kvi_tal_tablewidget.h | 81 -- src/kvilib/tal/kvi_tal_toolbar.cpp | 86 -- src/kvilib/tal/kvi_tal_toolbar.h | 112 -- src/kvilib/tal/kvi_tal_tooltip.cpp | 112 -- src/kvilib/tal/kvi_tal_tooltip.h | 70 - src/kvilib/tal/kvi_tal_vbox.cpp | 98 -- src/kvilib/tal/kvi_tal_vbox.h | 110 -- src/kvilib/tal/kvi_tal_wizard.cpp | 540 -------- src/kvilib/tal/kvi_tal_wizard.h | 168 --- src/kvirc/kernel/kvi_action.cpp | 2 +- src/kvirc/kernel/kvi_app.cpp | 6 +- src/kvirc/kernel/kvi_app.h | 2 +- src/kvirc/kernel/kvi_coreactions.cpp | 2 +- src/kvirc/kernel/kvi_filetransfer.cpp | 2 +- src/kvirc/kernel/kvi_filetransfer.h | 2 +- src/kvirc/kernel/kvi_ipc.h | 2 +- src/kvirc/kernel/kvi_ircconnection.cpp | 18 +- src/kvirc/kernel/kvi_ircconnection.h | 6 +- .../kernel/kvi_ircconnectiontargetresolver.cpp | 26 +- src/kvirc/kernel/kvi_ircconnectiontargetresolver.h | 10 +- src/kvirc/kernel/kvi_irccontext.cpp | 2 +- src/kvirc/kernel/kvi_irclink.cpp | 4 +- src/kvirc/kernel/kvi_irclink.h | 2 +- src/kvirc/kernel/kvi_ircsocket.cpp | 2 +- src/kvirc/kernel/kvi_sslmaster.cpp | 2 +- src/kvirc/kernel/kvi_sslmaster.h | 2 +- src/kvirc/kvs/kvi_kvs_asyncdnsoperation.cpp | 14 +- src/kvirc/kvs/kvi_kvs_asyncdnsoperation.h | 10 +- src/kvirc/kvs/kvi_kvs_corecallbackcommands.cpp | 8 +- src/kvirc/kvs/kvi_kvs_coresimplecommands_af.cpp | 4 +- src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp | 6 +- src/kvirc/kvs/kvi_kvs_coresimplecommands_sz.cpp | 2 +- src/kvirc/kvs/kvi_kvs_dnsmanager.cpp | 12 +- src/kvirc/kvs/kvi_kvs_dnsmanager.h | 10 +- src/kvirc/kvs/kvi_kvs_popupmenu.h | 2 +- src/kvirc/ui/kvi_actiondrawer.cpp | 2 +- src/kvirc/ui/kvi_actiondrawer.h | 2 +- src/kvirc/ui/kvi_channel.cpp | 2 +- src/kvirc/ui/kvi_console.cpp | 8 +- src/kvirc/ui/kvi_console.h | 2 +- src/kvirc/ui/kvi_cryptcontroller.h | 2 +- src/kvirc/ui/kvi_customtoolbar.cpp | 2 +- src/kvirc/ui/kvi_dynamictooltip.h | 2 +- src/kvirc/ui/kvi_filedialog.cpp | 2 +- src/kvirc/ui/kvi_filedialog.h | 2 +- src/kvirc/ui/kvi_frame.cpp | 2 +- src/kvirc/ui/kvi_frame.h | 2 +- src/kvirc/ui/kvi_imagedialog.h | 2 +- src/kvirc/ui/kvi_input.cpp | 6 +- src/kvirc/ui/kvi_input_editor.cpp | 2 +- src/kvirc/ui/kvi_irctoolbar.cpp | 2 +- src/kvirc/ui/kvi_ircview.cpp | 2 +- src/kvirc/ui/kvi_ircviewtools.h | 2 +- src/kvirc/ui/kvi_mdichild.cpp | 2 +- src/kvirc/ui/kvi_mdimanager.cpp | 4 +- src/kvirc/ui/kvi_menubar.cpp | 2 +- src/kvirc/ui/kvi_menubar.h | 2 +- src/kvirc/ui/kvi_modew.cpp | 2 +- src/kvirc/ui/kvi_optionswidget.cpp | 2 +- src/kvirc/ui/kvi_optionswidget.h | 2 +- src/kvirc/ui/kvi_query.cpp | 2 +- src/kvirc/ui/kvi_selectors.cpp | 2 +- src/kvirc/ui/kvi_selectors.h | 6 +- src/kvirc/ui/kvi_statusbar.cpp | 2 +- src/kvirc/ui/kvi_statusbar.h | 2 +- src/kvirc/ui/kvi_statusbarapplet.cpp | 8 +- src/kvirc/ui/kvi_statusbarapplet.h | 2 +- src/kvirc/ui/kvi_toolbar.cpp | 2 +- src/kvirc/ui/kvi_toolbar.h | 2 +- src/kvirc/ui/kvi_toolwindows_container.cpp | 2 +- src/kvirc/ui/kvi_topicw.cpp | 4 +- src/kvirc/ui/kvi_topicw.h | 4 +- src/kvirc/ui/kvi_userlistview.h | 2 +- src/kvirc/ui/kvi_window.cpp | 4 +- src/kvirc/ui/kvi_window.h | 4 +- src/kvirc/ui/kvi_windowlist.h | 2 +- src/kvirc/ui/kvi_windowlist_tree.cpp | 2 +- src/modules/about/aboutdialog.h | 2 +- src/modules/actioneditor/actioneditor.cpp | 6 +- src/modules/addon/managementdialog.cpp | 4 +- src/modules/addon/managementdialog.h | 2 +- src/modules/aliaseditor/aliaseditor.cpp | 2 +- src/modules/aliaseditor/aliaseditor.h | 2 +- src/modules/avatar/libkviavatar.cpp | 4 +- src/modules/channelsjoin/channelsjoinwindow.cpp | 2 +- src/modules/classeditor/classeditor.cpp | 2 +- src/modules/classeditor/classeditor.h | 2 +- src/modules/codetester/codetester.cpp | 2 +- src/modules/dcc/canvas.cpp | 2 +- src/modules/dcc/canvaswidget.cpp | 2 +- src/modules/dcc/chat.cpp | 4 +- src/modules/dcc/libkvidcc.cpp | 2 +- src/modules/dcc/marshal.cpp | 2 +- src/modules/dcc/requests.cpp | 2 +- src/modules/dcc/send.cpp | 2 +- src/modules/dcc/send.h | 6 +- src/modules/dcc/thread.cpp | 2 +- src/modules/dcc/thread.h | 2 +- src/modules/dcc/utils.cpp | 2 +- src/modules/dcc/video.cpp | 4 +- src/modules/dcc/video.h | 2 +- src/modules/dcc/voice.cpp | 4 +- src/modules/dcc/voice.h | 2 +- src/modules/dcc/window.cpp | 2 +- src/modules/dialog/libkvidialog.cpp | 2 +- src/modules/editor/scripteditor.cpp | 6 +- src/modules/editor/scripteditor.h | 2 +- src/modules/eventeditor/eventeditor.cpp | 4 +- src/modules/eventeditor/eventeditor.h | 2 +- .../filetransferwindow/filetransferwindow.cpp | 2 +- .../filetransferwindow/filetransferwindow.h | 6 +- src/modules/help/helpwidget.h | 2 +- src/modules/help/helpwindow.h | 4 +- src/modules/http/httpfiletransfer.cpp | 6 +- src/modules/http/httpfiletransfer.h | 2 +- src/modules/ident/libkviident.cpp | 2 +- src/modules/links/linkswindow.cpp | 2 +- src/modules/links/linkswindow.h | 2 +- src/modules/list/listwindow.cpp | 2 +- src/modules/list/listwindow.h | 2 +- src/modules/logview/logviewmdiwindow.cpp | 2 +- src/modules/logview/logviewmdiwindow.h | 2 +- src/modules/mircimport/libkvimircimport.cpp | 2 +- src/modules/mircimport/libkvimircimport.h | 4 +- src/modules/notifier/notifierwindow.h | 2 +- src/modules/objects/class_groupbox.cpp | 2 +- src/modules/objects/class_groupbox.h | 2 +- src/modules/objects/class_hbox.cpp | 2 +- src/modules/objects/class_mainwindow.cpp | 2 +- src/modules/objects/class_popupmenu.cpp | 2 +- src/modules/objects/class_socket.cpp | 14 +- src/modules/objects/class_socket.h | 6 +- src/modules/objects/class_toolbar.cpp | 4 +- src/modules/objects/class_toolbutton.cpp | 2 +- src/modules/objects/class_vbox.cpp | 2 +- src/modules/objects/class_widget.h | 2 +- src/modules/objects/class_wizard.cpp | 2 +- src/modules/objects/class_wizard.h | 2 +- src/modules/options/container.cpp | 2 +- src/modules/options/dialog.cpp | 8 +- src/modules/options/optw_avatar.cpp | 2 +- src/modules/options/optw_highlighting.cpp | 2 +- src/modules/options/optw_identity.cpp | 6 +- src/modules/options/optw_interfacelookglobal.cpp | 2 +- src/modules/options/optw_ircoutput.cpp | 2 +- src/modules/options/optw_lag.cpp | 2 +- src/modules/options/optw_mediatypes.cpp | 2 +- src/modules/options/optw_messages.cpp | 2 +- src/modules/options/optw_messages.h | 2 +- src/modules/options/optw_nickserv.cpp | 2 +- src/modules/options/optw_proxy.cpp | 8 +- src/modules/options/optw_servers.cpp | 6 +- src/modules/options/optw_sound.cpp | 4 +- src/modules/options/optw_texticons.cpp | 2 +- src/modules/options/optw_texticons.h | 4 +- src/modules/options/optw_tray.cpp | 2 +- src/modules/popupeditor/popupeditor.cpp | 2 +- src/modules/popupeditor/popupeditor.h | 2 +- src/modules/raweditor/raweditor.cpp | 4 +- src/modules/reguser/dialog.cpp | 4 +- src/modules/reguser/dialog.h | 4 +- src/modules/reguser/edituser.cpp | 4 +- src/modules/reguser/edituser.h | 4 +- src/modules/reguser/wizard.h | 2 +- src/modules/setup/setupwizard.cpp | 4 +- src/modules/setup/setupwizard.h | 8 +- .../sharedfileswindow/sharedfileswindow.cpp | 4 +- src/modules/str/libkvistr.cpp | 2 +- src/modules/term/termwidget.h | 2 +- src/modules/theme/managementdialog.cpp | 4 +- src/modules/theme/managementdialog.h | 6 +- src/modules/theme/savethemedialog.h | 2 +- src/modules/toolbareditor/toolbareditor.cpp | 2 +- src/modules/trayicon/libkvitrayicon.cpp | 2 +- src/modules/upnp/libkviupnp.cpp | 2 +- src/modules/url/libkviurl.cpp | 2 +- src/modules/url/libkviurl.h | 2 +- 260 files changed, 8627 insertions(+), 8627 deletions(-) create mode 100644 src/kvilib/ext/KviXlib.h delete mode 100644 src/kvilib/ext/kvi_xlib.h create mode 100644 src/kvilib/net/KviDnsResolver.cpp create mode 100644 src/kvilib/net/KviDnsResolver.h create mode 100644 src/kvilib/net/KviHttpRequest.cpp create mode 100644 src/kvilib/net/KviHttpRequest.h create mode 100644 src/kvilib/net/KviNetUtils.cpp create mode 100644 src/kvilib/net/KviNetUtils.h create mode 100644 src/kvilib/net/KviSASL.cpp create mode 100644 src/kvilib/net/KviSASL.h create mode 100644 src/kvilib/net/KviSSL.cpp create mode 100644 src/kvilib/net/KviSSL.h create mode 100644 src/kvilib/net/KviUrl.cpp create mode 100644 src/kvilib/net/KviUrl.h delete mode 100644 src/kvilib/net/kvi_dns.cpp delete mode 100644 src/kvilib/net/kvi_dns.h delete mode 100644 src/kvilib/net/kvi_http.cpp delete mode 100644 src/kvilib/net/kvi_http.h delete mode 100644 src/kvilib/net/kvi_netutils.cpp delete mode 100644 src/kvilib/net/kvi_netutils.h delete mode 100644 src/kvilib/net/kvi_sasl.cpp delete mode 100644 src/kvilib/net/kvi_sasl.h delete mode 100644 src/kvilib/net/kvi_ssl.cpp delete mode 100644 src/kvilib/net/kvi_ssl.h delete mode 100644 src/kvilib/net/kvi_url.cpp delete mode 100644 src/kvilib/net/kvi_url.h create mode 100644 src/kvilib/tal/KviTalApplication.cpp create mode 100644 src/kvilib/tal/KviTalApplication.h create mode 100644 src/kvilib/tal/KviTalFileDialog.cpp create mode 100644 src/kvilib/tal/KviTalFileDialog.h create mode 100644 src/kvilib/tal/KviTalGroupBox.cpp create mode 100644 src/kvilib/tal/KviTalGroupBox.h create mode 100644 src/kvilib/tal/KviTalHBox.cpp create mode 100644 src/kvilib/tal/KviTalHBox.h create mode 100644 src/kvilib/tal/KviTalIconAndRichTextItemDelegate.cpp create mode 100644 src/kvilib/tal/KviTalIconAndRichTextItemDelegate.h create mode 100644 src/kvilib/tal/KviTalListWidget.cpp create mode 100644 src/kvilib/tal/KviTalListWidget.h create mode 100644 src/kvilib/tal/KviTalMainWindow.cpp create mode 100644 src/kvilib/tal/KviTalMainWindow.h create mode 100644 src/kvilib/tal/KviTalMenuBar.cpp create mode 100644 src/kvilib/tal/KviTalMenuBar.h create mode 100644 src/kvilib/tal/KviTalPopupMenu.cpp create mode 100644 src/kvilib/tal/KviTalPopupMenu.h create mode 100644 src/kvilib/tal/KviTalSplitter.cpp create mode 100644 src/kvilib/tal/KviTalSplitter.h create mode 100644 src/kvilib/tal/KviTalTabDialog.cpp create mode 100644 src/kvilib/tal/KviTalTabDialog.h create mode 100644 src/kvilib/tal/KviTalTableWidget.cpp create mode 100644 src/kvilib/tal/KviTalTableWidget.h create mode 100644 src/kvilib/tal/KviTalToolBar.cpp create mode 100644 src/kvilib/tal/KviTalToolBar.h create mode 100644 src/kvilib/tal/KviTalToolTip.cpp create mode 100644 src/kvilib/tal/KviTalToolTip.h create mode 100644 src/kvilib/tal/KviTalVBox.cpp create mode 100644 src/kvilib/tal/KviTalVBox.h create mode 100644 src/kvilib/tal/KviTalWizard.cpp create mode 100644 src/kvilib/tal/KviTalWizard.h delete mode 100644 src/kvilib/tal/kvi_tal_application.cpp delete mode 100644 src/kvilib/tal/kvi_tal_application.h delete mode 100644 src/kvilib/tal/kvi_tal_filedialog.cpp delete mode 100644 src/kvilib/tal/kvi_tal_filedialog.h delete mode 100644 src/kvilib/tal/kvi_tal_groupbox.cpp delete mode 100644 src/kvilib/tal/kvi_tal_groupbox.h delete mode 100644 src/kvilib/tal/kvi_tal_hbox.cpp delete mode 100644 src/kvilib/tal/kvi_tal_hbox.h delete mode 100644 src/kvilib/tal/kvi_tal_itemdelegates.cpp delete mode 100644 src/kvilib/tal/kvi_tal_itemdelegates.h delete mode 100644 src/kvilib/tal/kvi_tal_listwidget.cpp delete mode 100644 src/kvilib/tal/kvi_tal_listwidget.h delete mode 100644 src/kvilib/tal/kvi_tal_mainwindow.cpp delete mode 100644 src/kvilib/tal/kvi_tal_mainwindow.h delete mode 100644 src/kvilib/tal/kvi_tal_menubar.cpp delete mode 100644 src/kvilib/tal/kvi_tal_menubar.h delete mode 100644 src/kvilib/tal/kvi_tal_popupmenu.cpp delete mode 100644 src/kvilib/tal/kvi_tal_popupmenu.h delete mode 100644 src/kvilib/tal/kvi_tal_splitter.cpp delete mode 100644 src/kvilib/tal/kvi_tal_splitter.h delete mode 100644 src/kvilib/tal/kvi_tal_tabdialog.cpp delete mode 100644 src/kvilib/tal/kvi_tal_tabdialog.h delete mode 100644 src/kvilib/tal/kvi_tal_tablewidget.cpp delete mode 100644 src/kvilib/tal/kvi_tal_tablewidget.h delete mode 100644 src/kvilib/tal/kvi_tal_toolbar.cpp delete mode 100644 src/kvilib/tal/kvi_tal_toolbar.h delete mode 100644 src/kvilib/tal/kvi_tal_tooltip.cpp delete mode 100644 src/kvilib/tal/kvi_tal_tooltip.h delete mode 100644 src/kvilib/tal/kvi_tal_vbox.cpp delete mode 100644 src/kvilib/tal/kvi_tal_vbox.h delete mode 100644 src/kvilib/tal/kvi_tal_wizard.cpp delete mode 100644 src/kvilib/tal/kvi_tal_wizard.h (limited to 'src') diff --git a/src/kvilib/CMakeLists.txt b/src/kvilib/CMakeLists.txt index 88006c468..5b97a6a94 100644 --- a/src/kvilib/CMakeLists.txt +++ b/src/kvilib/CMakeLists.txt @@ -20,24 +20,24 @@ SET(kvilib_MOC_HDRS ext/KviRegisteredUserDataBase.h ext/KviSharedFilesManager.h irc/KviIrcUserDataBase.h - net/kvi_dns.h - net/kvi_http.h + net/KviDnsResolver.h + net/KviHttpRequest.h system/KviLocale.h system/KviThread.h - tal/kvi_tal_application.h - tal/kvi_tal_filedialog.h - tal/kvi_tal_groupbox.h - tal/kvi_tal_hbox.h - tal/kvi_tal_listwidget.h - tal/kvi_tal_mainwindow.h - tal/kvi_tal_menubar.h - tal/kvi_tal_popupmenu.h - tal/kvi_tal_tabdialog.h - tal/kvi_tal_tablewidget.h - tal/kvi_tal_toolbar.h - tal/kvi_tal_tooltip.h - tal/kvi_tal_vbox.h - tal/kvi_tal_wizard.h + tal/KviTalApplication.h + tal/KviTalFileDialog.h + tal/KviTalGroupBox.h + tal/KviTalHBox.h + tal/KviTalListWidget.h + tal/KviTalMainWindow.h + tal/KviTalMenuBar.h + tal/KviTalPopupMenu.h + tal/KviTalTabDialog.h + tal/KviTalTableWidget.h + tal/KviTalToolBar.h + tal/KviTalToolTip.h + tal/KviTalVBox.h + tal/KviTalWizard.h ) IF(COMPILE_DBUS_SUPPORT) @@ -96,33 +96,33 @@ SET(kvilib_SRCS irc/KviNetwork.cpp irc/KviNickServRuleSet.cpp irc/KviUserIdentity.cpp - net/kvi_dns.cpp - net/kvi_http.cpp - net/kvi_netutils.cpp - net/kvi_sasl.cpp + net/KviDnsResolver.cpp + net/KviHttpRequest.cpp + net/KviNetUtils.cpp + net/KviSASL.cpp net/kvi_socket.cpp - net/kvi_ssl.cpp - net/kvi_url.cpp + net/KviSSL.cpp + net/KviUrl.cpp system/KviEnvironment.cpp system/KviLocale.cpp system/KviThread.cpp system/KviTimeUtils.cpp - tal/kvi_tal_application.cpp - tal/kvi_tal_filedialog.cpp - tal/kvi_tal_groupbox.cpp - tal/kvi_tal_hbox.cpp - tal/kvi_tal_itemdelegates.cpp - tal/kvi_tal_listwidget.cpp - tal/kvi_tal_mainwindow.cpp - tal/kvi_tal_menubar.cpp - tal/kvi_tal_popupmenu.cpp - tal/kvi_tal_splitter.cpp - tal/kvi_tal_tabdialog.cpp - tal/kvi_tal_tablewidget.cpp - tal/kvi_tal_toolbar.cpp - tal/kvi_tal_tooltip.cpp - tal/kvi_tal_vbox.cpp - tal/kvi_tal_wizard.cpp + tal/KviTalApplication.cpp + tal/KviTalFileDialog.cpp + tal/KviTalGroupBox.cpp + tal/KviTalHBox.cpp + tal/KviTalIconAndRichTextItemDelegate.cpp + tal/KviTalListWidget.cpp + tal/KviTalMainWindow.cpp + tal/KviTalMenuBar.cpp + tal/KviTalPopupMenu.cpp + tal/KviTalSplitter.cpp + tal/KviTalTabDialog.cpp + tal/KviTalTableWidget.cpp + tal/KviTalToolBar.cpp + tal/KviTalToolTip.cpp + tal/KviTalVBox.cpp + tal/KviTalWizard.cpp ) IF(NOT DEFINED COMPILE_DISABLE_AVDEVICE) diff --git a/src/kvilib/ext/KviXlib.h b/src/kvilib/ext/KviXlib.h new file mode 100644 index 000000000..818867558 --- /dev/null +++ b/src/kvilib/ext/KviXlib.h @@ -0,0 +1,52 @@ +#ifndef _KVI_XLIB_H_ +#define _KVI_XLIB_H_ +//============================================================================= +// +// File : KviXlib.h +// Creation date : Tue Aug 14 18:17:21 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifndef COMPILE_ON_WINDOWS + #ifndef COMPILE_NO_X + + #ifdef Bool + // Someone has defined Bool ? + #undef Bool + #endif + + #include + + // Too bad that X11/Xlib.h defines Bool, Error and Success... this basically + // SUX since we can't use them anywhere in the source! + // this breaks, enums in Qt, enums in KVIrc and other stuff all around... + // Shame on you Xlib.h author :D + + #ifdef Bool + // NO! + #undef Bool + #endif + + #endif // !COMPILE_NO_X +#endif + +#endif //_KVI_XLIB_H_ diff --git a/src/kvilib/ext/kvi_xlib.h b/src/kvilib/ext/kvi_xlib.h deleted file mode 100644 index bf898a652..000000000 --- a/src/kvilib/ext/kvi_xlib.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _KVI_XLIB_H_ -#define _KVI_XLIB_H_ -//============================================================================= -// -// File : kvi_xlib.h -// Creation date : Tue Aug 14 18:17:21 2001 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" - -#ifndef COMPILE_ON_WINDOWS - #ifndef COMPILE_NO_X - - #ifdef Bool - // Someone has defined Bool ? - #undef Bool - #endif - - #include - - // Too bad that X11/Xlib.h defines Bool, Error and Success... this basically - // SUX since we can't use them anywhere in the source! - // this breaks, enums in Qt, enums in KVIrc and other stuff all around... - // Shame on you Xlib.h author :D - - #ifdef Bool - // NO! - #undef Bool - #endif - - #endif // !COMPILE_NO_X -#endif - -#endif //_KVI_XLIB_H_ diff --git a/src/kvilib/irc/KviIrcServerDataBase.cpp b/src/kvilib/irc/KviIrcServerDataBase.cpp index 163b6e70d..5aae7b1d8 100644 --- a/src/kvilib/irc/KviIrcServerDataBase.cpp +++ b/src/kvilib/irc/KviIrcServerDataBase.cpp @@ -26,7 +26,7 @@ #include "KviIrcServerDataBase.h" #include "KviConfigurationFile.h" #include "KviLocale.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "KviNickServRuleSet.h" #include diff --git a/src/kvilib/net/KviDnsResolver.cpp b/src/kvilib/net/KviDnsResolver.cpp new file mode 100644 index 000000000..ef4cfcefb --- /dev/null +++ b/src/kvilib/net/KviDnsResolver.cpp @@ -0,0 +1,445 @@ +//============================================================================= +// +// File : KviDnsResolver.cpp +// Creation date : Sat Jul 21 2000 17:19:31 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviDnsResolver.h" +#include "kvi_error.h" +#include "KviNetUtils.h" + +#include + +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + #include + + #ifdef COMPILE_IPV6_SUPPORT + #ifdef WIN2K + #include + #else + #include + //#include + #endif + #endif +#else + #include + #include + #include +#endif + +// this is for FreeBSD +#ifndef EAI_ADDRFAMILY + #define EAI_ADDRFAMILY EAI_FAMILY +#endif + +#ifndef EAI_NODATA + #define EAI_NODATA 0 +#endif + + + +KviDnsResolverResult::KviDnsResolverResult() +{ + m_iError = KviError_success; + m_pHostnameList = new KviPointerList; + m_pHostnameList->setAutoDelete(true); + m_pIpAddressList = new KviPointerList; + m_pIpAddressList->setAutoDelete(true); + +} + +KviDnsResolverResult::~KviDnsResolverResult() +{ + delete m_pHostnameList; + delete m_pIpAddressList; +} + +void KviDnsResolverResult::appendHostname(const QString &host) +{ + m_pHostnameList->append(new QString(host)); +} + + +void KviDnsResolverResult::appendAddress(const QString &addr) +{ + m_pIpAddressList->append(new QString(addr)); +} + + + +KviDnsResolverThread::KviDnsResolverThread(KviDnsResolver * pDns) +{ + m_pParentDns = pDns; +} + +KviDnsResolverThread::~KviDnsResolverThread() +{ +} + +int KviDnsResolverThread::translateDnsError(int iErr) +{ +#if defined(COMPILE_IPV6_SUPPORT) || (!defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)) + + switch(iErr) + { + case EAI_FAMILY: return KviError_unsupportedAddressFamily; break; +#if (!defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)) && defined(EAI_ADDRFAMILY) && (EAI_ADDRFAMILY != EAI_FAMILY) + case EAI_ADDRFAMILY: return KviError_unsupportedAddressFamily; break; +#endif +// NOT FreeBSD ARE WE? +#if defined(EAI_NODATA) && (EAI_NODATA != EAI_NONAME) +// YARR + case EAI_NODATA: return KviError_validNameButNoIpAddress; break; +#endif + case EAI_FAIL: return KviError_unrecoverableNameserverError; break; + case EAI_AGAIN: return KviError_dnsTemporaneousFault; break; + // this should never happen + case EAI_BADFLAGS: return KviError_dnsInternalErrorBadFlags; break; + case EAI_MEMORY: return KviError_dnsInternalErrorOutOfMemory; break; + // got this when experimenting with protocols + case EAI_SERVICE: return KviError_dnsInternalErrorServiceNotSupported; break; +#if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) + case EAI_NONAME: return KviError_dnsNoName; break; +#endif + // got this when experimenting with protocols + case EAI_SOCKTYPE: return KviError_dnsInternalErrorUnsupportedSocketType; break; +#if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) + case EAI_SYSTEM: return -errno; +#endif + } + +#endif + return KviError_dnsQueryFailed; +} + +void KviDnsResolverThread::postDnsError(KviDnsResolverResult * dns,int iErr) +{ + dns->setError(iErr); + KviThreadDataEvent * e = new KviThreadDataEvent(KVI_DNS_THREAD_EVENT_DATA); + e->setData(dns); + postEvent(m_pParentDns,e); +} + +void KviDnsResolverThread::run() +{ + KviDnsResolverResult * dns = new KviDnsResolverResult(); + + dns->setQuery(m_szQuery); + + if(m_szQuery.isEmpty()) + { + postDnsError(dns,KviError_noHostToResolve); + return; + } + +#ifndef COMPILE_IPV6_SUPPORT + if(m_queryType != KviDnsResolver::IPv4) + { + if(m_queryType == KviDnsResolver::IPv6) + { + postDnsError(dns,KviError_noIPv6Support); + return; + } + m_queryType = KviDnsResolver::IPv4; + } +#endif + +#if (defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)) && !defined(COMPILE_IPV6_SUPPORT) + + if(m_queryType == KviDnsResolver::IPv6) + { + postDnsError(dns,KviError_noIPv6Support); + return; + } + + // gethostbyaddr and gethostbyname are thread-safe on Windoze + struct in_addr inAddr; + struct hostent *pHostEntry = 0; + + + // DIE DIE!....I hope that this stuff will disappear sooner or later :) + + if(KviNetUtils::stringIpToBinaryIp(m_szQuery,&inAddr)) + { + pHostEntry = gethostbyaddr((const char *)&inAddr,sizeof(inAddr),AF_INET); + } else { + pHostEntry = gethostbyname(m_szQuery.toUtf8().data()); + } + + if(!pHostEntry) + { + switch(h_errno) + { + case HOST_NOT_FOUND: dns->setError(KviError_hostNotFound); break; + case NO_ADDRESS: dns->setError(KviError_validNameButNoIpAddress); break; + case NO_RECOVERY: dns->setError(KviError_unrecoverableNameserverError); break; + case TRY_AGAIN: dns->setError(KviError_dnsTemporaneousFault); break; + default: dns->setError(KviError_dnsQueryFailed); break; + } + } else { + dns->appendHostname(pHostEntry->h_name); + QString szIp; + KviNetUtils::binaryIpToStringIp(* ((struct in_addr*)(pHostEntry->h_addr)),szIp); + dns->appendAddress(szIp); + + int idx = 1; + while(pHostEntry->h_addr_list[idx]) + { + QString tmp; + KviNetUtils::binaryIpToStringIp(* ((struct in_addr*)(pHostEntry->h_addr_list[idx])),tmp); + if(!tmp.isEmpty())dns->appendAddress(tmp); + ++idx; + } + if(pHostEntry->h_aliases[0]) + { + dns->appendHostname(QString::fromUtf8(pHostEntry->h_aliases[0])); + if(pHostEntry->h_aliases[1])dns->appendHostname(QString::fromUtf8(pHostEntry->h_aliases[1])); + } + } + + +#else + + int retVal; + + +//#ifdef HAVE_GETNAMEINFO + struct sockaddr_in ipv4Addr; + +#ifdef COMPILE_IPV6_SUPPORT + struct sockaddr_in6 ipv6Addr; + bool bIsIPv6Ip = false; +#endif + + bool bIsIPv4Ip = KviNetUtils::stringIpToBinaryIp(m_szQuery,(struct in_addr *)&(ipv4Addr.sin_addr)); + +#ifdef COMPILE_IPV6_SUPPORT + if(!bIsIPv4Ip)bIsIPv6Ip = KviNetUtils::stringIpToBinaryIp_V6(m_szQuery,(struct in6_addr *)&(ipv6Addr.sin6_addr)); +#endif + +//#ifdef HAVE_GETNAMEINFO + +#ifdef COMPILE_IPV6_SUPPORT + if(bIsIPv4Ip || bIsIPv6Ip) + { +#else + if(bIsIPv4Ip) + { +#endif + // use getnameinfo... + char retname[1025]; // should be enough.... + +#ifdef COMPILE_IPV6_SUPPORT + if(bIsIPv4Ip) + { +#endif + ipv4Addr.sin_family = AF_INET; + ipv4Addr.sin_port = 0; + // NI_NAMEREQD as last param ? + retVal = getnameinfo((struct sockaddr *)&ipv4Addr,sizeof(ipv4Addr),retname,1025,0,0,NI_NAMEREQD); +#ifdef COMPILE_IPV6_SUPPORT + } else { + ipv6Addr.sin6_family = AF_INET6; + ipv6Addr.sin6_port = 0; + retVal = getnameinfo((struct sockaddr *)&ipv6Addr,sizeof(ipv6Addr),retname,1025,0,0,NI_NAMEREQD); + } +#endif + + if(retVal != 0)dns->setError(translateDnsError(retVal)); + else { + dns->appendHostname(retname); + dns->appendAddress(m_szQuery); + } + + } else { +//#endif //HAVE_GETNAMEINFO + + +//#ifdef COMPILE_IPV6_SUPPORT +// struct in6_addr in6Addr; +//#endif + struct addrinfo * pRet = 0; + struct addrinfo * pNext; + struct addrinfo hints; + hints.ai_flags = 0; //AI_CANONNAME; <-- for IPV6 it makes cannoname to point to the IP address! +#ifdef COMPILE_IPV6_SUPPORT + hints.ai_family = (m_queryType == KviDnsResolver::IPv6) ? PF_INET6 : ((m_queryType == KviDnsResolver::IPv4) ? PF_INET : PF_UNSPEC); +#else + hints.ai_family = PF_INET; +#endif + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = 0; + hints.ai_addrlen = 0; + hints.ai_canonname = 0; + hints.ai_addr = 0; + hints.ai_next = 0; + + retVal = getaddrinfo(KviQString::toUtf8(m_szQuery).data(),0,&hints,&pRet); + + if(retVal != 0)dns->setError(translateDnsError(retVal)); + else { + dns->appendHostname(pRet->ai_canonname ? QString::fromUtf8(pRet->ai_canonname) : m_szQuery); + QString szIp; +#ifdef COMPILE_IPV6_SUPPORT + if(pRet->ai_family == PF_INET6)KviNetUtils::binaryIpToStringIp_V6(((sockaddr_in6 *)(pRet->ai_addr))->sin6_addr,szIp); + else { +#endif + KviNetUtils::binaryIpToStringIp(((sockaddr_in *)(pRet->ai_addr))->sin_addr,szIp); +#ifdef COMPILE_IPV6_SUPPORT + } +#endif + dns->appendAddress(szIp); + + pNext = pRet->ai_next; + while(pNext) + { + QString tmp; +#ifdef COMPILE_IPV6_SUPPORT + if(pNext->ai_family == PF_INET6)KviNetUtils::binaryIpToStringIp_V6(((sockaddr_in6 *)(pNext->ai_addr))->sin6_addr,tmp); + else { +#endif + KviNetUtils::binaryIpToStringIp(((sockaddr_in *)(pNext->ai_addr))->sin_addr,tmp); +#ifdef COMPILE_IPV6_SUPPORT + } +#endif + if(!tmp.isEmpty())dns->appendAddress(tmp); + + if(pNext->ai_canonname) + { + // FIXME: only of not equal to other names ? + dns->appendHostname(QString::fromUtf8(pNext->ai_canonname)); + } + + pNext = pNext->ai_next; + + } + } + if(pRet)freeaddrinfo(pRet); +//#ifdef HAVE_GETNAMEINFO + } +//#endif //HAVE_GETNAMEINFO + +#endif // !COMPILE_ON_WINDOWS + + + KviThreadDataEvent * e = new KviThreadDataEvent(KVI_DNS_THREAD_EVENT_DATA); + e->setData(dns); + postEvent(m_pParentDns,e); +} + + +KviDnsResolver::KviDnsResolver() +: QObject() +{ + m_pSlaveThread = new KviDnsResolverThread(this); + m_pDnsResult = new KviDnsResolverResult(); + m_pAuxData = 0; + m_state = Idle; +} + +KviDnsResolver::~KviDnsResolver() +{ + if(m_pSlaveThread)delete m_pSlaveThread; // will eventually terminate it (but it will also block us!!!) + KviThreadManager::killPendingEvents(this); + if(m_pDnsResult)delete m_pDnsResult; + if(m_pAuxData)qDebug("You're leaking memory man! m_pAuxData is non 0!"); +} + +bool KviDnsResolver::isRunning() const +{ + return (m_state == Busy); +} + +bool KviDnsResolver::lookup(const QString &query,QueryType type) +{ + if(m_state == Busy)return false; + m_pSlaveThread->setQuery(KviQString::trimmed(query),type); + bool bStarted = m_pSlaveThread->start(); + m_state = bStarted ? Busy : Failure; + return bStarted; +} + +int KviDnsResolver::error() +{ + if(!m_pDnsResult)return KviError_dnsQueryFailed; + return m_pDnsResult->error(); +} + +KviDnsResolverResult * KviDnsResolver::result() +{ + if(!m_pDnsResult)m_pDnsResult = new KviDnsResolverResult(); + return m_pDnsResult; +} + +KviPointerList * KviDnsResolver::hostnameList() +{ + return result()->hostnameList(); +} + +KviPointerList * KviDnsResolver::ipAddressList() +{ + return result()->ipAddressList(); +} + +int KviDnsResolver::hostnameCount() +{ + return result()->hostnameList()->count(); +} + +int KviDnsResolver::ipAddressCount() +{ + return result()->ipAddressList()->count(); +} + +const QString & KviDnsResolver::firstHostname() +{ + QString * pStr = result()->hostnameList()->first(); + if(pStr)return *pStr; + return KviQString::Empty; +} + +const QString & KviDnsResolver::firstIpAddress() +{ + QString * pStr = result()->ipAddressList()->first(); + if(pStr)return *pStr; + return KviQString::Empty; +} + +const QString & KviDnsResolver::query() +{ + return result()->query(); +} + +bool KviDnsResolver::event(QEvent *e) +{ + if(e->type() == KVI_THREAD_EVENT) + { + if(((KviThreadEvent *)e)->id() == KVI_DNS_THREAD_EVENT_DATA) + { + if(m_pDnsResult)delete m_pDnsResult; + m_pDnsResult = ((KviThreadDataEvent *)e)->getData(); + m_state = (m_pDnsResult->error() == KviError_success) ? Success : Failure; + emit lookupDone(this); + return true; + } // else ops... unknown thread event ? + } + return QObject::event(e); +} diff --git a/src/kvilib/net/KviDnsResolver.h b/src/kvilib/net/KviDnsResolver.h new file mode 100644 index 000000000..bf3552179 --- /dev/null +++ b/src/kvilib/net/KviDnsResolver.h @@ -0,0 +1,142 @@ +#ifndef _KVI_DNS_H_ +#define _KVI_DNS_H_ + +//============================================================================= +// +// File : KviDnsResolver.h +// Creation date : Sat Jul 21 2000 13:59:11 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "KviHeapObject.h" +#include "KviThread.h" +#include "KviQString.h" + + +class KviDnsResolverThread; // not part of the API + + +class KVILIB_API KviDnsResolverResult : public KviHeapObject +{ + friend class KviDnsResolver; + friend class KviDnsResolverThread; +protected: + KviDnsResolverResult(); +public: + ~KviDnsResolverResult(); +protected: + int m_iError; + KviPointerList * m_pHostnameList; + KviPointerList * m_pIpAddressList; + QString m_szQuery; +public: + int error(){ return m_iError; }; + // never store nor delete these pointers! + // (these are NEVER 0) + KviPointerList * hostnameList(){ return m_pHostnameList; }; + KviPointerList * ipAddressList(){ return m_pIpAddressList; }; + const QString &query(){ return m_szQuery; }; +protected: + void setError(int iError){ m_iError = iError; }; + void setQuery(const QString &query){ m_szQuery = query; }; + void appendHostname(const QString &host); + void appendAddress(const QString &addr); +}; + + + +class KVILIB_API KviDnsResolver : public QObject, public KviHeapObject +{ + Q_OBJECT + Q_PROPERTY(bool blockingDelete READ isRunning) +public: + KviDnsResolver(); + ~KviDnsResolver(); +public: + enum QueryType { IPv4, IPv6, Any }; + enum State { Idle, Busy, Failure, Success }; +protected: + void * m_pAuxData; + KviDnsResolverThread * m_pSlaveThread; + KviDnsResolverResult * m_pDnsResult; + State m_state; +public: + ///////////////////////////////////////////////////////////////////////////////////////////////////// + // + // Public interface + // + + // Lookup start + bool lookup(const QString &szQuery,QueryType type); + + // Current object state + State state(){ return m_state; }; + + // Results (return always non null-data..but valid results only if state() == Success or Failure) + int error(); + const QString & firstHostname(); + const QString & firstIpAddress(); + int hostnameCount(); + int ipAddressCount(); + KviPointerList * hostnameList(); + KviPointerList * ipAddressList(); + const QString & query(); + bool isRunning() const; + + // Auxiliary data store + void setAuxData(void * pAuxData){ m_pAuxData = pAuxData; }; + void * releaseAuxData(){ void * pData = m_pAuxData; m_pAuxData = 0; return pData; }; +protected: + virtual bool event(QEvent *e); +private: + KviDnsResolverResult * result(); +signals: + void lookupDone(KviDnsResolver *); +}; + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////// +// INTERNAL CLASSES +// + +#define KVI_DNS_THREAD_EVENT_DATA (KVI_THREAD_USER_EVENT_BASE + 7432) + +class KviDnsResolverThread : public KviThread +{ + friend class KviDnsResolver; +protected: + KviDnsResolverThread(KviDnsResolver * pDns); + ~KviDnsResolverThread(); +protected: + QString m_szQuery; + KviDnsResolver::QueryType m_queryType; + KviDnsResolver * m_pParentDns; +public: + void setQuery(const QString &query,KviDnsResolver::QueryType type){ m_szQuery = query; m_queryType = type; }; +protected: + virtual void run(); + int translateDnsError(int iErr); + void postDnsError(KviDnsResolverResult * dns,int iErr); +}; + + +#endif //_KVI_DNS_H_ diff --git a/src/kvilib/net/KviHttpRequest.cpp b/src/kvilib/net/KviHttpRequest.cpp new file mode 100644 index 000000000..1dfd59acc --- /dev/null +++ b/src/kvilib/net/KviHttpRequest.cpp @@ -0,0 +1,1432 @@ +//============================================================================= +// +// File : KviHttpRequest.cpp +// Creation date : Sat Aug 17 13:43:32 2002 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + + + +#include +#include +//#include + +#include "KviHttpRequest.h" +#include "KviLocale.h" +#include "KviNetUtils.h" +#include "KviDnsResolver.h" +#include "kvi_error.h" +#include "kvi_debug.h" +#include "kvi_socket.h" +#include "KviTimeUtils.h" + +#ifdef COMPILE_SSL_SUPPORT + #include "KviSSL.h" +#endif + + +#define KVI_HTTP_REQUEST_THREAD_EVENT_CONNECTED (KVI_THREAD_USER_EVENT_BASE + 0xCAFE) +#define KVI_HTTP_REQUEST_THREAD_EVENT_REQUESTSENT (KVI_THREAD_USER_EVENT_BASE + 0xCAFF) + +KviHttpRequest::KviHttpRequest() +: QObject() +{ + m_pDns = 0; + m_pThread = 0; + m_pFile = 0; + m_pPrivateData = 0; + m_bHeaderProcessed = false; + m_pBuffer = new KviDataBuffer(); + m_uConnectionTimeout = 60; + + resetStatus(); + resetData(); +} + +KviHttpRequest::~KviHttpRequest() +{ + resetInternalStatus(); + delete m_pBuffer; +} + +void KviHttpRequest::abort() +{ + resetInternalStatus(); + m_szLastError = __tr2qs("Aborted"); + emit terminated(false); +} + +void KviHttpRequest::resetInternalStatus() +{ + if(m_pThread)delete m_pThread; + if(m_pDns)delete m_pDns; + + m_pDns = 0; + m_pThread = 0; + + if(!m_pFile)return; + m_pFile->close(); + delete m_pFile; + m_pFile = 0; + + m_pBuffer->clear(); + m_bHeaderProcessed = false; + + KviThreadManager::killPendingEvents(this); +} + +void KviHttpRequest::resetStatus() +{ + m_szLastError = __tr2qs("No request"); + m_uTotalSize = 0; + m_uReceivedSize = 0; +} + +void KviHttpRequest::resetData() +{ + m_szFileName = ""; + m_eProcessingType = WholeFile; + m_eExistingFileAction = RenameIncoming; + m_url = QString(""); + m_uMaxContentLength = 0; + m_uContentOffset = 0; + m_bChunkedTransferEncoding = false; + m_bGzip = false; + m_bIgnoreRemainingData = false; + m_uRemainingChunkSize = 0; +} + +void KviHttpRequest::reset() +{ + resetStatus(); + resetData(); + resetInternalStatus(); +} + +bool KviHttpRequest::get(const KviUrl &u,ProcessingType p,const QString &szFileName) +{ + reset(); + setUrl(u); + setProcessingType(p); + setFileName(szFileName); + return start(); +} + +bool KviHttpRequest::start() +{ + // ensure that the file is closed + resetInternalStatus(); + resetStatus(); + + if(m_eProcessingType == StoreToFile) + { + if(m_szFileName.isEmpty()) + { + m_szLastError = __tr2qs("No filename specified for the \"StoreToFile\" processing type"); + return false; + } + + if((m_eExistingFileAction == Resume) && (m_uContentOffset == 0)) + { + // determine the content offset automatically + if(KviFile::exists(m_szFileName)) + { + // we check it + QFileInfo fi(m_szFileName); + m_uContentOffset = fi.size(); + } + } + } + + if(m_url.host().isEmpty()) + { + resetInternalStatus(); + m_szLastError = __tr2qs("Invalid URL: Missing hostname"); + return false; + } + + if(!KviQString::equalCI(m_url.protocol(),"http") && !KviQString::equalCI(m_url.protocol(),"https")) + { + resetInternalStatus(); + m_szLastError=__tr2qs("Unsupported protocol %1").arg(m_url.protocol()); + return false; + } + + if(KviNetUtils::isValidStringIp(m_url.host())) + { + m_szIp = m_url.host(); + QTimer::singleShot(10,this,SLOT(haveServerIp())); + return true; + } + + return startDnsLookup(); +} + +bool KviHttpRequest::startDnsLookup() +{ + m_pDns = new KviDnsResolver(); + connect(m_pDns,SIGNAL(lookupDone(KviDnsResolver *)),this,SLOT(dnsLookupDone(KviDnsResolver *))); + + if(!m_pDns->lookup(m_url.host(),KviDnsResolver::IPv4)) + { + resetInternalStatus(); + m_szLastError = __tr2qs("Unable to start the DNS lookup"); + return false; + } + + QString tmp; + KviQString::sprintf(tmp,__tr2qs("Looking up host %Q"),&(m_url.host())); + emit status(tmp); // FIXME + + emit resolvingHost(m_url.host()); + + return true; +} + +void KviHttpRequest::dnsLookupDone(KviDnsResolver *d) +{ + if(d->state() == KviDnsResolver::Success) + { + m_szIp = d->firstIpAddress(); + delete m_pDns; + m_pDns = 0; + QString tmp; + KviQString::sprintf(tmp,__tr2qs("Host %Q resolved to %Q"),&(m_url.host()),&m_szIp); + emit status(tmp); + haveServerIp(); + } else { + int iErr = d->error(); + resetInternalStatus(); + m_szLastError = KviError::getDescription(iErr); + emit terminated(false); + } +} + +void KviHttpRequest::haveServerIp() +{ + unsigned short uPort = m_url.port(); + if(uPort == 0)uPort = 80; + + QString tmp; + KviQString::sprintf(tmp,"%Q:%u",&m_szIp,uPort); + emit contactingHost(tmp); + + if(m_pThread)delete m_pThread; + + m_pThread = new KviHttpRequestThread( + this, + m_url.host(), + m_szIp, + uPort, + m_url.path(), + m_uContentOffset, + (m_eProcessingType == HeadersOnly) ? KviHttpRequestThread::Head : (m_szPostData.isEmpty() ? KviHttpRequestThread::Get : KviHttpRequestThread::Post), + m_szPostData, + m_url.protocol()=="https" + ); + + m_pThread->setConnectionTimeout(m_uConnectionTimeout); + + if(!m_pThread->start()) + { + resetInternalStatus(); + m_szLastError = __tr2qs("Unable to start the request slave thread"); + emit terminated(false); + return; + } + + KviQString::sprintf(tmp,__tr2qs("Contacting host %Q on port %u"),&m_szIp,uPort); + emit status(tmp); +} + +bool KviHttpRequest::event(QEvent *e) +{ + if(e->type() == KVI_THREAD_EVENT) + { + switch(((KviThreadEvent *)e)->id()) + { + case KVI_THREAD_EVENT_BINARYDATA: + { + KviDataBuffer * b = ((KviThreadDataEvent *)e)->getData(); + processData(b); + delete b; + return true; + } + break; + case KVI_HTTP_REQUEST_THREAD_EVENT_CONNECTED: + emit connectionEstabilished(); + emit status(__tr2qs("Connection established, sending request")); + return true; + break; + case KVI_HTTP_REQUEST_THREAD_EVENT_REQUESTSENT: + { + QString * req = ((KviThreadDataEvent *)e)->getData(); + QStringList sl = req->split("\r\n"); + emit requestSent(sl); + delete req; + return true; + } + break; + case KVI_THREAD_EVENT_SUCCESS: + if(!m_pThread && !m_bHeaderProcessed) + { + // the thread has already been deleted + // probably because the response was something like a 404 + // just ignore the event + return true; + } + switch(m_eProcessingType) + { + case WholeFile: + // happens always + emit binaryData(*m_pBuffer); + break; + case Blocks: + // an unprocessed block ?.. should never happend.. but well :D + if(m_pBuffer->size() > 0)emit binaryData(*m_pBuffer); + break; + case Lines: + if(m_pBuffer->size() > 0) + { + // something left in the buffer and has no trailing LF + KviCString tmp((const char *)(m_pBuffer->data()),m_pBuffer->size()); + emit data(tmp); + } + break; + case StoreToFile: + // same as above... should never happen.. but well :D + if(m_pFile && m_pBuffer->size() > 0)m_pFile->write((const char *)(m_pBuffer->data()),m_pBuffer->size()); + break; + default: + // nothing... just make gcc happy + break; + } + resetInternalStatus(); + m_szLastError = __tr2qs("Success"); + emit terminated(true); + return true; + break; + case KVI_THREAD_EVENT_ERROR: + { + KviCString * err = ((KviThreadDataEvent *)e)->getData(); + m_szLastError = __tr2qs_no_xgettext(err->ptr()); + delete err; + resetInternalStatus(); + emit terminated(false); + return true; + } + break; + case KVI_THREAD_EVENT_MESSAGE: + { + KviCString * msg = ((KviThreadDataEvent *)e)->getData(); + emit status(__tr2qs_no_xgettext(msg->ptr())); + delete msg; + return true; + } + break; + } + } + return QObject::event(e); +} + +void KviHttpRequest::emitLines(KviDataBuffer * pDataBuffer) +{ + int idx = pDataBuffer->find((const unsigned char *)"\n",1); + while(idx != -1) + { + KviCString tmp((const char *)(m_pBuffer->data()),idx); + tmp.stripRight('\r'); + pDataBuffer->remove(idx + 1); + idx = pDataBuffer->find((const unsigned char *)"\n",1); + emit data(tmp); + } +} + +// header += "Accept: "; +// QString acceptHeader = metaData("accept"); +// if (!acceptHeader.isEmpty()) +// header += acceptHeader; +// else +// header += DEFAULT_ACCEPT_HEADER; +// header += "\r\n"; +// +//#ifdef DO_GZIP +// if (m_request.allowCompressedPage) +// header += "Accept-Encoding: x-gzip, x-deflate, gzip, deflate, identity\r\n"; +//#endif +// +// if (!m_request.charsets.isEmpty()) +// header += "Accept-Charset: " + m_request.charsets + "\r\n"; +// +// if (!m_request.languages.isEmpty()) +// header += "Accept-Language: " + m_request.languages + "\r\n"; +// +// +// /* support for virtual hosts and required by HTTP 1.1 */ +// header += "Host: "; +// header += "Pragma: no-cache\r\n"; /* for HTTP/1.0 caches */ +// header += "Cache-control: no-cache\r\n"; /* for HTTP >=1.1 caches */ + +// header += "Referer: "; //Don't try to correct spelling! +// header += m_request.referrer; +// header += "\r\n"; +bool KviHttpRequest::openFile() +{ + if(m_eProcessingType != StoreToFile)return true; + + bool bAppend = false; + + // take action when the file is existing + if(KviFile::exists(m_szFileName)) + { + switch(m_eExistingFileAction) + { + case Resume: + { + bAppend = true; + } + break; + case RenameIncoming: + { + int i=0; + QString tmp = m_szFileName; + do { + i++; + m_szFileName = tmp + QString(".kvirnm-%1").arg(i); + } while(KviFile::exists(m_szFileName)); + } + break; + case RenameExisting: + { + int i=0; + QString tmp; + do { + i++; + tmp = m_szFileName + QString(".kvirnm-%1").arg(i); + } while(KviFile::exists(tmp)); + QDir d; + if(!d.rename(m_szFileName,tmp)) + { + // fail :( + resetInternalStatus(); + m_szLastError = __tr2qs("Failed to rename the existing file, please rename manually and retry"); + emit terminated(false); + return false; + } + } + break; + case Overwrite: + default: + // nothing + break; + } + } + + m_pFile = new KviFile(m_szFileName); + + if(!m_pFile->open(QFile::WriteOnly | (bAppend ? QFile::Append : QFile::Truncate))) + { + resetInternalStatus(); + KviQString::sprintf(m_szLastError,__tr2qs("Can't open file \"%Q\" for writing"),&m_szFileName); + emit terminated(false); + return false; + } + + return true; +} + + +bool KviHttpRequest::processHeader(KviCString &szHeader) +{ + int idx = szHeader.findFirstIdx("\r\n"); + KviCString szResponse; + if(idx != -1) + { + szResponse = szHeader.left(idx); + szHeader.cutLeft(idx + 2); + } else { + szResponse = szHeader; + szHeader = ""; + } + + szResponse.trimmed(); + + bool bValid = false; + + unsigned int uStatus = 0; + + // check the response value + if(kvi_strEqualCSN(szResponse.ptr(),"HTTP",4)) + { + KviCString szR = szResponse; + szR.cutToFirst(' '); + szR.trimmed(); + int idx = szR.findFirstIdx(' '); + KviCString szNumber; + if(idx != -1)szNumber = szR.left(idx); + else szNumber = szR; + bool bOk; + uStatus = szNumber.toUInt(&bOk); + if(bOk)bValid = true; + } + + QString szUniResponse = QString::fromUtf8(szResponse.ptr()); + + if(!bValid) + { + // the response is invalid ? + resetInternalStatus(); + m_szLastError = __tr2qs("Invalid HTTP response: %1").arg(szUniResponse); + emit terminated(false); + return false; + } + + QString tmp = __tr2qs("Received HTTP response: %1").arg(szUniResponse); + + emit status(tmp); + emit receivedResponse(szUniResponse); + + KviPointerList hlist; + hlist.setAutoDelete(true); + + idx = szHeader.findFirstIdx("\r\n"); + while(idx != -1) + { + if(idx > 0) + { + hlist.append(new KviCString(szHeader.ptr(),idx)); + szHeader.cutLeft(idx + 2); + } + idx = szHeader.findFirstIdx("\r\n"); + } + if(szHeader.hasData())hlist.append(new KviCString(szHeader)); + + KviPointerHashTable hdr(11,false,true); + hdr.setAutoDelete(true); + + for(KviCString * s = hlist.first();s;s = hlist.next()) + { + idx = s->findFirstIdx(":"); + if(idx != -1) + { + KviCString szName = s->left(idx); + s->cutLeft(idx + 1); + s->trimmed(); + hdr.replace(szName.ptr(),new KviCString(*s)); + //qDebug("FOUND HEADER (%s)=(%s)",szName.ptr(),s->ptr()); + } + } + + KviCString * size = hdr.find("Content-length"); + if(size) + { + bool bOk; + m_uTotalSize = size->toUInt(&bOk); + if(!bOk)m_uTotalSize = 0; + } + + KviCString * contentEncoding = hdr.find("Content-encoding"); + if(contentEncoding) + { + m_bGzip = contentEncoding->equalsCI("gzip"); + } + + KviCString * transferEncoding = hdr.find("Transfer-Encoding"); + if(transferEncoding) + { + if(kvi_strEqualCI(transferEncoding->ptr(),"chunked")) + { + // be prepared to handle the chunked transfer encoding as required by HTTP/1.1 + m_bChunkedTransferEncoding = true; + m_uRemainingChunkSize = 0; + } + } + + emit header(&hdr); + + // check the status + + // case 200: // OK + // case 206: // Partial content + + // case 100: // Continue ?? + // case 101: // Switching protocols ??? + // case 201: // Created + // case 202: // Accepted + // case 203: // Non-Authoritative Information + // case 204: // No content + // case 205: // Reset content + // case 300: // Multiple choices + // case 301: // Moved permanently + // case 302: // Found + // case 303: // See Other + // case 304: // Not modified + // case 305: // Use Proxy + // case 306: // ??? + // case 307: // Temporary Redirect + // case 400: // Bad request + // case 401: // Unauthorized + // case 402: // Payment Required + // case 403: // Forbidden + // case 404: // Not found + // case 405: // Method not allowed + // case 406: // Not acceptable + // case 407: // Proxy authentication required + // case 408: // Request timeout + // case 409: // Conflict + // case 410: // Gone + // case 411: // Length required + // case 412: // Precondition failed + // case 413: // Request entity too large + // case 414: // Request-URI Too Long + // case 415: // Unsupported media type + // case 416: // Requested range not satisfiable + // case 417: // Expectation Failed + // case 500: // Internal server error + // case 501: // Not implemented + // case 502: // Bad gateway + // case 503: // Service unavailable + // case 504: // Gateway timeout + // case 505: // HTTP Version not supported + + if((uStatus != 200) && (uStatus != 206)) + { + // this is not "OK" and not "Partial content" + // Error, redirect or something confusing + + // FIXME: Handle 30x codes by re-issuing the request with the new URI ? + + if(m_eProcessingType != HeadersOnly) + { + // this is an error then + resetInternalStatus(); + m_szLastError = szResponse.ptr(); + emit terminated(false); + return false; + } // else the server will terminate (it was a HEAD request) + } + + if((m_uMaxContentLength > 0) && (m_uTotalSize > ((unsigned int)m_uMaxContentLength))) + { + resetInternalStatus(); + m_szLastError=__tr2qs("Stream exceeding maximum length"); + emit terminated(false); + return false; + } + + // fixme: could check for data type etc... + + return true; +} +#define BUFFER_SIZE 32768 + +void KviHttpRequest::processData(KviDataBuffer * data) +{ +// unsigned char obuffer[BUFFER_SIZE]; + if(m_bChunkedTransferEncoding && m_bIgnoreRemainingData) + { + // In chunked transfer encoding mode there may be additional headers + // after the last chunk of data. We simply ignore them. + return; + } + + if(!m_bHeaderProcessed) + { + // time to process the header + m_pBuffer->append(*data); + + int idx = m_pBuffer->find((const unsigned char *)"\r\n\r\n",4); + if(idx == -1) + { + // header not complete + if(m_pBuffer->size() > 4096) + { + resetInternalStatus(); + m_szLastError = __tr2qs("Header too long: exceeded 4096 bytes"); + emit terminated(false); + } + return; + } + KviCString szHeader((const char *)(m_pBuffer->data()),idx); + m_pBuffer->remove(idx + 4); + + if(!processHeader(szHeader))return; + m_bHeaderProcessed = true; + + if(m_eProcessingType == StoreToFile) + { + if(!openFile())return; + } + + m_uReceivedSize = m_pBuffer->size(); + + + // here the header is complete and the eventual remaining data is in m_pBuffer. data has been already used. + + } else { + // header already processed + m_uReceivedSize += data->size(); + + // here the header is complete and some data *might* be already in m_pBuffer. data is unused yet. + + // Optimisation: If the transfer is NOT chunked (so we don't have to parse it) + // and the requested processing type is either Blocks or StoreToFile + // then we just can avoid to copy the data to m_pBuffer. + // This is a good optimisation since for large files we can save allocating + // space for and moving megabytes of data... + + + if((!m_bChunkedTransferEncoding) && ((m_eProcessingType == Blocks) || (m_eProcessingType == StoreToFile))) + { + switch(m_eProcessingType) + { + case Blocks: + emit binaryData(*data); + break; + case StoreToFile: + m_pFile->write((const char *)(data->data()),data->size()); + break; + default: + break; + } + + if(((m_uTotalSize > 0) && (m_uReceivedSize > m_uTotalSize)) || ((m_uMaxContentLength > 0) && (m_uReceivedSize > m_uMaxContentLength))) + { + resetInternalStatus(); + m_szLastError=__tr2qs("Stream exceeded expected length"); + emit terminated(false); + } + + return; + } + + // need to append to m_pBuffer and process it + m_pBuffer->append(*data); + } + + // we're processing data in m_pBuffer here + if(m_bChunkedTransferEncoding) + { + // The transfer encoding is chunked: the buffer contains + // chunks of data with an initial header composed + // of a hexadecimal length, an optional bullshit and a single CRLF + // The transfer terminates when we read a last chunk of size 0 + // that may be followed by optional headers... + // This sux :) + while(m_pBuffer->size() > 0) // <-- note that we may exit from this loop also for other conditions (there is a goto below) + { + // we process chunks of parts of chunks at a time. + if(m_uRemainingChunkSize > 0) + { + // process the current chunk data + unsigned int uProcessSize = m_uRemainingChunkSize; + if(uProcessSize > (unsigned int)m_pBuffer->size())uProcessSize = m_pBuffer->size(); + m_uRemainingChunkSize -= uProcessSize; + + switch(m_eProcessingType) + { + case Blocks: + if((unsigned int)m_pBuffer->size() == uProcessSize) + { + // avoid copying to a new buffer + emit binaryData(*m_pBuffer); + } else { + // must copy + KviDataBuffer tmp(uProcessSize,m_pBuffer->data()); + emit binaryData(tmp); + m_pBuffer->remove(uProcessSize); + } + break; + case Lines: + if((unsigned int)m_pBuffer->size() == uProcessSize) + { + // avoid copying to a new buffer + emitLines(m_pBuffer); + } else { + // must copy + KviDataBuffer tmp(uProcessSize,m_pBuffer->data()); + emitLines(&tmp); + m_pBuffer->remove(uProcessSize); + } + break; + case StoreToFile: + m_pFile->write((const char *)(m_pBuffer->data()),uProcessSize); + m_pBuffer->remove(uProcessSize); + break; + default: + // nothing.. just make gcc happy + break; + } + // now either the buffer is empty or there is another chunk header: continue looping + } else { + // We're looking for the beginning of a chunk now. + // Note that we might be at the end of a previous chunk that has a CRLF terminator + // we need to skip it. + int crlf = m_pBuffer->find((const unsigned char *)"\r\n",2); + if(crlf != -1) + { + if(crlf == 0) + { + // This is a plain CRLF at the beginning of the buffer BEFORE a chunk header. + // It comes from the previous chunk terminator. Skip it. + m_pBuffer->remove(2); + } else { + // got a chunk header + KviCString szHeader((const char *)(m_pBuffer->data()),crlf); + szHeader.cutFromFirst(' '); + // now szHeader should contain a hexadecimal chunk length... (why the hell it is hex and not decimal ????) + QString szHexHeader = szHeader.ptr(); + bool bOk; + m_uRemainingChunkSize = szHexHeader.toLong(&bOk,16); + if(!bOk) + { + resetInternalStatus(); + m_szLastError = __tr2qs("Protocol error: invalid chunk size"); + emit terminated(false); + return; + } + m_pBuffer->remove(crlf+2); + if(m_uRemainingChunkSize == 0) + { + // this is the last chunk of data. It may be followed by optional headers + // but we actually don't need them (since we're surely not in HEAD mode) + m_bIgnoreRemainingData = true; + m_pBuffer->clear(); + goto check_stream_length; + } + } + // the rest is valid data of a non-zero chunk: continue looping + } else { + // chunk header not complete + if(m_pBuffer->size() > 4096) + { + resetInternalStatus(); + m_szLastError = __tr2qs("Chunk header too long: exceeded 4096 bytes"); + emit terminated(false); + return; + } + goto check_stream_length; + } + } + } + } else { + // the transfer encoding is not chunked: m_pBuffer contains only valid data + switch(m_eProcessingType) + { + case Blocks: + if(m_pBuffer->size() > 0)emit binaryData(*m_pBuffer); + m_pBuffer->clear(); + break; + case Lines: + if(m_pBuffer->size() > 0)emitLines(m_pBuffer); + break; + case StoreToFile: + m_pFile->write((const char *)(m_pBuffer->data()),m_pBuffer->size()); + m_pBuffer->clear(); + break; + default: + // nothing.. just make gcc happy + break; + } + } + +check_stream_length: + + if(((m_uTotalSize > 0) && (m_uReceivedSize > m_uTotalSize)) || ((m_uMaxContentLength > 0) && (m_uReceivedSize > m_uMaxContentLength))) + { + resetInternalStatus(); + m_szLastError=__tr2qs("Stream exceeded expected length"); + emit terminated(false); + } + return; +} + +KviHttpRequestThread::KviHttpRequestThread( + KviHttpRequest * r, + const QString &szHost, + const QString &szIp, + unsigned short uPort, + const QString & szPath, + unsigned int uContentOffset, + RequestMethod m, + const QString &szPostData, + bool bUseSSL + ) : KviSensitiveThread() +{ + m_pRequest = r; + m_szHost = szHost; + m_szIp = szIp; + m_szPath = szPath; + m_uPort = uPort > 0 ? uPort : 80; + m_uContentOffset = uContentOffset; + m_eRequestMethod = m; + m_szPostData = szPostData; + m_sock = KVI_INVALID_SOCKET; + m_bUseSSL = bUseSSL; + m_uConnectionTimeout = 60; +#ifdef COMPILE_SSL_SUPPORT + m_pSSL = 0; +#endif +} + +KviHttpRequestThread::~KviHttpRequestThread() +{ +} + +bool KviHttpRequestThread::processInternalEvents() +{ + while(KviThreadEvent *e = dequeueEvent()) + { + switch(e->id()) + { + case KVI_THREAD_EVENT_TERMINATE: + { + delete e; + return false; + } + break; + default: + qDebug("Unrecognized event in http thread"); + delete e; + return false; + break; + } + } + + return true; +} + +bool KviHttpRequestThread::failure(const char *error) +{ + if(error) + { + postEvent(m_pRequest,new KviThreadDataEvent(KVI_THREAD_EVENT_ERROR,new KviCString(error))); + } /*else { + postEvent(m_pRequest,new KviThreadDataEvent(KVI_THREAD_EVENT_ERROR,new KviCString(__tr2qs("Aborted")))); + }*/ + return false; +} + +bool KviHttpRequestThread::selectForWrite(int iTimeoutInSecs) +{ + + kvi_time_t startTime = kvi_unixTime(); + + for(;;) + { + if(!processInternalEvents()) + { + return failure(0); + } + + fd_set writeSet; + + FD_ZERO(&writeSet); + + FD_SET(m_sock,&writeSet); + + struct timeval tmv; + tmv.tv_sec = 0; + tmv.tv_usec = 1000; // we wait 1000 usecs for an event + + + int nRet = kvi_socket_select(m_sock + 1,0,&writeSet,0,&tmv); + + if(nRet > 0) + { + if(FD_ISSET(m_sock,&writeSet)) + { + // connected! + return true; + } + } else { + if(nRet < 0) + { + int err = kvi_socket_error(); +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + if((err != EAGAIN) && (err != EINTR) && (err != WSAEWOULDBLOCK)) +#else + if((err != EAGAIN) && (err != EINTR)) +#endif + { + return failure(KviError::getUntranslatedDescription(KviError::translateSystemError(err))); + } + } + } + + + if((time(0) - startTime) > iTimeoutInSecs) + return failure(__tr_no_lookup("Operation timed out")); + + usleep(100000); // 1/10 sec + } + + return false; +} + +bool KviHttpRequestThread::sslFailure() +{ +#ifdef COMPILE_SSL_SUPPORT + KviCString buffer; + if(m_pSSL->getLastErrorString(buffer)) + { + failure(buffer.ptr()); + } else { + failure(__tr_no_lookup("Unexpected SSL error")); + } +#endif + return false; +} + +bool KviHttpRequestThread::connectToRemoteHost() +{ + m_sock = kvi_socket_create(KVI_SOCKET_PF_INET,KVI_SOCKET_TYPE_STREAM,0); //tcp + if(m_sock == KVI_INVALID_SOCKET) + return failure(__tr_no_lookup("Failed to create the socket")); + + if(!kvi_socket_setNonBlocking(m_sock)) + return failure(__tr_no_lookup("Failed to enter non blocking mode")); + + sockaddr_in saddr; + + if(!KviNetUtils::stringIpToBinaryIp(m_szIp,&(saddr.sin_addr))) + return failure(__tr_no_lookup("Invalid target address")); + + saddr.sin_port = htons(m_uPort); + saddr.sin_family = AF_INET; + + if(!kvi_socket_connect(m_sock,(struct sockaddr *)&saddr,sizeof(saddr))) + { + int err = kvi_socket_error(); + if(!kvi_socket_recoverableConnectError(err)) + { + return failure(KviError::getUntranslatedDescription(KviError::translateSystemError(err))); + } + } + + // now loop selecting for write + + if(!selectForWrite(m_uConnectionTimeout)) + return false; + + int sockError; + int iSize=sizeof(sockError); + if(!kvi_socket_getsockopt(m_sock,SOL_SOCKET,SO_ERROR,(void *)&sockError,&iSize))sockError = -1; + if(sockError != 0) + { + //failed + if(sockError > 0)sockError = KviError::translateSystemError(sockError); + else sockError = KviError_unknownError; + return failure(KviError::getUntranslatedDescription(sockError)); + } + +#ifdef COMPILE_SSL_SUPPORT + if(m_bUseSSL) + { + m_pSSL = new KviSSL(); + if(!m_pSSL->initContext(KviSSL::Client)) + return failure(__tr_no_lookup("Failed to initialize the SSL context")); + if(!m_pSSL->initSocket(m_sock)) + return failure(__tr_no_lookup("Failed to initialize the SSL connection")); + + for(;;) + { + switch(m_pSSL->connect()) + { + case KviSSL::Success: + // done: connected. + return true; + break; + case KviSSL::WantRead: + if(!selectForRead(m_uConnectionTimeout)) + return false; + break; + case KviSSL::WantWrite: + if(!selectForWrite(m_uConnectionTimeout)) + return false; + break; + case KviSSL::RemoteEndClosedConnection: + return failure(__tr_no_lookup("Remote end has closed the connection")); + break; + case KviSSL::SSLError: + return sslFailure(); + break; + case KviSSL::SyscallError: + { + // syscall problem + int err = kvi_socket_error(); + if(!kvi_socket_recoverableError(err)) + { + // Declare problems :) + return failure(__tr_no_lookup("Unrecoverable SSL error during handshake")); + } // else can recover ? (EAGAIN, EINTR ?) ... should select for read or for write + } + break; + default: + return sslFailure(); + break; + } + } + + // never here + return true; + } +#endif + + return true; +} + + +bool KviHttpRequestThread::sendBuffer(const char * buffer,int bufLen,int iTimeoutInSecs) +{ + const char * ptr = buffer; + int curLen = bufLen; + + time_t startTime = time(0); + + for(;;) + { + if(!processInternalEvents()) + return failure(); + + int wrtn; +#ifdef COMPILE_SSL_SUPPORT + if(m_pSSL) + { + wrtn = m_pSSL->write((char *)ptr,curLen); + } else { +#endif + wrtn = kvi_socket_send(m_sock,ptr,curLen); +#ifdef COMPILE_SSL_SUPPORT + } +#endif + + if(wrtn > 0) + { + curLen -= wrtn; + + if(curLen <= 0) + break; + + ptr += wrtn; + } else { + if(wrtn < 0) + { +#ifdef COMPILE_SSL_SUPPORT + if(m_pSSL) + { + // ops...might be an SSL error + switch(m_pSSL->getProtocolError(wrtn)) + { + case KviSSL::WantWrite: + if(!selectForWrite(m_uConnectionTimeout)) + return false; + break; + case KviSSL::WantRead: + if(!selectForRead(m_uConnectionTimeout)) + return false; + break; + case KviSSL::SyscallError: + if(wrtn == 0) + { + return failure(__tr_no_lookup("Remote end has closed the connection")); + } else { + int iSSLErr = m_pSSL->getLastError(true); + if(iSSLErr != 0) + { + return sslFailure(); + } else { + goto handle_system_error; + } + } + break; + case KviSSL::SSLError: + return sslFailure(); + break; + default: + return sslFailure(); + break; + } + } else { +#endif //COMPILE_SSL_SUPPORT + +handle_system_error: + int err = kvi_socket_error(); +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + if((err != EAGAIN) && (err != EINTR) && (err != WSAEWOULDBLOCK)) +#else + if((err != EAGAIN) && (err != EINTR)) +#endif + { + return failure(KviError::getUntranslatedDescription(KviError::translateSystemError(err))); + } +#ifdef COMPILE_SSL_SUPPORT + } +#endif + } + } + + int diff = time(0) - startTime; + if(diff > iTimeoutInSecs) + return failure(__tr_no_lookup("Operation timed out")); + + usleep(10000); + } + + return true; +} + +int KviHttpRequestThread::selectForReadStep() +{ + // calls select on the main socket + // returns 1 if there is data available for reading + // returns 0 if there is no data available but there was no error + // returns -1 if there was a critical error (socket closed) + fd_set readSet; + + FD_ZERO(&readSet); + + FD_SET(m_sock,&readSet); + + struct timeval tmv; + tmv.tv_sec = 0; + tmv.tv_usec = 1000; // we wait 1000 usecs for an event + + + int nRet = kvi_socket_select(m_sock + 1,&readSet,0,0,&tmv); + + if(nRet > 0) + { + if(FD_ISSET(m_sock,&readSet)) + { + // ok + return 1; + } + } else { + if(nRet < 0) + { + int err = kvi_socket_error(); +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + if((err != EAGAIN) && (err != EINTR) && (err != WSAEWOULDBLOCK)) +#else + if((err != EAGAIN) && (err != EINTR)) +#endif + { + failure(KviError::getUntranslatedDescription(KviError::translateSystemError(err))); + return -1; + } + } + } + + return 0; +} + +bool KviHttpRequestThread::selectForRead(int iTimeoutInSecs) +{ + // waits for some data to arrive on the socket + // up to iTimeoutInSecs seconds + // returns true if data is available on the socket + // or false if there was a select() error or no data + // was available in the specified amount of time + + time_t startTime = time(0); + + for(;;) + { + if(!processInternalEvents()) + { + return failure(); // ensure that the socket is closed + } + + int nRet = selectForReadStep(); + + if(nRet < 0)return false; + if(nRet > 0)return true; + + int diff = time(0) - startTime; + if(diff > iTimeoutInSecs) + return failure(__tr_no_lookup("Operation timed out (while selecting for read)")); + + usleep(100000); // 1/10 sec + } + + return false; +} + +bool KviHttpRequestThread::readDataStep() +{ + unsigned char buffer[2048]; + int readed; + + +#ifdef COMPILE_SSL_SUPPORT + if(m_pSSL) + { + readed = m_pSSL->read((char *)buffer,2048); + if(readed <= 0) + { + // ssl error....? + switch(m_pSSL->getProtocolError(readed)) + { + case KviSSL::ZeroReturn: + readed = 0; + break; + case KviSSL::WantRead: + return selectForRead(m_uConnectionTimeout); + break; + case KviSSL::WantWrite: + return selectForWrite(m_uConnectionTimeout); + break; + case KviSSL::SyscallError: + { + int iE = m_pSSL->getLastError(true); + if(iE != 0)return sslFailure(); + } + break; + case KviSSL::SSLError: + return sslFailure(); + break; + default: + return sslFailure(); + break; + } + } + } else { +#endif + readed = kvi_socket_read(m_sock,buffer,2048); +#ifdef COMPILE_SSL_SUPPORT + } +#endif + + if(readed > 0) + { + postEvent(m_pRequest,new KviThreadDataEvent(KVI_THREAD_EVENT_BINARYDATA,new KviDataBuffer(readed,buffer))); + } else { + if(readed < 0) + { + // Read error ? + int err = kvi_socket_error(); +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + if((err != EAGAIN) && (err != EINTR) && (err != WSAEWOULDBLOCK)) +#else + if((err != EAGAIN) && (err != EINTR)) +#endif + { + // yes...read error + return failure(KviError::getUntranslatedDescription(KviError::translateSystemError(err))); + } + return selectForRead(m_uConnectionTimeout); // EINTR or EAGAIN...transient problem + } else { + // readed == 0 + // Connection closed by remote host + postEvent(m_pRequest,new KviThreadEvent(KVI_THREAD_EVENT_SUCCESS)); + return false; + } + } + return selectForRead(m_uConnectionTimeout); +} + +void KviHttpRequestThread::run() +{ + // setup: + // nothing needed + + // run: + runInternal(); + + // cleanup: +#ifdef COMPILE_SSL_SUPPORT + if(m_pSSL) + { + delete m_pSSL; + m_pSSL = 0; + } +#endif + + if(kvi_socket_isValid(m_sock)) + { + kvi_socket_close(m_sock); + m_sock = KVI_INVALID_SOCKET; + } +} + +void KviHttpRequestThread::runInternal() +{ +#ifndef COMPILE_SSL_SUPPORT + if(m_bUseSSL) + { + failure(__tr_no_lookup("This KVIrc executable has no SSL support")); + return; + } +#endif + + if(!connectToRemoteHost())return; + + postEvent(m_pRequest,new KviThreadEvent(KVI_HTTP_REQUEST_THREAD_EVENT_CONNECTED)); + + // FIXME: Other headers ? + + KviCString szMethod; + switch(m_eRequestMethod) + { + case Head: szMethod = "HEAD"; break; + case Post: szMethod = "POST"; break; + case Get: szMethod = "GET"; break; + } + + KviCString szRequest(KviCString::Format,"%s %s HTTP/1.1\r\n" \ + "Host: %s\r\n" \ + "Connection: Close\r\n" \ + "User-Agent: KVIrc-http-slave/1.0.0\r\n" \ + "Accept: */*\r\n", + szMethod.ptr(),KviQString::toUtf8(m_szPath).data(),KviQString::toUtf8(m_szHost).data()); + + if(m_uContentOffset > 0) + szRequest.append(KviCString::Format,"Range: bytes=%u-\r\n",m_uContentOffset); + + if(m_eRequestMethod == Post) + { + szRequest.append(KviCString::Format,"Content-Type: application/x-www-form-urlencoded\r\n" \ + "Content-Length: %u\r\n" \ + "Cache-control: no-cache\r\n" \ + "Pragma: no-cache\r\n",m_szPostData.length()); + } + + szRequest += "\r\n"; + + if(m_eRequestMethod == Post) + { + if(!m_szPostData.isEmpty()) + szRequest.append(m_szPostData); + szRequest += "\r\n"; + } + + //qDebug("SENDING REQUEST:\n%s",szRequest.ptr()); + + if(!sendBuffer(szRequest.ptr(),szRequest.len(),60))return; + + // now loop reading data + postEvent(m_pRequest,new KviThreadDataEvent(KVI_HTTP_REQUEST_THREAD_EVENT_REQUESTSENT,new QString(szRequest))); + + for(;;) + { + if(!readDataStep())return; + } +} diff --git a/src/kvilib/net/KviHttpRequest.h b/src/kvilib/net/KviHttpRequest.h new file mode 100644 index 000000000..db4c96ab9 --- /dev/null +++ b/src/kvilib/net/KviHttpRequest.h @@ -0,0 +1,225 @@ +#ifndef _KVI_HTTP_H_ +#define _KVI_HTTP_H_ +//============================================================================= +// +// File : KviHttpRequest.h +// Creation date : Sat Aug 17 13:43:31 2002 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "KviHeapObject.h" +#include "KviCString.h" +#include "KviThread.h" +#include "kvi_sockettype.h" +#include "KviDataBuffer.h" +#include "kvi_inttypes.h" +#include "KviUrl.h" +#include "KviPointerHashTable.h" +#include "KviFile.h" + +#include +#include + +class KviDnsResolver; +class KviSSL; +class KviHttpRequestThread; + +// +// This class implements a HTTP protocol client. +// It's able to send GET, POST and HEAD requests, +// download stuff to a file or to a qt SLOT(). +// + +class KVILIB_API KviHttpRequest : public QObject, public KviHeapObject +{ + Q_OBJECT +public: + enum ProcessingType + { + HeadersOnly, // Download headers only (HEAD request) + WholeFile, // Emit the data as whole file (binaryData() is emitted) + Blocks, // Emit the data as blocks (binaryData() is emitted) + Lines, // Emit the data as ASCII text lines (the client must take care of decoding the data) + StoreToFile // Store the data to a file + }; + enum ExistingFileAction + { + Overwrite, // Overwrite existing file + RenameIncoming, // Automatically rename the incoming file + RenameExisting, // Automatically rename the existing file + Resume // Attempt to resume the file (get partial content) + }; +public: + KviHttpRequest(); + ~KviHttpRequest(); +protected: + // data + KviUrl m_url; + QString m_szFileName; + ProcessingType m_eProcessingType; + ExistingFileAction m_eExistingFileAction; + void * m_pPrivateData; + unsigned int m_uMaxContentLength; + unsigned int m_uContentOffset; + QString m_szPostData; + // status + QString m_szLastError; + unsigned int m_uTotalSize; + unsigned int m_uReceivedSize; + // internal status + QString m_szIp; + KviDnsResolver * m_pDns; + KviHttpRequestThread * m_pThread; + KviDataBuffer * m_pBuffer; + bool m_bHeaderProcessed; + bool m_bChunkedTransferEncoding; + bool m_bGzip; + unsigned int m_uRemainingChunkSize; + bool m_bIgnoreRemainingData; // used in chunked transfer after the last chunk has been seen + KviFile * m_pFile; + unsigned int m_uConnectionTimeout; // in seconds, 60 secs by default +protected: + bool startDnsLookup(); + virtual bool event(QEvent *e); + void processData(KviDataBuffer * data); + bool processHeader(KviCString &szHeader); + bool openFile(); + void emitLines(KviDataBuffer * pDataBuffer); + + void resetStatus(); + void resetData(); + void resetInternalStatus(); +protected slots: + void dnsLookupDone(KviDnsResolver *d); + void haveServerIp(); +public: + void setConnectionTimeout(unsigned int uConnectionTimeout) + { + m_uConnectionTimeout = uConnectionTimeout; + if(m_uConnectionTimeout < 5) + m_uConnectionTimeout = 5; // keep it sane + } + + const KviUrl & url(){ return m_url; }; + ProcessingType processingType(){ return m_eProcessingType; }; + ExistingFileAction existingFileAction(){ return m_eExistingFileAction; }; + const QString &fileName(){ return m_szFileName; }; + void * privateData(){ return m_pPrivateData; }; + unsigned int maxContentLength(){ return m_uMaxContentLength; }; + unsigned int contentOffset(){ return m_uContentOffset; }; + unsigned int totalSize(){ return m_uTotalSize; }; + unsigned int receivedSize(){ return m_uReceivedSize; }; + + void reset(); + + void setPostData(const QString &szPostData){ m_szPostData = szPostData; }; + void setUrl(const KviUrl &u){ m_url = u; }; + void setProcessingType(ProcessingType t){ m_eProcessingType = t; }; + void setExistingFileAction(ExistingFileAction a){ m_eExistingFileAction = a; }; + void setFileName(const QString &szFileName){ m_szFileName = szFileName; }; + void setPrivateData(void * ptr){ m_pPrivateData = ptr; }; + void setMaxContentLength(int uMaxContentLength){ m_uMaxContentLength = uMaxContentLength; }; //0 means unlimited + // this will work regardless of ExistingFileAction : even if the file doesn't exist + void setContentOffset(int uContentOffset){ m_uContentOffset = uContentOffset; }; + + bool start(); + + // this is a shortcut for reset()+setUrl()+setProcessingType()+setFileName()+start() + bool get(const KviUrl &u,ProcessingType p = WholeFile,const QString &szFileName = QString()); + + const QString & lastError(){ return m_szLastError; }; + + void abort(); +signals: + void resolvingHost(const QString &hostname); + void contactingHost(const QString &ipandport); + void connectionEstabilished(); + void receivedResponse(const QString &response); + + void terminated(bool bSuccess); + + + void status(const QString &message); + void data(const KviCString &data); + void binaryData(const KviDataBuffer &data); + void header(KviPointerHashTable * hdr); + void requestSent(const QStringList &request); +}; + + +class KviHttpRequestThread : public KviSensitiveThread +{ + friend class KviHttpRequest; +public: + enum RequestMethod { Post, Get, Head }; +protected: + KviHttpRequestThread(KviHttpRequest * r, + const QString &szHost, + const QString &szIp, + unsigned short uPort, + const QString &szPath, + unsigned int uContentOffset, + RequestMethod m, + const QString &szPostData = QString(), + bool bUseSSL = false + ); + +public: + ~KviHttpRequestThread(); +protected: + KviHttpRequest * m_pRequest; + + QString m_szHost; + QString m_szIp; + QString m_szPath; + unsigned int m_uContentOffset; + RequestMethod m_eRequestMethod; + QString m_szPostData; + + unsigned short m_uPort; + kvi_socket_t m_sock; + bool m_bUseSSL; + unsigned int m_uConnectionTimeout; +#ifdef COMPILE_SSL_SUPPORT + KviSSL * m_pSSL; +#endif +protected: + void setConnectionTimeout(unsigned int uTimeout) + { + m_uConnectionTimeout = uTimeout; + if(m_uConnectionTimeout < 5) + m_uConnectionTimeout = 5; // keep it sane + } + int selectForReadStep(); + bool selectForRead(int iTimeoutInSecs); + bool readDataStep(); + bool sendBuffer(const char *buffer,int bufLen,int iTimeoutInSecs); + bool failure(const char *error=0); + bool sslFailure(); + bool selectForWrite(int iTimeoutInSecs); + bool connectToRemoteHost(); + bool processInternalEvents(); + void runInternal(); + virtual void run(); +}; + + +#endif //_KVI_HTTP_H_ diff --git a/src/kvilib/net/KviNetUtils.cpp b/src/kvilib/net/KviNetUtils.cpp new file mode 100644 index 000000000..4e4edcfa2 --- /dev/null +++ b/src/kvilib/net/KviNetUtils.cpp @@ -0,0 +1,797 @@ +//============================================================================= +// +// File : KviNetUtils.cpp +// Creation date : Sun Jun 18 2000 18:37:27 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#define _KVI_NETUTILS_CPP_ + +#define NTDDI_VERSION NTDDI_WINXP + +#ifndef _WIN32_WINNT + #define _WIN32_WINNT _WIN32_WINNT_WINXP +#endif + +#include "KviNetUtils.h" +#include "kvi_memmove.h" + +#include + +#if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) + #include // struct timeval + #include + #include +#endif + +#ifdef COMPILE_ON_WINDOWS + #include +#endif + +#include +#include "KviQString.h" + +#ifdef COMPILE_GET_INTERFACE_ADDRESS + #include + #include +#endif //COMPILE_GET_INTERFACE_ADDRESS + +#ifndef HAVE_INET_ATON + + +// FIXME: #warning "Your system lacks the inet_aton function," +// FIXME: #warning "you're trying to compile this file without" +// FIXME: #warning "the kvi_sysconfig.h created by the cmake script," +// FIXME: #warning "Using own internal implementation of inet_aton." + +#include + +// Need own inet_aton implementation +// +// Check whether "cp" is a valid ascii representation +// of an Internet address and convert to a binary address. +// Returns 1 if the address is valid, 0 if not. +// This replaces inet_addr, the return value from which +// cannot distinguish between failure and a local broadcast address. +// +// Original code comes from the ircd source. +// + +bool kvi_stringIpToBinaryIp(const char *szIp,struct in_addr *address) +{ + register unsigned long val; + register int base, n; + register char c; + unsigned int parts[4]; + register unsigned int *pp = parts; + if(!szIp)return false; + c = *szIp; + for(;;){ + // Collect number up to ``.''. + // Values are specified as for C: + // 0x=hex, 0=octal, isdigit=decimal. + if(!isdigit(c))return false; + val = 0; + base = 10; + + if(c == '0'){ + c = *++szIp; + if((c == 'x')||(c == 'X'))base = 16, c = *++szIp; + else base = 8; + } + + for (;;) { + if(isascii(c) && isdigit(c)) { + val = (val * base) + (c - '0'); + c = *++szIp; + } else if (base == 16 && isascii(c) && isxdigit(c)) { + val = (val << 4) | (c + 10 - (islower(c) ? 'a' : 'A')); + c = *++szIp; + } else break; + } + + if(c == '.'){ + // Internet format: + // a.b.c.d + // a.b.c (with c treated as 16 bits) + // a.b (with b treated as 24 bits) + + if(pp >= (parts + 3)) return false; + *pp++ = val; + c = *++szIp; + } else break; + } + + // Check for trailing characters. + if ((c != '\0') && (!isascii(c) || !isspace(c)))return false; + + // Concact the address according to + // the number of parts specified. + n = pp - parts + 1; + + switch (n) { + case 0: return false; // initial nondigit + case 1: break; // a -- 32 bits + case 2: // a.b -- 8.24 bits + if(val > 0xffffff) return false; + val |= parts[0] << 24; + break; + case 3: // a.b.c -- 8.8.16 bits + if(val > 0xffff)return false; + val |= (parts[0] << 24) | (parts[1] << 16); + break; + case 4: // a.b.c.d -- 8.8.8.8 bits + if(val > 0xff)return false; + val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); + break; + } + + if(address)address->s_addr = htonl(val); + return true; + +} + +#else //!HAVE_INET_ATON + +bool kvi_stringIpToBinaryIp(const char *szIp,struct in_addr *address) +{ + if(!szIp)return false; + return (inet_aton(szIp,address) != 0); +} +#endif //!HAVE_INET_ATON + + + +#ifndef HAVE_INET_NTOA + +// FIXME: #warning "Your system lacks the inet_ntoa function," +// FIXME: #warning "you're trying to compile this file without" +// FIXME: #warning "the config.h created by the configure script," +// FIXME: #warning "Using own internal implementation of inet_ntoa." + +// +// Original code comes from the ircd source. +// + + +bool kvi_binaryIpToStringIp(struct in_addr in,QString &szBuffer) +{ + unsigned char *s = (unsigned char *)∈ + int a,b,c,d; + a = (int)*s++; + b = (int)*s++; + c = (int)*s++; + d = (int)*s; + + szBuffer.sprintf("%d.%d.%d.%d", a,b,c,d ); + return true; +} + +#else //HAVE_INET_NTOA + +bool kvi_binaryIpToStringIp(struct in_addr in,QString &szBuffer) +{ +// FIXME: #warning "This is NOT thread safe!" + + char * ptr = inet_ntoa(in); + if(!ptr)return false; + szBuffer = ptr; + return true; +} + +#endif //HAVE_INET_NTOA + +bool kvi_isValidStringIp(const char *szIp) +{ + struct in_addr address; + if(!szIp)return false; + if(!isdigit(*szIp))return false; + return kvi_stringIpToBinaryIp(szIp,&address); +} + +#ifdef COMPILE_IPV6_SUPPORT + +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + +static unsigned int scan_ip6(const char *s,char ip[16]) +{ + unsigned int i; + unsigned int len=0; + unsigned long u; + + char suffix[16]; + unsigned int prefixlen=0; + unsigned int suffixlen=0; + + for (i=0; i<16; i++) ip[i]=0; + + for (;;) { + if (*s == ':') { + len++; + if (s[1] == ':') { /* Found "::", skip to part 2 */ + s+=2; + len++; + break; + } + s++; + } + + { + char *tmp; + u=strtoul(s,&tmp,16); + i=tmp-s; + } + + if (!i) return 0; + if (prefixlen==12 && s[i]=='.') { + /* the last 4 bytes may be written as IPv4 address */ + if (kvi_stringIpToBinaryIp(s,(struct in_addr*)(ip+12))) + return i+len; + else + return 0; + } + + ip[prefixlen++] = (u >> 8); + ip[prefixlen++] = (u & 255); + + s += i; len += i; + + if (prefixlen==16) return len; + } + + /* part 2, after "::" */ + + for (;;) { + if (*s == ':') { + if (suffixlen==0) break; + s++; + len++; + } else if (suffixlen!=0) break; + + { + char *tmp; + u=strtol(s,&tmp,16); + i=tmp-s; + } + + if (!i) { + if (*s) len--; + break; + } + + if (suffixlen+prefixlen<=12 && s[i]=='.') { + + if (kvi_stringIpToBinaryIp(s,(struct in_addr*)(suffix+suffixlen))) { + suffixlen+=4; + len+=(unsigned int)strlen(s); + break; + } else prefixlen=12-suffixlen; /* make end-of-loop test true */ + } + + suffix[suffixlen++] = (u >> 8); + suffix[suffixlen++] = (u & 255); + s += i; len += i; + if (prefixlen+suffixlen==16) break; + } + + for (i=0; i9?hexdigit+'a'-10:hexdigit+'0'; +} + +static int fmt_xlong(char* s,unsigned int i) +{ + char* bak=s; + *s=tohex((i>>12)&0xf); if (s!=bak || *s!='0') ++s; + *s=tohex((i>>8)&0xf); if (s!=bak || *s!='0') ++s; + *s=tohex((i>>4)&0xf); if (s!=bak || *s!='0') ++s; + *s=tohex(i&0xf); + return s-bak+1; +} + +static unsigned int i2a(char* dest,unsigned int x) +{ + register unsigned int tmp=x; + register unsigned int len=0; + + if (x>=100) { *dest++=tmp/100+'0'; tmp=tmp%100; ++len; } + if (x>=10) { *dest++=tmp/10+'0'; tmp=tmp%10; ++len; } + *dest++=tmp+'0'; + return len+1; +} + +char *inet_ntoa_r(struct in_addr in,char* buf) +{ + unsigned int len; + unsigned char *ip=(unsigned char*)∈ + + len=i2a(buf,ip[0]); buf[len]='.'; ++len; + len+=i2a(buf+ len,ip[1]); buf[len]='.'; ++len; + len+=i2a(buf+ len,ip[2]); buf[len]='.'; ++len; + len+=i2a(buf+ len,ip[3]); buf[len]=0; + return buf; +} + +unsigned int fmt_ip6(char *s,const char ip[16]) +{ + unsigned int len; + unsigned int i; + unsigned int temp; + unsigned int compressing; // 0 not compressing, 1 compressing now, 2 already compressed once + + len = 0; + compressing = 0; + + for(int j=0;j<16;j+=2) + { + if (j==12 && !memcmp(ip,V4mappedprefix,12)) + { + inet_ntoa_r(*(struct in_addr*)(ip+12),s); + temp=(unsigned int)strlen(s); + return len+temp; + } + + temp = ((unsigned long) (unsigned char) ip[j] << 8) + (unsigned long) (unsigned char) ip[j+1]; + + if(temp == 0) + { + if(compressing == 0) + { + compressing=1; + if (j==0) + { + *s++=':'; + ++len; + } + } + } else { + if(compressing == 1) + { + compressing=2; // don't do it again + *s++=':'; ++len; + } + + i = fmt_xlong(s,temp); + len += i; + s += i; + + if (j<14) + { + *s++ = ':'; + ++len; + } + } + } + + if(compressing == 1) + { + *s++=':'; + ++len; + } + + *s=0; + return len; +} + +const char* inet_ntop(int AF, const void *CP, char *BUF, size_t LEN) +{ + char buf[100]; + size_t len; + + if (AF==AF_INET) + { + inet_ntoa_r(*(struct in_addr*)CP,buf); + len=strlen(buf); + } else if (AF==AF_INET6) + + { + len=fmt_ip6(buf,(char *)CP); + } else return 0; + + if (len + +bool kvi_select(int fd,bool * bCanRead,bool * bCanWrite,int iUSecs) +{ + // FIXME: This stuff should DIE! + fd_set rs; + fd_set ws; + FD_ZERO(&rs); + FD_ZERO(&ws); + FD_SET(fd,&rs); + FD_SET(fd,&ws); + struct timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = iUSecs; + + int ret = select(fd + 1,&rs,&ws,0,&tv); + if(ret < 1)return false; // EINTR or ENOSTUFFATALL + + *bCanRead = FD_ISSET(fd,&rs); + *bCanWrite = FD_ISSET(fd,&ws); + + return true; +} + +namespace KviNetUtils +{ + bool stringIpToBinaryIp(const QString &szStringIp,struct in_addr * address) + { +#ifndef HAVE_INET_ATON + QString szAddr = szStringIp.simplified(); + quint32 iAddr=0; + QStringList ipv4 = szAddr.split(".", QString::KeepEmptyParts, Qt::CaseInsensitive); + if (ipv4.count() == 4) { + int i = 0; + bool ok = TRUE; + while(ok && i < 4) { + uint byteValue = ipv4[i].toUInt(&ok); + if ( (byteValue > 255) && ok ) + ok = FALSE; + if (ok) + iAddr = (iAddr << 8) + byteValue; + ++i; + } + if (ok) + { + if(address)address->s_addr = htonl(iAddr); + return true; + } + } + return FALSE; +#else //HAVE_INET_ATON + if(szStringIp.isEmpty())return false; + return (inet_aton(KviQString::toUtf8(szStringIp).data(),address) != 0); +#endif //HAVE_INET_ATON + } + + + bool isValidStringIp(const QString &szIp) + { + struct in_addr address; + if(szIp.isEmpty())return false; + if(!szIp[0].isNumber())return false; + return stringIpToBinaryIp(szIp,&address); + } + + +#ifdef COMPILE_IPV6_SUPPORT + bool stringIpToBinaryIp_V6(const QString &szStringIp,struct in6_addr * address) + { + return (inet_pton(AF_INET6,KviQString::toUtf8(szStringIp).data(),(void *)address) == 1); + } + + bool isValidStringIPv6(const QString &szIp) + { + struct in6_addr address; + if(szIp.isEmpty())return false; + return stringIpToBinaryIp_V6(szIp,&address); + } + + bool binaryIpToStringIp_V6(struct in6_addr in,QString &szBuffer) + { + char buf[46]; + bool bRet = inet_ntop(AF_INET6,(void *)&in,buf,46); + szBuffer= buf; + return bRet; + } + +#endif //COMPILE_IPV6_SUPPORT + + bool binaryIpToStringIp(struct in_addr in,QString &szBuffer) + { + char * ptr = inet_ntoa(in); + if(!ptr)return false; + szBuffer = ptr; + return true; + } + + bool isRoutableIpString(const QString &szIpString) + { + struct in_addr a; + if(szIpString.isEmpty())return false; + stringIpToBinaryIp(szIpString,&a); + return isRoutableIp((const char *)&a); + } + + bool isRoutableIp(const char * ipaddr) + { + if(!ipaddr)return false; + const unsigned char * ip = (const unsigned char *)ipaddr; + if(ip[0] == 0)return false; // old-style broadcast + if(ip[0] == 10)return false; // Class A VPN + if(ip[0] == 127)return false; // loopback + if((ip[0] == 172) && (ip[1] >= 16) && (ip[1] <= 31))return false; // Class B VPN + if((ip[0] == 192) && (ip[1] == 168))return false; // Class C VPN + if((ip[0] == 169) && (ip[1] == 254))return false; // APIPA + if((ip[0] == 192) && (ip[1] == 0) && (ip[2] == 2))return false; // Class B VPN + if(ip[0] >= 224)return false; // class D multicast and class E reserved + + return true; + } + +#ifdef COMPILE_GET_INTERFACE_ADDRESS + union sockaddr_union { + struct sockaddr sa; + struct sockaddr_in sin; + }; + + bool getInterfaceAddress(const QString &szInterfaceName,QString &szBuffer) + { + union sockaddr_union *su; + struct ifreq ifr; + int len = szInterfaceName.length(); + if(len > (IFNAMSIZ - 1))return false; // invalid interface anyway + + kvi_memmove(ifr.ifr_name,KviQString::toUtf8(szInterfaceName).data(),len + 1); + + int fd = socket(AF_INET,SOCK_STREAM,0); + if(fd < 0)return false; + + if(ioctl(fd,SIOCGIFADDR,&ifr) == -1)return false; // supports only IPV4 ? + + close(fd); + + su = (union sockaddr_union *)&(ifr.ifr_addr); + + if (su->sa.sa_family != AF_INET) return false; + + return binaryIpToStringIp((struct in_addr)su->sin.sin_addr,szBuffer); + + // (this seems to work for AF_INET only anyway) +#else //!COMPILE_GET_INTERFACE_ADDRESS + bool getInterfaceAddress(const QString &,QString &) + { + return false; +#endif //!COMPILE_GET_INTERFACE_ADDRESS + } + + void formatNetworkBandwidthString(QString &szBuffer,unsigned int uBytesPerSec) + { + if(uBytesPerSec > (1024 * 1024)) + { + unsigned int uMB = uBytesPerSec / (1024 * 1024); + unsigned int uRem = ((uBytesPerSec % (1024 * 1024)) * 100) / (1024 * 1024); + + KviQString::sprintf(szBuffer,"%u.%u%u MiB/s",uMB,uRem / 10,uRem % 10); + + return; + } + + if(uBytesPerSec >= 1024) + { + unsigned int uKB = uBytesPerSec / 1024; + unsigned int uRem = ((uBytesPerSec % 1024) * 100) / 1024; + + KviQString::sprintf(szBuffer,"%u.%u%u KiB/s",uKB,uRem / 10,uRem % 10); + + return; + } + + KviQString::sprintf(szBuffer,"%u B/s",uBytesPerSec); + + } +} + +bool kvi_isRoutableIpString(const char * ipstring) +{ + struct in_addr a; + if(!ipstring)return false; + kvi_stringIpToBinaryIp(ipstring,&a); + return kvi_isRoutableIp((const char *)&a); +} + +bool kvi_isRoutableIp(const char * ipaddr) +{ + if(!ipaddr)return false; + const unsigned char * ip = (const unsigned char *)ipaddr; + + if(ip[0] == 0)return false; // old-style broadcast + if(ip[0] == 10)return false; // Class A VPN + if(ip[0] == 127)return false; // loopback + if((ip[0] == 172) && (ip[1] >= 16) && (ip[1] <= 31))return false; // Class B VPN + if((ip[0] == 192) && (ip[1] == 168))return false; // Class C VPN + if((ip[0] == 169) && (ip[1] == 254))return false; // APIPA + if((ip[0] == 192) && (ip[1] == 0) && (ip[2] == 2))return false; // Class B VPN + if(ip[0] >= 224)return false; // class D multicast and class E reserved + + return true; +} + +bool kvi_getLocalHostAddress(QString &buffer) +{ + // This will work only on windoze... + char buf[1024]; + if(gethostname(buf,1024) != 0)return false; + struct hostent * h = gethostbyname(buf); + if(!h)return false; + QString tmp; + int i=0; + while(h->h_addr_list[i]) + { + if(kvi_binaryIpToStringIp(*((struct in_addr *)(h->h_addr_list[i])),tmp)) + { + if(kvi_isRoutableIp(h->h_addr_list[i])) + { + buffer = tmp; + return true; + } + } + i++; + } + + buffer = tmp; + return true; +} + +KviSockaddr::KviSockaddr(const char * szIpAddress,kvi_u32_t uPort,bool bIPv6,bool bUdp) +{ + struct addrinfo hints; + kvi_memset((void *)&hints,0,sizeof(hints)); + hints.ai_flags = AI_NUMERICHOST; +#ifdef COMPILE_IPV6_SUPPORT + hints.ai_family = bIPv6 ? PF_INET6 : PF_INET; +#else + hints.ai_family = PF_INET; +#endif + + hints.ai_socktype = bUdp ? SOCK_DGRAM : SOCK_STREAM; + + hints.ai_protocol = 0; + m_pData = 0; + KviCString szPort(KviCString::Format,"%u",uPort); + getaddrinfo(szIpAddress,szPort.ptr(),&hints,&m_pData); +} + +KviSockaddr::KviSockaddr(kvi_u32_t uPort,bool bIPv6,bool bUdp) // passive sockaddr + +{ + struct addrinfo hints; + kvi_memset((void *)&hints,0,sizeof(hints)); + hints.ai_flags = AI_NUMERICHOST | AI_PASSIVE; +#ifdef COMPILE_IPV6_SUPPORT + hints.ai_family = bIPv6 ? PF_INET6 : PF_INET; +#else + hints.ai_family = PF_INET; +#endif + hints.ai_socktype = bUdp ? SOCK_DGRAM : SOCK_STREAM; + hints.ai_protocol = 0; + m_pData = 0; + KviCString szPort(KviCString::Format,"%u",uPort); + getaddrinfo(0,szPort.ptr(),&hints,&m_pData); +} + +KviSockaddr::~KviSockaddr() +{ + if(m_pData) + { + freeaddrinfo(m_pData); + m_pData = 0; + } +} + +struct sockaddr * KviSockaddr::socketAddress() +{ + if(!m_pData)return 0; + return (m_pData)->ai_addr; +} + +size_t KviSockaddr::addressLength() +{ + if(!m_pData)return 0; + return (m_pData)->ai_addrlen; +} + +int KviSockaddr::addressFamily() +{ + if(!m_pData)return 0; + return (m_pData)->ai_family; +} + +bool KviSockaddr::isIPv6() +{ + if(!m_pData)return false; +#ifdef COMPILE_IPV6_SUPPORT + return false; +#else + return (addressFamily() == AF_INET6); +#endif +} + +kvi_u32_t KviSockaddr::port() +{ + if(!m_pData)return 0; +#ifdef COMPILE_IPV6_SUPPORT + switch(m_pData->ai_family) + { + case AF_INET: + return ntohs(((struct sockaddr_in *)(m_pData->ai_addr))->sin_port); + break; + case AF_INET6: + return ntohs(((struct sockaddr_in6 *)(m_pData->ai_addr))->sin6_port); + break; + } + return 0; +#else + return ntohs(((struct sockaddr_in *)(m_pData->ai_addr))->sin_port); +#endif +} + +bool KviSockaddr::getStringAddress(QString &szBuffer) +{ + if(!m_pData)return 0; +#ifdef COMPILE_IPV6_SUPPORT + switch(((struct addrinfo *)m_pData)->ai_family) + { + case AF_INET: + return kvi_binaryIpToStringIp(((struct sockaddr_in *)(m_pData->ai_addr))->sin_addr,szBuffer); + break; + case AF_INET6: + return kvi_binaryIpToStringIp_V6(((struct sockaddr_in6 *)(m_pData->ai_addr))->sin6_addr,szBuffer); + break; + } + + return false; +#else + return kvi_binaryIpToStringIp(((struct sockaddr_in *)(m_pData->ai_addr))->sin_addr,szBuffer); +#endif +} diff --git a/src/kvilib/net/KviNetUtils.h b/src/kvilib/net/KviNetUtils.h new file mode 100644 index 000000000..f7872ad07 --- /dev/null +++ b/src/kvilib/net/KviNetUtils.h @@ -0,0 +1,99 @@ +#ifndef _KVI_NETUTILS_H_ +#define _KVI_NETUTILS_H_ +//============================================================================= +// +// File : KviNetUtils.h +// Creation date : Sun Jun 18 2000 18:37:27 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "kvi_inttypes.h" + +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + #include + #ifdef COMPILE_IPV6_SUPPORT + #ifdef WIN2K + #include + #else + #include + //#include + #define in6_addr in_addr6 + #endif + #else + #ifdef WIN2K + #include + #else + #include + #endif + #endif +#else + #include + #include + #include //in_addr + #include //inet_ntoa inet_ntop and inet_pton depend on this one. +#endif + +#include "KviCString.h" + +class KVILIB_API KviSockaddr +{ +public: + KviSockaddr(const char * szIpAddress,kvi_u32_t uPort,bool bIPv6,bool bUdp = false); + KviSockaddr(kvi_u32_t uPort,bool bIPv6,bool bUdp = false); // passive + ~KviSockaddr(); +private: + struct addrinfo * m_pData; +public: + struct sockaddr * socketAddress(); + size_t addressLength(); + int addressFamily(); + bool isIPv6(); + bool getStringAddress(QString &szBuffer); + kvi_u32_t port(); + +}; + + +KVILIB_API extern bool kvi_select(int fd,bool * bCanRead,bool * bCanWrite,int iUSecs = 0); + +// Warning : NOT THREAD SAFE! +KVILIB_API extern bool kvi_getLocalHostAddress(QString &buffer); +KVILIB_API extern bool kvi_isRoutableIp(const char * ipaddr); +KVILIB_API extern bool kvi_isRoutableIpString(const char * ipstring); + +namespace KviNetUtils +{ + KVILIB_API bool stringIpToBinaryIp(const QString &szStringIp,struct in_addr * address); + KVILIB_API bool isValidStringIp(const QString &szStringIp); + KVILIB_API bool binaryIpToStringIp(struct in_addr in,QString &szBuffer); + KVILIB_API bool getInterfaceAddress(const QString &szInterfaceName,QString &szBuffer); +#ifdef COMPILE_IPV6_SUPPORT + KVILIB_API bool isValidStringIPv6(const QString &szStringIp); + KVILIB_API bool stringIpToBinaryIp_V6(const QString &szStringIp,struct in6_addr * address); + KVILIB_API bool binaryIpToStringIp_V6(struct in6_addr in,QString &szBuffer); +#endif + KVILIB_API bool isRoutableIp(const char * ipaddr); + KVILIB_API bool isRoutableIpString(const QString &szIpString); + KVILIB_API void formatNetworkBandwidthString(QString &szBuffer,unsigned int uBytesPerSec); +} + + +#endif //!_KVI_NETUTILS_H_ diff --git a/src/kvilib/net/KviSASL.cpp b/src/kvilib/net/KviSASL.cpp new file mode 100644 index 000000000..39d56ea67 --- /dev/null +++ b/src/kvilib/net/KviSASL.cpp @@ -0,0 +1,198 @@ +//============================================================================= +// +// File : KviSASL.cpp +// Creation date : Mon Feb 14 2010 19:36:12 CEST by Fabio Bas +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2010 Fabio Bas (ctrlaltca at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + + + +#include "KviSASL.h" + +#include "KviMemory.h" + +#ifdef COMPILE_SSL_SUPPORT + +#include +#include +#include +#include +#include + +#endif + + +namespace KviSASL +{ + + bool plainMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass) + { + if(szIn=="+") + { + int answerLen = 3 + (2 * baNick.size()) + baPass.size(); + char * answer = (char *) KviMemory::allocate(answerLen); + char * answer2 = answer; + + memcpy(answer, baNick.data(), baNick.size()); + answer+=baNick.size(); + memset(answer, 0, 1); + answer++; + + memcpy(answer, baNick.data(), baNick.size()); + answer+=baNick.size(); + memset(answer, 0, 1); + answer++; + + memcpy(answer, baPass.data(), baPass.size()); + answer+=baPass.size(); + memset(answer, 0, 1); + answer++; + + szOut.bufferToBase64(answer2,answerLen); + KviMemory::free(answer2); + + return true; + } + return false; + } + +#ifdef COMPILE_SSL_SUPPORT + bool dh_blowfishMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass) + { + /* + * The format of the auth token is quite complex; the server sends us 3 strings: + * p - a prime number + * g - a generator number, tipically 2 or 5 are used. + * y - the server-generated public key + * These 3 strings are null-terminated and codified as pascal strings (they are prefixed + * with a 16-bit lenght identifiedr in "network" big-endian order) + * Then, the 3 strings are concatenated and base-64 encoded. + */ + + BF_KEY key; + quint16 size, pKlen; + int secretLen; + unsigned char *secret = NULL, *pubKey = NULL; + char * tmpBuf; + DH * dh = DH_new(); + int len = szIn.base64ToBuffer(&tmpBuf,false); + + if(len < 7) return false; + + // extract p + size = ntohs(*(unsigned int*)tmpBuf); + tmpBuf+=2; + len-=2; + if(size > len) return false; + + if(!(dh->p = BN_bin2bn((unsigned char*) tmpBuf, size, NULL))) + return false; + + tmpBuf+=size; + len-=size; + + // extract g + size = ntohs(*(unsigned int*)tmpBuf); + tmpBuf+=2; + len-=2; + if(size > len) return false; + + if(!(dh->g = BN_bin2bn((unsigned char*) tmpBuf, size, NULL))) + return false; + + tmpBuf+=size; + len-=size; + + // extract y + size = ntohs(*(unsigned int*)tmpBuf); + tmpBuf+=2; + len-=2; + if(size > len) return false; + + // create our keys and extract shared secret + // note: any memory checking tool (as valgrind) will complain on this call. blame openssl + if(!DH_generate_key(dh)) + return false; + + secret=(unsigned char *) KviMemory::allocate(DH_size(dh)); + // note: any memory checking tool (as valgrind) will complain on this call. blame openssl + if(-1 == (secretLen = DH_compute_key(secret, BN_bin2bn((unsigned char*) tmpBuf, size, NULL), dh))) + return false; + + pKlen=BN_num_bytes(dh->pub_key); + pubKey = (unsigned char *) KviMemory::allocate(pKlen); + BN_bn2bin(dh->pub_key, pubKey); + + //create crypto buffers + int passLen = baPass.size() + ((8 -( baPass.size() % 8)) % 8); + int passC = 0; + unsigned char *passIn = (unsigned char *) KviMemory::allocate(passLen); + unsigned char *passOut = (unsigned char *) KviMemory::allocate(passLen); + + memset(passIn, 0, passLen); + memset(passOut, 0, passLen); + memcpy(passIn, baPass.data(), baPass.size()); + + // crypt our password + BF_set_key(&key, secretLen, secret); + + for (passC=0; passC < passLen; passC += 8) + BF_ecb_encrypt(passIn + passC, passOut + passC, &key, BF_ENCRYPT); + + /* + * Build up the answer + * The format of the auth answer is quite complex, and formed by the byte concatenation of: + * 1) a 16 bit integer containing the byte length of our public key + * 2) our public key + * 3) our username (nickname), null-terminated + * 4) our password, crypted using blowfish in ecb mode and the dh secret as the blowfish key + * Then, the answer is to be base64 encoded. + */ + + int answerLen = 2 + pKlen + baNick.size() + 1 + passLen; + char * answer = (char *) malloc(answerLen); + char * answer2 = answer; + *((unsigned int *)answer) = htons(pKlen); + answer+=2; + memcpy(answer, pubKey, pKlen); + answer+=pKlen; + memcpy(answer, baNick.data(), baNick.size()); + answer+=baNick.size(); + memset(answer, 0, 1); + answer++; + memcpy(answer, passOut, passLen); + szOut.bufferToBase64(answer2,answerLen); + + //clean up + KviMemory::free(secret); + KviMemory::free(pubKey); + KviMemory::free(passIn); + KviMemory::free(passOut); + + return true; + } +#else + bool dh_blowfishMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass) + { + return false; + } +#endif + +}; diff --git a/src/kvilib/net/KviSASL.h b/src/kvilib/net/KviSASL.h new file mode 100644 index 000000000..511ba1796 --- /dev/null +++ b/src/kvilib/net/KviSASL.h @@ -0,0 +1,61 @@ +#ifndef _KVI_SASL_H_ +#define _KVI_SASL_H_ +//============================================================================= +// +// File : KviSASL.h +// Creation date : Mon Feb 14 2010 19:36:12 CEST by Fabio Bas +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2010 Fabio Bas (ctrlaltca at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "KviCString.h" + +/** +* \namespace KviSASL +* \brief This namespace implement some SASL authentication methods. +* +* Currently implementhed methods are PLAIN and DH-BLOWFISH +*/ + +namespace KviSASL +{ + /** + * \brief Create the auth message for PLAIN authentication + * \param szIn The server-provided token + * \param szOut A KviCString that will be filled with the authentication message + * \param baNick The username + * \param baPass The password + * \return bool + */ + extern KVILIB_API bool plainMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass); + + /** + * \brief Create the auth message for DH-BLOWFISH authentication + * \param szIn The server-provided token + * \param szOut A KviCString that will be filled with the authentication message + * \param baNick The username + * \param baPass The password + * \return bool + */ + extern KVILIB_API bool dh_blowfishMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass); + +}; + +#endif //_KVI_SASL_H_ diff --git a/src/kvilib/net/KviSSL.cpp b/src/kvilib/net/KviSSL.cpp new file mode 100644 index 000000000..dedc70632 --- /dev/null +++ b/src/kvilib/net/KviSSL.cpp @@ -0,0 +1,866 @@ +//============================================================================= +// +// File : KviSSL.cpp +// Creation date : Mon May 27 2002 21:36:12 CEST by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + + + +#include "KviSSL.h" +#include "KviLocale.h" + +#ifdef COMPILE_SSL_SUPPORT + +#include "KviThread.h" +#include "kvi_memmove.h" +#include "KviMemory.h" + +#include +#include +#include + +#include + +#if !(defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)) + #include +#endif + +static bool g_bSSLInitialized = false; +static KviMutex * g_pSSLMutex = 0; + + +static inline void my_ssl_lock() +{ + g_pSSLMutex->lock(); +} + +static inline void my_ssl_unlock() +{ + g_pSSLMutex->unlock(); +} + + +// THIS PART OF OpenSSL SUCKS + +static DH * dh_512 = 0; +static DH * dh_1024 = 0; +static DH * dh_2048 = 0; +static DH * dh_4096 = 0; + +static unsigned char dh512_p[]={ + 0x90,0x86,0xDD,0x06,0xE8,0x0F,0x10,0x86,0xF0,0x91,0xC5,0x55, + 0x4D,0x6B,0xAF,0x69,0x4F,0x01,0xED,0xF9,0x57,0x8F,0x3B,0xB8, + 0x9C,0x87,0xAE,0x85,0xC1,0xBF,0x57,0xA5,0xD5,0xBA,0x81,0x24, + 0xE7,0x99,0xE3,0xF6,0xCD,0xB4,0x41,0xB7,0x7F,0x6E,0x7B,0xB1, + 0xD2,0xF3,0xE9,0x0F,0xB9,0x0E,0x4D,0xEB,0x9D,0xD4,0xA9,0xE5, + 0x03,0x67,0xA7,0x27 +}; +static unsigned char dh512_g[]={ 0x05 }; + +static unsigned char dh1024_p[]={ + 0xA5,0x4C,0xB9,0xB9,0xC4,0x35,0x88,0x68,0x9B,0x79,0x48,0x6C, + 0x21,0xA7,0x8E,0xE2,0x9C,0xAF,0x2F,0x04,0xBF,0x45,0xBC,0xF5, + 0xAB,0x35,0x86,0xC8,0xBB,0x9B,0x75,0x18,0x7C,0x9B,0xAB,0xE8, + 0x52,0x7F,0x57,0x3E,0xD8,0x65,0x7D,0x2B,0xE1,0x6D,0x3D,0xA5, + 0x32,0xE8,0xA0,0x2B,0x7A,0x58,0x6B,0x47,0x16,0x4E,0xB1,0xFC, + 0x09,0xB7,0x7C,0xC6,0xE9,0x6E,0xC7,0xC7,0xA1,0x42,0x0F,0x4B, + 0x43,0xFB,0x58,0xBA,0xC7,0x66,0xD6,0xCA,0x6B,0xC7,0x45,0x7C, + 0x99,0xE4,0x46,0x02,0x93,0x3F,0x28,0xD2,0xCE,0x0C,0x8A,0xDD, + 0x6A,0x22,0x2E,0xA9,0x9A,0xCA,0x16,0x48,0x4E,0x67,0x4C,0xE9, + 0xC8,0x54,0xCD,0x18,0xC9,0xF3,0x30,0x3A,0x74,0xAB,0xF9,0xAF, + 0xE4,0xA4,0x0D,0x56,0x62,0x28,0x07,0xBF +}; +static unsigned char dh1024_g[]={ 0x05 }; + +static unsigned char dh2048_p[]={ + 0xBF,0x67,0x7B,0x79,0xA5,0x22,0xD3,0xB5,0x0C,0x13,0xE6,0x92, + 0x54,0xFD,0x64,0xBF,0x57,0x25,0xBD,0x02,0x7C,0xFD,0x72,0x97, + 0x82,0xA4,0xA6,0x0A,0xB9,0xE6,0x4B,0xFA,0xBD,0xFA,0x71,0x8A, + 0x2E,0x36,0xF9,0x03,0x58,0x1B,0xB6,0x3A,0xFD,0x15,0xCC,0x87, + 0x5D,0x04,0xF7,0x45,0xE0,0xE2,0x34,0x7F,0x54,0x5F,0x5D,0x14, + 0xD3,0xCA,0x3E,0xFD,0x2A,0x92,0x10,0x89,0xA0,0xB0,0xB4,0xE5, + 0x80,0x05,0x13,0xBE,0xA3,0xD0,0x42,0x4B,0x98,0x44,0x54,0xB3, + 0xE0,0x23,0x26,0xF5,0x6B,0x0E,0x4D,0x2A,0x81,0xB2,0x8A,0x06, + 0xC8,0x00,0x9E,0xAB,0x1B,0x77,0xDC,0x87,0x9C,0x6C,0xD5,0xEE, + 0xB4,0xB4,0xDD,0xDA,0x3F,0x40,0xA3,0xFA,0xC1,0x1E,0xC0,0xA2, + 0x9E,0xB8,0xAC,0x31,0xE8,0x12,0x93,0x9C,0x71,0xF6,0xE7,0xF0, + 0x65,0x7F,0xA5,0x20,0xF7,0x49,0x3D,0xD6,0xF9,0xD3,0xF0,0x3F, + 0xB3,0xF0,0xD0,0x23,0x22,0x82,0xA5,0xDD,0xFB,0xD9,0x9C,0x7D, + 0xE7,0xA0,0x78,0xE8,0xF9,0x02,0x0C,0x2F,0x1D,0x52,0xC7,0x61, + 0xED,0xA0,0xC9,0x06,0x14,0xDF,0xE7,0xB1,0x1E,0x50,0x98,0x4F, + 0x10,0xB9,0x87,0x4C,0x1C,0x9C,0xB3,0xD2,0x98,0x23,0x7C,0x47, + 0xD2,0x3C,0xC5,0x29,0x65,0xC5,0x67,0x4E,0xC0,0x76,0x0F,0x43, + 0x27,0x28,0x89,0x69,0x30,0x7D,0x04,0xFD,0xF7,0x89,0xE5,0xD6, + 0xE6,0x97,0x7D,0xBB,0x54,0x5F,0xB7,0x94,0x1D,0xBC,0x82,0xAB, + 0x9A,0xF5,0x0A,0x0C,0x89,0x68,0xE7,0x0A,0x8C,0x2D,0x0D,0x82, + 0x44,0xA7,0xB8,0xF9,0x0B,0x8E,0xCB,0xA4,0x6A,0xA7,0xEC,0x5F, + 0x0A,0xF8,0x5F,0xE7 +}; +static unsigned char dh2048_g[]={ 0x05 }; + +static unsigned char dh4096_p[]={ + 0xFA,0x14,0x72,0x52,0xC1,0x4D,0xE1,0x5A,0x49,0xD4,0xEF,0x09, + 0x2D,0xC0,0xA8,0xFD,0x55,0xAB,0xD7,0xD9,0x37,0x04,0x28,0x09, + 0xE2,0xE9,0x3E,0x77,0xE2,0xA1,0x7A,0x18,0xDD,0x46,0xA3,0x43, + 0x37,0x23,0x90,0x97,0xF3,0x0E,0xC9,0x03,0x50,0x7D,0x65,0xCF, + 0x78,0x62,0xA6,0x3A,0x62,0x22,0x83,0xA1,0x2F,0xFE,0x79,0xBA, + 0x35,0xFF,0x59,0xD8,0x1D,0x61,0xDD,0x1E,0x21,0x13,0x17,0xFE, + 0xCD,0x38,0x87,0x9E,0xF5,0x4F,0x79,0x10,0x61,0x8D,0xD4,0x22, + 0xF3,0x5A,0xED,0x5D,0xEA,0x21,0xE9,0x33,0x6B,0x48,0x12,0x0A, + 0x20,0x77,0xD4,0x25,0x60,0x61,0xDE,0xF6,0xB4,0x4F,0x1C,0x63, + 0x40,0x8B,0x3A,0x21,0x93,0x8B,0x79,0x53,0x51,0x2C,0xCA,0xB3, + 0x7B,0x29,0x56,0xA8,0xC7,0xF8,0xF4,0x7B,0x08,0x5E,0xA6,0xDC, + 0xA2,0x45,0x12,0x56,0xDD,0x41,0x92,0xF2,0xDD,0x5B,0x8F,0x23, + 0xF0,0xF3,0xEF,0xE4,0x3B,0x0A,0x44,0xDD,0xED,0x96,0x84,0xF1, + 0xA8,0x32,0x46,0xA3,0xDB,0x4A,0xBE,0x3D,0x45,0xBA,0x4E,0xF8, + 0x03,0xE5,0xDD,0x6B,0x59,0x0D,0x84,0x1E,0xCA,0x16,0x5A,0x8C, + 0xC8,0xDF,0x7C,0x54,0x44,0xC4,0x27,0xA7,0x3B,0x2A,0x97,0xCE, + 0xA3,0x7D,0x26,0x9C,0xAD,0xF4,0xC2,0xAC,0x37,0x4B,0xC3,0xAD, + 0x68,0x84,0x7F,0x99,0xA6,0x17,0xEF,0x6B,0x46,0x3A,0x7A,0x36, + 0x7A,0x11,0x43,0x92,0xAD,0xE9,0x9C,0xFB,0x44,0x6C,0x3D,0x82, + 0x49,0xCC,0x5C,0x6A,0x52,0x42,0xF8,0x42,0xFB,0x44,0xF9,0x39, + 0x73,0xFB,0x60,0x79,0x3B,0xC2,0x9E,0x0B,0xDC,0xD4,0xA6,0x67, + 0xF7,0x66,0x3F,0xFC,0x42,0x3B,0x1B,0xDB,0x4F,0x66,0xDC,0xA5, + 0x8F,0x66,0xF9,0xEA,0xC1,0xED,0x31,0xFB,0x48,0xA1,0x82,0x7D, + 0xF8,0xE0,0xCC,0xB1,0xC7,0x03,0xE4,0xF8,0xB3,0xFE,0xB7,0xA3, + 0x13,0x73,0xA6,0x7B,0xC1,0x0E,0x39,0xC7,0x94,0x48,0x26,0x00, + 0x85,0x79,0xFC,0x6F,0x7A,0xAF,0xC5,0x52,0x35,0x75,0xD7,0x75, + 0xA4,0x40,0xFA,0x14,0x74,0x61,0x16,0xF2,0xEB,0x67,0x11,0x6F, + 0x04,0x43,0x3D,0x11,0x14,0x4C,0xA7,0x94,0x2A,0x39,0xA1,0xC9, + 0x90,0xCF,0x83,0xC6,0xFF,0x02,0x8F,0xA3,0x2A,0xAC,0x26,0xDF, + 0x0B,0x8B,0xBE,0x64,0x4A,0xF1,0xA1,0xDC,0xEE,0xBA,0xC8,0x03, + 0x82,0xF6,0x62,0x2C,0x5D,0xB6,0xBB,0x13,0x19,0x6E,0x86,0xC5, + 0x5B,0x2B,0x5E,0x3A,0xF3,0xB3,0x28,0x6B,0x70,0x71,0x3A,0x8E, + 0xFF,0x5C,0x15,0xE6,0x02,0xA4,0xCE,0xED,0x59,0x56,0xCC,0x15, + 0x51,0x07,0x79,0x1A,0x0F,0x25,0x26,0x27,0x30,0xA9,0x15,0xB2, + 0xC8,0xD4,0x5C,0xCC,0x30,0xE8,0x1B,0xD8,0xD5,0x0F,0x19,0xA8, + 0x80,0xA4,0xC7,0x01,0xAA,0x8B,0xBA,0x53,0xBB,0x47,0xC2,0x1F, + 0x6B,0x54,0xB0,0x17,0x60,0xED,0x79,0x21,0x95,0xB6,0x05,0x84, + 0x37,0xC8,0x03,0xA4,0xDD,0xD1,0x06,0x69,0x8F,0x4C,0x39,0xE0, + 0xC8,0x5D,0x83,0x1D,0xBE,0x6A,0x9A,0x99,0xF3,0x9F,0x0B,0x45, + 0x29,0xD4,0xCB,0x29,0x66,0xEE,0x1E,0x7E,0x3D,0xD7,0x13,0x4E, + 0xDB,0x90,0x90,0x58,0xCB,0x5E,0x9B,0xCD,0x2E,0x2B,0x0F,0xA9, + 0x4E,0x78,0xAC,0x05,0x11,0x7F,0xE3,0x9E,0x27,0xD4,0x99,0xE1, + 0xB9,0xBD,0x78,0xE1,0x84,0x41,0xA0,0xDF +}; +static unsigned char dh4096_g[]={ 0x02 }; + +static DH * my_get_dh(int keylength) +{ + DH * dh = 0; + unsigned char * p = 0; + unsigned char * g = 0; + int sp = 0; + int sg = 0; + switch(keylength) + { + case 512: + dh = dh_512; + p = dh512_p; + g = dh512_g; + sp = sizeof(dh512_p); + sg = sizeof(dh512_g); + break; + case 1024: + dh = dh_1024; + p = dh1024_p; + g = dh1024_g; + sp = sizeof(dh1024_p); + sg = sizeof(dh1024_g); + break; + case 2048: + dh = dh_2048; + p = dh2048_p; + g = dh2048_g; + sp = sizeof(dh2048_p); + sg = sizeof(dh2048_g); + break; + case 4096: + dh = dh_4096; + p = dh4096_p; + g = dh4096_g; + sp = sizeof(dh4096_p); + sg = sizeof(dh4096_g); + break; + default: + // What the hell do you want from me ? + qDebug("OpenSSL is asking for a DH param with keylen %d: no way :D",keylength); + break; + + } + + if(dh)return dh; + dh = DH_new(); + if(!dh)return 0; + dh->p=BN_bin2bn(p,sp,0); + dh->g=BN_bin2bn(g,sg,0); + if((dh->p == 0) || (dh->g == 0)) + { + DH_free(dh); + return 0; + } + return dh; +} + +DH * my_ugly_dh_callback(SSL *, int, int keylength) +{ + my_ssl_lock(); + DH *dh = my_get_dh(keylength); + my_ssl_unlock(); + return dh; +} + +void KviSSL::globalInit() +{ + if(g_pSSLMutex)return; + g_pSSLMutex = new KviMutex(); +} + +void KviSSL::globalDestroy() +{ + if(!g_pSSLMutex)return; + if(dh_512)DH_free(dh_512); + if(dh_1024)DH_free(dh_1024); + if(dh_2048)DH_free(dh_2048); + if(dh_4096)DH_free(dh_4096); + globalSSLDestroy(); + delete g_pSSLMutex; + g_pSSLMutex = 0; +} + +void KviSSL::globalSSLInit() +{ + my_ssl_lock(); + if(!g_bSSLInitialized) + { + // FIXME: this should be done only if SSL is really needed + SSL_library_init(); + SSL_load_error_strings(); + //needed to support SHA2 in < OpenSSL 0.9.8o and 1.0.0a + OpenSSL_add_all_algorithms(); + g_bSSLInitialized = true; + } + my_ssl_unlock(); +} + +void KviSSL::globalSSLDestroy() +{ + my_ssl_lock(); + if(g_bSSLInitialized) + { + EVP_cleanup(); + g_bSSLInitialized = false; + } + my_ssl_unlock(); +} + +KviSSL::KviSSL() +{ + globalSSLInit(); + m_pSSL = 0; + m_pSSLCtx = 0; +} + +KviSSL::~KviSSL() +{ + shutdown(); +} + +#ifdef COMPILE_ON_WINDOWS + + // On windows we need to override new and delete operators + // to ensure that always the right new/delete pair is called for an object instance + // This bug is present in all the classes exported by a module that + // can be instantiated/destroyed from external modules. + // (this is a well known bug described in Q122675 of MSDN) + + void * KviSSL::operator new(size_t tSize) + { + return KviMemory::allocate(tSize); + } + + void KviSSL::operator delete(void * p) + { + KviMemory::free(p); + } + +#endif + +void KviSSL::shutdown() +{ + if(m_pSSL) + { + #if !(defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)) + //avoid to die on a SIGPIPE if the connection has close (SSL_shutdown can call send()) + //see bug #440 + signal( SIGPIPE, SIG_IGN ); + // At least attempt to shutdown the connection gracefully + SSL_shutdown(m_pSSL); + //restore normal SIGPIPE behaviour. + signal( SIGPIPE, SIG_DFL ); + #else + // At least attempt to shutdown the connection gracefully + SSL_shutdown(m_pSSL); + #endif + SSL_free(m_pSSL); + m_pSSL = 0; + } + if(m_pSSLCtx) + { + SSL_CTX_free(m_pSSLCtx); + m_pSSLCtx = 0; + } +} + +/** + * Used only during passive (server) mode + * Check the client certificate, always valid, even if it not exists + */ +int verify_clientCallback(int, X509_STORE_CTX *) +{ + //int preverify_ok, X509_STORE_CTX *x509_ctx + // From man page: If verify_callback returns 1, the verification process is continued. If verify_callback always returns 1, + // the TLS/SSL handshake will not be terminated with respect to verification failures and the connection will be established. + return 1; +} + +bool KviSSL::initContext(Method m) +{ + if(m_pSSL)return false; + m_pSSLCtx = SSL_CTX_new(m == Client ? SSLv23_client_method() : SSLv23_server_method()); + if(!m_pSSLCtx)return false; + + if (m == Server) + { + // we have to request the peer certificate, else only the client can see the peer identity, not the server + SSL_CTX_set_verify(m_pSSLCtx, SSL_VERIFY_PEER, verify_clientCallback); + } + + // we want all ciphers to be available here, except insecure ones, orderer by strength; + // ADH are moved to the end since they are less secure, but they don't need a certificate + // (so we can use secure dcc without a cert) + // NOTE: see bug ticket #155 + SSL_CTX_set_cipher_list(m_pSSLCtx,"ALL:!eNULL:!EXP:!SSLv2:+ADH@STRENGTH"); + SSL_CTX_set_tmp_dh_callback(m_pSSLCtx,my_ugly_dh_callback); + return true; +} + +bool KviSSL::initSocket(kvi_socket_t fd) +{ + if(!m_pSSLCtx)return false; + m_pSSL = SSL_new(m_pSSLCtx); + if(!m_pSSL)return false; + if(!SSL_set_fd(m_pSSL,fd))return false; + return true; + +} + +static int cb(char *buf, int size, int, void *u) +{ + KviCString * p = (KviCString *)u; + int len = p->len(); + if(len >= size)return 0; + kvi_memmove(buf,p->ptr(),len + 1); +// qDebug("PASS REQYESTED: %s",p->ptr()); + return len; +} + +KviSSL::Result KviSSL::useCertificateFile(const char * cert,const char * pass) +{ + if(!m_pSSLCtx)return NotInitialized; + m_szPass = pass; + if(m_szPass.len() < 4)m_szPass.append("xxxx"); + X509 * x509 = 0; + + FILE * f = fopen(cert,"r"); + if(!f) + return FileIoError; + +// qDebug("READING CERTIFICATE %s",cert); + if(PEM_read_X509(f,&x509,cb,&m_szPass)) + { + if(!SSL_CTX_use_certificate(m_pSSLCtx,x509)) + { + X509_free(x509); + fclose(f); + return SSLError; + } + X509_free(x509); + } + + fclose(f); + return Success; +} + + +KviSSL::Result KviSSL::usePrivateKeyFile(const char * key,const char * pass) +{ + if(!m_pSSLCtx)return NotInitialized; + m_szPass = pass; + if(m_szPass.len() < 4)m_szPass.append("xxxx"); + + EVP_PKEY * k = 0; + + FILE * f = fopen(key,"r"); + if(!f) + return FileIoError; + +// qDebug("READING KEY %s",key); + if(PEM_read_PrivateKey(f,&k,cb,&m_szPass)) + { + if(!SSL_CTX_use_PrivateKey(m_pSSLCtx,k)) + { + EVP_PKEY_free(k); + fclose(f); + return SSLError; + } + EVP_PKEY_free(k); + } + + fclose(f); + return Success; +} + +unsigned long KviSSL::getLastError(bool bPeek) +{ + return bPeek ? ERR_peek_error() : ERR_get_error(); +} + +bool KviSSL::getLastErrorString(KviCString &buffer,bool bPeek) +{ + unsigned long uErr = getLastError(bPeek); + if(uErr != 0) + { + const char * err = ERR_reason_error_string(uErr); + buffer = err ? err : "Unknown error"; + return true; + } + return false; +} + +KviSSL::Result KviSSL::connect() +{ + if(!m_pSSL)return NotInitialized; + int ret = SSL_connect(m_pSSL); + return connectOrAcceptError(ret); +} + +KviSSL::Result KviSSL::accept() +{ + if(!m_pSSL)return NotInitialized; + int ret = SSL_accept(m_pSSL); + return connectOrAcceptError(ret); +} + +KviSSL::Result KviSSL::connectOrAcceptError(int ret) +{ + switch(SSL_get_error(m_pSSL,ret)) + { + case SSL_ERROR_NONE: return Success; break; + case SSL_ERROR_WANT_READ: return WantRead; break; + case SSL_ERROR_WANT_WRITE: return WantWrite; break; + case SSL_ERROR_ZERO_RETURN: return RemoteEndClosedConnection; break; + case SSL_ERROR_WANT_X509_LOOKUP: return ObscureError; break; + case SSL_ERROR_SYSCALL: + { + if(getLastError(true) != 0)return SSLError; + if(ret == 0)return RemoteEndClosedConnection; + return SyscallError; + } + break; + case SSL_ERROR_SSL: return SSLError; break; + default: return UnknownError; break; + } + return UnknownError; +} + +int KviSSL::read(char * buffer,int len) +{ +// if(!m_pSSL)return -1; + return SSL_read(m_pSSL,buffer,len); +} +int KviSSL::write(const char * buffer,int len) +{ +// if(!m_pSSL)return -1; + return SSL_write(m_pSSL,buffer,len); +} + +KviSSL::Result KviSSL::getProtocolError(int ret) +{ + if(!m_pSSL)return NotInitialized; + switch(SSL_get_error(m_pSSL,ret)) + { + case SSL_ERROR_NONE: return Success; break; + case SSL_ERROR_WANT_READ: return WantRead; break; + case SSL_ERROR_WANT_WRITE: return WantWrite; break; + case SSL_ERROR_ZERO_RETURN: return ZeroReturn; break; + case SSL_ERROR_WANT_X509_LOOKUP: return ObscureError; break; + case SSL_ERROR_SYSCALL: return SyscallError; break; + case SSL_ERROR_SSL: return SSLError; break; + default: return UnknownError; break; + } + return UnknownError; +} + +KviSSLCertificate * KviSSL::getPeerCertificate() +{ + if(!m_pSSL)return 0; + X509 * x509 = SSL_get_peer_certificate(m_pSSL); + if(!x509)return 0; + return new KviSSLCertificate(x509); +} + +KviSSLCertificate * KviSSL::getLocalCertificate() +{ + if(!m_pSSL)return 0; + X509 * x509 = SSL_get_certificate(m_pSSL); + if(!x509)return 0; + return new KviSSLCertificate(x509); +} + +KviSSLCipherInfo * KviSSL::getCurrentCipherInfo() +{ + if(!m_pSSL)return 0; +#if OPENSSL_VERSION_NUMBER >= 0x10000000L + const SSL_CIPHER * c = SSL_get_current_cipher(m_pSSL); +#else + SSL_CIPHER * c = SSL_get_current_cipher(m_pSSL); +#endif + if(!c)return 0; + return new KviSSLCipherInfo(c); +} + + + +KviSSLCertificate::KviSSLCertificate(X509 * x509) +{ + m_pSubject = new KviPointerHashTable(17); + m_pSubject->setAutoDelete(true); + m_pIssuer = new KviPointerHashTable(17); + m_pIssuer->setAutoDelete(true); + m_pX509 = 0; + setX509(x509); +} + +KviSSLCertificate::~KviSSLCertificate() +{ + X509_free(m_pX509); + delete m_pSubject; + delete m_pIssuer; +} + +const char * KviSSLCertificate::getX509Base64() +{ + BUF_MEM *bptr; + BIO* mem = BIO_new(BIO_s_mem()); + PEM_write_bio_X509(mem, m_pX509); + int iLen = BIO_get_mem_data(mem, &bptr); + char * szTmp = (char *) KviMemory::allocate(iLen+1); + kvi_fastmove(szTmp, bptr, iLen); + *(szTmp+iLen) = '\0'; + BIO_free_all(mem); + return szTmp; +} + +#ifdef COMPILE_ON_WINDOWS + + // On windows we need to override new and delete operators + // to ensure that always the right new/delete pair is called for an object instance + // This bug is present in all the classes exported by a module that + // can be instantiated/destroyed from external modules. + // (this is a well known bug described in Q122675 of MSDN) + + void * KviSSLCertificate::operator new(size_t tSize) + { + return KviMemory::allocate(tSize); + } + + void KviSSLCertificate::operator delete(void * p) + { + KviMemory::free(p); + } + +#endif + +void KviSSLCertificate::setX509(X509 * x509) +{ + if(m_pX509)X509_free(m_pX509); + m_pX509 = x509; + m_iVersion = X509_get_version(x509); + extractSubject(); + extractIssuer(); + extractPubKeyInfo(); + extractSerialNumber(); + extractSignature(); +} + +bool KviSSLCertificate::fingerprintIsValid() +{ + if(!m_pX509) + return false; + + EVP_PKEY * pkey = X509_get_pubkey(m_pX509); + int rv = X509_verify(m_pX509, pkey); + + // careful: https://support.ntp.org/bugs/show_bug.cgi?id=1127 + // quote: X509_verify is a call to ASN1_item_verify which can return both 0 and -1 for error cases. + // In particular it can return -1 when the message digest type is not known, or memory allocation failed. + return (rv > 0); +} + +int KviSSLCertificate::fingerprintDigestId() +{ + if(!m_pX509) + return -1; + + int NID = OBJ_obj2nid(m_pX509->sig_alg->algorithm); + if (NID == NID_undef) + { + // unknow digest function: it means the signature can't be verified: the certificate can't be trusted + return 0; + } + + const EVP_MD * mdType = NULL; + mdType = EVP_get_digestbyname(OBJ_nid2sn(NID)); + + if (mdType == NULL) + { + // Unknown digest + return 0; + } + + return mdType->type; +} + +const char * KviSSLCertificate::fingerprintDigestStr() +{ + int iDigestType = fingerprintDigestId(); + + if(iDigestType == 0) + return ""; + + return OBJ_nid2ln(iDigestType); +} + +const char * KviSSLCertificate::fingerprintContents(QString digestName) +{ + unsigned char bufferData[EVP_MAX_MD_SIZE]; + unsigned int bufferLen = 0; + const char * pDigestName; + if (digestName.isEmpty()) + { + // use the one used to create the signature + pDigestName = OBJ_nid2sn(fingerprintDigestId()); + } else { + pDigestName = digestName.toUtf8().data(); + } + + if(getFingerprint(bufferData, &bufferLen, pDigestName) != 0) + return ""; + + QByteArray digestByteArray = QByteArray::fromRawData((char *) bufferData, bufferLen); + return digestByteArray.toHex().data(); +} + +int KviSSLCertificate::getFingerprint(unsigned char * bufferData, unsigned int * bufferLen, const char * digestName) +{ + //TODO if in the future we will want to check the return value, ensure this + // doesn't collide with the one from openssl + if(!m_pX509) + return -99; + + const EVP_MD * mdType = NULL; + mdType = EVP_get_digestbyname(digestName); + + if (mdType == NULL) + { + // Unknown digest + return -98; + } + + if (!X509_digest(m_pX509, mdType, bufferData, bufferLen)) + { + return -97; + } + + return 0; +} + +void KviSSLCertificate::extractSubject() +{ + char buffer[1024]; + char * t = X509_NAME_oneline(X509_get_subject_name(m_pX509),buffer,1024); + if (!t)return; + m_pSubject->clear(); + splitX509String(m_pSubject,t); +} + +void KviSSLCertificate::extractIssuer() +{ + char buffer[1024]; + char * t = X509_NAME_oneline(X509_get_issuer_name(m_pX509),buffer,1024); + if (!t)return; + m_pIssuer->clear(); + splitX509String(m_pIssuer,t); +} + +void KviSSLCertificate::splitX509String(KviPointerHashTable * dict,const char * t) +{ + KviCString buf = t; + int cnt; + KviCString ** arr = buf.splitToArray('/',50,&cnt); + if(arr) + { + if(cnt > 0) + { + for(int i=0;ifindFirstIdx('='); + if(idx != -1) + { + KviCString szTok = arr[i]->left(idx); + arr[i]->cutLeft(idx + 1); + if(szTok.hasData() && arr[i]->hasData()) + { + dict->replace(szTok.ptr(),new KviCString(arr[i]->ptr())); + } + } + } + } + + KviCString::freeArray(arr); + } +} + + +const char * KviSSLCertificate::dictEntry(KviPointerHashTable * dict,const char * entry) +{ + KviCString * t = dict->find(entry); + if(!t)return __tr("Unknown"); + return t->ptr(); +} + + +/* +void KviSSLCertificate::getPKeyType(int type,KviCString &buffer) +{ + switch(type) + { +#ifndef NO_RSA + case EVP_PKEY_RSA: buffer = "RSA"; break; +#endif +#ifndef NO_DSA + case EVP_PKEY_DSA: buffer = "DSA"; break; +#endif +#ifndef NO_DH + case EVP_PKEY_DH: buffer = "DH"; break; +#endif + case EVP_PKEY_NONE: buffer = "NONE"; break; + } +} +*/ + +void KviSSLCertificate::extractPubKeyInfo() +{ + EVP_PKEY *p = X509_get_pubkey(m_pX509); + if(p) + { + m_iPubKeyBits = EVP_PKEY_bits(p); + m_szPubKeyType = (p->type == NID_undef) ? __tr("Unknown") : OBJ_nid2ln(p->type); +// getPKeyType(p->type,m_szPubKeyType); + } else { + m_iPubKeyBits = 0; + m_szPubKeyType = "None"; + } + +} + +void KviSSLCertificate::extractSerialNumber() +{ + ASN1_INTEGER * i = X509_get_serialNumber(m_pX509); + if(i)m_iSerialNumber = ASN1_INTEGER_get(i); + else m_iSerialNumber = -1; +} + +void KviSSLCertificate::extractSignature() +{ + static char hexdigits[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + + //getPKeyType(X509_get_signature_type(m_pX509),m_szSignatureType); + + int i = OBJ_obj2nid(m_pX509->sig_alg->algorithm); + m_szSignatureType = (i == NID_undef) ? __tr("Unknown") : OBJ_nid2ln(i); + + m_szSignatureContents = ""; + + for(i = 0;i < m_pX509->signature->length;i++) + { + if(m_szSignatureContents.hasData())m_szSignatureContents.append(":"); + m_szSignatureContents.append(hexdigits[(m_pX509->signature->data[i] & 0xf0) >> 4]); + m_szSignatureContents.append(hexdigits[(m_pX509->signature->data[i] & 0x0f)]); + } +} + +/* +const char * KviSSLCertificate::verify() +{ + +} +*/ + +#if OPENSSL_VERSION_NUMBER >= 0x10000000L +KviSSLCipherInfo::KviSSLCipherInfo(const SSL_CIPHER * c) +#else +KviSSLCipherInfo::KviSSLCipherInfo(SSL_CIPHER * c) +#endif +{ + m_szVersion = SSL_CIPHER_get_version(c); + m_iNumBitsUsed = SSL_CIPHER_get_bits(c,&m_iNumBits); + m_szName = SSL_CIPHER_get_name(c); + char buf[1024]; + m_szDescription = SSL_CIPHER_description(c,buf,1024); +} + +KviSSLCipherInfo::~KviSSLCipherInfo() +{ +} + +#ifdef COMPILE_ON_WINDOWS + + // On windows we need to override new and delete operators + // to ensure that always the right new/delete pair is called for an object instance + // This bug is present in all the classes exported by a module that + // can be instantiated/destroyed from external modules. + // (this is a well known bug described in Q122675 of MSDN) + + void * KviSSLCipherInfo::operator new(size_t tSize) + { + return KviMemory::allocate(tSize); + } + + void KviSSLCipherInfo::operator delete(void * p) + { + KviMemory::free(p); + } + +#endif + +#endif //COMPILE_SSL_SUPPORT diff --git a/src/kvilib/net/KviSSL.h b/src/kvilib/net/KviSSL.h new file mode 100644 index 000000000..0555d7c44 --- /dev/null +++ b/src/kvilib/net/KviSSL.h @@ -0,0 +1,196 @@ +#ifndef _KVI_SSL_H_ +#define _KVI_SSL_H_ +//============================================================================= +// +// File : KviSSL.h +// Creation date : Mon May 27 2002 21:36:12 CEST by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#ifdef COMPILE_SSL_SUPPORT + +#include "KviCString.h" +#include "kvi_sockettype.h" + +#include "KviPointerHashTable.h" + +#include + + +class KVILIB_API KviSSLCertificate +{ +public: + KviSSLCertificate(X509 * x509); + ~KviSSLCertificate(); +protected: + X509 * m_pX509; + KviPointerHashTable * m_pSubject; + KviPointerHashTable * m_pIssuer; + int m_iPubKeyBits; + KviCString m_szPubKeyType; + int m_iSerialNumber; + int m_iVersion; + KviCString m_szSignatureType; + KviCString m_szSignatureContents; +private: + void extractSubject(); + void extractIssuer(); + void extractPubKeyInfo(); + void extractSerialNumber(); + void extractSignature(); + const char * dictEntry(KviPointerHashTable * dict,const char * entry); + void splitX509String(KviPointerHashTable * dict,const char * t); + int getFingerprint(unsigned char * bufferData, unsigned int * bufferLen, const char * digestName); +public: + void setX509(X509 * x509); + const char * getX509Base64(); //not owned, you'll need to delete this + + const char * signatureType(){ return m_szSignatureType.ptr(); }; + const char * signatureContents(){ return m_szSignatureContents.ptr(); }; + + const char * subjectCountry(){ return dictEntry(m_pSubject,"C"); }; + const char * subjectStateOrProvince(){ return dictEntry(m_pSubject,"ST"); }; + const char * subjectLocality(){ return dictEntry(m_pSubject,"L"); }; + const char * subjectOrganization(){ return dictEntry(m_pSubject,"O"); }; + const char * subjectOrganizationalUnit(){ return dictEntry(m_pSubject,"OU"); }; + const char * subjectCommonName(){ return dictEntry(m_pSubject,"CN"); }; + + const char * issuerCountry(){ return dictEntry(m_pIssuer,"C"); }; + const char * issuerStateOrProvince(){ return dictEntry(m_pIssuer,"ST"); }; + const char * issuerLocality(){ return dictEntry(m_pIssuer,"L"); }; + const char * issuerOrganization(){ return dictEntry(m_pIssuer,"O"); }; + const char * issuerOrganizationalUnit(){ return dictEntry(m_pIssuer,"OU"); }; + const char * issuerCommonName(){ return dictEntry(m_pIssuer,"CN"); }; + + int publicKeyBits(){ return m_iPubKeyBits; }; + const char * publicKeyType(){ return m_szPubKeyType.ptr(); }; + + int serialNumber(){ return m_iSerialNumber; }; + + int version(){ return m_iVersion; }; + + bool fingerprintIsValid(); + int fingerprintDigestId(); + const char * fingerprintDigestStr(); + const char * fingerprintContents(QString digestName = ""); + +#ifdef COMPILE_ON_WINDOWS + // On windows we need to override new and delete operators + // to ensure that always the right new/delete pair is called for an object instance + // This bug is present in all the classes exported by a module that + // can be instantiated/destroyed from external modules. + // (this is a well known bug described in Q122675 of MSDN) + void * operator new(size_t tSize); + void operator delete(void * p); +#endif +}; + +class KVILIB_API KviSSLCipherInfo +{ +public: +#if OPENSSL_VERSION_NUMBER >= 0x10000000L + KviSSLCipherInfo(const SSL_CIPHER * c); +#else + KviSSLCipherInfo(SSL_CIPHER * c); +#endif + ~KviSSLCipherInfo(); +protected: + KviCString m_szVersion; + int m_iNumBits; + int m_iNumBitsUsed; + KviCString m_szName; + KviCString m_szDescription; +public: + const char * name(){ return m_szName.ptr(); }; + const char * description(){ return m_szDescription.ptr(); }; + int bits(){ return m_iNumBits; }; + int bitsUsed(){ return m_iNumBitsUsed; }; + const char * version(){ return m_szVersion.ptr(); }; +#ifdef COMPILE_ON_WINDOWS + // On windows we need to override new and delete operators + // to ensure that always the right new/delete pair is called for an object instance + // This bug is present in all the classes exported by a module that + // can be instantiated/destroyed from external modules. + // (this is a well known bug described in Q122675 of MSDN) + void * operator new(size_t tSize); + void operator delete(void * p); +#endif +}; + +#ifdef Success + #undef Success +#endif + + +class KVILIB_API KviSSL +{ +public: + enum Method { Client, Server }; + enum Result { Success, NotInitialized, WantRead, WantWrite, ZeroReturn, FileIoError, + UnknownError, ObscureError, SSLError, SyscallError, RemoteEndClosedConnection }; +public: + KviSSL(); + ~KviSSL(); +public: + SSL * m_pSSL; + SSL_CTX * m_pSSLCtx; + KviCString m_szPass; +public: + static void globalInit(); + static void globalDestroy(); + static void globalSSLInit(); + static void globalSSLDestroy(); +public: + bool initSocket(kvi_socket_t fd); + bool initContext(KviSSL::Method m); + void shutdown(); + KviSSL::Result connect(); + KviSSL::Result accept(); + int read(char * buffer,int len); + int write(const char * buffer,int len); + // SSL ERRORS + unsigned long getLastError(bool bPeek = false); + bool getLastErrorString(KviCString &buffer,bool bPeek = false); + // Protocol error + KviSSL::Result getProtocolError(int ret); + KviSSLCertificate * getPeerCertificate(); + KviSSLCertificate * getLocalCertificate(); + KviSSLCipherInfo * getCurrentCipherInfo(); + KviSSL::Result useCertificateFile(const char * cert,const char * pass); + KviSSL::Result usePrivateKeyFile(const char * key,const char * pass); +#ifdef COMPILE_ON_WINDOWS + // On windows we need to override new and delete operators + // to ensure that always the right new/delete pair is called for an object instance + // This bug is present in all the classes exported by a module that + // can be instantiated/destroyed from external modules. + // (this is a well known bug described in Q122675 of MSDN) + void * operator new(size_t tSize); + void operator delete(void * p); +#endif +private: + KviSSL::Result connectOrAcceptError(int ret); +}; + + +#endif //COMPILE_SSL_SUPPORT + +#endif //_KVI_SSL_H_ diff --git a/src/kvilib/net/KviUrl.cpp b/src/kvilib/net/KviUrl.cpp new file mode 100644 index 000000000..24204cfd0 --- /dev/null +++ b/src/kvilib/net/KviUrl.cpp @@ -0,0 +1,93 @@ +//============================================================================= +// +// File : KviUrl.cpp +// Creation date : Sat Aug 17 14:09:18 2002 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + + + +#include "KviUrl.h" +#include + +KviUrl::KviUrl() +{ +} + +KviUrl::KviUrl(const KviUrl & u) +{ + *this = u; +} + +KviUrl::KviUrl(const char * szUrl) +{ + m_szUrl = QString::fromLocal8Bit(szUrl); + parse(); +} + +KviUrl::KviUrl(const QString &szUrl) +{ + m_szUrl = szUrl; + parse(); +} + +KviUrl::~KviUrl() +{ + +} + +void KviUrl::parse() +{ + QUrl url(m_szUrl); + m_szProtocol = url.scheme(); + m_szHost = url.host(); + m_szPath = url.encodedPath(); + if(url.hasQuery()) + { + m_szPath.append(QChar('?')); + m_szPath.append(url.encodedQuery()); + } + if(m_szPath.isEmpty()) m_szPath=QString("/"); + m_szUser = url.userName(); + m_szPass = url.password(); + m_uPort = url.port() > 0 ? url.port() : 80 ; +} + + +KviUrl & KviUrl::operator=(const QString& szUrl) +{ + m_szUrl = szUrl; + parse(); + return *this; +} + +KviUrl & KviUrl::operator=(const KviUrl &u) +{ + m_szUrl = u.m_szUrl; + m_szProtocol = u.m_szProtocol; + m_szHost = u.m_szHost; + m_szPath = u.m_szPath; + m_szUser = u.m_szUser; + m_szPass = u.m_szPass; + m_uPort = u.m_uPort; + return *this; +} + + diff --git a/src/kvilib/net/KviUrl.h b/src/kvilib/net/KviUrl.h new file mode 100644 index 000000000..39b046ad8 --- /dev/null +++ b/src/kvilib/net/KviUrl.h @@ -0,0 +1,65 @@ +#ifndef _KVI_URL_H_ +#define _KVI_URL_H_ +//============================================================================= +// +// File : KviUrl.h +// Creation date : Sat Aug 17 14:09:16 2002 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviCString.h" +#include "KviHeapObject.h" +#include "kvi_inttypes.h" + +class KVILIB_API KviUrl : public KviHeapObject +{ +public: + KviUrl(); + KviUrl(const char * szUrl); + KviUrl(const QString &szUrl); + KviUrl(const KviUrl &u); + ~KviUrl(); +protected: + QString m_szUrl; + + QString m_szProtocol; + QString m_szHost; + QString m_szPath; + QString m_szUser; + QString m_szPass; + kvi_u32_t m_uPort; +protected: + void parse(); +public: + const QString & url() const { return m_szUrl; }; + const QString & protocol() const { return m_szProtocol; }; + const QString & host() const { return m_szHost; }; + const QString & path() const { return m_szPath; }; + const QString & user() const { return m_szUser; }; + const QString & pass() const { return m_szPass; }; + kvi_u32_t port() const { return m_uPort; }; + + KviUrl & operator = (const QString& szUrl); + KviUrl & operator = (const KviUrl &u); + +}; + + +#endif //_KVI_URL_H_ diff --git a/src/kvilib/net/kvi_dns.cpp b/src/kvilib/net/kvi_dns.cpp deleted file mode 100644 index aabace901..000000000 --- a/src/kvilib/net/kvi_dns.cpp +++ /dev/null @@ -1,445 +0,0 @@ -//============================================================================= -// -// File : kvi_dns.cpp -// Creation date : Sat Jul 21 2000 17:19:31 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_dns.h" -#include "kvi_error.h" -#include "kvi_netutils.h" - -#include - -#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - #include - - #ifdef COMPILE_IPV6_SUPPORT - #ifdef WIN2K - #include - #else - #include - //#include - #endif - #endif -#else - #include - #include - #include -#endif - -// this is for FreeBSD -#ifndef EAI_ADDRFAMILY - #define EAI_ADDRFAMILY EAI_FAMILY -#endif - -#ifndef EAI_NODATA - #define EAI_NODATA 0 -#endif - - - -KviDnsResult::KviDnsResult() -{ - m_iError = KviError_success; - m_pHostnameList = new KviPointerList; - m_pHostnameList->setAutoDelete(true); - m_pIpAddressList = new KviPointerList; - m_pIpAddressList->setAutoDelete(true); - -} - -KviDnsResult::~KviDnsResult() -{ - delete m_pHostnameList; - delete m_pIpAddressList; -} - -void KviDnsResult::appendHostname(const QString &host) -{ - m_pHostnameList->append(new QString(host)); -} - - -void KviDnsResult::appendAddress(const QString &addr) -{ - m_pIpAddressList->append(new QString(addr)); -} - - - -KviDnsThread::KviDnsThread(KviDns * pDns) -{ - m_pParentDns = pDns; -} - -KviDnsThread::~KviDnsThread() -{ -} - -int KviDnsThread::translateDnsError(int iErr) -{ -#if defined(COMPILE_IPV6_SUPPORT) || (!defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)) - - switch(iErr) - { - case EAI_FAMILY: return KviError_unsupportedAddressFamily; break; -#if (!defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)) && defined(EAI_ADDRFAMILY) && (EAI_ADDRFAMILY != EAI_FAMILY) - case EAI_ADDRFAMILY: return KviError_unsupportedAddressFamily; break; -#endif -// NOT FreeBSD ARE WE? -#if defined(EAI_NODATA) && (EAI_NODATA != EAI_NONAME) -// YARR - case EAI_NODATA: return KviError_validNameButNoIpAddress; break; -#endif - case EAI_FAIL: return KviError_unrecoverableNameserverError; break; - case EAI_AGAIN: return KviError_dnsTemporaneousFault; break; - // this should never happen - case EAI_BADFLAGS: return KviError_dnsInternalErrorBadFlags; break; - case EAI_MEMORY: return KviError_dnsInternalErrorOutOfMemory; break; - // got this when experimenting with protocols - case EAI_SERVICE: return KviError_dnsInternalErrorServiceNotSupported; break; -#if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) - case EAI_NONAME: return KviError_dnsNoName; break; -#endif - // got this when experimenting with protocols - case EAI_SOCKTYPE: return KviError_dnsInternalErrorUnsupportedSocketType; break; -#if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) - case EAI_SYSTEM: return -errno; -#endif - } - -#endif - return KviError_dnsQueryFailed; -} - -void KviDnsThread::postDnsError(KviDnsResult * dns,int iErr) -{ - dns->setError(iErr); - KviThreadDataEvent * e = new KviThreadDataEvent(KVI_DNS_THREAD_EVENT_DATA); - e->setData(dns); - postEvent(m_pParentDns,e); -} - -void KviDnsThread::run() -{ - KviDnsResult * dns = new KviDnsResult(); - - dns->setQuery(m_szQuery); - - if(m_szQuery.isEmpty()) - { - postDnsError(dns,KviError_noHostToResolve); - return; - } - -#ifndef COMPILE_IPV6_SUPPORT - if(m_queryType != KviDns::IPv4) - { - if(m_queryType == KviDns::IPv6) - { - postDnsError(dns,KviError_noIPv6Support); - return; - } - m_queryType = KviDns::IPv4; - } -#endif - -#if (defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)) && !defined(COMPILE_IPV6_SUPPORT) - - if(m_queryType == KviDns::IPv6) - { - postDnsError(dns,KviError_noIPv6Support); - return; - } - - // gethostbyaddr and gethostbyname are thread-safe on Windoze - struct in_addr inAddr; - struct hostent *pHostEntry = 0; - - - // DIE DIE!....I hope that this stuff will disappear sooner or later :) - - if(KviNetUtils::stringIpToBinaryIp(m_szQuery,&inAddr)) - { - pHostEntry = gethostbyaddr((const char *)&inAddr,sizeof(inAddr),AF_INET); - } else { - pHostEntry = gethostbyname(m_szQuery.toUtf8().data()); - } - - if(!pHostEntry) - { - switch(h_errno) - { - case HOST_NOT_FOUND: dns->setError(KviError_hostNotFound); break; - case NO_ADDRESS: dns->setError(KviError_validNameButNoIpAddress); break; - case NO_RECOVERY: dns->setError(KviError_unrecoverableNameserverError); break; - case TRY_AGAIN: dns->setError(KviError_dnsTemporaneousFault); break; - default: dns->setError(KviError_dnsQueryFailed); break; - } - } else { - dns->appendHostname(pHostEntry->h_name); - QString szIp; - KviNetUtils::binaryIpToStringIp(* ((struct in_addr*)(pHostEntry->h_addr)),szIp); - dns->appendAddress(szIp); - - int idx = 1; - while(pHostEntry->h_addr_list[idx]) - { - QString tmp; - KviNetUtils::binaryIpToStringIp(* ((struct in_addr*)(pHostEntry->h_addr_list[idx])),tmp); - if(!tmp.isEmpty())dns->appendAddress(tmp); - ++idx; - } - if(pHostEntry->h_aliases[0]) - { - dns->appendHostname(QString::fromUtf8(pHostEntry->h_aliases[0])); - if(pHostEntry->h_aliases[1])dns->appendHostname(QString::fromUtf8(pHostEntry->h_aliases[1])); - } - } - - -#else - - int retVal; - - -//#ifdef HAVE_GETNAMEINFO - struct sockaddr_in ipv4Addr; - -#ifdef COMPILE_IPV6_SUPPORT - struct sockaddr_in6 ipv6Addr; - bool bIsIPv6Ip = false; -#endif - - bool bIsIPv4Ip = KviNetUtils::stringIpToBinaryIp(m_szQuery,(struct in_addr *)&(ipv4Addr.sin_addr)); - -#ifdef COMPILE_IPV6_SUPPORT - if(!bIsIPv4Ip)bIsIPv6Ip = KviNetUtils::stringIpToBinaryIp_V6(m_szQuery,(struct in6_addr *)&(ipv6Addr.sin6_addr)); -#endif - -//#ifdef HAVE_GETNAMEINFO - -#ifdef COMPILE_IPV6_SUPPORT - if(bIsIPv4Ip || bIsIPv6Ip) - { -#else - if(bIsIPv4Ip) - { -#endif - // use getnameinfo... - char retname[1025]; // should be enough.... - -#ifdef COMPILE_IPV6_SUPPORT - if(bIsIPv4Ip) - { -#endif - ipv4Addr.sin_family = AF_INET; - ipv4Addr.sin_port = 0; - // NI_NAMEREQD as last param ? - retVal = getnameinfo((struct sockaddr *)&ipv4Addr,sizeof(ipv4Addr),retname,1025,0,0,NI_NAMEREQD); -#ifdef COMPILE_IPV6_SUPPORT - } else { - ipv6Addr.sin6_family = AF_INET6; - ipv6Addr.sin6_port = 0; - retVal = getnameinfo((struct sockaddr *)&ipv6Addr,sizeof(ipv6Addr),retname,1025,0,0,NI_NAMEREQD); - } -#endif - - if(retVal != 0)dns->setError(translateDnsError(retVal)); - else { - dns->appendHostname(retname); - dns->appendAddress(m_szQuery); - } - - } else { -//#endif //HAVE_GETNAMEINFO - - -//#ifdef COMPILE_IPV6_SUPPORT -// struct in6_addr in6Addr; -//#endif - struct addrinfo * pRet = 0; - struct addrinfo * pNext; - struct addrinfo hints; - hints.ai_flags = 0; //AI_CANONNAME; <-- for IPV6 it makes cannoname to point to the IP address! -#ifdef COMPILE_IPV6_SUPPORT - hints.ai_family = (m_queryType == KviDns::IPv6) ? PF_INET6 : ((m_queryType == KviDns::IPv4) ? PF_INET : PF_UNSPEC); -#else - hints.ai_family = PF_INET; -#endif - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = 0; - hints.ai_addrlen = 0; - hints.ai_canonname = 0; - hints.ai_addr = 0; - hints.ai_next = 0; - - retVal = getaddrinfo(KviQString::toUtf8(m_szQuery).data(),0,&hints,&pRet); - - if(retVal != 0)dns->setError(translateDnsError(retVal)); - else { - dns->appendHostname(pRet->ai_canonname ? QString::fromUtf8(pRet->ai_canonname) : m_szQuery); - QString szIp; -#ifdef COMPILE_IPV6_SUPPORT - if(pRet->ai_family == PF_INET6)KviNetUtils::binaryIpToStringIp_V6(((sockaddr_in6 *)(pRet->ai_addr))->sin6_addr,szIp); - else { -#endif - KviNetUtils::binaryIpToStringIp(((sockaddr_in *)(pRet->ai_addr))->sin_addr,szIp); -#ifdef COMPILE_IPV6_SUPPORT - } -#endif - dns->appendAddress(szIp); - - pNext = pRet->ai_next; - while(pNext) - { - QString tmp; -#ifdef COMPILE_IPV6_SUPPORT - if(pNext->ai_family == PF_INET6)KviNetUtils::binaryIpToStringIp_V6(((sockaddr_in6 *)(pNext->ai_addr))->sin6_addr,tmp); - else { -#endif - KviNetUtils::binaryIpToStringIp(((sockaddr_in *)(pNext->ai_addr))->sin_addr,tmp); -#ifdef COMPILE_IPV6_SUPPORT - } -#endif - if(!tmp.isEmpty())dns->appendAddress(tmp); - - if(pNext->ai_canonname) - { - // FIXME: only of not equal to other names ? - dns->appendHostname(QString::fromUtf8(pNext->ai_canonname)); - } - - pNext = pNext->ai_next; - - } - } - if(pRet)freeaddrinfo(pRet); -//#ifdef HAVE_GETNAMEINFO - } -//#endif //HAVE_GETNAMEINFO - -#endif // !COMPILE_ON_WINDOWS - - - KviThreadDataEvent * e = new KviThreadDataEvent(KVI_DNS_THREAD_EVENT_DATA); - e->setData(dns); - postEvent(m_pParentDns,e); -} - - -KviDns::KviDns() -: QObject() -{ - m_pSlaveThread = new KviDnsThread(this); - m_pDnsResult = new KviDnsResult(); - m_pAuxData = 0; - m_state = Idle; -} - -KviDns::~KviDns() -{ - if(m_pSlaveThread)delete m_pSlaveThread; // will eventually terminate it (but it will also block us!!!) - KviThreadManager::killPendingEvents(this); - if(m_pDnsResult)delete m_pDnsResult; - if(m_pAuxData)qDebug("You're leaking memory man! m_pAuxData is non 0!"); -} - -bool KviDns::isRunning() const -{ - return (m_state == Busy); -} - -bool KviDns::lookup(const QString &query,QueryType type) -{ - if(m_state == Busy)return false; - m_pSlaveThread->setQuery(KviQString::trimmed(query),type); - bool bStarted = m_pSlaveThread->start(); - m_state = bStarted ? Busy : Failure; - return bStarted; -} - -int KviDns::error() -{ - if(!m_pDnsResult)return KviError_dnsQueryFailed; - return m_pDnsResult->error(); -} - -KviDnsResult * KviDns::result() -{ - if(!m_pDnsResult)m_pDnsResult = new KviDnsResult(); - return m_pDnsResult; -} - -KviPointerList * KviDns::hostnameList() -{ - return result()->hostnameList(); -} - -KviPointerList * KviDns::ipAddressList() -{ - return result()->ipAddressList(); -} - -int KviDns::hostnameCount() -{ - return result()->hostnameList()->count(); -} - -int KviDns::ipAddressCount() -{ - return result()->ipAddressList()->count(); -} - -const QString & KviDns::firstHostname() -{ - QString * pStr = result()->hostnameList()->first(); - if(pStr)return *pStr; - return KviQString::Empty; -} - -const QString & KviDns::firstIpAddress() -{ - QString * pStr = result()->ipAddressList()->first(); - if(pStr)return *pStr; - return KviQString::Empty; -} - -const QString & KviDns::query() -{ - return result()->query(); -} - -bool KviDns::event(QEvent *e) -{ - if(e->type() == KVI_THREAD_EVENT) - { - if(((KviThreadEvent *)e)->id() == KVI_DNS_THREAD_EVENT_DATA) - { - if(m_pDnsResult)delete m_pDnsResult; - m_pDnsResult = ((KviThreadDataEvent *)e)->getData(); - m_state = (m_pDnsResult->error() == KviError_success) ? Success : Failure; - emit lookupDone(this); - return true; - } // else ops... unknown thread event ? - } - return QObject::event(e); -} diff --git a/src/kvilib/net/kvi_dns.h b/src/kvilib/net/kvi_dns.h deleted file mode 100644 index 9a9825b23..000000000 --- a/src/kvilib/net/kvi_dns.h +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef _KVI_DNS_H_ -#define _KVI_DNS_H_ - -//============================================================================= -// -// File : kvi_dns.h -// Creation date : Sat Jul 21 2000 13:59:11 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" -#include "KviHeapObject.h" -#include "KviThread.h" -#include "KviQString.h" - - -class KviDnsThread; // not part of the API - - -class KVILIB_API KviDnsResult : public KviHeapObject -{ - friend class KviDns; - friend class KviDnsThread; -protected: - KviDnsResult(); -public: - ~KviDnsResult(); -protected: - int m_iError; - KviPointerList * m_pHostnameList; - KviPointerList * m_pIpAddressList; - QString m_szQuery; -public: - int error(){ return m_iError; }; - // never store nor delete these pointers! - // (these are NEVER 0) - KviPointerList * hostnameList(){ return m_pHostnameList; }; - KviPointerList * ipAddressList(){ return m_pIpAddressList; }; - const QString &query(){ return m_szQuery; }; -protected: - void setError(int iError){ m_iError = iError; }; - void setQuery(const QString &query){ m_szQuery = query; }; - void appendHostname(const QString &host); - void appendAddress(const QString &addr); -}; - - - -class KVILIB_API KviDns : public QObject, public KviHeapObject -{ - Q_OBJECT - Q_PROPERTY(bool blockingDelete READ isRunning) -public: - KviDns(); - ~KviDns(); -public: - enum QueryType { IPv4, IPv6, Any }; - enum State { Idle, Busy, Failure, Success }; -protected: - void * m_pAuxData; - KviDnsThread * m_pSlaveThread; - KviDnsResult * m_pDnsResult; - State m_state; -public: - ///////////////////////////////////////////////////////////////////////////////////////////////////// - // - // Public interface - // - - // Lookup start - bool lookup(const QString &szQuery,QueryType type); - - // Current object state - State state(){ return m_state; }; - - // Results (return always non null-data..but valid results only if state() == Success or Failure) - int error(); - const QString & firstHostname(); - const QString & firstIpAddress(); - int hostnameCount(); - int ipAddressCount(); - KviPointerList * hostnameList(); - KviPointerList * ipAddressList(); - const QString & query(); - bool isRunning() const; - - // Auxiliary data store - void setAuxData(void * pAuxData){ m_pAuxData = pAuxData; }; - void * releaseAuxData(){ void * pData = m_pAuxData; m_pAuxData = 0; return pData; }; -protected: - virtual bool event(QEvent *e); -private: - KviDnsResult * result(); -signals: - void lookupDone(KviDns *); -}; - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// -// INTERNAL CLASSES -// - -#define KVI_DNS_THREAD_EVENT_DATA (KVI_THREAD_USER_EVENT_BASE + 7432) - -class KviDnsThread : public KviThread -{ - friend class KviDns; -protected: - KviDnsThread(KviDns * pDns); - ~KviDnsThread(); -protected: - QString m_szQuery; - KviDns::QueryType m_queryType; - KviDns * m_pParentDns; -public: - void setQuery(const QString &query,KviDns::QueryType type){ m_szQuery = query; m_queryType = type; }; -protected: - virtual void run(); - int translateDnsError(int iErr); - void postDnsError(KviDnsResult * dns,int iErr); -}; - - -#endif //_KVI_DNS_H_ diff --git a/src/kvilib/net/kvi_http.cpp b/src/kvilib/net/kvi_http.cpp deleted file mode 100644 index 4bbec0d59..000000000 --- a/src/kvilib/net/kvi_http.cpp +++ /dev/null @@ -1,1432 +0,0 @@ -//============================================================================= -// -// File : kvi_http.cpp -// Creation date : Sat Aug 17 13:43:32 2002 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - - - -#include -#include -//#include - -#include "kvi_http.h" -#include "KviLocale.h" -#include "kvi_netutils.h" -#include "kvi_dns.h" -#include "kvi_error.h" -#include "kvi_debug.h" -#include "kvi_socket.h" -#include "KviTimeUtils.h" - -#ifdef COMPILE_SSL_SUPPORT - #include "kvi_ssl.h" -#endif - - -#define KVI_HTTP_REQUEST_THREAD_EVENT_CONNECTED (KVI_THREAD_USER_EVENT_BASE + 0xCAFE) -#define KVI_HTTP_REQUEST_THREAD_EVENT_REQUESTSENT (KVI_THREAD_USER_EVENT_BASE + 0xCAFF) - -KviHttpRequest::KviHttpRequest() -: QObject() -{ - m_pDns = 0; - m_pThread = 0; - m_pFile = 0; - m_pPrivateData = 0; - m_bHeaderProcessed = false; - m_pBuffer = new KviDataBuffer(); - m_uConnectionTimeout = 60; - - resetStatus(); - resetData(); -} - -KviHttpRequest::~KviHttpRequest() -{ - resetInternalStatus(); - delete m_pBuffer; -} - -void KviHttpRequest::abort() -{ - resetInternalStatus(); - m_szLastError = __tr2qs("Aborted"); - emit terminated(false); -} - -void KviHttpRequest::resetInternalStatus() -{ - if(m_pThread)delete m_pThread; - if(m_pDns)delete m_pDns; - - m_pDns = 0; - m_pThread = 0; - - if(!m_pFile)return; - m_pFile->close(); - delete m_pFile; - m_pFile = 0; - - m_pBuffer->clear(); - m_bHeaderProcessed = false; - - KviThreadManager::killPendingEvents(this); -} - -void KviHttpRequest::resetStatus() -{ - m_szLastError = __tr2qs("No request"); - m_uTotalSize = 0; - m_uReceivedSize = 0; -} - -void KviHttpRequest::resetData() -{ - m_szFileName = ""; - m_eProcessingType = WholeFile; - m_eExistingFileAction = RenameIncoming; - m_url = QString(""); - m_uMaxContentLength = 0; - m_uContentOffset = 0; - m_bChunkedTransferEncoding = false; - m_bGzip = false; - m_bIgnoreRemainingData = false; - m_uRemainingChunkSize = 0; -} - -void KviHttpRequest::reset() -{ - resetStatus(); - resetData(); - resetInternalStatus(); -} - -bool KviHttpRequest::get(const KviUrl &u,ProcessingType p,const QString &szFileName) -{ - reset(); - setUrl(u); - setProcessingType(p); - setFileName(szFileName); - return start(); -} - -bool KviHttpRequest::start() -{ - // ensure that the file is closed - resetInternalStatus(); - resetStatus(); - - if(m_eProcessingType == StoreToFile) - { - if(m_szFileName.isEmpty()) - { - m_szLastError = __tr2qs("No filename specified for the \"StoreToFile\" processing type"); - return false; - } - - if((m_eExistingFileAction == Resume) && (m_uContentOffset == 0)) - { - // determine the content offset automatically - if(KviFile::exists(m_szFileName)) - { - // we check it - QFileInfo fi(m_szFileName); - m_uContentOffset = fi.size(); - } - } - } - - if(m_url.host().isEmpty()) - { - resetInternalStatus(); - m_szLastError = __tr2qs("Invalid URL: Missing hostname"); - return false; - } - - if(!KviQString::equalCI(m_url.protocol(),"http") && !KviQString::equalCI(m_url.protocol(),"https")) - { - resetInternalStatus(); - m_szLastError=__tr2qs("Unsupported protocol %1").arg(m_url.protocol()); - return false; - } - - if(KviNetUtils::isValidStringIp(m_url.host())) - { - m_szIp = m_url.host(); - QTimer::singleShot(10,this,SLOT(haveServerIp())); - return true; - } - - return startDnsLookup(); -} - -bool KviHttpRequest::startDnsLookup() -{ - m_pDns = new KviDns(); - connect(m_pDns,SIGNAL(lookupDone(KviDns *)),this,SLOT(dnsLookupDone(KviDns *))); - - if(!m_pDns->lookup(m_url.host(),KviDns::IPv4)) - { - resetInternalStatus(); - m_szLastError = __tr2qs("Unable to start the DNS lookup"); - return false; - } - - QString tmp; - KviQString::sprintf(tmp,__tr2qs("Looking up host %Q"),&(m_url.host())); - emit status(tmp); // FIXME - - emit resolvingHost(m_url.host()); - - return true; -} - -void KviHttpRequest::dnsLookupDone(KviDns *d) -{ - if(d->state() == KviDns::Success) - { - m_szIp = d->firstIpAddress(); - delete m_pDns; - m_pDns = 0; - QString tmp; - KviQString::sprintf(tmp,__tr2qs("Host %Q resolved to %Q"),&(m_url.host()),&m_szIp); - emit status(tmp); - haveServerIp(); - } else { - int iErr = d->error(); - resetInternalStatus(); - m_szLastError = KviError::getDescription(iErr); - emit terminated(false); - } -} - -void KviHttpRequest::haveServerIp() -{ - unsigned short uPort = m_url.port(); - if(uPort == 0)uPort = 80; - - QString tmp; - KviQString::sprintf(tmp,"%Q:%u",&m_szIp,uPort); - emit contactingHost(tmp); - - if(m_pThread)delete m_pThread; - - m_pThread = new KviHttpRequestThread( - this, - m_url.host(), - m_szIp, - uPort, - m_url.path(), - m_uContentOffset, - (m_eProcessingType == HeadersOnly) ? KviHttpRequestThread::Head : (m_szPostData.isEmpty() ? KviHttpRequestThread::Get : KviHttpRequestThread::Post), - m_szPostData, - m_url.protocol()=="https" - ); - - m_pThread->setConnectionTimeout(m_uConnectionTimeout); - - if(!m_pThread->start()) - { - resetInternalStatus(); - m_szLastError = __tr2qs("Unable to start the request slave thread"); - emit terminated(false); - return; - } - - KviQString::sprintf(tmp,__tr2qs("Contacting host %Q on port %u"),&m_szIp,uPort); - emit status(tmp); -} - -bool KviHttpRequest::event(QEvent *e) -{ - if(e->type() == KVI_THREAD_EVENT) - { - switch(((KviThreadEvent *)e)->id()) - { - case KVI_THREAD_EVENT_BINARYDATA: - { - KviDataBuffer * b = ((KviThreadDataEvent *)e)->getData(); - processData(b); - delete b; - return true; - } - break; - case KVI_HTTP_REQUEST_THREAD_EVENT_CONNECTED: - emit connectionEstabilished(); - emit status(__tr2qs("Connection established, sending request")); - return true; - break; - case KVI_HTTP_REQUEST_THREAD_EVENT_REQUESTSENT: - { - QString * req = ((KviThreadDataEvent *)e)->getData(); - QStringList sl = req->split("\r\n"); - emit requestSent(sl); - delete req; - return true; - } - break; - case KVI_THREAD_EVENT_SUCCESS: - if(!m_pThread && !m_bHeaderProcessed) - { - // the thread has already been deleted - // probably because the response was something like a 404 - // just ignore the event - return true; - } - switch(m_eProcessingType) - { - case WholeFile: - // happens always - emit binaryData(*m_pBuffer); - break; - case Blocks: - // an unprocessed block ?.. should never happend.. but well :D - if(m_pBuffer->size() > 0)emit binaryData(*m_pBuffer); - break; - case Lines: - if(m_pBuffer->size() > 0) - { - // something left in the buffer and has no trailing LF - KviCString tmp((const char *)(m_pBuffer->data()),m_pBuffer->size()); - emit data(tmp); - } - break; - case StoreToFile: - // same as above... should never happen.. but well :D - if(m_pFile && m_pBuffer->size() > 0)m_pFile->write((const char *)(m_pBuffer->data()),m_pBuffer->size()); - break; - default: - // nothing... just make gcc happy - break; - } - resetInternalStatus(); - m_szLastError = __tr2qs("Success"); - emit terminated(true); - return true; - break; - case KVI_THREAD_EVENT_ERROR: - { - KviCString * err = ((KviThreadDataEvent *)e)->getData(); - m_szLastError = __tr2qs_no_xgettext(err->ptr()); - delete err; - resetInternalStatus(); - emit terminated(false); - return true; - } - break; - case KVI_THREAD_EVENT_MESSAGE: - { - KviCString * msg = ((KviThreadDataEvent *)e)->getData(); - emit status(__tr2qs_no_xgettext(msg->ptr())); - delete msg; - return true; - } - break; - } - } - return QObject::event(e); -} - -void KviHttpRequest::emitLines(KviDataBuffer * pDataBuffer) -{ - int idx = pDataBuffer->find((const unsigned char *)"\n",1); - while(idx != -1) - { - KviCString tmp((const char *)(m_pBuffer->data()),idx); - tmp.stripRight('\r'); - pDataBuffer->remove(idx + 1); - idx = pDataBuffer->find((const unsigned char *)"\n",1); - emit data(tmp); - } -} - -// header += "Accept: "; -// QString acceptHeader = metaData("accept"); -// if (!acceptHeader.isEmpty()) -// header += acceptHeader; -// else -// header += DEFAULT_ACCEPT_HEADER; -// header += "\r\n"; -// -//#ifdef DO_GZIP -// if (m_request.allowCompressedPage) -// header += "Accept-Encoding: x-gzip, x-deflate, gzip, deflate, identity\r\n"; -//#endif -// -// if (!m_request.charsets.isEmpty()) -// header += "Accept-Charset: " + m_request.charsets + "\r\n"; -// -// if (!m_request.languages.isEmpty()) -// header += "Accept-Language: " + m_request.languages + "\r\n"; -// -// -// /* support for virtual hosts and required by HTTP 1.1 */ -// header += "Host: "; -// header += "Pragma: no-cache\r\n"; /* for HTTP/1.0 caches */ -// header += "Cache-control: no-cache\r\n"; /* for HTTP >=1.1 caches */ - -// header += "Referer: "; //Don't try to correct spelling! -// header += m_request.referrer; -// header += "\r\n"; -bool KviHttpRequest::openFile() -{ - if(m_eProcessingType != StoreToFile)return true; - - bool bAppend = false; - - // take action when the file is existing - if(KviFile::exists(m_szFileName)) - { - switch(m_eExistingFileAction) - { - case Resume: - { - bAppend = true; - } - break; - case RenameIncoming: - { - int i=0; - QString tmp = m_szFileName; - do { - i++; - m_szFileName = tmp + QString(".kvirnm-%1").arg(i); - } while(KviFile::exists(m_szFileName)); - } - break; - case RenameExisting: - { - int i=0; - QString tmp; - do { - i++; - tmp = m_szFileName + QString(".kvirnm-%1").arg(i); - } while(KviFile::exists(tmp)); - QDir d; - if(!d.rename(m_szFileName,tmp)) - { - // fail :( - resetInternalStatus(); - m_szLastError = __tr2qs("Failed to rename the existing file, please rename manually and retry"); - emit terminated(false); - return false; - } - } - break; - case Overwrite: - default: - // nothing - break; - } - } - - m_pFile = new KviFile(m_szFileName); - - if(!m_pFile->open(QFile::WriteOnly | (bAppend ? QFile::Append : QFile::Truncate))) - { - resetInternalStatus(); - KviQString::sprintf(m_szLastError,__tr2qs("Can't open file \"%Q\" for writing"),&m_szFileName); - emit terminated(false); - return false; - } - - return true; -} - - -bool KviHttpRequest::processHeader(KviCString &szHeader) -{ - int idx = szHeader.findFirstIdx("\r\n"); - KviCString szResponse; - if(idx != -1) - { - szResponse = szHeader.left(idx); - szHeader.cutLeft(idx + 2); - } else { - szResponse = szHeader; - szHeader = ""; - } - - szResponse.trimmed(); - - bool bValid = false; - - unsigned int uStatus = 0; - - // check the response value - if(kvi_strEqualCSN(szResponse.ptr(),"HTTP",4)) - { - KviCString szR = szResponse; - szR.cutToFirst(' '); - szR.trimmed(); - int idx = szR.findFirstIdx(' '); - KviCString szNumber; - if(idx != -1)szNumber = szR.left(idx); - else szNumber = szR; - bool bOk; - uStatus = szNumber.toUInt(&bOk); - if(bOk)bValid = true; - } - - QString szUniResponse = QString::fromUtf8(szResponse.ptr()); - - if(!bValid) - { - // the response is invalid ? - resetInternalStatus(); - m_szLastError = __tr2qs("Invalid HTTP response: %1").arg(szUniResponse); - emit terminated(false); - return false; - } - - QString tmp = __tr2qs("Received HTTP response: %1").arg(szUniResponse); - - emit status(tmp); - emit receivedResponse(szUniResponse); - - KviPointerList hlist; - hlist.setAutoDelete(true); - - idx = szHeader.findFirstIdx("\r\n"); - while(idx != -1) - { - if(idx > 0) - { - hlist.append(new KviCString(szHeader.ptr(),idx)); - szHeader.cutLeft(idx + 2); - } - idx = szHeader.findFirstIdx("\r\n"); - } - if(szHeader.hasData())hlist.append(new KviCString(szHeader)); - - KviPointerHashTable hdr(11,false,true); - hdr.setAutoDelete(true); - - for(KviCString * s = hlist.first();s;s = hlist.next()) - { - idx = s->findFirstIdx(":"); - if(idx != -1) - { - KviCString szName = s->left(idx); - s->cutLeft(idx + 1); - s->trimmed(); - hdr.replace(szName.ptr(),new KviCString(*s)); - //qDebug("FOUND HEADER (%s)=(%s)",szName.ptr(),s->ptr()); - } - } - - KviCString * size = hdr.find("Content-length"); - if(size) - { - bool bOk; - m_uTotalSize = size->toUInt(&bOk); - if(!bOk)m_uTotalSize = 0; - } - - KviCString * contentEncoding = hdr.find("Content-encoding"); - if(contentEncoding) - { - m_bGzip = contentEncoding->equalsCI("gzip"); - } - - KviCString * transferEncoding = hdr.find("Transfer-Encoding"); - if(transferEncoding) - { - if(kvi_strEqualCI(transferEncoding->ptr(),"chunked")) - { - // be prepared to handle the chunked transfer encoding as required by HTTP/1.1 - m_bChunkedTransferEncoding = true; - m_uRemainingChunkSize = 0; - } - } - - emit header(&hdr); - - // check the status - - // case 200: // OK - // case 206: // Partial content - - // case 100: // Continue ?? - // case 101: // Switching protocols ??? - // case 201: // Created - // case 202: // Accepted - // case 203: // Non-Authoritative Information - // case 204: // No content - // case 205: // Reset content - // case 300: // Multiple choices - // case 301: // Moved permanently - // case 302: // Found - // case 303: // See Other - // case 304: // Not modified - // case 305: // Use Proxy - // case 306: // ??? - // case 307: // Temporary Redirect - // case 400: // Bad request - // case 401: // Unauthorized - // case 402: // Payment Required - // case 403: // Forbidden - // case 404: // Not found - // case 405: // Method not allowed - // case 406: // Not acceptable - // case 407: // Proxy authentication required - // case 408: // Request timeout - // case 409: // Conflict - // case 410: // Gone - // case 411: // Length required - // case 412: // Precondition failed - // case 413: // Request entity too large - // case 414: // Request-URI Too Long - // case 415: // Unsupported media type - // case 416: // Requested range not satisfiable - // case 417: // Expectation Failed - // case 500: // Internal server error - // case 501: // Not implemented - // case 502: // Bad gateway - // case 503: // Service unavailable - // case 504: // Gateway timeout - // case 505: // HTTP Version not supported - - if((uStatus != 200) && (uStatus != 206)) - { - // this is not "OK" and not "Partial content" - // Error, redirect or something confusing - - // FIXME: Handle 30x codes by re-issuing the request with the new URI ? - - if(m_eProcessingType != HeadersOnly) - { - // this is an error then - resetInternalStatus(); - m_szLastError = szResponse.ptr(); - emit terminated(false); - return false; - } // else the server will terminate (it was a HEAD request) - } - - if((m_uMaxContentLength > 0) && (m_uTotalSize > ((unsigned int)m_uMaxContentLength))) - { - resetInternalStatus(); - m_szLastError=__tr2qs("Stream exceeding maximum length"); - emit terminated(false); - return false; - } - - // fixme: could check for data type etc... - - return true; -} -#define BUFFER_SIZE 32768 - -void KviHttpRequest::processData(KviDataBuffer * data) -{ -// unsigned char obuffer[BUFFER_SIZE]; - if(m_bChunkedTransferEncoding && m_bIgnoreRemainingData) - { - // In chunked transfer encoding mode there may be additional headers - // after the last chunk of data. We simply ignore them. - return; - } - - if(!m_bHeaderProcessed) - { - // time to process the header - m_pBuffer->append(*data); - - int idx = m_pBuffer->find((const unsigned char *)"\r\n\r\n",4); - if(idx == -1) - { - // header not complete - if(m_pBuffer->size() > 4096) - { - resetInternalStatus(); - m_szLastError = __tr2qs("Header too long: exceeded 4096 bytes"); - emit terminated(false); - } - return; - } - KviCString szHeader((const char *)(m_pBuffer->data()),idx); - m_pBuffer->remove(idx + 4); - - if(!processHeader(szHeader))return; - m_bHeaderProcessed = true; - - if(m_eProcessingType == StoreToFile) - { - if(!openFile())return; - } - - m_uReceivedSize = m_pBuffer->size(); - - - // here the header is complete and the eventual remaining data is in m_pBuffer. data has been already used. - - } else { - // header already processed - m_uReceivedSize += data->size(); - - // here the header is complete and some data *might* be already in m_pBuffer. data is unused yet. - - // Optimisation: If the transfer is NOT chunked (so we don't have to parse it) - // and the requested processing type is either Blocks or StoreToFile - // then we just can avoid to copy the data to m_pBuffer. - // This is a good optimisation since for large files we can save allocating - // space for and moving megabytes of data... - - - if((!m_bChunkedTransferEncoding) && ((m_eProcessingType == Blocks) || (m_eProcessingType == StoreToFile))) - { - switch(m_eProcessingType) - { - case Blocks: - emit binaryData(*data); - break; - case StoreToFile: - m_pFile->write((const char *)(data->data()),data->size()); - break; - default: - break; - } - - if(((m_uTotalSize > 0) && (m_uReceivedSize > m_uTotalSize)) || ((m_uMaxContentLength > 0) && (m_uReceivedSize > m_uMaxContentLength))) - { - resetInternalStatus(); - m_szLastError=__tr2qs("Stream exceeded expected length"); - emit terminated(false); - } - - return; - } - - // need to append to m_pBuffer and process it - m_pBuffer->append(*data); - } - - // we're processing data in m_pBuffer here - if(m_bChunkedTransferEncoding) - { - // The transfer encoding is chunked: the buffer contains - // chunks of data with an initial header composed - // of a hexadecimal length, an optional bullshit and a single CRLF - // The transfer terminates when we read a last chunk of size 0 - // that may be followed by optional headers... - // This sux :) - while(m_pBuffer->size() > 0) // <-- note that we may exit from this loop also for other conditions (there is a goto below) - { - // we process chunks of parts of chunks at a time. - if(m_uRemainingChunkSize > 0) - { - // process the current chunk data - unsigned int uProcessSize = m_uRemainingChunkSize; - if(uProcessSize > (unsigned int)m_pBuffer->size())uProcessSize = m_pBuffer->size(); - m_uRemainingChunkSize -= uProcessSize; - - switch(m_eProcessingType) - { - case Blocks: - if((unsigned int)m_pBuffer->size() == uProcessSize) - { - // avoid copying to a new buffer - emit binaryData(*m_pBuffer); - } else { - // must copy - KviDataBuffer tmp(uProcessSize,m_pBuffer->data()); - emit binaryData(tmp); - m_pBuffer->remove(uProcessSize); - } - break; - case Lines: - if((unsigned int)m_pBuffer->size() == uProcessSize) - { - // avoid copying to a new buffer - emitLines(m_pBuffer); - } else { - // must copy - KviDataBuffer tmp(uProcessSize,m_pBuffer->data()); - emitLines(&tmp); - m_pBuffer->remove(uProcessSize); - } - break; - case StoreToFile: - m_pFile->write((const char *)(m_pBuffer->data()),uProcessSize); - m_pBuffer->remove(uProcessSize); - break; - default: - // nothing.. just make gcc happy - break; - } - // now either the buffer is empty or there is another chunk header: continue looping - } else { - // We're looking for the beginning of a chunk now. - // Note that we might be at the end of a previous chunk that has a CRLF terminator - // we need to skip it. - int crlf = m_pBuffer->find((const unsigned char *)"\r\n",2); - if(crlf != -1) - { - if(crlf == 0) - { - // This is a plain CRLF at the beginning of the buffer BEFORE a chunk header. - // It comes from the previous chunk terminator. Skip it. - m_pBuffer->remove(2); - } else { - // got a chunk header - KviCString szHeader((const char *)(m_pBuffer->data()),crlf); - szHeader.cutFromFirst(' '); - // now szHeader should contain a hexadecimal chunk length... (why the hell it is hex and not decimal ????) - QString szHexHeader = szHeader.ptr(); - bool bOk; - m_uRemainingChunkSize = szHexHeader.toLong(&bOk,16); - if(!bOk) - { - resetInternalStatus(); - m_szLastError = __tr2qs("Protocol error: invalid chunk size"); - emit terminated(false); - return; - } - m_pBuffer->remove(crlf+2); - if(m_uRemainingChunkSize == 0) - { - // this is the last chunk of data. It may be followed by optional headers - // but we actually don't need them (since we're surely not in HEAD mode) - m_bIgnoreRemainingData = true; - m_pBuffer->clear(); - goto check_stream_length; - } - } - // the rest is valid data of a non-zero chunk: continue looping - } else { - // chunk header not complete - if(m_pBuffer->size() > 4096) - { - resetInternalStatus(); - m_szLastError = __tr2qs("Chunk header too long: exceeded 4096 bytes"); - emit terminated(false); - return; - } - goto check_stream_length; - } - } - } - } else { - // the transfer encoding is not chunked: m_pBuffer contains only valid data - switch(m_eProcessingType) - { - case Blocks: - if(m_pBuffer->size() > 0)emit binaryData(*m_pBuffer); - m_pBuffer->clear(); - break; - case Lines: - if(m_pBuffer->size() > 0)emitLines(m_pBuffer); - break; - case StoreToFile: - m_pFile->write((const char *)(m_pBuffer->data()),m_pBuffer->size()); - m_pBuffer->clear(); - break; - default: - // nothing.. just make gcc happy - break; - } - } - -check_stream_length: - - if(((m_uTotalSize > 0) && (m_uReceivedSize > m_uTotalSize)) || ((m_uMaxContentLength > 0) && (m_uReceivedSize > m_uMaxContentLength))) - { - resetInternalStatus(); - m_szLastError=__tr2qs("Stream exceeded expected length"); - emit terminated(false); - } - return; -} - -KviHttpRequestThread::KviHttpRequestThread( - KviHttpRequest * r, - const QString &szHost, - const QString &szIp, - unsigned short uPort, - const QString & szPath, - unsigned int uContentOffset, - RequestMethod m, - const QString &szPostData, - bool bUseSSL - ) : KviSensitiveThread() -{ - m_pRequest = r; - m_szHost = szHost; - m_szIp = szIp; - m_szPath = szPath; - m_uPort = uPort > 0 ? uPort : 80; - m_uContentOffset = uContentOffset; - m_eRequestMethod = m; - m_szPostData = szPostData; - m_sock = KVI_INVALID_SOCKET; - m_bUseSSL = bUseSSL; - m_uConnectionTimeout = 60; -#ifdef COMPILE_SSL_SUPPORT - m_pSSL = 0; -#endif -} - -KviHttpRequestThread::~KviHttpRequestThread() -{ -} - -bool KviHttpRequestThread::processInternalEvents() -{ - while(KviThreadEvent *e = dequeueEvent()) - { - switch(e->id()) - { - case KVI_THREAD_EVENT_TERMINATE: - { - delete e; - return false; - } - break; - default: - qDebug("Unrecognized event in http thread"); - delete e; - return false; - break; - } - } - - return true; -} - -bool KviHttpRequestThread::failure(const char *error) -{ - if(error) - { - postEvent(m_pRequest,new KviThreadDataEvent(KVI_THREAD_EVENT_ERROR,new KviCString(error))); - } /*else { - postEvent(m_pRequest,new KviThreadDataEvent(KVI_THREAD_EVENT_ERROR,new KviCString(__tr2qs("Aborted")))); - }*/ - return false; -} - -bool KviHttpRequestThread::selectForWrite(int iTimeoutInSecs) -{ - - kvi_time_t startTime = kvi_unixTime(); - - for(;;) - { - if(!processInternalEvents()) - { - return failure(0); - } - - fd_set writeSet; - - FD_ZERO(&writeSet); - - FD_SET(m_sock,&writeSet); - - struct timeval tmv; - tmv.tv_sec = 0; - tmv.tv_usec = 1000; // we wait 1000 usecs for an event - - - int nRet = kvi_socket_select(m_sock + 1,0,&writeSet,0,&tmv); - - if(nRet > 0) - { - if(FD_ISSET(m_sock,&writeSet)) - { - // connected! - return true; - } - } else { - if(nRet < 0) - { - int err = kvi_socket_error(); -#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - if((err != EAGAIN) && (err != EINTR) && (err != WSAEWOULDBLOCK)) -#else - if((err != EAGAIN) && (err != EINTR)) -#endif - { - return failure(KviError::getUntranslatedDescription(KviError::translateSystemError(err))); - } - } - } - - - if((time(0) - startTime) > iTimeoutInSecs) - return failure(__tr_no_lookup("Operation timed out")); - - usleep(100000); // 1/10 sec - } - - return false; -} - -bool KviHttpRequestThread::sslFailure() -{ -#ifdef COMPILE_SSL_SUPPORT - KviCString buffer; - if(m_pSSL->getLastErrorString(buffer)) - { - failure(buffer.ptr()); - } else { - failure(__tr_no_lookup("Unexpected SSL error")); - } -#endif - return false; -} - -bool KviHttpRequestThread::connectToRemoteHost() -{ - m_sock = kvi_socket_create(KVI_SOCKET_PF_INET,KVI_SOCKET_TYPE_STREAM,0); //tcp - if(m_sock == KVI_INVALID_SOCKET) - return failure(__tr_no_lookup("Failed to create the socket")); - - if(!kvi_socket_setNonBlocking(m_sock)) - return failure(__tr_no_lookup("Failed to enter non blocking mode")); - - sockaddr_in saddr; - - if(!KviNetUtils::stringIpToBinaryIp(m_szIp,&(saddr.sin_addr))) - return failure(__tr_no_lookup("Invalid target address")); - - saddr.sin_port = htons(m_uPort); - saddr.sin_family = AF_INET; - - if(!kvi_socket_connect(m_sock,(struct sockaddr *)&saddr,sizeof(saddr))) - { - int err = kvi_socket_error(); - if(!kvi_socket_recoverableConnectError(err)) - { - return failure(KviError::getUntranslatedDescription(KviError::translateSystemError(err))); - } - } - - // now loop selecting for write - - if(!selectForWrite(m_uConnectionTimeout)) - return false; - - int sockError; - int iSize=sizeof(sockError); - if(!kvi_socket_getsockopt(m_sock,SOL_SOCKET,SO_ERROR,(void *)&sockError,&iSize))sockError = -1; - if(sockError != 0) - { - //failed - if(sockError > 0)sockError = KviError::translateSystemError(sockError); - else sockError = KviError_unknownError; - return failure(KviError::getUntranslatedDescription(sockError)); - } - -#ifdef COMPILE_SSL_SUPPORT - if(m_bUseSSL) - { - m_pSSL = new KviSSL(); - if(!m_pSSL->initContext(KviSSL::Client)) - return failure(__tr_no_lookup("Failed to initialize the SSL context")); - if(!m_pSSL->initSocket(m_sock)) - return failure(__tr_no_lookup("Failed to initialize the SSL connection")); - - for(;;) - { - switch(m_pSSL->connect()) - { - case KviSSL::Success: - // done: connected. - return true; - break; - case KviSSL::WantRead: - if(!selectForRead(m_uConnectionTimeout)) - return false; - break; - case KviSSL::WantWrite: - if(!selectForWrite(m_uConnectionTimeout)) - return false; - break; - case KviSSL::RemoteEndClosedConnection: - return failure(__tr_no_lookup("Remote end has closed the connection")); - break; - case KviSSL::SSLError: - return sslFailure(); - break; - case KviSSL::SyscallError: - { - // syscall problem - int err = kvi_socket_error(); - if(!kvi_socket_recoverableError(err)) - { - // Declare problems :) - return failure(__tr_no_lookup("Unrecoverable SSL error during handshake")); - } // else can recover ? (EAGAIN, EINTR ?) ... should select for read or for write - } - break; - default: - return sslFailure(); - break; - } - } - - // never here - return true; - } -#endif - - return true; -} - - -bool KviHttpRequestThread::sendBuffer(const char * buffer,int bufLen,int iTimeoutInSecs) -{ - const char * ptr = buffer; - int curLen = bufLen; - - time_t startTime = time(0); - - for(;;) - { - if(!processInternalEvents()) - return failure(); - - int wrtn; -#ifdef COMPILE_SSL_SUPPORT - if(m_pSSL) - { - wrtn = m_pSSL->write((char *)ptr,curLen); - } else { -#endif - wrtn = kvi_socket_send(m_sock,ptr,curLen); -#ifdef COMPILE_SSL_SUPPORT - } -#endif - - if(wrtn > 0) - { - curLen -= wrtn; - - if(curLen <= 0) - break; - - ptr += wrtn; - } else { - if(wrtn < 0) - { -#ifdef COMPILE_SSL_SUPPORT - if(m_pSSL) - { - // ops...might be an SSL error - switch(m_pSSL->getProtocolError(wrtn)) - { - case KviSSL::WantWrite: - if(!selectForWrite(m_uConnectionTimeout)) - return false; - break; - case KviSSL::WantRead: - if(!selectForRead(m_uConnectionTimeout)) - return false; - break; - case KviSSL::SyscallError: - if(wrtn == 0) - { - return failure(__tr_no_lookup("Remote end has closed the connection")); - } else { - int iSSLErr = m_pSSL->getLastError(true); - if(iSSLErr != 0) - { - return sslFailure(); - } else { - goto handle_system_error; - } - } - break; - case KviSSL::SSLError: - return sslFailure(); - break; - default: - return sslFailure(); - break; - } - } else { -#endif //COMPILE_SSL_SUPPORT - -handle_system_error: - int err = kvi_socket_error(); -#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - if((err != EAGAIN) && (err != EINTR) && (err != WSAEWOULDBLOCK)) -#else - if((err != EAGAIN) && (err != EINTR)) -#endif - { - return failure(KviError::getUntranslatedDescription(KviError::translateSystemError(err))); - } -#ifdef COMPILE_SSL_SUPPORT - } -#endif - } - } - - int diff = time(0) - startTime; - if(diff > iTimeoutInSecs) - return failure(__tr_no_lookup("Operation timed out")); - - usleep(10000); - } - - return true; -} - -int KviHttpRequestThread::selectForReadStep() -{ - // calls select on the main socket - // returns 1 if there is data available for reading - // returns 0 if there is no data available but there was no error - // returns -1 if there was a critical error (socket closed) - fd_set readSet; - - FD_ZERO(&readSet); - - FD_SET(m_sock,&readSet); - - struct timeval tmv; - tmv.tv_sec = 0; - tmv.tv_usec = 1000; // we wait 1000 usecs for an event - - - int nRet = kvi_socket_select(m_sock + 1,&readSet,0,0,&tmv); - - if(nRet > 0) - { - if(FD_ISSET(m_sock,&readSet)) - { - // ok - return 1; - } - } else { - if(nRet < 0) - { - int err = kvi_socket_error(); -#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - if((err != EAGAIN) && (err != EINTR) && (err != WSAEWOULDBLOCK)) -#else - if((err != EAGAIN) && (err != EINTR)) -#endif - { - failure(KviError::getUntranslatedDescription(KviError::translateSystemError(err))); - return -1; - } - } - } - - return 0; -} - -bool KviHttpRequestThread::selectForRead(int iTimeoutInSecs) -{ - // waits for some data to arrive on the socket - // up to iTimeoutInSecs seconds - // returns true if data is available on the socket - // or false if there was a select() error or no data - // was available in the specified amount of time - - time_t startTime = time(0); - - for(;;) - { - if(!processInternalEvents()) - { - return failure(); // ensure that the socket is closed - } - - int nRet = selectForReadStep(); - - if(nRet < 0)return false; - if(nRet > 0)return true; - - int diff = time(0) - startTime; - if(diff > iTimeoutInSecs) - return failure(__tr_no_lookup("Operation timed out (while selecting for read)")); - - usleep(100000); // 1/10 sec - } - - return false; -} - -bool KviHttpRequestThread::readDataStep() -{ - unsigned char buffer[2048]; - int readed; - - -#ifdef COMPILE_SSL_SUPPORT - if(m_pSSL) - { - readed = m_pSSL->read((char *)buffer,2048); - if(readed <= 0) - { - // ssl error....? - switch(m_pSSL->getProtocolError(readed)) - { - case KviSSL::ZeroReturn: - readed = 0; - break; - case KviSSL::WantRead: - return selectForRead(m_uConnectionTimeout); - break; - case KviSSL::WantWrite: - return selectForWrite(m_uConnectionTimeout); - break; - case KviSSL::SyscallError: - { - int iE = m_pSSL->getLastError(true); - if(iE != 0)return sslFailure(); - } - break; - case KviSSL::SSLError: - return sslFailure(); - break; - default: - return sslFailure(); - break; - } - } - } else { -#endif - readed = kvi_socket_read(m_sock,buffer,2048); -#ifdef COMPILE_SSL_SUPPORT - } -#endif - - if(readed > 0) - { - postEvent(m_pRequest,new KviThreadDataEvent(KVI_THREAD_EVENT_BINARYDATA,new KviDataBuffer(readed,buffer))); - } else { - if(readed < 0) - { - // Read error ? - int err = kvi_socket_error(); -#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - if((err != EAGAIN) && (err != EINTR) && (err != WSAEWOULDBLOCK)) -#else - if((err != EAGAIN) && (err != EINTR)) -#endif - { - // yes...read error - return failure(KviError::getUntranslatedDescription(KviError::translateSystemError(err))); - } - return selectForRead(m_uConnectionTimeout); // EINTR or EAGAIN...transient problem - } else { - // readed == 0 - // Connection closed by remote host - postEvent(m_pRequest,new KviThreadEvent(KVI_THREAD_EVENT_SUCCESS)); - return false; - } - } - return selectForRead(m_uConnectionTimeout); -} - -void KviHttpRequestThread::run() -{ - // setup: - // nothing needed - - // run: - runInternal(); - - // cleanup: -#ifdef COMPILE_SSL_SUPPORT - if(m_pSSL) - { - delete m_pSSL; - m_pSSL = 0; - } -#endif - - if(kvi_socket_isValid(m_sock)) - { - kvi_socket_close(m_sock); - m_sock = KVI_INVALID_SOCKET; - } -} - -void KviHttpRequestThread::runInternal() -{ -#ifndef COMPILE_SSL_SUPPORT - if(m_bUseSSL) - { - failure(__tr_no_lookup("This KVIrc executable has no SSL support")); - return; - } -#endif - - if(!connectToRemoteHost())return; - - postEvent(m_pRequest,new KviThreadEvent(KVI_HTTP_REQUEST_THREAD_EVENT_CONNECTED)); - - // FIXME: Other headers ? - - KviCString szMethod; - switch(m_eRequestMethod) - { - case Head: szMethod = "HEAD"; break; - case Post: szMethod = "POST"; break; - case Get: szMethod = "GET"; break; - } - - KviCString szRequest(KviCString::Format,"%s %s HTTP/1.1\r\n" \ - "Host: %s\r\n" \ - "Connection: Close\r\n" \ - "User-Agent: KVIrc-http-slave/1.0.0\r\n" \ - "Accept: */*\r\n", - szMethod.ptr(),KviQString::toUtf8(m_szPath).data(),KviQString::toUtf8(m_szHost).data()); - - if(m_uContentOffset > 0) - szRequest.append(KviCString::Format,"Range: bytes=%u-\r\n",m_uContentOffset); - - if(m_eRequestMethod == Post) - { - szRequest.append(KviCString::Format,"Content-Type: application/x-www-form-urlencoded\r\n" \ - "Content-Length: %u\r\n" \ - "Cache-control: no-cache\r\n" \ - "Pragma: no-cache\r\n",m_szPostData.length()); - } - - szRequest += "\r\n"; - - if(m_eRequestMethod == Post) - { - if(!m_szPostData.isEmpty()) - szRequest.append(m_szPostData); - szRequest += "\r\n"; - } - - //qDebug("SENDING REQUEST:\n%s",szRequest.ptr()); - - if(!sendBuffer(szRequest.ptr(),szRequest.len(),60))return; - - // now loop reading data - postEvent(m_pRequest,new KviThreadDataEvent(KVI_HTTP_REQUEST_THREAD_EVENT_REQUESTSENT,new QString(szRequest))); - - for(;;) - { - if(!readDataStep())return; - } -} diff --git a/src/kvilib/net/kvi_http.h b/src/kvilib/net/kvi_http.h deleted file mode 100644 index c53d32ce6..000000000 --- a/src/kvilib/net/kvi_http.h +++ /dev/null @@ -1,225 +0,0 @@ -#ifndef _KVI_HTTP_H_ -#define _KVI_HTTP_H_ -//============================================================================= -// -// File : kvi_http.h -// Creation date : Sat Aug 17 13:43:31 2002 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" -#include "KviHeapObject.h" -#include "KviCString.h" -#include "KviThread.h" -#include "kvi_sockettype.h" -#include "KviDataBuffer.h" -#include "kvi_inttypes.h" -#include "kvi_url.h" -#include "KviPointerHashTable.h" -#include "KviFile.h" - -#include -#include - -class KviDns; -class KviSSL; -class KviHttpRequestThread; - -// -// This class implements a HTTP protocol client. -// It's able to send GET, POST and HEAD requests, -// download stuff to a file or to a qt SLOT(). -// - -class KVILIB_API KviHttpRequest : public QObject, public KviHeapObject -{ - Q_OBJECT -public: - enum ProcessingType - { - HeadersOnly, // Download headers only (HEAD request) - WholeFile, // Emit the data as whole file (binaryData() is emitted) - Blocks, // Emit the data as blocks (binaryData() is emitted) - Lines, // Emit the data as ASCII text lines (the client must take care of decoding the data) - StoreToFile // Store the data to a file - }; - enum ExistingFileAction - { - Overwrite, // Overwrite existing file - RenameIncoming, // Automatically rename the incoming file - RenameExisting, // Automatically rename the existing file - Resume // Attempt to resume the file (get partial content) - }; -public: - KviHttpRequest(); - ~KviHttpRequest(); -protected: - // data - KviUrl m_url; - QString m_szFileName; - ProcessingType m_eProcessingType; - ExistingFileAction m_eExistingFileAction; - void * m_pPrivateData; - unsigned int m_uMaxContentLength; - unsigned int m_uContentOffset; - QString m_szPostData; - // status - QString m_szLastError; - unsigned int m_uTotalSize; - unsigned int m_uReceivedSize; - // internal status - QString m_szIp; - KviDns * m_pDns; - KviHttpRequestThread * m_pThread; - KviDataBuffer * m_pBuffer; - bool m_bHeaderProcessed; - bool m_bChunkedTransferEncoding; - bool m_bGzip; - unsigned int m_uRemainingChunkSize; - bool m_bIgnoreRemainingData; // used in chunked transfer after the last chunk has been seen - KviFile * m_pFile; - unsigned int m_uConnectionTimeout; // in seconds, 60 secs by default -protected: - bool startDnsLookup(); - virtual bool event(QEvent *e); - void processData(KviDataBuffer * data); - bool processHeader(KviCString &szHeader); - bool openFile(); - void emitLines(KviDataBuffer * pDataBuffer); - - void resetStatus(); - void resetData(); - void resetInternalStatus(); -protected slots: - void dnsLookupDone(KviDns *d); - void haveServerIp(); -public: - void setConnectionTimeout(unsigned int uConnectionTimeout) - { - m_uConnectionTimeout = uConnectionTimeout; - if(m_uConnectionTimeout < 5) - m_uConnectionTimeout = 5; // keep it sane - } - - const KviUrl & url(){ return m_url; }; - ProcessingType processingType(){ return m_eProcessingType; }; - ExistingFileAction existingFileAction(){ return m_eExistingFileAction; }; - const QString &fileName(){ return m_szFileName; }; - void * privateData(){ return m_pPrivateData; }; - unsigned int maxContentLength(){ return m_uMaxContentLength; }; - unsigned int contentOffset(){ return m_uContentOffset; }; - unsigned int totalSize(){ return m_uTotalSize; }; - unsigned int receivedSize(){ return m_uReceivedSize; }; - - void reset(); - - void setPostData(const QString &szPostData){ m_szPostData = szPostData; }; - void setUrl(const KviUrl &u){ m_url = u; }; - void setProcessingType(ProcessingType t){ m_eProcessingType = t; }; - void setExistingFileAction(ExistingFileAction a){ m_eExistingFileAction = a; }; - void setFileName(const QString &szFileName){ m_szFileName = szFileName; }; - void setPrivateData(void * ptr){ m_pPrivateData = ptr; }; - void setMaxContentLength(int uMaxContentLength){ m_uMaxContentLength = uMaxContentLength; }; //0 means unlimited - // this will work regardless of ExistingFileAction : even if the file doesn't exist - void setContentOffset(int uContentOffset){ m_uContentOffset = uContentOffset; }; - - bool start(); - - // this is a shortcut for reset()+setUrl()+setProcessingType()+setFileName()+start() - bool get(const KviUrl &u,ProcessingType p = WholeFile,const QString &szFileName = QString()); - - const QString & lastError(){ return m_szLastError; }; - - void abort(); -signals: - void resolvingHost(const QString &hostname); - void contactingHost(const QString &ipandport); - void connectionEstabilished(); - void receivedResponse(const QString &response); - - void terminated(bool bSuccess); - - - void status(const QString &message); - void data(const KviCString &data); - void binaryData(const KviDataBuffer &data); - void header(KviPointerHashTable * hdr); - void requestSent(const QStringList &request); -}; - - -class KviHttpRequestThread : public KviSensitiveThread -{ - friend class KviHttpRequest; -public: - enum RequestMethod { Post, Get, Head }; -protected: - KviHttpRequestThread(KviHttpRequest * r, - const QString &szHost, - const QString &szIp, - unsigned short uPort, - const QString &szPath, - unsigned int uContentOffset, - RequestMethod m, - const QString &szPostData = QString(), - bool bUseSSL = false - ); - -public: - ~KviHttpRequestThread(); -protected: - KviHttpRequest * m_pRequest; - - QString m_szHost; - QString m_szIp; - QString m_szPath; - unsigned int m_uContentOffset; - RequestMethod m_eRequestMethod; - QString m_szPostData; - - unsigned short m_uPort; - kvi_socket_t m_sock; - bool m_bUseSSL; - unsigned int m_uConnectionTimeout; -#ifdef COMPILE_SSL_SUPPORT - KviSSL * m_pSSL; -#endif -protected: - void setConnectionTimeout(unsigned int uTimeout) - { - m_uConnectionTimeout = uTimeout; - if(m_uConnectionTimeout < 5) - m_uConnectionTimeout = 5; // keep it sane - } - int selectForReadStep(); - bool selectForRead(int iTimeoutInSecs); - bool readDataStep(); - bool sendBuffer(const char *buffer,int bufLen,int iTimeoutInSecs); - bool failure(const char *error=0); - bool sslFailure(); - bool selectForWrite(int iTimeoutInSecs); - bool connectToRemoteHost(); - bool processInternalEvents(); - void runInternal(); - virtual void run(); -}; - - -#endif //_KVI_HTTP_H_ diff --git a/src/kvilib/net/kvi_netutils.cpp b/src/kvilib/net/kvi_netutils.cpp deleted file mode 100644 index 304ddb0b3..000000000 --- a/src/kvilib/net/kvi_netutils.cpp +++ /dev/null @@ -1,797 +0,0 @@ -//============================================================================= -// -// File : kvi_netutlis.cpp -// Creation date : Sun Jun 18 2000 18:37:27 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#define _KVI_NETUTILS_CPP_ - -#define NTDDI_VERSION NTDDI_WINXP - -#ifndef _WIN32_WINNT - #define _WIN32_WINNT _WIN32_WINNT_WINXP -#endif - -#include "kvi_netutils.h" -#include "kvi_memmove.h" - -#include - -#if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) - #include // struct timeval - #include - #include -#endif - -#ifdef COMPILE_ON_WINDOWS - #include -#endif - -#include -#include "KviQString.h" - -#ifdef COMPILE_GET_INTERFACE_ADDRESS - #include - #include -#endif //COMPILE_GET_INTERFACE_ADDRESS - -#ifndef HAVE_INET_ATON - - -// FIXME: #warning "Your system lacks the inet_aton function," -// FIXME: #warning "you're trying to compile this file without" -// FIXME: #warning "the kvi_sysconfig.h created by the cmake script," -// FIXME: #warning "Using own internal implementation of inet_aton." - -#include - -// Need own inet_aton implementation -// -// Check whether "cp" is a valid ascii representation -// of an Internet address and convert to a binary address. -// Returns 1 if the address is valid, 0 if not. -// This replaces inet_addr, the return value from which -// cannot distinguish between failure and a local broadcast address. -// -// Original code comes from the ircd source. -// - -bool kvi_stringIpToBinaryIp(const char *szIp,struct in_addr *address) -{ - register unsigned long val; - register int base, n; - register char c; - unsigned int parts[4]; - register unsigned int *pp = parts; - if(!szIp)return false; - c = *szIp; - for(;;){ - // Collect number up to ``.''. - // Values are specified as for C: - // 0x=hex, 0=octal, isdigit=decimal. - if(!isdigit(c))return false; - val = 0; - base = 10; - - if(c == '0'){ - c = *++szIp; - if((c == 'x')||(c == 'X'))base = 16, c = *++szIp; - else base = 8; - } - - for (;;) { - if(isascii(c) && isdigit(c)) { - val = (val * base) + (c - '0'); - c = *++szIp; - } else if (base == 16 && isascii(c) && isxdigit(c)) { - val = (val << 4) | (c + 10 - (islower(c) ? 'a' : 'A')); - c = *++szIp; - } else break; - } - - if(c == '.'){ - // Internet format: - // a.b.c.d - // a.b.c (with c treated as 16 bits) - // a.b (with b treated as 24 bits) - - if(pp >= (parts + 3)) return false; - *pp++ = val; - c = *++szIp; - } else break; - } - - // Check for trailing characters. - if ((c != '\0') && (!isascii(c) || !isspace(c)))return false; - - // Concact the address according to - // the number of parts specified. - n = pp - parts + 1; - - switch (n) { - case 0: return false; // initial nondigit - case 1: break; // a -- 32 bits - case 2: // a.b -- 8.24 bits - if(val > 0xffffff) return false; - val |= parts[0] << 24; - break; - case 3: // a.b.c -- 8.8.16 bits - if(val > 0xffff)return false; - val |= (parts[0] << 24) | (parts[1] << 16); - break; - case 4: // a.b.c.d -- 8.8.8.8 bits - if(val > 0xff)return false; - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - break; - } - - if(address)address->s_addr = htonl(val); - return true; - -} - -#else //!HAVE_INET_ATON - -bool kvi_stringIpToBinaryIp(const char *szIp,struct in_addr *address) -{ - if(!szIp)return false; - return (inet_aton(szIp,address) != 0); -} -#endif //!HAVE_INET_ATON - - - -#ifndef HAVE_INET_NTOA - -// FIXME: #warning "Your system lacks the inet_ntoa function," -// FIXME: #warning "you're trying to compile this file without" -// FIXME: #warning "the config.h created by the configure script," -// FIXME: #warning "Using own internal implementation of inet_ntoa." - -// -// Original code comes from the ircd source. -// - - -bool kvi_binaryIpToStringIp(struct in_addr in,QString &szBuffer) -{ - unsigned char *s = (unsigned char *)∈ - int a,b,c,d; - a = (int)*s++; - b = (int)*s++; - c = (int)*s++; - d = (int)*s; - - szBuffer.sprintf("%d.%d.%d.%d", a,b,c,d ); - return true; -} - -#else //HAVE_INET_NTOA - -bool kvi_binaryIpToStringIp(struct in_addr in,QString &szBuffer) -{ -// FIXME: #warning "This is NOT thread safe!" - - char * ptr = inet_ntoa(in); - if(!ptr)return false; - szBuffer = ptr; - return true; -} - -#endif //HAVE_INET_NTOA - -bool kvi_isValidStringIp(const char *szIp) -{ - struct in_addr address; - if(!szIp)return false; - if(!isdigit(*szIp))return false; - return kvi_stringIpToBinaryIp(szIp,&address); -} - -#ifdef COMPILE_IPV6_SUPPORT - -#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - -static unsigned int scan_ip6(const char *s,char ip[16]) -{ - unsigned int i; - unsigned int len=0; - unsigned long u; - - char suffix[16]; - unsigned int prefixlen=0; - unsigned int suffixlen=0; - - for (i=0; i<16; i++) ip[i]=0; - - for (;;) { - if (*s == ':') { - len++; - if (s[1] == ':') { /* Found "::", skip to part 2 */ - s+=2; - len++; - break; - } - s++; - } - - { - char *tmp; - u=strtoul(s,&tmp,16); - i=tmp-s; - } - - if (!i) return 0; - if (prefixlen==12 && s[i]=='.') { - /* the last 4 bytes may be written as IPv4 address */ - if (kvi_stringIpToBinaryIp(s,(struct in_addr*)(ip+12))) - return i+len; - else - return 0; - } - - ip[prefixlen++] = (u >> 8); - ip[prefixlen++] = (u & 255); - - s += i; len += i; - - if (prefixlen==16) return len; - } - - /* part 2, after "::" */ - - for (;;) { - if (*s == ':') { - if (suffixlen==0) break; - s++; - len++; - } else if (suffixlen!=0) break; - - { - char *tmp; - u=strtol(s,&tmp,16); - i=tmp-s; - } - - if (!i) { - if (*s) len--; - break; - } - - if (suffixlen+prefixlen<=12 && s[i]=='.') { - - if (kvi_stringIpToBinaryIp(s,(struct in_addr*)(suffix+suffixlen))) { - suffixlen+=4; - len+=(unsigned int)strlen(s); - break; - } else prefixlen=12-suffixlen; /* make end-of-loop test true */ - } - - suffix[suffixlen++] = (u >> 8); - suffix[suffixlen++] = (u & 255); - s += i; len += i; - if (prefixlen+suffixlen==16) break; - } - - for (i=0; i9?hexdigit+'a'-10:hexdigit+'0'; -} - -static int fmt_xlong(char* s,unsigned int i) -{ - char* bak=s; - *s=tohex((i>>12)&0xf); if (s!=bak || *s!='0') ++s; - *s=tohex((i>>8)&0xf); if (s!=bak || *s!='0') ++s; - *s=tohex((i>>4)&0xf); if (s!=bak || *s!='0') ++s; - *s=tohex(i&0xf); - return s-bak+1; -} - -static unsigned int i2a(char* dest,unsigned int x) -{ - register unsigned int tmp=x; - register unsigned int len=0; - - if (x>=100) { *dest++=tmp/100+'0'; tmp=tmp%100; ++len; } - if (x>=10) { *dest++=tmp/10+'0'; tmp=tmp%10; ++len; } - *dest++=tmp+'0'; - return len+1; -} - -char *inet_ntoa_r(struct in_addr in,char* buf) -{ - unsigned int len; - unsigned char *ip=(unsigned char*)∈ - - len=i2a(buf,ip[0]); buf[len]='.'; ++len; - len+=i2a(buf+ len,ip[1]); buf[len]='.'; ++len; - len+=i2a(buf+ len,ip[2]); buf[len]='.'; ++len; - len+=i2a(buf+ len,ip[3]); buf[len]=0; - return buf; -} - -unsigned int fmt_ip6(char *s,const char ip[16]) -{ - unsigned int len; - unsigned int i; - unsigned int temp; - unsigned int compressing; // 0 not compressing, 1 compressing now, 2 already compressed once - - len = 0; - compressing = 0; - - for(int j=0;j<16;j+=2) - { - if (j==12 && !memcmp(ip,V4mappedprefix,12)) - { - inet_ntoa_r(*(struct in_addr*)(ip+12),s); - temp=(unsigned int)strlen(s); - return len+temp; - } - - temp = ((unsigned long) (unsigned char) ip[j] << 8) + (unsigned long) (unsigned char) ip[j+1]; - - if(temp == 0) - { - if(compressing == 0) - { - compressing=1; - if (j==0) - { - *s++=':'; - ++len; - } - } - } else { - if(compressing == 1) - { - compressing=2; // don't do it again - *s++=':'; ++len; - } - - i = fmt_xlong(s,temp); - len += i; - s += i; - - if (j<14) - { - *s++ = ':'; - ++len; - } - } - } - - if(compressing == 1) - { - *s++=':'; - ++len; - } - - *s=0; - return len; -} - -const char* inet_ntop(int AF, const void *CP, char *BUF, size_t LEN) -{ - char buf[100]; - size_t len; - - if (AF==AF_INET) - { - inet_ntoa_r(*(struct in_addr*)CP,buf); - len=strlen(buf); - } else if (AF==AF_INET6) - - { - len=fmt_ip6(buf,(char *)CP); - } else return 0; - - if (len - -bool kvi_select(int fd,bool * bCanRead,bool * bCanWrite,int iUSecs) -{ - // FIXME: This stuff should DIE! - fd_set rs; - fd_set ws; - FD_ZERO(&rs); - FD_ZERO(&ws); - FD_SET(fd,&rs); - FD_SET(fd,&ws); - struct timeval tv; - - tv.tv_sec = 0; - tv.tv_usec = iUSecs; - - int ret = select(fd + 1,&rs,&ws,0,&tv); - if(ret < 1)return false; // EINTR or ENOSTUFFATALL - - *bCanRead = FD_ISSET(fd,&rs); - *bCanWrite = FD_ISSET(fd,&ws); - - return true; -} - -namespace KviNetUtils -{ - bool stringIpToBinaryIp(const QString &szStringIp,struct in_addr * address) - { -#ifndef HAVE_INET_ATON - QString szAddr = szStringIp.simplified(); - quint32 iAddr=0; - QStringList ipv4 = szAddr.split(".", QString::KeepEmptyParts, Qt::CaseInsensitive); - if (ipv4.count() == 4) { - int i = 0; - bool ok = TRUE; - while(ok && i < 4) { - uint byteValue = ipv4[i].toUInt(&ok); - if ( (byteValue > 255) && ok ) - ok = FALSE; - if (ok) - iAddr = (iAddr << 8) + byteValue; - ++i; - } - if (ok) - { - if(address)address->s_addr = htonl(iAddr); - return true; - } - } - return FALSE; -#else //HAVE_INET_ATON - if(szStringIp.isEmpty())return false; - return (inet_aton(KviQString::toUtf8(szStringIp).data(),address) != 0); -#endif //HAVE_INET_ATON - } - - - bool isValidStringIp(const QString &szIp) - { - struct in_addr address; - if(szIp.isEmpty())return false; - if(!szIp[0].isNumber())return false; - return stringIpToBinaryIp(szIp,&address); - } - - -#ifdef COMPILE_IPV6_SUPPORT - bool stringIpToBinaryIp_V6(const QString &szStringIp,struct in6_addr * address) - { - return (inet_pton(AF_INET6,KviQString::toUtf8(szStringIp).data(),(void *)address) == 1); - } - - bool isValidStringIPv6(const QString &szIp) - { - struct in6_addr address; - if(szIp.isEmpty())return false; - return stringIpToBinaryIp_V6(szIp,&address); - } - - bool binaryIpToStringIp_V6(struct in6_addr in,QString &szBuffer) - { - char buf[46]; - bool bRet = inet_ntop(AF_INET6,(void *)&in,buf,46); - szBuffer= buf; - return bRet; - } - -#endif //COMPILE_IPV6_SUPPORT - - bool binaryIpToStringIp(struct in_addr in,QString &szBuffer) - { - char * ptr = inet_ntoa(in); - if(!ptr)return false; - szBuffer = ptr; - return true; - } - - bool isRoutableIpString(const QString &szIpString) - { - struct in_addr a; - if(szIpString.isEmpty())return false; - stringIpToBinaryIp(szIpString,&a); - return isRoutableIp((const char *)&a); - } - - bool isRoutableIp(const char * ipaddr) - { - if(!ipaddr)return false; - const unsigned char * ip = (const unsigned char *)ipaddr; - if(ip[0] == 0)return false; // old-style broadcast - if(ip[0] == 10)return false; // Class A VPN - if(ip[0] == 127)return false; // loopback - if((ip[0] == 172) && (ip[1] >= 16) && (ip[1] <= 31))return false; // Class B VPN - if((ip[0] == 192) && (ip[1] == 168))return false; // Class C VPN - if((ip[0] == 169) && (ip[1] == 254))return false; // APIPA - if((ip[0] == 192) && (ip[1] == 0) && (ip[2] == 2))return false; // Class B VPN - if(ip[0] >= 224)return false; // class D multicast and class E reserved - - return true; - } - -#ifdef COMPILE_GET_INTERFACE_ADDRESS - union sockaddr_union { - struct sockaddr sa; - struct sockaddr_in sin; - }; - - bool getInterfaceAddress(const QString &szInterfaceName,QString &szBuffer) - { - union sockaddr_union *su; - struct ifreq ifr; - int len = szInterfaceName.length(); - if(len > (IFNAMSIZ - 1))return false; // invalid interface anyway - - kvi_memmove(ifr.ifr_name,KviQString::toUtf8(szInterfaceName).data(),len + 1); - - int fd = socket(AF_INET,SOCK_STREAM,0); - if(fd < 0)return false; - - if(ioctl(fd,SIOCGIFADDR,&ifr) == -1)return false; // supports only IPV4 ? - - close(fd); - - su = (union sockaddr_union *)&(ifr.ifr_addr); - - if (su->sa.sa_family != AF_INET) return false; - - return binaryIpToStringIp((struct in_addr)su->sin.sin_addr,szBuffer); - - // (this seems to work for AF_INET only anyway) -#else //!COMPILE_GET_INTERFACE_ADDRESS - bool getInterfaceAddress(const QString &,QString &) - { - return false; -#endif //!COMPILE_GET_INTERFACE_ADDRESS - } - - void formatNetworkBandwidthString(QString &szBuffer,unsigned int uBytesPerSec) - { - if(uBytesPerSec > (1024 * 1024)) - { - unsigned int uMB = uBytesPerSec / (1024 * 1024); - unsigned int uRem = ((uBytesPerSec % (1024 * 1024)) * 100) / (1024 * 1024); - - KviQString::sprintf(szBuffer,"%u.%u%u MiB/s",uMB,uRem / 10,uRem % 10); - - return; - } - - if(uBytesPerSec >= 1024) - { - unsigned int uKB = uBytesPerSec / 1024; - unsigned int uRem = ((uBytesPerSec % 1024) * 100) / 1024; - - KviQString::sprintf(szBuffer,"%u.%u%u KiB/s",uKB,uRem / 10,uRem % 10); - - return; - } - - KviQString::sprintf(szBuffer,"%u B/s",uBytesPerSec); - - } -} - -bool kvi_isRoutableIpString(const char * ipstring) -{ - struct in_addr a; - if(!ipstring)return false; - kvi_stringIpToBinaryIp(ipstring,&a); - return kvi_isRoutableIp((const char *)&a); -} - -bool kvi_isRoutableIp(const char * ipaddr) -{ - if(!ipaddr)return false; - const unsigned char * ip = (const unsigned char *)ipaddr; - - if(ip[0] == 0)return false; // old-style broadcast - if(ip[0] == 10)return false; // Class A VPN - if(ip[0] == 127)return false; // loopback - if((ip[0] == 172) && (ip[1] >= 16) && (ip[1] <= 31))return false; // Class B VPN - if((ip[0] == 192) && (ip[1] == 168))return false; // Class C VPN - if((ip[0] == 169) && (ip[1] == 254))return false; // APIPA - if((ip[0] == 192) && (ip[1] == 0) && (ip[2] == 2))return false; // Class B VPN - if(ip[0] >= 224)return false; // class D multicast and class E reserved - - return true; -} - -bool kvi_getLocalHostAddress(QString &buffer) -{ - // This will work only on windoze... - char buf[1024]; - if(gethostname(buf,1024) != 0)return false; - struct hostent * h = gethostbyname(buf); - if(!h)return false; - QString tmp; - int i=0; - while(h->h_addr_list[i]) - { - if(kvi_binaryIpToStringIp(*((struct in_addr *)(h->h_addr_list[i])),tmp)) - { - if(kvi_isRoutableIp(h->h_addr_list[i])) - { - buffer = tmp; - return true; - } - } - i++; - } - - buffer = tmp; - return true; -} - -KviSockaddr::KviSockaddr(const char * szIpAddress,kvi_u32_t uPort,bool bIPv6,bool bUdp) -{ - struct addrinfo hints; - kvi_memset((void *)&hints,0,sizeof(hints)); - hints.ai_flags = AI_NUMERICHOST; -#ifdef COMPILE_IPV6_SUPPORT - hints.ai_family = bIPv6 ? PF_INET6 : PF_INET; -#else - hints.ai_family = PF_INET; -#endif - - hints.ai_socktype = bUdp ? SOCK_DGRAM : SOCK_STREAM; - - hints.ai_protocol = 0; - m_pData = 0; - KviCString szPort(KviCString::Format,"%u",uPort); - getaddrinfo(szIpAddress,szPort.ptr(),&hints,&m_pData); -} - -KviSockaddr::KviSockaddr(kvi_u32_t uPort,bool bIPv6,bool bUdp) // passive sockaddr - -{ - struct addrinfo hints; - kvi_memset((void *)&hints,0,sizeof(hints)); - hints.ai_flags = AI_NUMERICHOST | AI_PASSIVE; -#ifdef COMPILE_IPV6_SUPPORT - hints.ai_family = bIPv6 ? PF_INET6 : PF_INET; -#else - hints.ai_family = PF_INET; -#endif - hints.ai_socktype = bUdp ? SOCK_DGRAM : SOCK_STREAM; - hints.ai_protocol = 0; - m_pData = 0; - KviCString szPort(KviCString::Format,"%u",uPort); - getaddrinfo(0,szPort.ptr(),&hints,&m_pData); -} - -KviSockaddr::~KviSockaddr() -{ - if(m_pData) - { - freeaddrinfo(m_pData); - m_pData = 0; - } -} - -struct sockaddr * KviSockaddr::socketAddress() -{ - if(!m_pData)return 0; - return (m_pData)->ai_addr; -} - -size_t KviSockaddr::addressLength() -{ - if(!m_pData)return 0; - return (m_pData)->ai_addrlen; -} - -int KviSockaddr::addressFamily() -{ - if(!m_pData)return 0; - return (m_pData)->ai_family; -} - -bool KviSockaddr::isIPv6() -{ - if(!m_pData)return false; -#ifdef COMPILE_IPV6_SUPPORT - return false; -#else - return (addressFamily() == AF_INET6); -#endif -} - -kvi_u32_t KviSockaddr::port() -{ - if(!m_pData)return 0; -#ifdef COMPILE_IPV6_SUPPORT - switch(m_pData->ai_family) - { - case AF_INET: - return ntohs(((struct sockaddr_in *)(m_pData->ai_addr))->sin_port); - break; - case AF_INET6: - return ntohs(((struct sockaddr_in6 *)(m_pData->ai_addr))->sin6_port); - break; - } - return 0; -#else - return ntohs(((struct sockaddr_in *)(m_pData->ai_addr))->sin_port); -#endif -} - -bool KviSockaddr::getStringAddress(QString &szBuffer) -{ - if(!m_pData)return 0; -#ifdef COMPILE_IPV6_SUPPORT - switch(((struct addrinfo *)m_pData)->ai_family) - { - case AF_INET: - return kvi_binaryIpToStringIp(((struct sockaddr_in *)(m_pData->ai_addr))->sin_addr,szBuffer); - break; - case AF_INET6: - return kvi_binaryIpToStringIp_V6(((struct sockaddr_in6 *)(m_pData->ai_addr))->sin6_addr,szBuffer); - break; - } - - return false; -#else - return kvi_binaryIpToStringIp(((struct sockaddr_in *)(m_pData->ai_addr))->sin_addr,szBuffer); -#endif -} diff --git a/src/kvilib/net/kvi_netutils.h b/src/kvilib/net/kvi_netutils.h deleted file mode 100644 index ac8c8d5ea..000000000 --- a/src/kvilib/net/kvi_netutils.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef _KVI_NETUTILS_H_ -#define _KVI_NETUTILS_H_ -//============================================================================= -// -// File : kvi_netutlis.h -// Creation date : Sun Jun 18 2000 18:37:27 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" -#include "kvi_inttypes.h" - -#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - #include - #ifdef COMPILE_IPV6_SUPPORT - #ifdef WIN2K - #include - #else - #include - //#include - #define in6_addr in_addr6 - #endif - #else - #ifdef WIN2K - #include - #else - #include - #endif - #endif -#else - #include - #include - #include //in_addr - #include //inet_ntoa inet_ntop and inet_pton depend on this one. -#endif - -#include "KviCString.h" - -class KVILIB_API KviSockaddr -{ -public: - KviSockaddr(const char * szIpAddress,kvi_u32_t uPort,bool bIPv6,bool bUdp = false); - KviSockaddr(kvi_u32_t uPort,bool bIPv6,bool bUdp = false); // passive - ~KviSockaddr(); -private: - struct addrinfo * m_pData; -public: - struct sockaddr * socketAddress(); - size_t addressLength(); - int addressFamily(); - bool isIPv6(); - bool getStringAddress(QString &szBuffer); - kvi_u32_t port(); - -}; - - -KVILIB_API extern bool kvi_select(int fd,bool * bCanRead,bool * bCanWrite,int iUSecs = 0); - -// Warning : NOT THREAD SAFE! -KVILIB_API extern bool kvi_getLocalHostAddress(QString &buffer); -KVILIB_API extern bool kvi_isRoutableIp(const char * ipaddr); -KVILIB_API extern bool kvi_isRoutableIpString(const char * ipstring); - -namespace KviNetUtils -{ - KVILIB_API bool stringIpToBinaryIp(const QString &szStringIp,struct in_addr * address); - KVILIB_API bool isValidStringIp(const QString &szStringIp); - KVILIB_API bool binaryIpToStringIp(struct in_addr in,QString &szBuffer); - KVILIB_API bool getInterfaceAddress(const QString &szInterfaceName,QString &szBuffer); -#ifdef COMPILE_IPV6_SUPPORT - KVILIB_API bool isValidStringIPv6(const QString &szStringIp); - KVILIB_API bool stringIpToBinaryIp_V6(const QString &szStringIp,struct in6_addr * address); - KVILIB_API bool binaryIpToStringIp_V6(struct in6_addr in,QString &szBuffer); -#endif - KVILIB_API bool isRoutableIp(const char * ipaddr); - KVILIB_API bool isRoutableIpString(const QString &szIpString); - KVILIB_API void formatNetworkBandwidthString(QString &szBuffer,unsigned int uBytesPerSec); -} - - -#endif //!_KVI_NETUTILS_H_ diff --git a/src/kvilib/net/kvi_sasl.cpp b/src/kvilib/net/kvi_sasl.cpp deleted file mode 100644 index 3a56749a7..000000000 --- a/src/kvilib/net/kvi_sasl.cpp +++ /dev/null @@ -1,198 +0,0 @@ -//============================================================================= -// -// File : kvi_sasl.cpp -// Creation date : Mon Feb 14 2010 19:36:12 CEST by Fabio Bas -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2010 Fabio Bas (ctrlaltca at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - - - -#include "kvi_sasl.h" - -#include "KviMemory.h" - -#ifdef COMPILE_SSL_SUPPORT - -#include -#include -#include -#include -#include - -#endif - - -namespace KviSASL -{ - - bool plainMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass) - { - if(szIn=="+") - { - int answerLen = 3 + (2 * baNick.size()) + baPass.size(); - char * answer = (char *) KviMemory::allocate(answerLen); - char * answer2 = answer; - - memcpy(answer, baNick.data(), baNick.size()); - answer+=baNick.size(); - memset(answer, 0, 1); - answer++; - - memcpy(answer, baNick.data(), baNick.size()); - answer+=baNick.size(); - memset(answer, 0, 1); - answer++; - - memcpy(answer, baPass.data(), baPass.size()); - answer+=baPass.size(); - memset(answer, 0, 1); - answer++; - - szOut.bufferToBase64(answer2,answerLen); - KviMemory::free(answer2); - - return true; - } - return false; - } - -#ifdef COMPILE_SSL_SUPPORT - bool dh_blowfishMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass) - { - /* - * The format of the auth token is quite complex; the server sends us 3 strings: - * p - a prime number - * g - a generator number, tipically 2 or 5 are used. - * y - the server-generated public key - * These 3 strings are null-terminated and codified as pascal strings (they are prefixed - * with a 16-bit lenght identifiedr in "network" big-endian order) - * Then, the 3 strings are concatenated and base-64 encoded. - */ - - BF_KEY key; - quint16 size, pKlen; - int secretLen; - unsigned char *secret = NULL, *pubKey = NULL; - char * tmpBuf; - DH * dh = DH_new(); - int len = szIn.base64ToBuffer(&tmpBuf,false); - - if(len < 7) return false; - - // extract p - size = ntohs(*(unsigned int*)tmpBuf); - tmpBuf+=2; - len-=2; - if(size > len) return false; - - if(!(dh->p = BN_bin2bn((unsigned char*) tmpBuf, size, NULL))) - return false; - - tmpBuf+=size; - len-=size; - - // extract g - size = ntohs(*(unsigned int*)tmpBuf); - tmpBuf+=2; - len-=2; - if(size > len) return false; - - if(!(dh->g = BN_bin2bn((unsigned char*) tmpBuf, size, NULL))) - return false; - - tmpBuf+=size; - len-=size; - - // extract y - size = ntohs(*(unsigned int*)tmpBuf); - tmpBuf+=2; - len-=2; - if(size > len) return false; - - // create our keys and extract shared secret - // note: any memory checking tool (as valgrind) will complain on this call. blame openssl - if(!DH_generate_key(dh)) - return false; - - secret=(unsigned char *) KviMemory::allocate(DH_size(dh)); - // note: any memory checking tool (as valgrind) will complain on this call. blame openssl - if(-1 == (secretLen = DH_compute_key(secret, BN_bin2bn((unsigned char*) tmpBuf, size, NULL), dh))) - return false; - - pKlen=BN_num_bytes(dh->pub_key); - pubKey = (unsigned char *) KviMemory::allocate(pKlen); - BN_bn2bin(dh->pub_key, pubKey); - - //create crypto buffers - int passLen = baPass.size() + ((8 -( baPass.size() % 8)) % 8); - int passC = 0; - unsigned char *passIn = (unsigned char *) KviMemory::allocate(passLen); - unsigned char *passOut = (unsigned char *) KviMemory::allocate(passLen); - - memset(passIn, 0, passLen); - memset(passOut, 0, passLen); - memcpy(passIn, baPass.data(), baPass.size()); - - // crypt our password - BF_set_key(&key, secretLen, secret); - - for (passC=0; passC < passLen; passC += 8) - BF_ecb_encrypt(passIn + passC, passOut + passC, &key, BF_ENCRYPT); - - /* - * Build up the answer - * The format of the auth answer is quite complex, and formed by the byte concatenation of: - * 1) a 16 bit integer containing the byte length of our public key - * 2) our public key - * 3) our username (nickname), null-terminated - * 4) our password, crypted using blowfish in ecb mode and the dh secret as the blowfish key - * Then, the answer is to be base64 encoded. - */ - - int answerLen = 2 + pKlen + baNick.size() + 1 + passLen; - char * answer = (char *) malloc(answerLen); - char * answer2 = answer; - *((unsigned int *)answer) = htons(pKlen); - answer+=2; - memcpy(answer, pubKey, pKlen); - answer+=pKlen; - memcpy(answer, baNick.data(), baNick.size()); - answer+=baNick.size(); - memset(answer, 0, 1); - answer++; - memcpy(answer, passOut, passLen); - szOut.bufferToBase64(answer2,answerLen); - - //clean up - KviMemory::free(secret); - KviMemory::free(pubKey); - KviMemory::free(passIn); - KviMemory::free(passOut); - - return true; - } -#else - bool dh_blowfishMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass) - { - return false; - } -#endif - -}; diff --git a/src/kvilib/net/kvi_sasl.h b/src/kvilib/net/kvi_sasl.h deleted file mode 100644 index 12db86dc3..000000000 --- a/src/kvilib/net/kvi_sasl.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef _KVI_SASL_H_ -#define _KVI_SASL_H_ -//============================================================================= -// -// File : kvi_sasl.h -// Creation date : Mon Feb 14 2010 19:36:12 CEST by Fabio Bas -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2010 Fabio Bas (ctrlaltca at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" -#include "KviCString.h" - -/** -* \namespace KviSASL -* \brief This namespace implement some SASL authentication methods. -* -* Currently implementhed methods are PLAIN and DH-BLOWFISH -*/ - -namespace KviSASL -{ - /** - * \brief Create the auth message for PLAIN authentication - * \param szIn The server-provided token - * \param szOut A KviCString that will be filled with the authentication message - * \param baNick The username - * \param baPass The password - * \return bool - */ - extern KVILIB_API bool plainMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass); - - /** - * \brief Create the auth message for DH-BLOWFISH authentication - * \param szIn The server-provided token - * \param szOut A KviCString that will be filled with the authentication message - * \param baNick The username - * \param baPass The password - * \return bool - */ - extern KVILIB_API bool dh_blowfishMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass); - -}; - -#endif //_KVI_SASL_H_ diff --git a/src/kvilib/net/kvi_ssl.cpp b/src/kvilib/net/kvi_ssl.cpp deleted file mode 100644 index b807d12b9..000000000 --- a/src/kvilib/net/kvi_ssl.cpp +++ /dev/null @@ -1,866 +0,0 @@ -//============================================================================= -// -// File : kvi_ssl.cpp -// Creation date : Mon May 27 2002 21:36:12 CEST by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - - - -#include "kvi_ssl.h" -#include "KviLocale.h" - -#ifdef COMPILE_SSL_SUPPORT - -#include "KviThread.h" -#include "kvi_memmove.h" -#include "KviMemory.h" - -#include -#include -#include - -#include - -#if !(defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)) - #include -#endif - -static bool g_bSSLInitialized = false; -static KviMutex * g_pSSLMutex = 0; - - -static inline void my_ssl_lock() -{ - g_pSSLMutex->lock(); -} - -static inline void my_ssl_unlock() -{ - g_pSSLMutex->unlock(); -} - - -// THIS PART OF OpenSSL SUCKS - -static DH * dh_512 = 0; -static DH * dh_1024 = 0; -static DH * dh_2048 = 0; -static DH * dh_4096 = 0; - -static unsigned char dh512_p[]={ - 0x90,0x86,0xDD,0x06,0xE8,0x0F,0x10,0x86,0xF0,0x91,0xC5,0x55, - 0x4D,0x6B,0xAF,0x69,0x4F,0x01,0xED,0xF9,0x57,0x8F,0x3B,0xB8, - 0x9C,0x87,0xAE,0x85,0xC1,0xBF,0x57,0xA5,0xD5,0xBA,0x81,0x24, - 0xE7,0x99,0xE3,0xF6,0xCD,0xB4,0x41,0xB7,0x7F,0x6E,0x7B,0xB1, - 0xD2,0xF3,0xE9,0x0F,0xB9,0x0E,0x4D,0xEB,0x9D,0xD4,0xA9,0xE5, - 0x03,0x67,0xA7,0x27 -}; -static unsigned char dh512_g[]={ 0x05 }; - -static unsigned char dh1024_p[]={ - 0xA5,0x4C,0xB9,0xB9,0xC4,0x35,0x88,0x68,0x9B,0x79,0x48,0x6C, - 0x21,0xA7,0x8E,0xE2,0x9C,0xAF,0x2F,0x04,0xBF,0x45,0xBC,0xF5, - 0xAB,0x35,0x86,0xC8,0xBB,0x9B,0x75,0x18,0x7C,0x9B,0xAB,0xE8, - 0x52,0x7F,0x57,0x3E,0xD8,0x65,0x7D,0x2B,0xE1,0x6D,0x3D,0xA5, - 0x32,0xE8,0xA0,0x2B,0x7A,0x58,0x6B,0x47,0x16,0x4E,0xB1,0xFC, - 0x09,0xB7,0x7C,0xC6,0xE9,0x6E,0xC7,0xC7,0xA1,0x42,0x0F,0x4B, - 0x43,0xFB,0x58,0xBA,0xC7,0x66,0xD6,0xCA,0x6B,0xC7,0x45,0x7C, - 0x99,0xE4,0x46,0x02,0x93,0x3F,0x28,0xD2,0xCE,0x0C,0x8A,0xDD, - 0x6A,0x22,0x2E,0xA9,0x9A,0xCA,0x16,0x48,0x4E,0x67,0x4C,0xE9, - 0xC8,0x54,0xCD,0x18,0xC9,0xF3,0x30,0x3A,0x74,0xAB,0xF9,0xAF, - 0xE4,0xA4,0x0D,0x56,0x62,0x28,0x07,0xBF -}; -static unsigned char dh1024_g[]={ 0x05 }; - -static unsigned char dh2048_p[]={ - 0xBF,0x67,0x7B,0x79,0xA5,0x22,0xD3,0xB5,0x0C,0x13,0xE6,0x92, - 0x54,0xFD,0x64,0xBF,0x57,0x25,0xBD,0x02,0x7C,0xFD,0x72,0x97, - 0x82,0xA4,0xA6,0x0A,0xB9,0xE6,0x4B,0xFA,0xBD,0xFA,0x71,0x8A, - 0x2E,0x36,0xF9,0x03,0x58,0x1B,0xB6,0x3A,0xFD,0x15,0xCC,0x87, - 0x5D,0x04,0xF7,0x45,0xE0,0xE2,0x34,0x7F,0x54,0x5F,0x5D,0x14, - 0xD3,0xCA,0x3E,0xFD,0x2A,0x92,0x10,0x89,0xA0,0xB0,0xB4,0xE5, - 0x80,0x05,0x13,0xBE,0xA3,0xD0,0x42,0x4B,0x98,0x44,0x54,0xB3, - 0xE0,0x23,0x26,0xF5,0x6B,0x0E,0x4D,0x2A,0x81,0xB2,0x8A,0x06, - 0xC8,0x00,0x9E,0xAB,0x1B,0x77,0xDC,0x87,0x9C,0x6C,0xD5,0xEE, - 0xB4,0xB4,0xDD,0xDA,0x3F,0x40,0xA3,0xFA,0xC1,0x1E,0xC0,0xA2, - 0x9E,0xB8,0xAC,0x31,0xE8,0x12,0x93,0x9C,0x71,0xF6,0xE7,0xF0, - 0x65,0x7F,0xA5,0x20,0xF7,0x49,0x3D,0xD6,0xF9,0xD3,0xF0,0x3F, - 0xB3,0xF0,0xD0,0x23,0x22,0x82,0xA5,0xDD,0xFB,0xD9,0x9C,0x7D, - 0xE7,0xA0,0x78,0xE8,0xF9,0x02,0x0C,0x2F,0x1D,0x52,0xC7,0x61, - 0xED,0xA0,0xC9,0x06,0x14,0xDF,0xE7,0xB1,0x1E,0x50,0x98,0x4F, - 0x10,0xB9,0x87,0x4C,0x1C,0x9C,0xB3,0xD2,0x98,0x23,0x7C,0x47, - 0xD2,0x3C,0xC5,0x29,0x65,0xC5,0x67,0x4E,0xC0,0x76,0x0F,0x43, - 0x27,0x28,0x89,0x69,0x30,0x7D,0x04,0xFD,0xF7,0x89,0xE5,0xD6, - 0xE6,0x97,0x7D,0xBB,0x54,0x5F,0xB7,0x94,0x1D,0xBC,0x82,0xAB, - 0x9A,0xF5,0x0A,0x0C,0x89,0x68,0xE7,0x0A,0x8C,0x2D,0x0D,0x82, - 0x44,0xA7,0xB8,0xF9,0x0B,0x8E,0xCB,0xA4,0x6A,0xA7,0xEC,0x5F, - 0x0A,0xF8,0x5F,0xE7 -}; -static unsigned char dh2048_g[]={ 0x05 }; - -static unsigned char dh4096_p[]={ - 0xFA,0x14,0x72,0x52,0xC1,0x4D,0xE1,0x5A,0x49,0xD4,0xEF,0x09, - 0x2D,0xC0,0xA8,0xFD,0x55,0xAB,0xD7,0xD9,0x37,0x04,0x28,0x09, - 0xE2,0xE9,0x3E,0x77,0xE2,0xA1,0x7A,0x18,0xDD,0x46,0xA3,0x43, - 0x37,0x23,0x90,0x97,0xF3,0x0E,0xC9,0x03,0x50,0x7D,0x65,0xCF, - 0x78,0x62,0xA6,0x3A,0x62,0x22,0x83,0xA1,0x2F,0xFE,0x79,0xBA, - 0x35,0xFF,0x59,0xD8,0x1D,0x61,0xDD,0x1E,0x21,0x13,0x17,0xFE, - 0xCD,0x38,0x87,0x9E,0xF5,0x4F,0x79,0x10,0x61,0x8D,0xD4,0x22, - 0xF3,0x5A,0xED,0x5D,0xEA,0x21,0xE9,0x33,0x6B,0x48,0x12,0x0A, - 0x20,0x77,0xD4,0x25,0x60,0x61,0xDE,0xF6,0xB4,0x4F,0x1C,0x63, - 0x40,0x8B,0x3A,0x21,0x93,0x8B,0x79,0x53,0x51,0x2C,0xCA,0xB3, - 0x7B,0x29,0x56,0xA8,0xC7,0xF8,0xF4,0x7B,0x08,0x5E,0xA6,0xDC, - 0xA2,0x45,0x12,0x56,0xDD,0x41,0x92,0xF2,0xDD,0x5B,0x8F,0x23, - 0xF0,0xF3,0xEF,0xE4,0x3B,0x0A,0x44,0xDD,0xED,0x96,0x84,0xF1, - 0xA8,0x32,0x46,0xA3,0xDB,0x4A,0xBE,0x3D,0x45,0xBA,0x4E,0xF8, - 0x03,0xE5,0xDD,0x6B,0x59,0x0D,0x84,0x1E,0xCA,0x16,0x5A,0x8C, - 0xC8,0xDF,0x7C,0x54,0x44,0xC4,0x27,0xA7,0x3B,0x2A,0x97,0xCE, - 0xA3,0x7D,0x26,0x9C,0xAD,0xF4,0xC2,0xAC,0x37,0x4B,0xC3,0xAD, - 0x68,0x84,0x7F,0x99,0xA6,0x17,0xEF,0x6B,0x46,0x3A,0x7A,0x36, - 0x7A,0x11,0x43,0x92,0xAD,0xE9,0x9C,0xFB,0x44,0x6C,0x3D,0x82, - 0x49,0xCC,0x5C,0x6A,0x52,0x42,0xF8,0x42,0xFB,0x44,0xF9,0x39, - 0x73,0xFB,0x60,0x79,0x3B,0xC2,0x9E,0x0B,0xDC,0xD4,0xA6,0x67, - 0xF7,0x66,0x3F,0xFC,0x42,0x3B,0x1B,0xDB,0x4F,0x66,0xDC,0xA5, - 0x8F,0x66,0xF9,0xEA,0xC1,0xED,0x31,0xFB,0x48,0xA1,0x82,0x7D, - 0xF8,0xE0,0xCC,0xB1,0xC7,0x03,0xE4,0xF8,0xB3,0xFE,0xB7,0xA3, - 0x13,0x73,0xA6,0x7B,0xC1,0x0E,0x39,0xC7,0x94,0x48,0x26,0x00, - 0x85,0x79,0xFC,0x6F,0x7A,0xAF,0xC5,0x52,0x35,0x75,0xD7,0x75, - 0xA4,0x40,0xFA,0x14,0x74,0x61,0x16,0xF2,0xEB,0x67,0x11,0x6F, - 0x04,0x43,0x3D,0x11,0x14,0x4C,0xA7,0x94,0x2A,0x39,0xA1,0xC9, - 0x90,0xCF,0x83,0xC6,0xFF,0x02,0x8F,0xA3,0x2A,0xAC,0x26,0xDF, - 0x0B,0x8B,0xBE,0x64,0x4A,0xF1,0xA1,0xDC,0xEE,0xBA,0xC8,0x03, - 0x82,0xF6,0x62,0x2C,0x5D,0xB6,0xBB,0x13,0x19,0x6E,0x86,0xC5, - 0x5B,0x2B,0x5E,0x3A,0xF3,0xB3,0x28,0x6B,0x70,0x71,0x3A,0x8E, - 0xFF,0x5C,0x15,0xE6,0x02,0xA4,0xCE,0xED,0x59,0x56,0xCC,0x15, - 0x51,0x07,0x79,0x1A,0x0F,0x25,0x26,0x27,0x30,0xA9,0x15,0xB2, - 0xC8,0xD4,0x5C,0xCC,0x30,0xE8,0x1B,0xD8,0xD5,0x0F,0x19,0xA8, - 0x80,0xA4,0xC7,0x01,0xAA,0x8B,0xBA,0x53,0xBB,0x47,0xC2,0x1F, - 0x6B,0x54,0xB0,0x17,0x60,0xED,0x79,0x21,0x95,0xB6,0x05,0x84, - 0x37,0xC8,0x03,0xA4,0xDD,0xD1,0x06,0x69,0x8F,0x4C,0x39,0xE0, - 0xC8,0x5D,0x83,0x1D,0xBE,0x6A,0x9A,0x99,0xF3,0x9F,0x0B,0x45, - 0x29,0xD4,0xCB,0x29,0x66,0xEE,0x1E,0x7E,0x3D,0xD7,0x13,0x4E, - 0xDB,0x90,0x90,0x58,0xCB,0x5E,0x9B,0xCD,0x2E,0x2B,0x0F,0xA9, - 0x4E,0x78,0xAC,0x05,0x11,0x7F,0xE3,0x9E,0x27,0xD4,0x99,0xE1, - 0xB9,0xBD,0x78,0xE1,0x84,0x41,0xA0,0xDF -}; -static unsigned char dh4096_g[]={ 0x02 }; - -static DH * my_get_dh(int keylength) -{ - DH * dh = 0; - unsigned char * p = 0; - unsigned char * g = 0; - int sp = 0; - int sg = 0; - switch(keylength) - { - case 512: - dh = dh_512; - p = dh512_p; - g = dh512_g; - sp = sizeof(dh512_p); - sg = sizeof(dh512_g); - break; - case 1024: - dh = dh_1024; - p = dh1024_p; - g = dh1024_g; - sp = sizeof(dh1024_p); - sg = sizeof(dh1024_g); - break; - case 2048: - dh = dh_2048; - p = dh2048_p; - g = dh2048_g; - sp = sizeof(dh2048_p); - sg = sizeof(dh2048_g); - break; - case 4096: - dh = dh_4096; - p = dh4096_p; - g = dh4096_g; - sp = sizeof(dh4096_p); - sg = sizeof(dh4096_g); - break; - default: - // What the hell do you want from me ? - qDebug("OpenSSL is asking for a DH param with keylen %d: no way :D",keylength); - break; - - } - - if(dh)return dh; - dh = DH_new(); - if(!dh)return 0; - dh->p=BN_bin2bn(p,sp,0); - dh->g=BN_bin2bn(g,sg,0); - if((dh->p == 0) || (dh->g == 0)) - { - DH_free(dh); - return 0; - } - return dh; -} - -DH * my_ugly_dh_callback(SSL *, int, int keylength) -{ - my_ssl_lock(); - DH *dh = my_get_dh(keylength); - my_ssl_unlock(); - return dh; -} - -void KviSSL::globalInit() -{ - if(g_pSSLMutex)return; - g_pSSLMutex = new KviMutex(); -} - -void KviSSL::globalDestroy() -{ - if(!g_pSSLMutex)return; - if(dh_512)DH_free(dh_512); - if(dh_1024)DH_free(dh_1024); - if(dh_2048)DH_free(dh_2048); - if(dh_4096)DH_free(dh_4096); - globalSSLDestroy(); - delete g_pSSLMutex; - g_pSSLMutex = 0; -} - -void KviSSL::globalSSLInit() -{ - my_ssl_lock(); - if(!g_bSSLInitialized) - { - // FIXME: this should be done only if SSL is really needed - SSL_library_init(); - SSL_load_error_strings(); - //needed to support SHA2 in < OpenSSL 0.9.8o and 1.0.0a - OpenSSL_add_all_algorithms(); - g_bSSLInitialized = true; - } - my_ssl_unlock(); -} - -void KviSSL::globalSSLDestroy() -{ - my_ssl_lock(); - if(g_bSSLInitialized) - { - EVP_cleanup(); - g_bSSLInitialized = false; - } - my_ssl_unlock(); -} - -KviSSL::KviSSL() -{ - globalSSLInit(); - m_pSSL = 0; - m_pSSLCtx = 0; -} - -KviSSL::~KviSSL() -{ - shutdown(); -} - -#ifdef COMPILE_ON_WINDOWS - - // On windows we need to override new and delete operators - // to ensure that always the right new/delete pair is called for an object instance - // This bug is present in all the classes exported by a module that - // can be instantiated/destroyed from external modules. - // (this is a well known bug described in Q122675 of MSDN) - - void * KviSSL::operator new(size_t tSize) - { - return KviMemory::allocate(tSize); - } - - void KviSSL::operator delete(void * p) - { - KviMemory::free(p); - } - -#endif - -void KviSSL::shutdown() -{ - if(m_pSSL) - { - #if !(defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)) - //avoid to die on a SIGPIPE if the connection has close (SSL_shutdown can call send()) - //see bug #440 - signal( SIGPIPE, SIG_IGN ); - // At least attempt to shutdown the connection gracefully - SSL_shutdown(m_pSSL); - //restore normal SIGPIPE behaviour. - signal( SIGPIPE, SIG_DFL ); - #else - // At least attempt to shutdown the connection gracefully - SSL_shutdown(m_pSSL); - #endif - SSL_free(m_pSSL); - m_pSSL = 0; - } - if(m_pSSLCtx) - { - SSL_CTX_free(m_pSSLCtx); - m_pSSLCtx = 0; - } -} - -/** - * Used only during passive (server) mode - * Check the client certificate, always valid, even if it not exists - */ -int verify_clientCallback(int, X509_STORE_CTX *) -{ - //int preverify_ok, X509_STORE_CTX *x509_ctx - // From man page: If verify_callback returns 1, the verification process is continued. If verify_callback always returns 1, - // the TLS/SSL handshake will not be terminated with respect to verification failures and the connection will be established. - return 1; -} - -bool KviSSL::initContext(Method m) -{ - if(m_pSSL)return false; - m_pSSLCtx = SSL_CTX_new(m == Client ? SSLv23_client_method() : SSLv23_server_method()); - if(!m_pSSLCtx)return false; - - if (m == Server) - { - // we have to request the peer certificate, else only the client can see the peer identity, not the server - SSL_CTX_set_verify(m_pSSLCtx, SSL_VERIFY_PEER, verify_clientCallback); - } - - // we want all ciphers to be available here, except insecure ones, orderer by strength; - // ADH are moved to the end since they are less secure, but they don't need a certificate - // (so we can use secure dcc without a cert) - // NOTE: see bug ticket #155 - SSL_CTX_set_cipher_list(m_pSSLCtx,"ALL:!eNULL:!EXP:!SSLv2:+ADH@STRENGTH"); - SSL_CTX_set_tmp_dh_callback(m_pSSLCtx,my_ugly_dh_callback); - return true; -} - -bool KviSSL::initSocket(kvi_socket_t fd) -{ - if(!m_pSSLCtx)return false; - m_pSSL = SSL_new(m_pSSLCtx); - if(!m_pSSL)return false; - if(!SSL_set_fd(m_pSSL,fd))return false; - return true; - -} - -static int cb(char *buf, int size, int, void *u) -{ - KviCString * p = (KviCString *)u; - int len = p->len(); - if(len >= size)return 0; - kvi_memmove(buf,p->ptr(),len + 1); -// qDebug("PASS REQYESTED: %s",p->ptr()); - return len; -} - -KviSSL::Result KviSSL::useCertificateFile(const char * cert,const char * pass) -{ - if(!m_pSSLCtx)return NotInitialized; - m_szPass = pass; - if(m_szPass.len() < 4)m_szPass.append("xxxx"); - X509 * x509 = 0; - - FILE * f = fopen(cert,"r"); - if(!f) - return FileIoError; - -// qDebug("READING CERTIFICATE %s",cert); - if(PEM_read_X509(f,&x509,cb,&m_szPass)) - { - if(!SSL_CTX_use_certificate(m_pSSLCtx,x509)) - { - X509_free(x509); - fclose(f); - return SSLError; - } - X509_free(x509); - } - - fclose(f); - return Success; -} - - -KviSSL::Result KviSSL::usePrivateKeyFile(const char * key,const char * pass) -{ - if(!m_pSSLCtx)return NotInitialized; - m_szPass = pass; - if(m_szPass.len() < 4)m_szPass.append("xxxx"); - - EVP_PKEY * k = 0; - - FILE * f = fopen(key,"r"); - if(!f) - return FileIoError; - -// qDebug("READING KEY %s",key); - if(PEM_read_PrivateKey(f,&k,cb,&m_szPass)) - { - if(!SSL_CTX_use_PrivateKey(m_pSSLCtx,k)) - { - EVP_PKEY_free(k); - fclose(f); - return SSLError; - } - EVP_PKEY_free(k); - } - - fclose(f); - return Success; -} - -unsigned long KviSSL::getLastError(bool bPeek) -{ - return bPeek ? ERR_peek_error() : ERR_get_error(); -} - -bool KviSSL::getLastErrorString(KviCString &buffer,bool bPeek) -{ - unsigned long uErr = getLastError(bPeek); - if(uErr != 0) - { - const char * err = ERR_reason_error_string(uErr); - buffer = err ? err : "Unknown error"; - return true; - } - return false; -} - -KviSSL::Result KviSSL::connect() -{ - if(!m_pSSL)return NotInitialized; - int ret = SSL_connect(m_pSSL); - return connectOrAcceptError(ret); -} - -KviSSL::Result KviSSL::accept() -{ - if(!m_pSSL)return NotInitialized; - int ret = SSL_accept(m_pSSL); - return connectOrAcceptError(ret); -} - -KviSSL::Result KviSSL::connectOrAcceptError(int ret) -{ - switch(SSL_get_error(m_pSSL,ret)) - { - case SSL_ERROR_NONE: return Success; break; - case SSL_ERROR_WANT_READ: return WantRead; break; - case SSL_ERROR_WANT_WRITE: return WantWrite; break; - case SSL_ERROR_ZERO_RETURN: return RemoteEndClosedConnection; break; - case SSL_ERROR_WANT_X509_LOOKUP: return ObscureError; break; - case SSL_ERROR_SYSCALL: - { - if(getLastError(true) != 0)return SSLError; - if(ret == 0)return RemoteEndClosedConnection; - return SyscallError; - } - break; - case SSL_ERROR_SSL: return SSLError; break; - default: return UnknownError; break; - } - return UnknownError; -} - -int KviSSL::read(char * buffer,int len) -{ -// if(!m_pSSL)return -1; - return SSL_read(m_pSSL,buffer,len); -} -int KviSSL::write(const char * buffer,int len) -{ -// if(!m_pSSL)return -1; - return SSL_write(m_pSSL,buffer,len); -} - -KviSSL::Result KviSSL::getProtocolError(int ret) -{ - if(!m_pSSL)return NotInitialized; - switch(SSL_get_error(m_pSSL,ret)) - { - case SSL_ERROR_NONE: return Success; break; - case SSL_ERROR_WANT_READ: return WantRead; break; - case SSL_ERROR_WANT_WRITE: return WantWrite; break; - case SSL_ERROR_ZERO_RETURN: return ZeroReturn; break; - case SSL_ERROR_WANT_X509_LOOKUP: return ObscureError; break; - case SSL_ERROR_SYSCALL: return SyscallError; break; - case SSL_ERROR_SSL: return SSLError; break; - default: return UnknownError; break; - } - return UnknownError; -} - -KviSSLCertificate * KviSSL::getPeerCertificate() -{ - if(!m_pSSL)return 0; - X509 * x509 = SSL_get_peer_certificate(m_pSSL); - if(!x509)return 0; - return new KviSSLCertificate(x509); -} - -KviSSLCertificate * KviSSL::getLocalCertificate() -{ - if(!m_pSSL)return 0; - X509 * x509 = SSL_get_certificate(m_pSSL); - if(!x509)return 0; - return new KviSSLCertificate(x509); -} - -KviSSLCipherInfo * KviSSL::getCurrentCipherInfo() -{ - if(!m_pSSL)return 0; -#if OPENSSL_VERSION_NUMBER >= 0x10000000L - const SSL_CIPHER * c = SSL_get_current_cipher(m_pSSL); -#else - SSL_CIPHER * c = SSL_get_current_cipher(m_pSSL); -#endif - if(!c)return 0; - return new KviSSLCipherInfo(c); -} - - - -KviSSLCertificate::KviSSLCertificate(X509 * x509) -{ - m_pSubject = new KviPointerHashTable(17); - m_pSubject->setAutoDelete(true); - m_pIssuer = new KviPointerHashTable(17); - m_pIssuer->setAutoDelete(true); - m_pX509 = 0; - setX509(x509); -} - -KviSSLCertificate::~KviSSLCertificate() -{ - X509_free(m_pX509); - delete m_pSubject; - delete m_pIssuer; -} - -const char * KviSSLCertificate::getX509Base64() -{ - BUF_MEM *bptr; - BIO* mem = BIO_new(BIO_s_mem()); - PEM_write_bio_X509(mem, m_pX509); - int iLen = BIO_get_mem_data(mem, &bptr); - char * szTmp = (char *) KviMemory::allocate(iLen+1); - kvi_fastmove(szTmp, bptr, iLen); - *(szTmp+iLen) = '\0'; - BIO_free_all(mem); - return szTmp; -} - -#ifdef COMPILE_ON_WINDOWS - - // On windows we need to override new and delete operators - // to ensure that always the right new/delete pair is called for an object instance - // This bug is present in all the classes exported by a module that - // can be instantiated/destroyed from external modules. - // (this is a well known bug described in Q122675 of MSDN) - - void * KviSSLCertificate::operator new(size_t tSize) - { - return KviMemory::allocate(tSize); - } - - void KviSSLCertificate::operator delete(void * p) - { - KviMemory::free(p); - } - -#endif - -void KviSSLCertificate::setX509(X509 * x509) -{ - if(m_pX509)X509_free(m_pX509); - m_pX509 = x509; - m_iVersion = X509_get_version(x509); - extractSubject(); - extractIssuer(); - extractPubKeyInfo(); - extractSerialNumber(); - extractSignature(); -} - -bool KviSSLCertificate::fingerprintIsValid() -{ - if(!m_pX509) - return false; - - EVP_PKEY * pkey = X509_get_pubkey(m_pX509); - int rv = X509_verify(m_pX509, pkey); - - // careful: https://support.ntp.org/bugs/show_bug.cgi?id=1127 - // quote: X509_verify is a call to ASN1_item_verify which can return both 0 and -1 for error cases. - // In particular it can return -1 when the message digest type is not known, or memory allocation failed. - return (rv > 0); -} - -int KviSSLCertificate::fingerprintDigestId() -{ - if(!m_pX509) - return -1; - - int NID = OBJ_obj2nid(m_pX509->sig_alg->algorithm); - if (NID == NID_undef) - { - // unknow digest function: it means the signature can't be verified: the certificate can't be trusted - return 0; - } - - const EVP_MD * mdType = NULL; - mdType = EVP_get_digestbyname(OBJ_nid2sn(NID)); - - if (mdType == NULL) - { - // Unknown digest - return 0; - } - - return mdType->type; -} - -const char * KviSSLCertificate::fingerprintDigestStr() -{ - int iDigestType = fingerprintDigestId(); - - if(iDigestType == 0) - return ""; - - return OBJ_nid2ln(iDigestType); -} - -const char * KviSSLCertificate::fingerprintContents(QString digestName) -{ - unsigned char bufferData[EVP_MAX_MD_SIZE]; - unsigned int bufferLen = 0; - const char * pDigestName; - if (digestName.isEmpty()) - { - // use the one used to create the signature - pDigestName = OBJ_nid2sn(fingerprintDigestId()); - } else { - pDigestName = digestName.toUtf8().data(); - } - - if(getFingerprint(bufferData, &bufferLen, pDigestName) != 0) - return ""; - - QByteArray digestByteArray = QByteArray::fromRawData((char *) bufferData, bufferLen); - return digestByteArray.toHex().data(); -} - -int KviSSLCertificate::getFingerprint(unsigned char * bufferData, unsigned int * bufferLen, const char * digestName) -{ - //TODO if in the future we will want to check the return value, ensure this - // doesn't collide with the one from openssl - if(!m_pX509) - return -99; - - const EVP_MD * mdType = NULL; - mdType = EVP_get_digestbyname(digestName); - - if (mdType == NULL) - { - // Unknown digest - return -98; - } - - if (!X509_digest(m_pX509, mdType, bufferData, bufferLen)) - { - return -97; - } - - return 0; -} - -void KviSSLCertificate::extractSubject() -{ - char buffer[1024]; - char * t = X509_NAME_oneline(X509_get_subject_name(m_pX509),buffer,1024); - if (!t)return; - m_pSubject->clear(); - splitX509String(m_pSubject,t); -} - -void KviSSLCertificate::extractIssuer() -{ - char buffer[1024]; - char * t = X509_NAME_oneline(X509_get_issuer_name(m_pX509),buffer,1024); - if (!t)return; - m_pIssuer->clear(); - splitX509String(m_pIssuer,t); -} - -void KviSSLCertificate::splitX509String(KviPointerHashTable * dict,const char * t) -{ - KviCString buf = t; - int cnt; - KviCString ** arr = buf.splitToArray('/',50,&cnt); - if(arr) - { - if(cnt > 0) - { - for(int i=0;ifindFirstIdx('='); - if(idx != -1) - { - KviCString szTok = arr[i]->left(idx); - arr[i]->cutLeft(idx + 1); - if(szTok.hasData() && arr[i]->hasData()) - { - dict->replace(szTok.ptr(),new KviCString(arr[i]->ptr())); - } - } - } - } - - KviCString::freeArray(arr); - } -} - - -const char * KviSSLCertificate::dictEntry(KviPointerHashTable * dict,const char * entry) -{ - KviCString * t = dict->find(entry); - if(!t)return __tr("Unknown"); - return t->ptr(); -} - - -/* -void KviSSLCertificate::getPKeyType(int type,KviCString &buffer) -{ - switch(type) - { -#ifndef NO_RSA - case EVP_PKEY_RSA: buffer = "RSA"; break; -#endif -#ifndef NO_DSA - case EVP_PKEY_DSA: buffer = "DSA"; break; -#endif -#ifndef NO_DH - case EVP_PKEY_DH: buffer = "DH"; break; -#endif - case EVP_PKEY_NONE: buffer = "NONE"; break; - } -} -*/ - -void KviSSLCertificate::extractPubKeyInfo() -{ - EVP_PKEY *p = X509_get_pubkey(m_pX509); - if(p) - { - m_iPubKeyBits = EVP_PKEY_bits(p); - m_szPubKeyType = (p->type == NID_undef) ? __tr("Unknown") : OBJ_nid2ln(p->type); -// getPKeyType(p->type,m_szPubKeyType); - } else { - m_iPubKeyBits = 0; - m_szPubKeyType = "None"; - } - -} - -void KviSSLCertificate::extractSerialNumber() -{ - ASN1_INTEGER * i = X509_get_serialNumber(m_pX509); - if(i)m_iSerialNumber = ASN1_INTEGER_get(i); - else m_iSerialNumber = -1; -} - -void KviSSLCertificate::extractSignature() -{ - static char hexdigits[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; - - //getPKeyType(X509_get_signature_type(m_pX509),m_szSignatureType); - - int i = OBJ_obj2nid(m_pX509->sig_alg->algorithm); - m_szSignatureType = (i == NID_undef) ? __tr("Unknown") : OBJ_nid2ln(i); - - m_szSignatureContents = ""; - - for(i = 0;i < m_pX509->signature->length;i++) - { - if(m_szSignatureContents.hasData())m_szSignatureContents.append(":"); - m_szSignatureContents.append(hexdigits[(m_pX509->signature->data[i] & 0xf0) >> 4]); - m_szSignatureContents.append(hexdigits[(m_pX509->signature->data[i] & 0x0f)]); - } -} - -/* -const char * KviSSLCertificate::verify() -{ - -} -*/ - -#if OPENSSL_VERSION_NUMBER >= 0x10000000L -KviSSLCipherInfo::KviSSLCipherInfo(const SSL_CIPHER * c) -#else -KviSSLCipherInfo::KviSSLCipherInfo(SSL_CIPHER * c) -#endif -{ - m_szVersion = SSL_CIPHER_get_version(c); - m_iNumBitsUsed = SSL_CIPHER_get_bits(c,&m_iNumBits); - m_szName = SSL_CIPHER_get_name(c); - char buf[1024]; - m_szDescription = SSL_CIPHER_description(c,buf,1024); -} - -KviSSLCipherInfo::~KviSSLCipherInfo() -{ -} - -#ifdef COMPILE_ON_WINDOWS - - // On windows we need to override new and delete operators - // to ensure that always the right new/delete pair is called for an object instance - // This bug is present in all the classes exported by a module that - // can be instantiated/destroyed from external modules. - // (this is a well known bug described in Q122675 of MSDN) - - void * KviSSLCipherInfo::operator new(size_t tSize) - { - return KviMemory::allocate(tSize); - } - - void KviSSLCipherInfo::operator delete(void * p) - { - KviMemory::free(p); - } - -#endif - -#endif //COMPILE_SSL_SUPPORT diff --git a/src/kvilib/net/kvi_ssl.h b/src/kvilib/net/kvi_ssl.h deleted file mode 100644 index 66413d627..000000000 --- a/src/kvilib/net/kvi_ssl.h +++ /dev/null @@ -1,196 +0,0 @@ -#ifndef _KVI_SSL_H_ -#define _KVI_SSL_H_ -//============================================================================= -// -// File : kvi_ssl.h -// Creation date : Mon May 27 2002 21:36:12 CEST by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" - -#ifdef COMPILE_SSL_SUPPORT - -#include "KviCString.h" -#include "kvi_sockettype.h" - -#include "KviPointerHashTable.h" - -#include - - -class KVILIB_API KviSSLCertificate -{ -public: - KviSSLCertificate(X509 * x509); - ~KviSSLCertificate(); -protected: - X509 * m_pX509; - KviPointerHashTable * m_pSubject; - KviPointerHashTable * m_pIssuer; - int m_iPubKeyBits; - KviCString m_szPubKeyType; - int m_iSerialNumber; - int m_iVersion; - KviCString m_szSignatureType; - KviCString m_szSignatureContents; -private: - void extractSubject(); - void extractIssuer(); - void extractPubKeyInfo(); - void extractSerialNumber(); - void extractSignature(); - const char * dictEntry(KviPointerHashTable * dict,const char * entry); - void splitX509String(KviPointerHashTable * dict,const char * t); - int getFingerprint(unsigned char * bufferData, unsigned int * bufferLen, const char * digestName); -public: - void setX509(X509 * x509); - const char * getX509Base64(); //not owned, you'll need to delete this - - const char * signatureType(){ return m_szSignatureType.ptr(); }; - const char * signatureContents(){ return m_szSignatureContents.ptr(); }; - - const char * subjectCountry(){ return dictEntry(m_pSubject,"C"); }; - const char * subjectStateOrProvince(){ return dictEntry(m_pSubject,"ST"); }; - const char * subjectLocality(){ return dictEntry(m_pSubject,"L"); }; - const char * subjectOrganization(){ return dictEntry(m_pSubject,"O"); }; - const char * subjectOrganizationalUnit(){ return dictEntry(m_pSubject,"OU"); }; - const char * subjectCommonName(){ return dictEntry(m_pSubject,"CN"); }; - - const char * issuerCountry(){ return dictEntry(m_pIssuer,"C"); }; - const char * issuerStateOrProvince(){ return dictEntry(m_pIssuer,"ST"); }; - const char * issuerLocality(){ return dictEntry(m_pIssuer,"L"); }; - const char * issuerOrganization(){ return dictEntry(m_pIssuer,"O"); }; - const char * issuerOrganizationalUnit(){ return dictEntry(m_pIssuer,"OU"); }; - const char * issuerCommonName(){ return dictEntry(m_pIssuer,"CN"); }; - - int publicKeyBits(){ return m_iPubKeyBits; }; - const char * publicKeyType(){ return m_szPubKeyType.ptr(); }; - - int serialNumber(){ return m_iSerialNumber; }; - - int version(){ return m_iVersion; }; - - bool fingerprintIsValid(); - int fingerprintDigestId(); - const char * fingerprintDigestStr(); - const char * fingerprintContents(QString digestName = ""); - -#ifdef COMPILE_ON_WINDOWS - // On windows we need to override new and delete operators - // to ensure that always the right new/delete pair is called for an object instance - // This bug is present in all the classes exported by a module that - // can be instantiated/destroyed from external modules. - // (this is a well known bug described in Q122675 of MSDN) - void * operator new(size_t tSize); - void operator delete(void * p); -#endif -}; - -class KVILIB_API KviSSLCipherInfo -{ -public: -#if OPENSSL_VERSION_NUMBER >= 0x10000000L - KviSSLCipherInfo(const SSL_CIPHER * c); -#else - KviSSLCipherInfo(SSL_CIPHER * c); -#endif - ~KviSSLCipherInfo(); -protected: - KviCString m_szVersion; - int m_iNumBits; - int m_iNumBitsUsed; - KviCString m_szName; - KviCString m_szDescription; -public: - const char * name(){ return m_szName.ptr(); }; - const char * description(){ return m_szDescription.ptr(); }; - int bits(){ return m_iNumBits; }; - int bitsUsed(){ return m_iNumBitsUsed; }; - const char * version(){ return m_szVersion.ptr(); }; -#ifdef COMPILE_ON_WINDOWS - // On windows we need to override new and delete operators - // to ensure that always the right new/delete pair is called for an object instance - // This bug is present in all the classes exported by a module that - // can be instantiated/destroyed from external modules. - // (this is a well known bug described in Q122675 of MSDN) - void * operator new(size_t tSize); - void operator delete(void * p); -#endif -}; - -#ifdef Success - #undef Success -#endif - - -class KVILIB_API KviSSL -{ -public: - enum Method { Client, Server }; - enum Result { Success, NotInitialized, WantRead, WantWrite, ZeroReturn, FileIoError, - UnknownError, ObscureError, SSLError, SyscallError, RemoteEndClosedConnection }; -public: - KviSSL(); - ~KviSSL(); -public: - SSL * m_pSSL; - SSL_CTX * m_pSSLCtx; - KviCString m_szPass; -public: - static void globalInit(); - static void globalDestroy(); - static void globalSSLInit(); - static void globalSSLDestroy(); -public: - bool initSocket(kvi_socket_t fd); - bool initContext(KviSSL::Method m); - void shutdown(); - KviSSL::Result connect(); - KviSSL::Result accept(); - int read(char * buffer,int len); - int write(const char * buffer,int len); - // SSL ERRORS - unsigned long getLastError(bool bPeek = false); - bool getLastErrorString(KviCString &buffer,bool bPeek = false); - // Protocol error - KviSSL::Result getProtocolError(int ret); - KviSSLCertificate * getPeerCertificate(); - KviSSLCertificate * getLocalCertificate(); - KviSSLCipherInfo * getCurrentCipherInfo(); - KviSSL::Result useCertificateFile(const char * cert,const char * pass); - KviSSL::Result usePrivateKeyFile(const char * key,const char * pass); -#ifdef COMPILE_ON_WINDOWS - // On windows we need to override new and delete operators - // to ensure that always the right new/delete pair is called for an object instance - // This bug is present in all the classes exported by a module that - // can be instantiated/destroyed from external modules. - // (this is a well known bug described in Q122675 of MSDN) - void * operator new(size_t tSize); - void operator delete(void * p); -#endif -private: - KviSSL::Result connectOrAcceptError(int ret); -}; - - -#endif //COMPILE_SSL_SUPPORT - -#endif //_KVI_SSL_H_ diff --git a/src/kvilib/net/kvi_url.cpp b/src/kvilib/net/kvi_url.cpp deleted file mode 100644 index f644d8fe1..000000000 --- a/src/kvilib/net/kvi_url.cpp +++ /dev/null @@ -1,93 +0,0 @@ -//============================================================================= -// -// File : kvi_url.cpp -// Creation date : Sat Aug 17 14:09:18 2002 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - - - -#include "kvi_url.h" -#include - -KviUrl::KviUrl() -{ -} - -KviUrl::KviUrl(const KviUrl & u) -{ - *this = u; -} - -KviUrl::KviUrl(const char * szUrl) -{ - m_szUrl = QString::fromLocal8Bit(szUrl); - parse(); -} - -KviUrl::KviUrl(const QString &szUrl) -{ - m_szUrl = szUrl; - parse(); -} - -KviUrl::~KviUrl() -{ - -} - -void KviUrl::parse() -{ - QUrl url(m_szUrl); - m_szProtocol = url.scheme(); - m_szHost = url.host(); - m_szPath = url.encodedPath(); - if(url.hasQuery()) - { - m_szPath.append(QChar('?')); - m_szPath.append(url.encodedQuery()); - } - if(m_szPath.isEmpty()) m_szPath=QString("/"); - m_szUser = url.userName(); - m_szPass = url.password(); - m_uPort = url.port() > 0 ? url.port() : 80 ; -} - - -KviUrl & KviUrl::operator=(const QString& szUrl) -{ - m_szUrl = szUrl; - parse(); - return *this; -} - -KviUrl & KviUrl::operator=(const KviUrl &u) -{ - m_szUrl = u.m_szUrl; - m_szProtocol = u.m_szProtocol; - m_szHost = u.m_szHost; - m_szPath = u.m_szPath; - m_szUser = u.m_szUser; - m_szPass = u.m_szPass; - m_uPort = u.m_uPort; - return *this; -} - - diff --git a/src/kvilib/net/kvi_url.h b/src/kvilib/net/kvi_url.h deleted file mode 100644 index 813af9645..000000000 --- a/src/kvilib/net/kvi_url.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _KVI_URL_H_ -#define _KVI_URL_H_ -//============================================================================= -// -// File : kvi_url.h -// Creation date : Sat Aug 17 14:09:16 2002 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "KviCString.h" -#include "KviHeapObject.h" -#include "kvi_inttypes.h" - -class KVILIB_API KviUrl : public KviHeapObject -{ -public: - KviUrl(); - KviUrl(const char * szUrl); - KviUrl(const QString &szUrl); - KviUrl(const KviUrl &u); - ~KviUrl(); -protected: - QString m_szUrl; - - QString m_szProtocol; - QString m_szHost; - QString m_szPath; - QString m_szUser; - QString m_szPass; - kvi_u32_t m_uPort; -protected: - void parse(); -public: - const QString & url() const { return m_szUrl; }; - const QString & protocol() const { return m_szProtocol; }; - const QString & host() const { return m_szHost; }; - const QString & path() const { return m_szPath; }; - const QString & user() const { return m_szUser; }; - const QString & pass() const { return m_szPass; }; - kvi_u32_t port() const { return m_uPort; }; - - KviUrl & operator = (const QString& szUrl); - KviUrl & operator = (const KviUrl &u); - -}; - - -#endif //_KVI_URL_H_ diff --git a/src/kvilib/tal/KviTalApplication.cpp b/src/kvilib/tal/KviTalApplication.cpp new file mode 100644 index 000000000..9e2a2f538 --- /dev/null +++ b/src/kvilib/tal/KviTalApplication.cpp @@ -0,0 +1,56 @@ +//============================================================================= +// +// File : KviTalApplication.cpp +// Creation date : Sun Aug 12 2001 04:34:21 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + + +#include "KviTalApplication.h" + +#ifdef COMPILE_KDE_SUPPORT + KviTalApplication::KviTalApplication(int &, char **) + : KApplication() + { + } +#else + KviTalApplication::KviTalApplication(int & iArgc, char ** ppcArgv) + : QApplication(iArgc,ppcArgv) + { + } +#endif + +KviTalApplication::~KviTalApplication() +{ +} + +void KviTalApplication::commitData(QSessionManager & manager) +{ + saveConfiguration(); +#ifdef COMPILE_KDE_SUPPORT + KApplication::commitData(manager); +#else + QApplication::commitData(manager); +#endif +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalApplication.moc" +#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalApplication.h b/src/kvilib/tal/KviTalApplication.h new file mode 100644 index 000000000..cbbe5c889 --- /dev/null +++ b/src/kvilib/tal/KviTalApplication.h @@ -0,0 +1,83 @@ +#ifndef _KVI_TAL_APPLICATION_H_ +#define _KVI_TAL_APPLICATION_H_ +//============================================================================= +// +// File : KviTalApplication.h +// Creation date : Sun Jun 18 2000 12:53:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= +// +// This file was originally named kvi_appbase_kde.h, created on 1999 +// +//============================================================================= + +/** +* \file KviTalApplication.h +* \author Szymon Stefanek +* \brief Toolkit Abstraction Level class +*/ + +#include "kvi_settings.h" + +/** +* \class KviTalApplication +* \brief Toolkit Abstraction Layer: application class +*/ + +#ifdef COMPILE_KDE_SUPPORT + +#include +class KVILIB_API KviTalApplication : public KApplication +#else + +#include +class KVILIB_API KviTalApplication : public QApplication +#endif +{ + Q_OBJECT +public: + /** + * \brief Constructs the application object + * \param iArgc The number of arguments + * \param ppcArgv The arguments list + * \return KviTalApplication + */ + KviTalApplication(int & iArgc, char ** ppcArgv); + + /** + * \brief Destructs the application object + */ + ~KviTalApplication(); + + /** + * \brief Commits the data and save the session + * \param manager The session manager + * \return void + */ + void commitData(QSessionManager & manager); + + /** + * \brief Saves configuration to disk + * \return void + */ + virtual void saveConfiguration() = 0; +}; + +#endif // _KVI_TAL_APPLICATION_H_ diff --git a/src/kvilib/tal/KviTalFileDialog.cpp b/src/kvilib/tal/KviTalFileDialog.cpp new file mode 100644 index 000000000..b60cfc870 --- /dev/null +++ b/src/kvilib/tal/KviTalFileDialog.cpp @@ -0,0 +1,112 @@ +//============================================================================= +// +// File : KviTalFileDialog.cpp +// Creation date : Thu Sep 11 2003 04:09:24 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2003-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + + + +#include "KviTalFileDialog.h" + +#ifdef COMPILE_KDE_SUPPORT + +KviTalFileDialog::KviTalFileDialog(const QString & szDirName, const QString & szFilter, QWidget * pParent, const char *, bool) +: KFileDialog(KUrl(szDirName),szFilter,pParent) +{ + //clearWFlags(WDestructiveClose); +} + +#else // COMPILE_KDE_SUPPORT + +KviTalFileDialog::KviTalFileDialog(const QString & szDirName, const QString & szFilter, QWidget * pParent, const char *, bool bModal) +: QFileDialog(pParent,"",szDirName,szFilter) +{ + setModal(bModal); +} + +#endif // COMPILE_KDE_SUPPORT + +KviTalFileDialog::~KviTalFileDialog() +{ +} + +void KviTalFileDialog::setFileMode(FileMode m) +{ + switch(m) + { +#ifdef COMPILE_KDE_SUPPORT + case AnyFile: + setMode(KFile::File | KFile::LocalOnly); + setOperationMode(Saving); + break; + case ExistingFile: + setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly); + setOperationMode(Opening); + break; + case ExistingFiles: + setMode(KFile::Files | KFile::ExistingOnly | KFile::LocalOnly); + setOperationMode(Opening); + break; + case Directory: + setMode(KFile::Directory); + break; + case DirectoryOnly: + setMode(KFile::Directory); + break; + default: + setMode(KFile::File | KFile::LocalOnly); + setOperationMode(Saving); + break; +#else // COMPILE_KDE_SUPPORT + case AnyFile: + QFileDialog::setFileMode(QFileDialog::AnyFile); + break; + case ExistingFile: + QFileDialog::setFileMode(QFileDialog::ExistingFile); + break; + case ExistingFiles: + QFileDialog::setFileMode(QFileDialog::ExistingFiles); + break; + case Directory: + QFileDialog::setFileMode(QFileDialog::Directory); + break; + case DirectoryOnly: + QFileDialog::setFileMode(QFileDialog::DirectoryOnly); + break; + default: + QFileDialog::setFileMode(QFileDialog::AnyFile); + break; +#endif // COMPILE_KDE_SUPPORT + } +} + +void KviTalFileDialog::setDirectory(const QString & szDirectory) +{ +#ifdef COMPILE_KDE_SUPPORT + setUrl(KUrl(szDirectory)); +#else + QFileDialog::setDirectory(szDirectory); +#endif +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalFileDialog.moc" +#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalFileDialog.h b/src/kvilib/tal/KviTalFileDialog.h new file mode 100644 index 000000000..523cda79b --- /dev/null +++ b/src/kvilib/tal/KviTalFileDialog.h @@ -0,0 +1,118 @@ +#ifndef _KVI_TAL_FILEDIALOG_H_ +#define _KVI_TAL_FILEDIALOG_H_ + +//============================================================================= +// +// File : KviTalFileDialog.h +// Creation date : Thu Sep 11 2003 04:41:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2003-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +/** +* \file KviTalFileDialog.h +* \author Szymon Stefanek +* \brief Toolkit Abstraction Layer class +*/ + +#include "kvi_settings.h" + +/** +* \class KviTalFileDialog +* \brief Toolkit Abstraction Layer: filedialog class +*/ + +#ifdef COMPILE_KDE_SUPPORT + +#include + +class KVILIB_API KviTalFileDialog : public KFileDialog + +#else // COMPILE_KDE_SUPPORT + +#include + +class KVILIB_API KviTalFileDialog : public QFileDialog + +#endif // COMPILE_KDE_SUPPORT +{ + Q_OBJECT +public: + /** + * \brief Constructs the filedialog object + * \param szDirName The initial directory to display + * \param szFilter The filter to use to display + * \param pParent The parent object + * \param pcName The caption name of the dialog + * \param bModal Whether the dialog is modal + * \return KviTalFileDialog + */ + KviTalFileDialog(const QString & szDirName, const QString & szFilter = QString(), QWidget * pParent = 0, const char * pcName = 0, bool bModal = false); + + /** + * \brief Destroys the filedialog object + */ + ~KviTalFileDialog(); +public: + /** + * \enum FileMode + * \brief Indicate what the user may select in the file dialog + */ + enum FileMode { + AnyFile, /**< The name of a file, whether it exists or not */ + ExistingFile, /**< The name of a single existing file */ + ExistingFiles, /**< The names of zero or more existing files */ + Directory, /**< The name of a directory. Both files and directories are displayed */ + DirectoryOnly /**< The name of a directory. The file dialog will only display directories */ + }; + + /** + * \brief Sets the file mode + * \param m The mode :) + * \return void + */ + void setFileMode(FileMode m); + + /** + * \brief Sets the current directory + * \param szDirectory The directory + * \return void + */ + void setDirectory(const QString & szDirectory); + + /** + * \brief Returns an existing directory selected by the user + * \param szDir The directory to display + * \param szCaption The caption of the dialog + * \param pParent The parent object + * \return QString + */ + static QString getExistingDirectoryPath(const QString & szDir = QString(), const QString & szCaption = QString(), QWidget * pParent = 0) + { +#ifdef COMPILE_KDE_SUPPORT + // QFileDialog allows making new directories...kfiledialog not :/ + return KFileDialog::getExistingDirectory(KUrl(szDir),pParent,szCaption); + //return getExistingDirectory(dir,parent,caption); +#else // COMPILE_KDE_SUPPORT + return getExistingDirectory(pParent,szCaption,szDir); +#endif // COMPILE_KDE_SUPPORT + }; +}; + +#endif // _KVI_TAL_FILEDIALOG_H_ diff --git a/src/kvilib/tal/KviTalGroupBox.cpp b/src/kvilib/tal/KviTalGroupBox.cpp new file mode 100644 index 000000000..86ba10935 --- /dev/null +++ b/src/kvilib/tal/KviTalGroupBox.cpp @@ -0,0 +1,140 @@ +//============================================================================= +// +// File : KviTalGroupBox.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalGroupBox.h" + +#include +#include + +KviTalGroupBox::KviTalGroupBox(QWidget * pParent, char * pcName) +: QGroupBox(pParent) +{ + setObjectName(pcName); + m_pLayout = new QHBoxLayout(this); + QGroupBox::setLayout(m_pLayout); +} + +KviTalGroupBox::KviTalGroupBox(QWidget * pParent) +: QGroupBox(pParent) +{ + m_pLayout = 0; +} + +KviTalGroupBox::KviTalGroupBox(const QString & szTitle, QWidget * pParent) +: QGroupBox(szTitle,pParent) +{ + m_pLayout = 0; +} + +KviTalGroupBox::KviTalGroupBox(Qt::Orientation orientation, QWidget * pParent) +: QGroupBox(pParent) +{ + if(orientation == Qt::Vertical) + m_pLayout = new QHBoxLayout(this); + else + m_pLayout = new QVBoxLayout(this); + QGroupBox::setLayout(m_pLayout); +} + +KviTalGroupBox::KviTalGroupBox(Qt::Orientation orientation, const QString & szTitle, QWidget * pParent) +: QGroupBox(szTitle,pParent) +{ + mOrientation = orientation; + if(orientation == Qt::Vertical) + m_pLayout = new QHBoxLayout(this); + else + m_pLayout = new QVBoxLayout(this); + QGroupBox::setLayout(m_pLayout); +} + +KviTalGroupBox::~KviTalGroupBox() +{ +} + +void KviTalGroupBox::childEvent(QChildEvent * e) +{ + if(!e->child()->isWidgetType()) + return; + if(e->child()->parent() != this) + return; + if(!m_pLayout) + return; + if(m_pLayout != layout()) + return; + + switch(e->type()) + { + case QEvent::ChildAdded: + m_pLayout->addWidget((QWidget *)(e->child())); + break; + case QEvent::ChildRemoved: + m_pLayout->removeWidget((QWidget *)(e->child())); + break; + default: + break; + } +} + +void KviTalGroupBox::addSpace(int iSpace) +{ + if(m_pLayout && m_pLayout==layout()) + { + if(mOrientation == Qt::Vertical) + ((QHBoxLayout*)m_pLayout)->addSpacing(iSpace); + else + ((QVBoxLayout*)m_pLayout)->addSpacing(iSpace); + } +} + +void KviTalGroupBox::setOrientation(Qt::Orientation orientation) +{ + if(m_pLayout) + { + delete m_pLayout; + m_pLayout = NULL; + } + + mOrientation = orientation; + + if(orientation == Qt::Vertical) + m_pLayout = new QHBoxLayout(this); + else + m_pLayout = new QVBoxLayout(this); + QGroupBox::setLayout(m_pLayout); +} + +void KviTalGroupBox::setLayout(QLayout * layout) +{ + if(m_pLayout) + { + delete m_pLayout; + m_pLayout = NULL; + } + + QGroupBox::setLayout(layout); +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalGroupBox.moc" +#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalGroupBox.h b/src/kvilib/tal/KviTalGroupBox.h new file mode 100644 index 000000000..767fe08eb --- /dev/null +++ b/src/kvilib/tal/KviTalGroupBox.h @@ -0,0 +1,149 @@ +#ifndef _KVI_TAL_GROUPBOX_H_ +#define _KVI_TAL_GROUPBOX_H_ + +//============================================================================= +// +// File : KviTalGroupBox.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +/** +* \file KviTalGroupBox.h +* \author Szymon Stefanek +* \brief Class for groupbox +*/ + +#include "kvi_settings.h" + +#include +#include + +/** +* \class KviTalGroupBox +* \brief Toolkit Abstraction Layer: groupbox class +*/ +class KVILIB_API KviTalGroupBox : public QGroupBox +{ + Q_OBJECT +public: + /** + * \brief Constructs the groupbox object + * \param pParent The parent object + * \param pcName the name of the groupbox + * \return KviTalGroupBox + */ + KviTalGroupBox(QWidget * pParent, char * pcName=0); + + /** + * \brief Constructs the groupbox object + * \param pParent The parent object + * \return KviTalGroupBox + */ + KviTalGroupBox(QWidget * pParent = 0); + + /** + * \brief Constructs the groupbox object + * \param szTitle The title of the groupbox + * \param pParent The parent object + * \return KviTalGroupBox + */ + KviTalGroupBox(const QString & szTitle, QWidget * pParent = 0); + + /** + * \brief Constructs the groupbox object + * \param orientation The orientation of the groupbox + * \param pParent The parent object + * \return KviTalGroupBox + */ + KviTalGroupBox(Qt::Orientation orientation, QWidget * pParent = 0); + + /** + * \brief Constructs the groupbox object + * \param orientation The orientation of the groupbox + * \param szTitle The title of the groupbox + * \param pParent The parent object + * \return KviTalGroupBox + */ + KviTalGroupBox(Qt::Orientation orientation, const QString & szTitle, QWidget * pParent = 0); + + /** + * \brief Destroys the groupbox object + */ + ~KviTalGroupBox(); +protected: + Qt::Orientation mOrientation; + QLayout * m_pLayout; +public: + /** + * \brief Sets the inside margin + * \param iMargin The margin in pixels + * \return void + */ + void setInsideMargin(int iMargin) + { if(layout()) layout()->setMargin(iMargin); }; + + /** + * \brief Sets the inside spacing + * \param iSpacing The spacing in pixels + * \return void + */ + void setInsideSpacing(int iSpacing) + { if(layout()) layout()->setSpacing(iSpacing); }; + + /** + * \brief Returns the inside margin + * \return int + */ + int insideMargin() + { if(layout()) return layout()->margin(); return 0; }; + + /** + * \brief Returns the inside spacing + * \return int + */ + int insideSpacing() + { if(layout()) return layout()->spacing(); return 0; }; + + /** + * \brief Adds a space + * \param iSpace The space in pixels + * \return void + */ + void addSpace(int iSpace); + + /** + * \brief Sets the orientation + * \param orientation The orientation :) + * \return void + */ + void setOrientation(Qt::Orientation orientation); + + /** + * \brief Sets a new layout + * \param newLayout The new layout + * \return void + */ + void setLayout(QLayout * newLayout); +protected: + virtual void childEvent(QChildEvent * e); +}; + +#endif // _KVI_TAL_GROUPBOX_H_ diff --git a/src/kvilib/tal/KviTalHBox.cpp b/src/kvilib/tal/KviTalHBox.cpp new file mode 100644 index 000000000..4953a012d --- /dev/null +++ b/src/kvilib/tal/KviTalHBox.cpp @@ -0,0 +1,128 @@ +//============================================================================= +// +// File : KviTalHBox.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalHBox.h" + +#include + +// Tables used in $setAlignment & $alignment +const char * const align_tbl[] = { + "Left", + "Right", + "HCenter", + "VCenter", + "Center", + "Top", + "Bottom", + "WordBreak" +}; + +const int align_cod[] = { + Qt::AlignLeft, + Qt::AlignRight, + Qt::AlignHCenter, + Qt::AlignVCenter, + Qt::AlignCenter, + Qt::AlignTop, + Qt::AlignBottom, + Qt::AlignJustify, +}; + +#define align_num (sizeof(align_tbl) / sizeof(align_tbl[0])) + +KviTalHBox::KviTalHBox(QWidget * pParent, char * pcName) +: QWidget(pParent) +{ + setObjectName(pcName); + + m_pLayout = new QHBoxLayout(this); + m_pLayout->setMargin(3); + m_pLayout->setSpacing(2); + + setLayout(m_pLayout); +} + +KviTalHBox::~KviTalHBox() +{ +} + +void KviTalHBox::childEvent(QChildEvent * e) +{ + if(!e->child()->isWidgetType()) + return; + if(e->child()->parent() != this) + return; + + switch(e->type()) + { + case QEvent::ChildAdded: + m_pLayout->addWidget((QWidget *)(e->child())); + break; + case QEvent::ChildRemoved: + m_pLayout->removeWidget((QWidget *)(e->child())); + break; + default: + break; + } +} + +void KviTalHBox::setStretchFactor(QWidget * pChild, int iStretch) +{ + m_pLayout->setStretchFactor(pChild,iStretch); +} + +void KviTalHBox::setSpacing(int iSpacing) +{ + m_pLayout->setSpacing(iSpacing); +} + +void KviTalHBox::setMargin(int iMargin) +{ + m_pLayout->setContentsMargins(iMargin,iMargin,iMargin,iMargin); +} + +void KviTalHBox::setAlignment(Qt::Alignment alignment) +{ + m_pLayout->setAlignment(this,alignment); +} + +void KviTalHBox::setAlignment(QWidget * pChild, Qt::Alignment alignment) +{ + m_pLayout->setAlignment(pChild,alignment); +} + +void KviTalHBox::addStretch(int iStretch) +{ + m_pLayout->addStretch(iStretch); +} + +void KviTalHBox::addSpacing(int iSpacing) +{ + m_pLayout->addSpacing(iSpacing); +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalHBox.moc" +#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalHBox.h b/src/kvilib/tal/KviTalHBox.h new file mode 100644 index 000000000..07870c31a --- /dev/null +++ b/src/kvilib/tal/KviTalHBox.h @@ -0,0 +1,118 @@ +#ifndef _KVI_TAL_HBOX_H_ +#define _KVI_TAL_HBOX_H_ + +//============================================================================= +// +// File : KviTalHBox.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +/** +* \file KviTalHBox.h +* \author Szymon Stefanek +* \brief Class for horizontal box +*/ + +#include "kvi_settings.h" + +#include +#include + +/** +* \class KviTalHBox +* \brief Toolkit Abstraction Layer: hbox class +*/ +class KVILIB_API KviTalHBox : public QWidget +{ + Q_OBJECT +public: + /** + * \brief Constructs an horizontal box object + * \param pParent The parent object + * \param pcName The name of the box + * \return KviTalHBox + */ + KviTalHBox(QWidget * pParent, char * pcName = 0); + + /** + * \brief Destroys an horizontal box object + */ + ~KviTalHBox(); +private: + QHBoxLayout * m_pLayout; +public: + /** + * \brief Sets the stretch factor for an object + * \param pChild The object to stretch + * \param iStretch The stretch factor to use + * \return void + */ + void setStretchFactor(QWidget * pChild, int iStretch); + + /** + * \brief Sets the spacing of the box + * \param iSpace The space in pixels + * \return void + */ + void setSpacing(int iSpace); + + /** + * \brief Sets the margin of the box + * \param iMargin The margin in pixels + * \return void + */ + void setMargin(int iMargin); + + /** + * \brief Sets the alignment of the box + * \param alignment The alignment + * \return void + */ + void setAlignment(Qt::Alignment alignment); + + /** + * \brief Sets the alignment of the box + * \param pChild The child object to align + * \param alignment The alignment + * \return void + */ + void setAlignment(QWidget * pChild, Qt::Alignment alignment); + + /** + * \brief Adds the stretch factor + * \param iStretch The stretch factor + * \return void + */ + void addStretch(int iStretch); + + /** + * \brief Adds a non-stretchable spacing item + * \param iSpace the width of the item + * \return void + */ + void addSpacing(int iSpace); + +protected: + virtual void childEvent(QChildEvent * e); +}; + +#endif // _KVI_TAL_HBOX_H_ diff --git a/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.cpp b/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.cpp new file mode 100644 index 000000000..6d658836b --- /dev/null +++ b/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.cpp @@ -0,0 +1,93 @@ +//============================================================================= +// +// File : KviTalIconAndRichTextItemDelegate.cpp +// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalIconAndRichTextItemDelegate.h" + +#include +#include +#include +#include + +KviTalIconAndRichTextItemDelegate::KviTalIconAndRichTextItemDelegate(QAbstractItemView * pWidget) +: QStyledItemDelegate(pWidget), m_pParent(pWidget), m_pDefaultPix(0) +{ +} + +KviTalIconAndRichTextItemDelegate::~KviTalIconAndRichTextItemDelegate() +{ +} + +void KviTalIconAndRichTextItemDelegate::paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const +{ + pPainter->save(); + QStyleOptionViewItemV4 opt = option; + initStyleOption(&opt, index); + + if (opt.state & QStyle::State_Selected) + QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem,&opt, pPainter); + + QString szText = index.data(Qt::DisplayRole).toString(); + QPixmap pixmap; + QRect decorationRect; + QVariant value = index.data(Qt::DecorationRole); + + QIcon ico; + if(value.canConvert()) + { + ico = QIcon(value.value()); + if(ico.isNull()) + { + if(m_pDefaultPix) + pPainter->drawPixmap(opt.rect.x()+LVI_BORDER,opt.rect.y()+LVI_BORDER,*m_pDefaultPix); + } else { + pPainter->drawPixmap(opt.rect.x()+LVI_BORDER,opt.rect.y()+LVI_BORDER,ico.pixmap(LVI_ICON_SIZE,LVI_ICON_SIZE)); + } + } else { + if(m_pDefaultPix) + pPainter->drawPixmap(opt.rect.x()+LVI_BORDER,opt.rect.y()+LVI_BORDER,*m_pDefaultPix); + } + + QTextDocument doc; + doc.setHtml(szText); + doc.setDefaultFont(opt.font); + pPainter->translate(opt.rect.x()+LVI_AFTER_ICON,opt.rect.y()+LVI_BORDER); + doc.setTextWidth(opt.rect.width()-LVI_AFTER_ICON); + QRect cliprect = QRect(QPoint(0,0),QSize(opt.rect.width()-LVI_AFTER_ICON,opt.rect.height())); + doc.drawContents(pPainter,cliprect); + pPainter->restore(); +} + +QSize KviTalIconAndRichTextItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex & index) const +{ + QString szText = index.data(Qt::DisplayRole).toString(); + QTextDocument doc; + doc.setHtml(szText); + doc.setDefaultFont(option.font); + doc.setTextWidth(option.rect.width()-LVI_AFTER_ICON); + int iHeight = doc.documentLayout()->documentSize().toSize().height(); + if(iHeight < (LVI_ICON_SIZE+(2 * LVI_BORDER))) + iHeight = LVI_ICON_SIZE; + + return QSize(((QListWidget *)parent())->viewport()->size().width(), iHeight + (2 * LVI_BORDER)); +} diff --git a/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.h b/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.h new file mode 100644 index 000000000..6bfb429b5 --- /dev/null +++ b/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.h @@ -0,0 +1,95 @@ +#ifndef _KVI_TAL_DELEGATES_H_ +#define _KVI_TAL_DELEGATES_H_ + +//============================================================================= +// +// File : KviTalIconAndRichTextItemDelegate.h +// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +/** +* \file KviTalIconAndRichTextItemDelegate.h +* \author Szymon Stefanek +* \brief Class for item delegates +*/ + +#include "kvi_settings.h" + +#include +#include +#include +#include + +#define LVI_ICON_SIZE 32 +#define LVI_BORDER 4 +#define LVI_SPACING 8 +#define LVI_MINIMUM_TEXT_WIDTH 300 +#define LVI_MINIMUM_CELL_WIDTH (LVI_MINIMUM_TEXT_WIDTH + LVI_BORDER + LVI_ICON_SIZE + LVI_SPACING + LVI_BORDER) + +#define LVI_AFTER_ICON (LVI_BORDER + LVI_ICON_SIZE + LVI_SPACING) +/** +* \class KviTalIconAndRichTextItemDelegate +* \brief Toolkit Abstraction Layer: itemdelegate class +*/ +class KVILIB_API KviTalIconAndRichTextItemDelegate : public QStyledItemDelegate +{ +public: + /** + * \brief Constructs the icon and rich text item delegate object + * \param pWidget The item which we have to delegate for the paint + * \return KviTalIconAndRichTextItemDelegate + */ + KviTalIconAndRichTextItemDelegate(QAbstractItemView * pWidget = 0); + + /** + * \brief Destroys the icon and rich text item delegate object + */ + ~KviTalIconAndRichTextItemDelegate(); +protected: + QAbstractItemView * m_pParent; + QPixmap * m_pDefaultPix; +public: + /** + * \brief Returns the size hint for the view + * \param option The style options for the item + * \param index The model index for the item + * \return QSize + */ + QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; + + /** + * \brief Paints the view + * \param pPainter The painter to draw the view + * \param option The style options for the item + * \param index The model index for the item + * \return void + */ + void paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const; + + /** + * \brief Sets the default icon + * \param pPix The icon pixmap + * \return void + */ + void setDefaultIcon(QPixmap * pPix){ m_pDefaultPix = pPix; }; +}; + +#endif // _KVI_TAL_LISTWIDGET_H_ diff --git a/src/kvilib/tal/KviTalListWidget.cpp b/src/kvilib/tal/KviTalListWidget.cpp new file mode 100644 index 000000000..dd92bfe64 --- /dev/null +++ b/src/kvilib/tal/KviTalListWidget.cpp @@ -0,0 +1,189 @@ +//============================================================================= +// +// File : KviTalListWidget.cpp +// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalListWidget.h" +#include "KviTalIconAndRichTextItemDelegate.h" + +#include +#include +#include +#include + +KviTalListWidget::KviTalListWidget(QWidget * pParent,QString name,Qt::WindowType f) +: QListWidget(pParent) +{ + setObjectName(name); + setWindowFlags(f); +} +bool KviTalListWidget::event(QEvent * e) +{ + + if (e->type() == QEvent::ToolTip) + { + QHelpEvent *helpEvent = static_cast(e); + const QPoint &p=helpEvent->pos(); + QListWidgetItem *item=itemAt(p); + if (item) + { + emit tipRequest(item,p); + } + } + return QListWidget::event(e); +} + +KviTalListWidgetText::KviTalListWidgetText(KviTalListWidget *listbox, const QString &text) +:KviTalListWidgetItem(listbox) +{ + setText(text); +} + +KviTalListWidgetText::KviTalListWidgetText(const QString &text) +:KviTalListWidgetItem() +{ + setText(text); +} +/* +KviTalListWidgetText::KviTalListWidgetText(KviTalListWidget* listbox, const QString &text, KviTalListWidgetItem *after) +: KviTalListWidgetItem(listbox, after) +{ + setText(text); +}*/ + +KviTalListWidgetText::~KviTalListWidgetText() +{ +} + +void KviTalListWidgetText::paint(QPainter *painter) +{ + int itemHeight = height(listWidget()); + QFontMetrics fm = painter->fontMetrics(); + int yPos = ((itemHeight - fm.height()) / 2) + fm.ascent(); + painter->drawText(3, yPos, text()); +} + +int KviTalListWidgetText::height(const KviTalListWidget* lb) const +{ + int h = lb ? lb->fontMetrics().lineSpacing() + 2 : 0; + return qMax(h, QApplication::globalStrut().height()); +} + +int KviTalListWidgetText::width(const KviTalListWidget* lb) const +{ + int w = lb ? lb->fontMetrics().width(text()) + 6 : 0; + return qMax(w, QApplication::globalStrut().width()); +} + +int KviTalListWidgetText::rtti() const +{ + return RTTI; +} + +KviTalListWidgetPixmap::KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap &pixmap) +: KviTalListWidgetItem(listbox) +{ + pm = pixmap; +} + +KviTalListWidgetPixmap::KviTalListWidgetPixmap(const QPixmap &pixmap) +: KviTalListWidgetItem() +{ + pm = pixmap; +} + +// KviTalListWidgetPixmap::KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap &pixmap, KviTalListWidgetItem *after) +// : KviTalListWidgetItem(listbox, after) +// { +// pm = pixmap; +// } + +KviTalListWidgetPixmap::~KviTalListWidgetPixmap() +{ +} + +KviTalListWidgetPixmap::KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap &pix, const QString& text) +: KviTalListWidgetItem(listbox) +{ + pm = pix; + setText(text); + setIcon(QIcon(pix)); +} + +KviTalListWidgetPixmap::KviTalListWidgetPixmap(const QPixmap & pix, const QString& text) +: KviTalListWidgetItem() +{ + pm = pix; + setText(text); +} + +// KviTalListWidgetPixmap::KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap & pix, const QString& text,KviTalListWidgetItem *after) +// : KviTalListWidgetItem(listbox, after) +// { +// pm = pix; +// setText(text); +// } + +void KviTalListWidgetPixmap::paint(QPainter *painter) +{ + int itemHeight = height(listWidget()); + int yPos; + + const QPixmap *pm = pixmap(); + if (pm && ! pm->isNull()) { + yPos = (itemHeight - pm->height()) / 2; + painter->drawPixmap(3, yPos, *pm); + } + + if (!text().isEmpty()) { + QFontMetrics fm = painter->fontMetrics(); + yPos = ((itemHeight - fm.height()) / 2) + fm.ascent(); + painter->drawText(pm->width() + 5, yPos, text()); + } +} + +int KviTalListWidgetPixmap::height(const KviTalListWidget* lb) const +{ + int h; + if (text().isEmpty()) + h = pm.height(); + else + h = qMax(pm.height(), lb->fontMetrics().lineSpacing() + 2); + return qMax(h, QApplication::globalStrut().height()); +} + +int KviTalListWidgetPixmap::width(const KviTalListWidget* lb) const +{ + if (text().isEmpty()) + return qMax(pm.width() + 6, QApplication::globalStrut().width()); + return qMax(pm.width() + lb->fontMetrics().width(text()) + 6, + QApplication::globalStrut().width()); +} + +int KviTalListWidgetPixmap::rtti() const +{ + return RTTI; +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalListWidget.moc" +#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalListWidget.h b/src/kvilib/tal/KviTalListWidget.h new file mode 100644 index 000000000..266571ebd --- /dev/null +++ b/src/kvilib/tal/KviTalListWidget.h @@ -0,0 +1,113 @@ +#ifndef _KVI_TAL_LISTWIDGET_H_ +#define _KVI_TAL_LISTWIDGET_H_ + +//============================================================================= +// +// File : KviTalListWidget.h +// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "KviTalIconAndRichTextItemDelegate.h" + + +#include + +class KviTalListWidgetItem; + + +class KVILIB_API KviTalListWidget : public QListWidget +{ + Q_OBJECT +public: + KviTalListWidget(QWidget * pParent,QString name,Qt::WindowType f = Qt::Widget); + KviTalListWidget(QWidget * pParent) + : QListWidget (pParent){}; + virtual ~KviTalListWidget() {}; + +protected: + virtual bool event(QEvent * e); +signals: + void tipRequest(QListWidgetItem *,const QPoint &); + +}; + +class KVILIB_API KviTalListWidgetItem : public QListWidgetItem +{ +public: + KviTalListWidgetItem() + : QListWidgetItem() {}; + KviTalListWidgetItem(KviTalListWidget * pParent) + : QListWidgetItem(pParent){}; + KviTalListWidgetItem(KviTalListWidget * pParent, QString& label) + : QListWidgetItem(label, pParent){}; + KviTalListWidget* listWidget() { return (KviTalListWidget*) QListWidgetItem::listWidget(); }; + virtual ~KviTalListWidgetItem() {}; + +}; + +class KVILIB_API KviTalListWidgetText : public KviTalListWidgetItem +{ +public: + KviTalListWidgetText(KviTalListWidget* listbox, const QString & text=QString()); + KviTalListWidgetText(const QString & text=QString()); + ~KviTalListWidgetText(); + + int height(const KviTalListWidget *) const; + int width(const KviTalListWidget *) const; + + int rtti() const; + enum { RTTI = 1 }; + +protected: + virtual void paint(QPainter *); + +private: + Q_DISABLE_COPY(KviTalListWidgetText) +}; + + +class KVILIB_API KviTalListWidgetPixmap : public KviTalListWidgetItem +{ +public: + KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap &); + KviTalListWidgetPixmap(const QPixmap &); + KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap &, const QString&); + KviTalListWidgetPixmap(const QPixmap &, const QString&); + ~KviTalListWidgetPixmap(); + + const QPixmap *pixmap() const { return ± } + + int height(const KviTalListWidget *) const; + int width(const KviTalListWidget *) const; + + int rtti() const; + enum { RTTI = 2 }; + +protected: + virtual void paint(QPainter *); + +private: + Q_DISABLE_COPY(KviTalListWidgetPixmap) + QPixmap pm; +}; + +#endif // _KVI_TAL_LISTWIDGET_H_ diff --git a/src/kvilib/tal/KviTalMainWindow.cpp b/src/kvilib/tal/KviTalMainWindow.cpp new file mode 100644 index 000000000..6ffd0f703 --- /dev/null +++ b/src/kvilib/tal/KviTalMainWindow.cpp @@ -0,0 +1,65 @@ +//============================================================================= +// +// File : KviTalMainWindow.coo +// Creation date : Sun Aug 12 2001 04:40:24 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + + +#include "KviTalMainWindow.h" + +#ifdef COMPILE_KDE_SUPPORT + + KviTalMainWindow::KviTalMainWindow(QWidget * pParent, const char * pcName) + : KMainWindow(pParent) + { + //setWindowTitle(pcName); + setObjectName(pcName); + } + +#else + KviTalMainWindow::KviTalMainWindow(QWidget * pParent, const char * pcName) + : QMainWindow(pParent) + { + setObjectName(pcName); + } + +#endif + +KviTalMainWindow::~KviTalMainWindow() +{ +} + +bool KviTalMainWindow::usesBigPixmaps() +{ + return (iconSize().width() > 40); +} + +void KviTalMainWindow::setUsesBigPixmaps(bool bUse) +{ + if(bUse) + setIconSize(QSize(48,48)); + else + setIconSize(QSize(24,24)); +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalMainWindow.moc" +#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalMainWindow.h b/src/kvilib/tal/KviTalMainWindow.h new file mode 100644 index 000000000..a51309320 --- /dev/null +++ b/src/kvilib/tal/KviTalMainWindow.h @@ -0,0 +1,85 @@ +#ifndef _KVI_TAL_MAINWINDOW_H_ +#define _KVI_TAL_MAINWINDOW_H_ +//============================================================================= +// +// File : KviTalMainWindow.h +// Creation date : Sun Aug 12 2001 04:41:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +/** +* \file KviTalMainWindow.h +* \author Szymon Stefanek +* \brief Toolkit Abstraction Layer class +*/ + +#include "kvi_settings.h" + +/** +* \class KviTalMainWindow +* \brief Toolkit Abstraction Layer: mainwindow class +*/ + +#ifdef COMPILE_KDE_SUPPORT + +#include +#include // statusBar() is overridden to return a KStatusBar + +class KVILIB_API KviTalMainWindow : public KMainWindow + +#else + +#include + +class KVILIB_API KviTalMainWindow : public QMainWindow + +#endif +{ + Q_OBJECT +public: + /** + * \brief Constructs the mainwindow object + * \param pParent The parent object + * \param pcName The name of the object + * \return KviTalMainWindow + */ + KviTalMainWindow(QWidget * pParent, const char * pcName); + + /** + * \brief Destroys the mainwindow object + * \return KviTalMainWindow + */ + ~KviTalMainWindow(); +public: + /** + * \brief Returns true if the mainwindow uses big pixmaps + * \return bool + */ + bool usesBigPixmaps(); + + /** + * \brief Sets the use of big pixmaps + * \param bUse Whether to use big pixmaps + * \return void + */ + void setUsesBigPixmaps(bool bUse); +}; + +#endif // _KVI_TAL_MAINWINDOW_H_ diff --git a/src/kvilib/tal/KviTalMenuBar.cpp b/src/kvilib/tal/KviTalMenuBar.cpp new file mode 100644 index 000000000..fd396c676 --- /dev/null +++ b/src/kvilib/tal/KviTalMenuBar.cpp @@ -0,0 +1,51 @@ +//============================================================================= +// +// File : KviTalMenuBar.cpp +// Creation date : Sun Aug 12 06:35:18 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + + +#include "KviTalMenuBar.h" + +#ifdef COMPILE_KDE_SUPPORT + + KviTalMenuBar::KviTalMenuBar(QWidget * pParent, const char * pcName) + : KMenuBar(pParent) + { + setWindowTitle(pcName); + } + +#else + + KviTalMenuBar::KviTalMenuBar(QWidget * pParent, const char * pcName) + : QMenuBar(pParent) + { + } + +#endif + +KviTalMenuBar::~KviTalMenuBar() +{ +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalMenuBar.moc" +#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalMenuBar.h b/src/kvilib/tal/KviTalMenuBar.h new file mode 100644 index 000000000..e845753b1 --- /dev/null +++ b/src/kvilib/tal/KviTalMenuBar.h @@ -0,0 +1,71 @@ +#ifndef _KVI_TAL_MENUBAR_H_ +#define _KVI_TAL_MENUBAR_H_ +//============================================================================= +// +// File : KviTalMenuBar.h +// Creation date : Sun Aug 12 06:35:15 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +/** +* \file KviTalMenuBar.h +* \author Szymon Stefanek +* \brief Toolkit Abstraction Layer class +*/ + +#include "kvi_settings.h" + +/** +* \class KviTalMenuBar +* \brief Toolkit Abstraction Layer: menubar class +*/ + +#ifdef COMPILE_KDE_SUPPORT + +#include + +class KVILIB_API KviTalMenuBar : public KMenuBar + +#else + +#include + +class KVILIB_API KviTalMenuBar : public QMenuBar + +#endif +{ + Q_OBJECT +public: + /** + * \brief Constructs the menubar object + * \param pParent The parent object + * \param pcName The name of the menubar + * \return KviTalMenuBar + */ + KviTalMenuBar(QWidget * pParent, const char * pcName); + + /** + * \brief Destroys the menubar object + */ + ~KviTalMenuBar(); +}; + + +#endif //_KVI_TAL_MENUBAR_H_ diff --git a/src/kvilib/tal/KviTalPopupMenu.cpp b/src/kvilib/tal/KviTalPopupMenu.cpp new file mode 100644 index 000000000..c99aae95b --- /dev/null +++ b/src/kvilib/tal/KviTalPopupMenu.cpp @@ -0,0 +1,215 @@ +//============================================================================= +// +// File : KviTalPopupMenu.cpp +// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalPopupMenu.h" + +#include +#include +#include +#include + +KviTalPopupMenu::KviTalPopupMenu(QWidget * pParent,const QString &szName) +: QMenu(pParent) +{ + connect(this,SIGNAL(triggered(QAction *)),this,SLOT(slottriggered(QAction *))); + setObjectName(szName); + identifier = 0; + +} + +KviTalPopupMenu::~KviTalPopupMenu() +{ + clear(); +} + +QAction * KviTalPopupMenu::getAction(int id) +{ + QAction * a = actionsDict.value(id); + return a ? a : 0; +} + +int KviTalPopupMenu::insertItem(const QString &szText) +{ + QAction * a = addAction(szText); + actionsDict[identifier++] = a; + return identifier-1; +} + +int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText) +{ + QAction * a = addAction(QIcon(pix),szText); + actionsDict[identifier++] = a; + return identifier-1; +} + +int KviTalPopupMenu::insertItem(const QString &szText,int id) +{ + QAction * a = addAction(szText); + actionsDict[id] = a; + return id; +} + +int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText,int id) +{ + QAction * a = addAction(QIcon(pix),szText); + actionsDict[id] = a; + return id; +} + +int KviTalPopupMenu::insertItem(const QString &szText,const QObject * pReceiver,const char * szSlot) +{ + QAction * action = addAction(szText); + + // create a compatible slot + signalMapper[action] = new QSignalMapper(this); + signalMapper[action]->setMapping(action, identifier); + + connect(action, SIGNAL(triggered()), signalMapper[action], SLOT(map())); + connect(signalMapper[action], SIGNAL(mapped(int)), pReceiver, szSlot); + + actionsDict[identifier++]=action; + return identifier-1; +} + +int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText,const QObject * pReceiver,const char * szSlot) +{ + QAction * action = addAction(pix, szText); + + // create a compatible slot + signalMapper[action] = new QSignalMapper(this); + signalMapper[action]->setMapping(action, identifier); + + connect(action, SIGNAL(triggered()), signalMapper[action], SLOT(map())); + connect(signalMapper[action], SIGNAL(mapped(int)), pReceiver, szSlot); + + actionsDict.insert(identifier, action); + actionsDict[identifier++] = action; + return identifier-1; +} + +int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText,QMenu *pMenu) +{ + QAction * a = addMenu(pMenu); + a->setText(szText); + a->setIcon(QIcon(pix)); + actionsDict[identifier++] = a; + return identifier-1; +} + +int KviTalPopupMenu::insertItem(const QString &szText,QMenu *pMenu) +{ + QAction * a = addMenu(pMenu); + a->setText(szText); + actionsDict[identifier++] = a; + return identifier-1; +} + +int KviTalPopupMenu::insertItem(QWidget * pWidget) +{ + QWidgetAction * pAct = new QWidgetAction(this); + pAct->setDefaultWidget(pWidget); + addAction(pAct); + return 0; +} + +void KviTalPopupMenu::setItemChecked(int id,bool check) +{ + QAction * action = actionsDict.value(id); + action->setCheckable(true); + action->setChecked(check); +} + +void KviTalPopupMenu::setItemParameter(int id, int param) +{ + QAction * action = actionsDict.value(id); + + // take care of the slot + if (signalMapper[action]) + { + signalMapper[action]->removeMappings(action); + signalMapper[action]->setMapping(action, param); + } + + QVariant par(param); + if (action) action->setData(par); +} + +int KviTalPopupMenu::itemParameter(int id) +{ + QAction * action = actionsDict.value(id); + if (action) + return action->data().toInt(); + else return 0; +} + +void KviTalPopupMenu::clear() +{ + QMenu::clear(); + identifier = 0; + actionsDict.clear(); + signalMapper.clear(); +} + +QString KviTalPopupMenu::text(int id) +{ + QAction * action = actionsDict.value(id); + return action->text(); +} + +void KviTalPopupMenu::setItemEnabled(int id,bool bFlag) +{ + QAction * action = actionsDict.value(id); + action->setEnabled(bFlag); +} + +int KviTalPopupMenu::insertSeparator() +{ + QAction * a = addSeparator(); + actionsDict[identifier++] = a; + return -1; +} + +void KviTalPopupMenu::slottriggered(QAction * a) +{ + if (signalMapper[a]) return; // When signalmapper is used we don't need this event + + int i = actionsDict.key(a, -1); // See if action exists and get ID + if (i != -1) + { + emit activated(i); + } + + return; +} + +void KviTalPopupMenu::slotActionTriggered(bool) +{ + QAction * action = (QAction *)sender(); + slottriggered(action); +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalPopupMenu.moc" +#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES + diff --git a/src/kvilib/tal/KviTalPopupMenu.h b/src/kvilib/tal/KviTalPopupMenu.h new file mode 100644 index 000000000..e0cedc352 --- /dev/null +++ b/src/kvilib/tal/KviTalPopupMenu.h @@ -0,0 +1,68 @@ +#ifndef _KVI_TAL_POPUPMENU_H_ +#define _KVI_TAL_POPUPMENU_H_ + +//============================================================================= +// +// File : KviTalPopupMenu.h +// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= +#include "kvi_settings.h" +#include "KviQString.h" + +#include +#include +#include + +class KVILIB_API KviTalPopupMenu : public QMenu +{ + Q_OBJECT +protected: + QHash actionsDict; + // We need QSignalMapper to keep slot system for insertItem() + QHash signalMapper; + int identifier; +public: + KviTalPopupMenu(QWidget * pParent=0,const QString &szName = KviQString::Empty); + virtual ~KviTalPopupMenu() ; + int insertItem(const QString &szText); + int insertItem(const QPixmap &pix,const QString &szText); + int insertItem(const QString &szText,int id); + int insertItem(const QPixmap &pix,const QString &szText,int id); + int insertItem(const QString &szText,const QObject * pReceiver,const char * szSlot); + int insertItem(const QPixmap &pix,const QString &szText,const QObject * pReceiver,const char * szSlot); + int insertItem(const QPixmap &pix,const QString &szText,QMenu *pMenu); + int insertItem(const QString &szText,QMenu *pMenu); + int insertItem(QWidget * pWidget); + void setItemChecked(int id,bool check); + void setItemEnabled(int id,bool bFlag); + void setItemParameter(int id, int param); + int itemParameter(int id); + QAction * getAction(int id); + void clear(); + QString text(int); + int insertSeparator(); +protected slots: + void slottriggered(QAction *); + void slotActionTriggered(bool); +signals: + void activated(int); +}; +#endif // _KVI_TAL_POPUPMENU_H_ diff --git a/src/kvilib/tal/KviTalSplitter.cpp b/src/kvilib/tal/KviTalSplitter.cpp new file mode 100644 index 000000000..48cd0a83a --- /dev/null +++ b/src/kvilib/tal/KviTalSplitter.cpp @@ -0,0 +1,25 @@ +//============================================================================= +// +// File : KviTalSplitter.cpp +// Creation date : Mon Aug 31 2009 19:47:08 by Fabio Bas +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2009 Fabio Bas (ctrlaltca at libero dot it) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalSplitter.h" diff --git a/src/kvilib/tal/KviTalSplitter.h b/src/kvilib/tal/KviTalSplitter.h new file mode 100644 index 000000000..945f055ee --- /dev/null +++ b/src/kvilib/tal/KviTalSplitter.h @@ -0,0 +1,37 @@ +#ifndef _KVI_TAL_SPLITTER_H_ +#define _KVI_TAL_SPLITTER_H_ + +//============================================================================= +// +// File : KviTalSplitter.cpp +// Creation date : Mon Aug 31 2009 19:47:08 by Fabio Bas +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2009 Fabio Bas (ctrlaltca at libero dot it) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +/** +* \file KviTalSplitter.h +* \author fabio bas +* \brief Class used to workaround unwanted behaviours in QSplitter +*/ + +#include +#define KviTalSplitter QSplitter + +#endif // _KVI_TAL_SPLITTER_H_ diff --git a/src/kvilib/tal/KviTalTabDialog.cpp b/src/kvilib/tal/KviTalTabDialog.cpp new file mode 100644 index 000000000..566768d14 --- /dev/null +++ b/src/kvilib/tal/KviTalTabDialog.cpp @@ -0,0 +1,82 @@ +//============================================================================= +// +// File : KviTalTabDialog.cpp +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalTabDialog.h" + +#include +#include +#include +#include + +KviTalTabDialog::KviTalTabDialog(QWidget * pParent,const char * name,bool bModal) +: QDialog(pParent) +{ + setObjectName(name); + setModal(bModal); + + m_pLayout = new QGridLayout(this); + m_pLayout->setColumnStretch(0,10); + setLayout(m_pLayout); + + m_pTabWidget = new QTabWidget(this); + m_pLayout->addWidget(m_pTabWidget,0,0,1,3); +} + +KviTalTabDialog::~KviTalTabDialog() +{ +} + +void KviTalTabDialog::addTab(QWidget * widget, const QString & label) +{ + m_pTabWidget->addTab(widget,label); +} + +void KviTalTabDialog::setOkButton(const QString & text) +{ + QPushButton * pBtnOk = new QPushButton(text,this); + m_pLayout->addWidget(pBtnOk,1,1); + connect(pBtnOk,SIGNAL(clicked()),this,SLOT(okPressed())); +} + +void KviTalTabDialog::setCancelButton(const QString & text) +{ + QPushButton * pBtnCancel = new QPushButton(text,this); + m_pLayout->addWidget(pBtnCancel,1,2); + connect(pBtnCancel,SIGNAL(clicked()),this,SLOT(cancelPressed())); +} + +void KviTalTabDialog::okPressed() +{ + emit applyButtonPressed(); +} + +void KviTalTabDialog::cancelPressed() +{ + emit cancelButtonPressed(); +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalTabDialog.moc" +#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalTabDialog.h b/src/kvilib/tal/KviTalTabDialog.h new file mode 100644 index 000000000..de8302649 --- /dev/null +++ b/src/kvilib/tal/KviTalTabDialog.h @@ -0,0 +1,57 @@ +#ifndef _KVI_TAL_TABDIALOG_H_ +#define _KVI_TAL_TABDIALOG_H_ + +//============================================================================= +// +// File : KviTalTabDialog.h +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include + +class QGridLayout; +class QTabWidget; + +class KVILIB_API KviTalTabDialog : public QDialog +{ + Q_OBJECT +public: + KviTalTabDialog(QWidget * pParent = 0,const char * name = 0,bool bModal = false); + ~KviTalTabDialog(); +protected: + void setOkButton(const QString &); + void setCancelButton(const QString &); + void addTab(QWidget *,const QString &); +protected slots: + void okPressed(); + void cancelPressed(); +private: + QGridLayout * m_pLayout; + QTabWidget * m_pTabWidget; +signals: + void applyButtonPressed(); + void cancelButtonPressed(); +}; + +#endif // _KVI_TAL_TABDIALOG_H_ diff --git a/src/kvilib/tal/KviTalTableWidget.cpp b/src/kvilib/tal/KviTalTableWidget.cpp new file mode 100644 index 000000000..1c107c043 --- /dev/null +++ b/src/kvilib/tal/KviTalTableWidget.cpp @@ -0,0 +1,101 @@ +//============================================================================= +// +// File : KviTalTableWidget.cpp +// Creation date : Fri Jun 27 2008 10:00:08 by Fabio Bas +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2008 Fabio Bas (ctrlaltca at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + + +#include "KviTalTableWidget.h" +/* +#include "KviPointerHashTable.h" + +#include +#include +#include +#include +#include +#include +#include +*/ +KviTalTableWidget::KviTalTableWidget(QWidget * pParent) +: QTableWidget(pParent) +{ +/* + connect(this,SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),this,SLOT(redirect_currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *))); + connect(this,SIGNAL(itemActivated(QTreeWidgetItem *,int)),this,SLOT(redirect_itemActivated(QTreeWidgetItem *,int))); + connect(this,SIGNAL(itemChanged(QTreeWidgetItem *,int)),this,SLOT(redirect_itemChanged(QTreeWidgetItem *,int))); + connect(this,SIGNAL(itemClicked(QTreeWidgetItem *,int)),this,SLOT(redirect_itemClicked(QTreeWidgetItem *,int))); + connect(this,SIGNAL(itemCollapsed(QTreeWidgetItem *)),this,SLOT(redirect_itemCollapsed(QTreeWidgetItem *))); + connect(this,SIGNAL(itemExpanded(QTreeWidgetItem *)),this,SLOT(redirect_itemExpanded(QTreeWidgetItem *))); + connect(this,SIGNAL(itemDoubleClicked(QTreeWidgetItem *,int)),this,SLOT(redirect_itemDoubleClicked(QTreeWidgetItem *,int))); + connect(this,SIGNAL(itemEntered(QTreeWidgetItem *,int)),this,SLOT(redirect_itemEntered(QTreeWidgetItem *,int))); + connect(this,SIGNAL(itemPressed(QTreeWidgetItem *,int)),this,SLOT(redirect_itemPressed(QTreeWidgetItem *,int))); +*/ +} +/* +void KviTalTreeWidget::redirect_currentItemChanged(QTreeWidgetItem *pItemCurr,QTreeWidgetItem *pItemPrev) +{ + emit currentItemChanged((KviTalTreeWidgetItem *)pItemCurr,(KviTalTreeWidgetItem *)pItemPrev); +} + +void KviTalTreeWidget::redirect_itemActivated(QTreeWidgetItem *pItem,int col) +{ + emit itemActivated((KviTalTreeWidgetItem *)pItem,col); +} + +void KviTalTreeWidget::redirect_itemChanged(QTreeWidgetItem *pItem,int col) +{ + emit itemChanged((KviTalTreeWidgetItem *)pItem,col); +} + + +void KviTalTreeWidget::redirect_itemClicked(QTreeWidgetItem *pItem,int col) +{ + emit itemClicked((KviTalTreeWidgetItem *)pItem,col); +} + +void KviTalTreeWidget::redirect_itemCollapsed(QTreeWidgetItem *pItem) +{ + emit itemCollapsed((KviTalTreeWidgetItem *)pItem); +} + +void KviTalTreeWidget::redirect_itemExpanded(QTreeWidgetItem *pItem) +{ + emit itemExpanded((KviTalTreeWidgetItem *)pItem); +} + +void KviTalTreeWidget::redirect_itemDoubleClicked(QTreeWidgetItem *pItem,int col) +{ + emit itemDoubleClicked((KviTalTreeWidgetItem *)pItem,col); +} + +void KviTalTreeWidget::redirect_itemEntered(QTreeWidgetItem *pItem,int col) +{ + emit itemEntered((KviTalTreeWidgetItem *)pItem,col); +} +void KviTalTreeWidget::redirect_itemPressed(QTreeWidgetItem *pItem,int col) +{ + emit itemPressed((KviTalTreeWidgetItem *)pItem,col); +} +*/ +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalTableWidget.moc" +#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalTableWidget.h b/src/kvilib/tal/KviTalTableWidget.h new file mode 100644 index 000000000..11956101c --- /dev/null +++ b/src/kvilib/tal/KviTalTableWidget.h @@ -0,0 +1,81 @@ +#ifndef _KVI_TAL_TABLEWIDGET_H_ +#define _KVI_TAL_TABLEWIDGET_H_ + +//============================================================================= +// +// File : KviTalTableWidget.h +// Creation date : Fri Jun 27 2008 10:00:08 by Fabio Bas +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2008 Fabio Bas (ctrlaltca at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" +#include "KviQString.h" + +#include +#include + +class KviTalTableWidgetItem; + +class KVILIB_API KviTalTableWidget : public QTableWidget +{ + friend class KviTalTableWidgetItem; + Q_OBJECT +public: + KviTalTableWidget(QWidget * pParent); + virtual ~KviTalTableWidget() {}; +public: +}; + + +class KVILIB_API KviTalTableWidgetItem : public QTableWidgetItem +{ +public: + KviTalTableWidgetItem(KviTalTableWidget * pParent) + : QTableWidgetItem() + { + pParent->insertRow(pParent->rowCount()); + pParent->setItem(pParent->rowCount()-1, 0, this); + }; + + KviTalTableWidgetItem(KviTalTableWidget * pParent, int row, int column) + : QTableWidgetItem() + { + pParent->setItem(row, column, this); + }; + + KviTalTableWidgetItem(const KviTalTableWidgetItem & other) + : QTableWidgetItem(other) {}; +}; + +class KVILIB_API KviTalTableWidgetItemEx : public KviTalTableWidgetItem +{ +public: + KviTalTableWidgetItemEx(KviTalTableWidget * pParent) + : KviTalTableWidgetItem(pParent) {}; + + KviTalTableWidgetItemEx(KviTalTableWidget * pParent, int row, int column) + : KviTalTableWidgetItem(pParent, row, column) {}; + + KviTalTableWidgetItemEx(const KviTalTableWidgetItem & other) + : KviTalTableWidgetItem(other) {}; + virtual void displayUpdate() = 0; +}; + +#endif // _KVI_TAL_TABLEWIDGET_H_ diff --git a/src/kvilib/tal/KviTalToolBar.cpp b/src/kvilib/tal/KviTalToolBar.cpp new file mode 100644 index 000000000..98c2895bd --- /dev/null +++ b/src/kvilib/tal/KviTalToolBar.cpp @@ -0,0 +1,86 @@ +//============================================================================= +// +// File : KviTalToolBar.cpp +// Creation date : Mon Aug 13 05:05:45 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalToolBar.h" + +#ifdef COMPILE_KDE_SUPPORT + KviTalToolBar::KviTalToolBar(const QString & szLabel, QMainWindow * pWnd, Qt::ToolBarArea type, bool bNewLine, const char * pcName) + : KToolBar(pcName,pWnd,type,bNewLine) + { + setWindowTitle(szLabel); + //toolbars are locked by default + setToolBarsLocked(false); + } +#else + KviTalToolBar::KviTalToolBar(const QString & szLabel, QMainWindow * pWnd, Qt::ToolBarArea type, bool bNewLine, const char * pcName) + : QToolBar(szLabel,pWnd) + { + //setFrameStyle(QFrame::NoFrame); + setObjectName(pcName); + if(!layout()) + this->setLayout(new QBoxLayout(QBoxLayout::LeftToRight)); + pWnd->addToolBar(type,this); + } + + KviTalToolBar::KviTalToolBar(QMainWindow * pWnd, const char * pcName) + : QToolBar(pWnd) + { + //setFrameStyle(QFrame::NoFrame); + setObjectName(pcName); + if(!layout()) + this->setLayout(new QBoxLayout(QBoxLayout::LeftToRight)); + pWnd->addToolBar(this); + } + + QBoxLayout * KviTalToolBar::boxLayout() + { + return (QBoxLayout*)this->layout(); + } + + void KviTalToolBar::setBoxLayout(QBoxLayout * pLayout) + { + this->setLayout(pLayout); + } +#endif // COMPILE_KDE_SUPPORT + + bool KviTalToolBar::usesBigPixmaps() + { + return (iconSize().width() > 40); + } + + void KviTalToolBar::setUsesBigPixmaps(bool bUse) + { + if(bUse) + setIconSize(QSize(48,48)); + else + setIconSize(QSize(22,22)); + } + +KviTalToolBar::~KviTalToolBar() +{ +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalToolBar.moc" +#endif // COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalToolBar.h b/src/kvilib/tal/KviTalToolBar.h new file mode 100644 index 000000000..e59af5179 --- /dev/null +++ b/src/kvilib/tal/KviTalToolBar.h @@ -0,0 +1,112 @@ +#ifndef _KVI_TAL_TOOLBAR_H_ +#define _KVI_TAL_TOOLBAR_H_ +//============================================================================= +// +// File : KviTalToolBar.h +// Creation date : Mon Aug 13 05:05:44 2001 GMT by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) +// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +/** +* \file KviTalToolBar.h +* \author Szymon Stefanek +* \brief Toolkit Abstraction Layer class +*/ + +#include "kvi_settings.h" + +/** +* \class KviTalToolBar +* \brief Toolkit Abstraction Layer: toolbar class +*/ + +#ifdef COMPILE_KDE_SUPPORT + +#include + +class KVILIB_API KviTalToolBar : public KToolBar + +#else // COMPILE_KDE_SUPPORT + +#include +#include +#include + +class KVILIB_API KviTalToolBar : public QToolBar + +#endif // COMPILE_KDE_SUPPORT + +{ + Q_OBJECT +public: + /** + * \brief Constructs a toolbar object + * \param szLabel The label of the toolbar + * \param pWnd The mainwindow where to attach the toolbar + * \param type The type of the toolbar + * \param bNewLine Whether to add a newline + * \param pcName The name of the toolbar + * \return KviTalToolBar + */ + KviTalToolBar(const QString & szLabel, QMainWindow * pWnd, Qt::ToolBarArea type = Qt::TopToolBarArea, bool bNewLine = false, const char * pcName = 0); + + /** + * \brief Destroys a toolbar object + */ + ~KviTalToolBar(); +#ifndef COMPILE_KDE_SUPPORT +public: + /** + * \brief Constructs a toolbar object + * \param pWnd The mainwindow where to attach the toolbar + * \param pcName The name of the toolbar + * \return KviTalToolBar + */ + KviTalToolBar(QMainWindow * pWnd, const char * pcName = 0); +public: + /** + * \brief Returns the box layout object + * \return QBoxLayout * + */ + QBoxLayout * boxLayout(); + + /** + * \brief Sets the box layout + * \param pLayout The box layout + * \return void + */ + void setBoxLayout(QBoxLayout * pLayout); +#endif // COMPILE_KDE_SUPPORT + /** + * \brief Returns true if the toolbar uses big pixmaps + * \return bool + */ + bool usesBigPixmaps(); + + /** + * \brief Sets the use of big pixmaps + * \param bUse Whether to use big pixmaps + * \return void + */ + void setUsesBigPixmaps(bool bUse); +}; + +#endif //_KVI_TAL_TOOLBAR_H_ diff --git a/src/kvilib/tal/KviTalToolTip.cpp b/src/kvilib/tal/KviTalToolTip.cpp new file mode 100644 index 000000000..86f740d06 --- /dev/null +++ b/src/kvilib/tal/KviTalToolTip.cpp @@ -0,0 +1,112 @@ +//============================================================================= +// +// File : KviTalToolTip.cpp +// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalToolTip.h" + +#include +#include + +KviTalToolTipHelper::KviTalToolTipHelper(KviTalToolTip * pToolTip,QWidget * pWidget) +: QObject(pWidget) +{ + m_pToolTip = pToolTip; + pWidget->installEventFilter(this); +} + +KviTalToolTipHelper::~KviTalToolTipHelper() +{ + if(m_pToolTip) + { + m_pToolTip->helperDying(); + delete m_pToolTip; + } +} + +void KviTalToolTipHelper::toolTipDying() +{ + m_pToolTip = 0; +} + +bool KviTalToolTipHelper::eventFilter(QObject *,QEvent * pEvent) +{ + if((pEvent->type() == QEvent::ToolTip) && m_pToolTip) + { +// qDebug("TOOL TIP EVENT WITH POSITION %d,%d",((QHelpEvent *)pEvent)->pos().x(),((QHelpEvent *)pEvent)->pos().y()); + m_pToolTip->maybeTip(((QHelpEvent *)pEvent)->pos()); + return true; + } + return false; +} + + +KviTalToolTip::KviTalToolTip(QWidget * pParent) +{ + m_pHelper = new KviTalToolTipHelper(this,pParent); + m_pParent = pParent; +} + +KviTalToolTip::~KviTalToolTip() +{ + if(m_pHelper) + { + m_pHelper->toolTipDying(); + delete m_pHelper; + } +} + +void KviTalToolTip::helperDying() +{ + m_pHelper = 0; +} + +void KviTalToolTip::add(QWidget * widget,const QString & text) +{ + widget->setToolTip(text); +} + +void KviTalToolTip::remove(QWidget *widget) +{ + + widget->setToolTip(""); +} + +void KviTalToolTip::tip(const QRect & rect,const QString & text) +{ +// qDebug("TOOL TIP AT %d,%d",rect.topLeft().x(),rect.topLeft().y()); + QPoint pnt=m_pParent->mapToGlobal(rect.topLeft()); + pnt.setX(pnt.x()+16); + pnt.setY(pnt.y()+16); + QToolTip::showText(m_pParent->mapToGlobal(rect.topLeft()),text, m_pParent, rect); +} + +void KviTalToolTip::maybeTip(const QPoint &) +{ + // does nothing here.. +} + +#ifndef COMPILE_ON_WINDOWS + #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalToolTip.moc" + #endif //!COMPILE_USE_STANDALONE_MOC_SOURCES +#endif diff --git a/src/kvilib/tal/KviTalToolTip.h b/src/kvilib/tal/KviTalToolTip.h new file mode 100644 index 000000000..a07e9d02f --- /dev/null +++ b/src/kvilib/tal/KviTalToolTip.h @@ -0,0 +1,70 @@ +#ifndef _KVI_TAL_TOOLTIP_H_ +#define _KVI_TAL_TOOLTIP_H_ + +//============================================================================= +// +// File : KviTalToolTip.h +// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include +#include + +class KviTalToolTip; + +// This is useful only with Qt4, but we put it here anyway +// to have both a consistent API and make moc happy +class KviTalToolTipHelper : public QObject +{ + friend class KviTalToolTip; + Q_OBJECT +public: + KviTalToolTipHelper(KviTalToolTip * pToolTip,QWidget * pWidget); + ~KviTalToolTipHelper(); +protected: + KviTalToolTip * m_pToolTip; +protected: + virtual bool eventFilter(QObject * pObject,QEvent * pEvent); + void toolTipDying(); +}; + + +class KVILIB_API KviTalToolTip +{ + friend class KviTalToolTipHelper; +public: + KviTalToolTip(QWidget * pParent); + virtual ~KviTalToolTip(); +protected: + KviTalToolTipHelper * m_pHelper; + QWidget * m_pParent; +public: + static void add(QWidget * widget,const QString & text); + static void remove(QWidget * widget); + virtual void tip(const QRect & rect,const QString & text); +protected: + virtual void maybeTip(const QPoint & p); + void helperDying(); +}; + +#endif // _KVI_TAL_TOOLTIP_H_ diff --git a/src/kvilib/tal/KviTalVBox.cpp b/src/kvilib/tal/KviTalVBox.cpp new file mode 100644 index 000000000..986ea158a --- /dev/null +++ b/src/kvilib/tal/KviTalVBox.cpp @@ -0,0 +1,98 @@ +//============================================================================= +// +// File : KviTalVBox.cpp +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalVBox.h" + +#include + +KviTalVBox::KviTalVBox(QWidget * pParent, char * pcName) +: QWidget(pParent) +{ + setObjectName(pcName); + + m_pLayout = new QVBoxLayout(this); + m_pLayout->setMargin(3); + m_pLayout->setSpacing(2); + + setLayout(m_pLayout); +} + +KviTalVBox::~KviTalVBox() +{ +} + +void KviTalVBox::childEvent(QChildEvent * e) +{ + if(!e->child()->isWidgetType()) + return; + if(e->child()->parent() != this) + return; + + switch(e->type()) + { + case QEvent::ChildAdded: + m_pLayout->addWidget((QWidget *)(e->child())); + break; + case QEvent::ChildRemoved: + m_pLayout->removeWidget((QWidget *)(e->child())); + break; + default: + break; + } +} + +void KviTalVBox::setStretchFactor(QWidget * pChild, int iStretch) +{ + m_pLayout->setStretchFactor(pChild,iStretch); +} + +void KviTalVBox::setSpacing(int iSpacing) +{ + m_pLayout->setSpacing(iSpacing); +} + +void KviTalVBox::addStretch(int iStretch) +{ + m_pLayout->addStretch(iStretch); +} + +void KviTalVBox::setMargin(int iMargin) +{ + m_pLayout->setContentsMargins(iMargin,iMargin,iMargin,iMargin); +} + +void KviTalVBox::setAlignment(Qt::Alignment alignment) +{ + m_pLayout->setAlignment(alignment); +} + +void KviTalVBox::setAlignment(QWidget * pChild, Qt::Alignment alignment) +{ + m_pLayout->setAlignment(pChild,alignment); +} + +#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalVBox.moc" +#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/KviTalVBox.h b/src/kvilib/tal/KviTalVBox.h new file mode 100644 index 000000000..b7f92c485 --- /dev/null +++ b/src/kvilib/tal/KviTalVBox.h @@ -0,0 +1,110 @@ +#ifndef _KVI_TAL_VBOX_H_ +#define _KVI_TAL_VBOX_H_ + +//============================================================================= +// +// File : KviTalVBox.h +// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) +// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) +// +// 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 opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +/** +* \file KviTalVBox.h +* \author Szymon Stefanek +* \brief Class for vertical box +*/ + +#include "kvi_settings.h" + +#include +#include + +/** +* \class KviTalVBox +* \brief Toolkit Abstraction Layer: vbox class +*/ +class KVILIB_API KviTalVBox : public QWidget +{ + Q_OBJECT +public: + /** + * \brief Constructs a vertical box object + * \param pParent The parent object + * \param pcName The name of the box + * \return KviTalVBox + */ + KviTalVBox(QWidget * pParent, char * pcName = 0); + + /** + * \brief Destroys a vertical box object + */ + ~KviTalVBox(); +private: + QVBoxLayout * m_pLayout; +public: + /** + * \brief Sets the stretch factor for an object + * \param pChild The object to stretch + * \param iStretch The stretch factor to use + * \return void + */ + void setStretchFactor(QWidget * pChild, int iStretch); + + /** + * \brief Sets the spacing of the box + * \param iSpacing The space in pixels + * \return void + */ + void setSpacing(int iSpacing); + + /** + * \brief Sets the margin of the box + * \param iMargin The margin in pixels + * \return void + */ + void setMargin(int iMargin); + + /** + * \brief Sets the alignment of the box + * \param alignment The alignment + * \return void + */ + void setAlignment(Qt::Alignment alignment); + + /** + * \brief Sets the alignment of the box for a child object + * \param pChild The object to align + * \param alignment The alignment + * \return void + */ + void setAlignment(QWidget * pChild, Qt::Alignment alignment); + + /** + * \brief Adds the stretch factor + * \param iStretch The stretch factor + * \return void + */ + void addStretch(int iStretch); +protected: + virtual void childEvent(QChildEvent * e); +}; + +#endif // _KVI_TAL_VBOX_H_ diff --git a/src/kvilib/tal/KviTalWizard.cpp b/src/kvilib/tal/KviTalWizard.cpp new file mode 100644 index 000000000..6ef6e9d12 --- /dev/null +++ b/src/kvilib/tal/KviTalWizard.cpp @@ -0,0 +1,540 @@ +//============================================================================= +// +// File : KviTalWizard.cpp +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviTalWizard.h" +#include "KviTalHBox.h" +#include "KviPointerList.h" +#include "KviLocale.h" + +#include +#include +#include +#include +#include +#include +#include + + +class KviTalWizardPageData +{ +public: + enum EnableFlags + { + EnableNext = 1, + EnableBack = 2, + EnableHelp = 4, + EnableCancel = 8, + EnableFinish = 16 + }; +public: + QWidget * pWidget; + QString szTitle; + bool bEnabled; + int iEnableFlags; + int iVisibleIndex; +}; + +class KviTalWizardPrivate +{ +public: + KviPointerList * pPageList; + int iEnabledPageCount; + KviTalWizardPageData * pCurrentPage; + QGridLayout * pLayout; + QLabel * pTitleLabel; + QLabel * pStepsLabel; + QPushButton * pBackButton; + QPushButton * pCancelButton; + QPushButton * pHelpButton; + QPushButton * pNextButton; + QWidget * pNextSpacer; + QPushButton * pFinishButton; + QWidget * pFinishSpacer; + QStackedWidget * pWidgetStack; +public: + KviTalWizardPageData * findPage(QWidget * pWidget) + { + for(KviTalWizardPageData * pData = pPageList->first();pData;pData = pPageList->next()) + { + if(pData->pWidget == pWidget) return pData; + } + return NULL; + } + + KviTalWizardPageData * findFirstEnabledPage() + { + KviTalWizardPageData * pData; + for(pData = pPageList->first();pData;pData = pPageList->next()) + { + if(pData->bEnabled) return pData; + } + return NULL; + } + + KviTalWizardPageData * findLastEnabledPage() + { + KviTalWizardPageData * pData; + for(pData = pPageList->last();pData;pData = pPageList->prev()) + { + if(pData->bEnabled) return pData; + } + return NULL; + } + + KviTalWizardPageData * findNextEnabledPage(QWidget * pReference) + { + if(!pReference) return findFirstEnabledPage(); + KviTalWizardPageData * pData = findPage(pReference); + if(!pData) return NULL; + for(pData = pPageList->next();pData;pData = pPageList->next()) + { + if(pData->bEnabled) return pData; + } + return NULL; + } + + KviTalWizardPageData * findPrevEnabledPage(QWidget * pReference) + { + if(!pReference) return findLastEnabledPage(); + KviTalWizardPageData * pData = findPage(pReference); + if(!pData) return NULL; + for(pData = pPageList->prev();pData;pData = pPageList->prev()) + { + if(pData->bEnabled) return pData; + } + return NULL; + } + + int reindexPages() + { + int iEnabledCount = 0; + for(KviTalWizardPageData * pData = pPageList->first();pData;pData = pPageList->next()) + { + if(pData->bEnabled) + { + iEnabledCount++; + pData->iVisibleIndex = iEnabledCount; + } + } + return iEnabledCount; + } +}; + + +KviTalWizard::KviTalWizard(QWidget * pParent) +: QDialog(pParent) +{ + m_p = new KviTalWizardPrivate; + m_p->pPageList = new KviPointerList; + m_p->pPageList->setAutoDelete(true); + m_p->pCurrentPage = NULL; + m_p->iEnabledPageCount = 0; + m_p->pLayout = new QGridLayout(this); + + m_p->pTitleLabel = new QLabel(this); + m_p->pLayout->addWidget(m_p->pTitleLabel,0,0,1,3); + + m_p->pStepsLabel = new QLabel(this); + m_p->pStepsLabel->setMinimumWidth(80); + m_p->pStepsLabel->setAlignment(Qt::AlignRight); + m_p->pLayout->addWidget(m_p->pStepsLabel,0,4,1,3); + + QFrame * f1 = new QFrame(this); + f1->setFrameStyle(QFrame::Sunken | QFrame::HLine); + m_p->pLayout->addWidget(f1,1,0,1,7); + + m_p->pWidgetStack = new QStackedWidget(this); + m_p->pLayout->addWidget(m_p->pWidgetStack,2,0,1,7); + + QFrame * f2 = new QFrame(this); + f2->setFrameStyle(QFrame::Sunken | QFrame::HLine); + m_p->pLayout->addWidget(f2,3,0,1,7); + + KviTalHBox * pButtonBox = new KviTalHBox(this); + m_p->pLayout->addWidget(pButtonBox,4,0,1,7); + + pButtonBox->setMargin(0); + pButtonBox->setSpacing(0); + + + m_p->pCancelButton = new QPushButton(__tr("Cancel"),pButtonBox); + m_p->pCancelButton->setMinimumWidth(80); + QObject::connect( + m_p->pCancelButton, + SIGNAL(clicked()), + this, + SLOT(cancelButtonClicked()) + ); + + QWidget * pSpacer = new QWidget(pButtonBox); + pSpacer->setFixedWidth(4); + + m_p->pHelpButton = new QPushButton(__tr("Help"),pButtonBox); + m_p->pHelpButton->setMinimumWidth(80); + QObject::connect( + m_p->pHelpButton, + SIGNAL(clicked()), + this, + SLOT(helpButtonClicked()) + ); + + QWidget * pLargeSpacer = new QWidget(pButtonBox); + pLargeSpacer->setMinimumWidth(50); + pButtonBox->setStretchFactor(pLargeSpacer,100); + + QString szText = "< "; + szText += __tr("Back"); + m_p->pBackButton = new QPushButton(szText,pButtonBox); + m_p->pBackButton->setMinimumWidth(80); + QObject::connect( + m_p->pBackButton, + SIGNAL(clicked()), + this, + SLOT(backButtonClicked()) + ); + + m_p->pNextSpacer = new QWidget(pButtonBox); + m_p->pNextSpacer->setFixedWidth(4); + + szText = __tr("Next"); + szText += " >"; + m_p->pNextButton = new QPushButton(szText,pButtonBox); + m_p->pNextButton->setMinimumWidth(80); + QObject::connect( + m_p->pNextButton, + SIGNAL(clicked()), + this, + SLOT(nextButtonClicked()) + ); + + m_p->pFinishSpacer = new QWidget(pButtonBox); + m_p->pFinishSpacer->setFixedWidth(4); + + m_p->pFinishButton = new QPushButton(__tr("Finish"),pButtonBox); + m_p->pFinishButton->setMinimumWidth(80); + QObject::connect( + m_p->pFinishButton, + SIGNAL(clicked()), + this, + SLOT(finishButtonClicked()) + ); + + m_p->pLayout->setMargin(8); + m_p->pLayout->setSpacing(4); + m_p->pLayout->setRowStretch(2,1); + m_p->pLayout->setColumnStretch(0,1); +} + +KviTalWizard::~KviTalWizard() +{ + delete m_p->pPageList; + delete m_p; +} + +void KviTalWizard::insertPage(QWidget * pWidget,const QString &szTitle,int iIndex) +{ + KviTalWizardPageData * pPageData = m_p->findPage(pWidget); + if(!pPageData) + { + pPageData = new KviTalWizardPageData; + pPageData->pWidget = pWidget; + pPageData->iEnableFlags = \ + KviTalWizardPageData::EnableNext | \ + KviTalWizardPageData::EnableCancel | \ + KviTalWizardPageData::EnableBack; + if(iIndex < 0) + { + m_p->pPageList->append(pPageData); + m_p->iEnabledPageCount++; + pPageData->iVisibleIndex = m_p->iEnabledPageCount; + } else { + m_p->pPageList->insert(iIndex,pPageData); + m_p->iEnabledPageCount = m_p->reindexPages(); + } + m_p->pWidgetStack->addWidget(pWidget); + } + pPageData->szTitle = szTitle; + pPageData->bEnabled = true; + +} + +void KviTalWizard::addPage(QWidget * pWidget,const QString &szTitle) +{ + insertPage(pWidget,szTitle,-1); +} + +bool KviTalWizard::setPageEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return false; + pData->bEnabled = bEnabled; + m_p->iEnabledPageCount = m_p->reindexPages(); + setCurrentPage(m_p->pCurrentPage); + return true; +} + +bool KviTalWizard::setPageTitle(QWidget * pWidget,const QString &szTitle) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return false; + pData->szTitle = szTitle; + return true; +} + +bool KviTalWizard::setCurrentPage(QWidget * pWidget) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return false; + setCurrentPage(pData); + return true; +} + +QWidget * KviTalWizard::currentPage() +{ + if(!m_p->pCurrentPage) + return NULL; + return m_p->pCurrentPage->pWidget; +} + +void KviTalWizard::setCurrentPage(KviTalWizardPageData * pData) +{ + m_p->pCurrentPage = pData; + + bool bCancelEnabled = true; + bool bNextEnabled = false; + bool bBackEnabled = false; + bool bHelpEnabled = false; + bool bFinishEnabled = false; + + QString szTitle; + QString szSteps; + + if(pData) + { + bNextEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableNext) && m_p->findNextEnabledPage(pData->pWidget); + bBackEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableBack) && m_p->findPrevEnabledPage(pData->pWidget); + bCancelEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableCancel); + bFinishEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableFinish); + bHelpEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableHelp); + m_p->pWidgetStack->setCurrentWidget(pData->pWidget); + + szTitle = ""; + szTitle += pData->szTitle; + szTitle += ""; + QPalette pal = m_p->pStepsLabel->palette(); + QColor clrWin = pal.color(QPalette::Normal,QPalette::Window); + QColor clrTxt = pal.color(QPalette::Normal,QPalette::WindowText); + QColor clrMid = qRgb( + (clrWin.red() + clrTxt.red()) / 2, + (clrWin.green() + clrTxt.green()) / 2, + (clrWin.blue() + clrTxt.blue()) / 2 + ); + + szSteps = "["; + szSteps += QString("Step %1 of %2").arg(pData->iVisibleIndex).arg(m_p->iEnabledPageCount); + szSteps += "]"; + } + + m_p->pTitleLabel->setText(szTitle); + m_p->pStepsLabel->setText(szSteps); + + m_p->pNextButton->setEnabled(bNextEnabled); + if(bNextEnabled) + { + m_p->pNextButton->show(); + m_p->pNextSpacer->show(); + m_p->pNextButton->setDefault(true); + } else { + m_p->pNextButton->hide(); + m_p->pNextSpacer->hide(); + m_p->pNextButton->setDefault(false); + } + m_p->pBackButton->setEnabled(bBackEnabled); + m_p->pHelpButton->setEnabled(bHelpEnabled); + if(bHelpEnabled) + m_p->pHelpButton->show(); + else + m_p->pHelpButton->hide(); + m_p->pCancelButton->setEnabled(bCancelEnabled); + m_p->pFinishButton->setEnabled(bFinishEnabled); + if(bFinishEnabled) + { + m_p->pFinishButton->show(); + m_p->pFinishSpacer->show(); + m_p->pFinishButton->setDefault(true); + } else { + m_p->pFinishButton->hide(); + m_p->pFinishSpacer->hide(); + m_p->pFinishButton->setDefault(false); + } +} + +void KviTalWizard::showEvent(QShowEvent * e) +{ + if(!(m_p->pCurrentPage)) + { + // display the first page + KviTalWizardPageData * pData = m_p->findFirstEnabledPage(); + if(pData) + setCurrentPage(pData->pWidget); + } + QDialog::showEvent(e); + emit pageChanged(m_p->pCurrentPage->szTitle); +} + +void KviTalWizard::closeEvent(QCloseEvent * e) +{ + e->ignore(); + cancelButtonClicked(); +} + +void KviTalWizard::backButtonClicked() +{ + if(!m_p->pCurrentPage) + return; + setCurrentPage(m_p->findPrevEnabledPage(m_p->pCurrentPage->pWidget)); + emit pageChanged(m_p->pCurrentPage->szTitle); +} + +void KviTalWizard::nextButtonClicked() +{ + setCurrentPage(m_p->findNextEnabledPage(m_p->pCurrentPage->pWidget)); + emit pageChanged(m_p->pCurrentPage->szTitle); +} + +void KviTalWizard::helpButtonClicked() +{ + emit helpClicked(); +} + +void KviTalWizard::cancelButtonClicked() +{ + reject(); +} + +void KviTalWizard::finishButtonClicked() +{ + accept(); +} + +void KviTalWizard::setHelpEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return; + if(bEnabled) + pData->iEnableFlags |= KviTalWizardPageData::EnableHelp; + else + pData->iEnableFlags &= ~KviTalWizardPageData::EnableHelp; + if(pData == m_p->pCurrentPage) + setCurrentPage(pData); +} + +void KviTalWizard::setCancelEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return; + if(bEnabled) + pData->iEnableFlags |= KviTalWizardPageData::EnableCancel; + else + pData->iEnableFlags &= ~KviTalWizardPageData::EnableCancel; + if(pData == m_p->pCurrentPage) + setCurrentPage(pData); +} + +void KviTalWizard::setFinishEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return; + if(bEnabled) + pData->iEnableFlags |= KviTalWizardPageData::EnableFinish; + else + pData->iEnableFlags &= ~KviTalWizardPageData::EnableFinish; + if(pData == m_p->pCurrentPage) + setCurrentPage(pData); +} + +void KviTalWizard::setNextEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return; + if(bEnabled) + pData->iEnableFlags |= KviTalWizardPageData::EnableNext; + else + pData->iEnableFlags &= ~KviTalWizardPageData::EnableNext; + if(pData == m_p->pCurrentPage) + setCurrentPage(pData); +} + +void KviTalWizard::setBackEnabled(QWidget * pWidget,bool bEnabled) +{ + KviTalWizardPageData * pData = m_p->findPage(pWidget); + if(!pData) + return; + if(bEnabled) + pData->iEnableFlags |= KviTalWizardPageData::EnableBack; + else + pData->iEnableFlags &= ~KviTalWizardPageData::EnableBack; + if(pData == m_p->pCurrentPage) + setCurrentPage(pData); +} + +QPushButton * KviTalWizard::cancelButton() +{ + return m_p->pCancelButton; +} + +QPushButton * KviTalWizard::helpButton() +{ + return m_p->pHelpButton; +} + +QPushButton * KviTalWizard::finishButton() +{ + return m_p->pFinishButton; +} + +QPushButton * KviTalWizard::nextButton() +{ + return m_p->pNextButton; +} + +QPushButton * KviTalWizard::backButton() +{ + return m_p->pBackButton; +} + +#ifdef COMPILE_ON_WINDOWS + #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES + #include "KviTalWizard.moc" + #endif //!COMPILE_USE_STANDALONE_MOC_SOURCES +#endif diff --git a/src/kvilib/tal/KviTalWizard.h b/src/kvilib/tal/KviTalWizard.h new file mode 100644 index 000000000..df8208d12 --- /dev/null +++ b/src/kvilib/tal/KviTalWizard.h @@ -0,0 +1,168 @@ +#ifndef _KVI_TAL_WIZARD_H_ +#define _KVI_TAL_WIZARD_H_ + +//============================================================================= +// +// File : KviTalWizard.h +// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2007-2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_settings.h" + +#include + + +class QShowEvent; +class QPushButton; +class KviTalWizardPrivate; +class KviTalWizardPageData; + +/// +/// \class KviTalWizard +/// +/// \brief Provides a wizard-style dialog with steps +/// +class KVILIB_API KviTalWizard : public QDialog +{ + Q_OBJECT +public: + KviTalWizard(QWidget * pParent); + ~KviTalWizard(); +protected: + KviTalWizardPrivate * m_p; +public: + /// + /// Adds a page to the wizard with the specified title. + /// The pages are displayed in order they're added. + /// Adding a page a second time is equivalent to calling + /// setPageTitle() and enabling the page. + /// + void addPage(QWidget * pWidget,const QString &szTitle); + /// + /// Adds a page to the wizard with the specified title + /// and in the specified position. + /// Adding a page a second time is equivalent to calling + /// setPageTitle() and enabling the page. + /// + void insertPage(QWidget * pWidget,const QString &szTitle,int iIndex); + /// + /// Enables or disables a page. A disabled page + /// is skipped when the user presses "Next" in the + /// previous page or "Back" in the page after. + /// Disabling the current page has no effect. + /// + /// Returns true on success or false if the pWidget + /// does not identify a page that has been added to this wizard. + /// + bool setPageEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Changes a page title. + /// + /// Returns true on success or false if the pWidget + /// does not identify a page that has been added to this wizard. + /// + bool setPageTitle(QWidget * pWidget,const QString &szTitle); + /// + /// Switches the wizard to the specified page. + /// Please note that this class handles page switching + /// automatically so you usually don't need to call this function. + /// + /// Returns true on success or false if the pWidget + /// does not identify a page that has been added to this wizard. + /// + bool setCurrentPage(QWidget * pWidget); + /// + /// Returns a pointer to the current page + /// + QWidget * currentPage(); + /// + /// Enables or disables the help button for the specified page. + /// By default the help button is always disabled. + /// + void setHelpEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Enables or disables the cancel button for the specified page. + /// By default the cancel button is always enabled. + /// + void setCancelEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Enables or disables the finish button for the specified page. + /// By default the finish button is always disabled. + /// + void setFinishEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Enables or disables the next button for the specified page. + /// By default the next button is always enabled. + /// + void setNextEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Enables or disables the prev button for the specified page. + /// By default the prev button is always enabled. + /// + void setBackEnabled(QWidget * pWidget,bool bEnabled); + /// + /// Returns a pointer to the cancel button displayed in the dialog. + /// + QPushButton * cancelButton(); + /// + /// Returns a pointer to the help button displayed in the dialog. + /// + QPushButton * helpButton(); + /// + /// Returns a pointer to the finish button displayed in the dialog. + /// + QPushButton * finishButton(); + /// + /// Returns a pointer to the next button displayed in the dialog. + /// + QPushButton * nextButton(); + /// + /// Returns a pointer to the back button displayed in the dialog. + /// + QPushButton * backButton(); +signals: + /// + /// Emitted when the help button is clicked. + /// + void helpClicked(); + void pageChanged(QString title); +protected: + /// + /// Displays the first page if no other page is shown yet. + /// + virtual void showEvent(QShowEvent * e); + + /// + /// Handles redirects the close button to the "cancel" operation. + /// + virtual void closeEvent(QCloseEvent * e); +protected: + void setCurrentPage(KviTalWizardPageData * pData); +protected slots: + void backButtonClicked(); + void nextButtonClicked(); + void helpButtonClicked(); + void cancelButtonClicked(); + void finishButtonClicked(); +}; + + +#endif // _KVI_TAL_WIZARD_H_ diff --git a/src/kvilib/tal/kvi_tal_application.cpp b/src/kvilib/tal/kvi_tal_application.cpp deleted file mode 100644 index 5cf1178ae..000000000 --- a/src/kvilib/tal/kvi_tal_application.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_application.cpp -// Creation date : Sun Aug 12 2001 04:34:21 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - - -#include "kvi_tal_application.h" - -#ifdef COMPILE_KDE_SUPPORT - KviTalApplication::KviTalApplication(int &, char **) - : KApplication() - { - } -#else - KviTalApplication::KviTalApplication(int & iArgc, char ** ppcArgv) - : QApplication(iArgc,ppcArgv) - { - } -#endif - -KviTalApplication::~KviTalApplication() -{ -} - -void KviTalApplication::commitData(QSessionManager & manager) -{ - saveConfiguration(); -#ifdef COMPILE_KDE_SUPPORT - KApplication::commitData(manager); -#else - QApplication::commitData(manager); -#endif -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_application.moc" -#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_application.h b/src/kvilib/tal/kvi_tal_application.h deleted file mode 100644 index a915d5b79..000000000 --- a/src/kvilib/tal/kvi_tal_application.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef _KVI_TAL_APPLICATION_H_ -#define _KVI_TAL_APPLICATION_H_ -//============================================================================= -// -// File : kvi_tal_application.h -// Creation date : Sun Jun 18 2000 12:53:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= -// -// This file was originally named kvi_appbase_kde.h, created on 1999 -// -//============================================================================= - -/** -* \file kvi_tal_application.h -* \author Szymon Stefanek -* \brief Toolkit Abstraction Level class -*/ - -#include "kvi_settings.h" - -/** -* \class KviTalApplication -* \brief Toolkit Abstraction Layer: application class -*/ - -#ifdef COMPILE_KDE_SUPPORT - -#include -class KVILIB_API KviTalApplication : public KApplication -#else - -#include -class KVILIB_API KviTalApplication : public QApplication -#endif -{ - Q_OBJECT -public: - /** - * \brief Constructs the application object - * \param iArgc The number of arguments - * \param ppcArgv The arguments list - * \return KviTalApplication - */ - KviTalApplication(int & iArgc, char ** ppcArgv); - - /** - * \brief Destructs the application object - */ - ~KviTalApplication(); - - /** - * \brief Commits the data and save the session - * \param manager The session manager - * \return void - */ - void commitData(QSessionManager & manager); - - /** - * \brief Saves configuration to disk - * \return void - */ - virtual void saveConfiguration() = 0; -}; - -#endif // _KVI_TAL_APPLICATION_H_ diff --git a/src/kvilib/tal/kvi_tal_filedialog.cpp b/src/kvilib/tal/kvi_tal_filedialog.cpp deleted file mode 100644 index 7403e6e60..000000000 --- a/src/kvilib/tal/kvi_tal_filedialog.cpp +++ /dev/null @@ -1,112 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_filedialog.cpp -// Creation date : Thu Sep 11 2003 04:09:24 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2003-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - - - -#include "kvi_tal_filedialog.h" - -#ifdef COMPILE_KDE_SUPPORT - -KviTalFileDialog::KviTalFileDialog(const QString & szDirName, const QString & szFilter, QWidget * pParent, const char *, bool) -: KFileDialog(KUrl(szDirName),szFilter,pParent) -{ - //clearWFlags(WDestructiveClose); -} - -#else // COMPILE_KDE_SUPPORT - -KviTalFileDialog::KviTalFileDialog(const QString & szDirName, const QString & szFilter, QWidget * pParent, const char *, bool bModal) -: QFileDialog(pParent,"",szDirName,szFilter) -{ - setModal(bModal); -} - -#endif // COMPILE_KDE_SUPPORT - -KviTalFileDialog::~KviTalFileDialog() -{ -} - -void KviTalFileDialog::setFileMode(FileMode m) -{ - switch(m) - { -#ifdef COMPILE_KDE_SUPPORT - case AnyFile: - setMode(KFile::File | KFile::LocalOnly); - setOperationMode(Saving); - break; - case ExistingFile: - setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly); - setOperationMode(Opening); - break; - case ExistingFiles: - setMode(KFile::Files | KFile::ExistingOnly | KFile::LocalOnly); - setOperationMode(Opening); - break; - case Directory: - setMode(KFile::Directory); - break; - case DirectoryOnly: - setMode(KFile::Directory); - break; - default: - setMode(KFile::File | KFile::LocalOnly); - setOperationMode(Saving); - break; -#else // COMPILE_KDE_SUPPORT - case AnyFile: - QFileDialog::setFileMode(QFileDialog::AnyFile); - break; - case ExistingFile: - QFileDialog::setFileMode(QFileDialog::ExistingFile); - break; - case ExistingFiles: - QFileDialog::setFileMode(QFileDialog::ExistingFiles); - break; - case Directory: - QFileDialog::setFileMode(QFileDialog::Directory); - break; - case DirectoryOnly: - QFileDialog::setFileMode(QFileDialog::DirectoryOnly); - break; - default: - QFileDialog::setFileMode(QFileDialog::AnyFile); - break; -#endif // COMPILE_KDE_SUPPORT - } -} - -void KviTalFileDialog::setDirectory(const QString & szDirectory) -{ -#ifdef COMPILE_KDE_SUPPORT - setUrl(KUrl(szDirectory)); -#else - QFileDialog::setDirectory(szDirectory); -#endif -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_filedialog.moc" -#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_filedialog.h b/src/kvilib/tal/kvi_tal_filedialog.h deleted file mode 100644 index 19c51013a..000000000 --- a/src/kvilib/tal/kvi_tal_filedialog.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef _KVI_TAL_FILEDIALOG_H_ -#define _KVI_TAL_FILEDIALOG_H_ - -//============================================================================= -// -// File : kvi_tal_filedialog.h -// Creation date : Thu Sep 11 2003 04:41:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2003-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -/** -* \file kvi_tal_filedialog.h -* \author Szymon Stefanek -* \brief Toolkit Abstraction Layer class -*/ - -#include "kvi_settings.h" - -/** -* \class KviTalFileDialog -* \brief Toolkit Abstraction Layer: filedialog class -*/ - -#ifdef COMPILE_KDE_SUPPORT - -#include - -class KVILIB_API KviTalFileDialog : public KFileDialog - -#else // COMPILE_KDE_SUPPORT - -#include - -class KVILIB_API KviTalFileDialog : public QFileDialog - -#endif // COMPILE_KDE_SUPPORT -{ - Q_OBJECT -public: - /** - * \brief Constructs the filedialog object - * \param szDirName The initial directory to display - * \param szFilter The filter to use to display - * \param pParent The parent object - * \param pcName The caption name of the dialog - * \param bModal Whether the dialog is modal - * \return KviTalFileDialog - */ - KviTalFileDialog(const QString & szDirName, const QString & szFilter = QString(), QWidget * pParent = 0, const char * pcName = 0, bool bModal = false); - - /** - * \brief Destroys the filedialog object - */ - ~KviTalFileDialog(); -public: - /** - * \enum FileMode - * \brief Indicate what the user may select in the file dialog - */ - enum FileMode { - AnyFile, /**< The name of a file, whether it exists or not */ - ExistingFile, /**< The name of a single existing file */ - ExistingFiles, /**< The names of zero or more existing files */ - Directory, /**< The name of a directory. Both files and directories are displayed */ - DirectoryOnly /**< The name of a directory. The file dialog will only display directories */ - }; - - /** - * \brief Sets the file mode - * \param m The mode :) - * \return void - */ - void setFileMode(FileMode m); - - /** - * \brief Sets the current directory - * \param szDirectory The directory - * \return void - */ - void setDirectory(const QString & szDirectory); - - /** - * \brief Returns an existing directory selected by the user - * \param szDir The directory to display - * \param szCaption The caption of the dialog - * \param pParent The parent object - * \return QString - */ - static QString getExistingDirectoryPath(const QString & szDir = QString(), const QString & szCaption = QString(), QWidget * pParent = 0) - { -#ifdef COMPILE_KDE_SUPPORT - // QFileDialog allows making new directories...kfiledialog not :/ - return KFileDialog::getExistingDirectory(KUrl(szDir),pParent,szCaption); - //return getExistingDirectory(dir,parent,caption); -#else // COMPILE_KDE_SUPPORT - return getExistingDirectory(pParent,szCaption,szDir); -#endif // COMPILE_KDE_SUPPORT - }; -}; - -#endif // _KVI_TAL_FILEDIALOG_H_ diff --git a/src/kvilib/tal/kvi_tal_groupbox.cpp b/src/kvilib/tal/kvi_tal_groupbox.cpp deleted file mode 100644 index 019632ddb..000000000 --- a/src/kvilib/tal/kvi_tal_groupbox.cpp +++ /dev/null @@ -1,140 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_groupbox.cpp -// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_groupbox.h" - -#include -#include - -KviTalGroupBox::KviTalGroupBox(QWidget * pParent, char * pcName) -: QGroupBox(pParent) -{ - setObjectName(pcName); - m_pLayout = new QHBoxLayout(this); - QGroupBox::setLayout(m_pLayout); -} - -KviTalGroupBox::KviTalGroupBox(QWidget * pParent) -: QGroupBox(pParent) -{ - m_pLayout = 0; -} - -KviTalGroupBox::KviTalGroupBox(const QString & szTitle, QWidget * pParent) -: QGroupBox(szTitle,pParent) -{ - m_pLayout = 0; -} - -KviTalGroupBox::KviTalGroupBox(Qt::Orientation orientation, QWidget * pParent) -: QGroupBox(pParent) -{ - if(orientation == Qt::Vertical) - m_pLayout = new QHBoxLayout(this); - else - m_pLayout = new QVBoxLayout(this); - QGroupBox::setLayout(m_pLayout); -} - -KviTalGroupBox::KviTalGroupBox(Qt::Orientation orientation, const QString & szTitle, QWidget * pParent) -: QGroupBox(szTitle,pParent) -{ - mOrientation = orientation; - if(orientation == Qt::Vertical) - m_pLayout = new QHBoxLayout(this); - else - m_pLayout = new QVBoxLayout(this); - QGroupBox::setLayout(m_pLayout); -} - -KviTalGroupBox::~KviTalGroupBox() -{ -} - -void KviTalGroupBox::childEvent(QChildEvent * e) -{ - if(!e->child()->isWidgetType()) - return; - if(e->child()->parent() != this) - return; - if(!m_pLayout) - return; - if(m_pLayout != layout()) - return; - - switch(e->type()) - { - case QEvent::ChildAdded: - m_pLayout->addWidget((QWidget *)(e->child())); - break; - case QEvent::ChildRemoved: - m_pLayout->removeWidget((QWidget *)(e->child())); - break; - default: - break; - } -} - -void KviTalGroupBox::addSpace(int iSpace) -{ - if(m_pLayout && m_pLayout==layout()) - { - if(mOrientation == Qt::Vertical) - ((QHBoxLayout*)m_pLayout)->addSpacing(iSpace); - else - ((QVBoxLayout*)m_pLayout)->addSpacing(iSpace); - } -} - -void KviTalGroupBox::setOrientation(Qt::Orientation orientation) -{ - if(m_pLayout) - { - delete m_pLayout; - m_pLayout = NULL; - } - - mOrientation = orientation; - - if(orientation == Qt::Vertical) - m_pLayout = new QHBoxLayout(this); - else - m_pLayout = new QVBoxLayout(this); - QGroupBox::setLayout(m_pLayout); -} - -void KviTalGroupBox::setLayout(QLayout * layout) -{ - if(m_pLayout) - { - delete m_pLayout; - m_pLayout = NULL; - } - - QGroupBox::setLayout(layout); -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_groupbox.moc" -#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_groupbox.h b/src/kvilib/tal/kvi_tal_groupbox.h deleted file mode 100644 index b1a01b8e8..000000000 --- a/src/kvilib/tal/kvi_tal_groupbox.h +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef _KVI_TAL_GROUPBOX_H_ -#define _KVI_TAL_GROUPBOX_H_ - -//============================================================================= -// -// File : kvi_tal_groupbox.h -// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -/** -* \file kvi_tal_groupbox.h -* \author Szymon Stefanek -* \brief Class for groupbox -*/ - -#include "kvi_settings.h" - -#include -#include - -/** -* \class KviTalGroupBox -* \brief Toolkit Abstraction Layer: groupbox class -*/ -class KVILIB_API KviTalGroupBox : public QGroupBox -{ - Q_OBJECT -public: - /** - * \brief Constructs the groupbox object - * \param pParent The parent object - * \param pcName the name of the groupbox - * \return KviTalGroupBox - */ - KviTalGroupBox(QWidget * pParent, char * pcName=0); - - /** - * \brief Constructs the groupbox object - * \param pParent The parent object - * \return KviTalGroupBox - */ - KviTalGroupBox(QWidget * pParent = 0); - - /** - * \brief Constructs the groupbox object - * \param szTitle The title of the groupbox - * \param pParent The parent object - * \return KviTalGroupBox - */ - KviTalGroupBox(const QString & szTitle, QWidget * pParent = 0); - - /** - * \brief Constructs the groupbox object - * \param orientation The orientation of the groupbox - * \param pParent The parent object - * \return KviTalGroupBox - */ - KviTalGroupBox(Qt::Orientation orientation, QWidget * pParent = 0); - - /** - * \brief Constructs the groupbox object - * \param orientation The orientation of the groupbox - * \param szTitle The title of the groupbox - * \param pParent The parent object - * \return KviTalGroupBox - */ - KviTalGroupBox(Qt::Orientation orientation, const QString & szTitle, QWidget * pParent = 0); - - /** - * \brief Destroys the groupbox object - */ - ~KviTalGroupBox(); -protected: - Qt::Orientation mOrientation; - QLayout * m_pLayout; -public: - /** - * \brief Sets the inside margin - * \param iMargin The margin in pixels - * \return void - */ - void setInsideMargin(int iMargin) - { if(layout()) layout()->setMargin(iMargin); }; - - /** - * \brief Sets the inside spacing - * \param iSpacing The spacing in pixels - * \return void - */ - void setInsideSpacing(int iSpacing) - { if(layout()) layout()->setSpacing(iSpacing); }; - - /** - * \brief Returns the inside margin - * \return int - */ - int insideMargin() - { if(layout()) return layout()->margin(); return 0; }; - - /** - * \brief Returns the inside spacing - * \return int - */ - int insideSpacing() - { if(layout()) return layout()->spacing(); return 0; }; - - /** - * \brief Adds a space - * \param iSpace The space in pixels - * \return void - */ - void addSpace(int iSpace); - - /** - * \brief Sets the orientation - * \param orientation The orientation :) - * \return void - */ - void setOrientation(Qt::Orientation orientation); - - /** - * \brief Sets a new layout - * \param newLayout The new layout - * \return void - */ - void setLayout(QLayout * newLayout); -protected: - virtual void childEvent(QChildEvent * e); -}; - -#endif // _KVI_TAL_GROUPBOX_H_ diff --git a/src/kvilib/tal/kvi_tal_hbox.cpp b/src/kvilib/tal/kvi_tal_hbox.cpp deleted file mode 100644 index 1ef76a912..000000000 --- a/src/kvilib/tal/kvi_tal_hbox.cpp +++ /dev/null @@ -1,128 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_hbox.cpp -// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) -// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_hbox.h" - -#include - -// Tables used in $setAlignment & $alignment -const char * const align_tbl[] = { - "Left", - "Right", - "HCenter", - "VCenter", - "Center", - "Top", - "Bottom", - "WordBreak" -}; - -const int align_cod[] = { - Qt::AlignLeft, - Qt::AlignRight, - Qt::AlignHCenter, - Qt::AlignVCenter, - Qt::AlignCenter, - Qt::AlignTop, - Qt::AlignBottom, - Qt::AlignJustify, -}; - -#define align_num (sizeof(align_tbl) / sizeof(align_tbl[0])) - -KviTalHBox::KviTalHBox(QWidget * pParent, char * pcName) -: QWidget(pParent) -{ - setObjectName(pcName); - - m_pLayout = new QHBoxLayout(this); - m_pLayout->setMargin(3); - m_pLayout->setSpacing(2); - - setLayout(m_pLayout); -} - -KviTalHBox::~KviTalHBox() -{ -} - -void KviTalHBox::childEvent(QChildEvent * e) -{ - if(!e->child()->isWidgetType()) - return; - if(e->child()->parent() != this) - return; - - switch(e->type()) - { - case QEvent::ChildAdded: - m_pLayout->addWidget((QWidget *)(e->child())); - break; - case QEvent::ChildRemoved: - m_pLayout->removeWidget((QWidget *)(e->child())); - break; - default: - break; - } -} - -void KviTalHBox::setStretchFactor(QWidget * pChild, int iStretch) -{ - m_pLayout->setStretchFactor(pChild,iStretch); -} - -void KviTalHBox::setSpacing(int iSpacing) -{ - m_pLayout->setSpacing(iSpacing); -} - -void KviTalHBox::setMargin(int iMargin) -{ - m_pLayout->setContentsMargins(iMargin,iMargin,iMargin,iMargin); -} - -void KviTalHBox::setAlignment(Qt::Alignment alignment) -{ - m_pLayout->setAlignment(this,alignment); -} - -void KviTalHBox::setAlignment(QWidget * pChild, Qt::Alignment alignment) -{ - m_pLayout->setAlignment(pChild,alignment); -} - -void KviTalHBox::addStretch(int iStretch) -{ - m_pLayout->addStretch(iStretch); -} - -void KviTalHBox::addSpacing(int iSpacing) -{ - m_pLayout->addSpacing(iSpacing); -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_hbox.moc" -#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_hbox.h b/src/kvilib/tal/kvi_tal_hbox.h deleted file mode 100644 index c5d0f0dd8..000000000 --- a/src/kvilib/tal/kvi_tal_hbox.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef _KVI_TAL_HBOX_H_ -#define _KVI_TAL_HBOX_H_ - -//============================================================================= -// -// File : kvi_tal_hbox.h -// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) -// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -/** -* \file kvi_tal_hbox.h -* \author Szymon Stefanek -* \brief Class for horizontal box -*/ - -#include "kvi_settings.h" - -#include -#include - -/** -* \class KviTalHBox -* \brief Toolkit Abstraction Layer: hbox class -*/ -class KVILIB_API KviTalHBox : public QWidget -{ - Q_OBJECT -public: - /** - * \brief Constructs an horizontal box object - * \param pParent The parent object - * \param pcName The name of the box - * \return KviTalHBox - */ - KviTalHBox(QWidget * pParent, char * pcName = 0); - - /** - * \brief Destroys an horizontal box object - */ - ~KviTalHBox(); -private: - QHBoxLayout * m_pLayout; -public: - /** - * \brief Sets the stretch factor for an object - * \param pChild The object to stretch - * \param iStretch The stretch factor to use - * \return void - */ - void setStretchFactor(QWidget * pChild, int iStretch); - - /** - * \brief Sets the spacing of the box - * \param iSpace The space in pixels - * \return void - */ - void setSpacing(int iSpace); - - /** - * \brief Sets the margin of the box - * \param iMargin The margin in pixels - * \return void - */ - void setMargin(int iMargin); - - /** - * \brief Sets the alignment of the box - * \param alignment The alignment - * \return void - */ - void setAlignment(Qt::Alignment alignment); - - /** - * \brief Sets the alignment of the box - * \param pChild The child object to align - * \param alignment The alignment - * \return void - */ - void setAlignment(QWidget * pChild, Qt::Alignment alignment); - - /** - * \brief Adds the stretch factor - * \param iStretch The stretch factor - * \return void - */ - void addStretch(int iStretch); - - /** - * \brief Adds a non-stretchable spacing item - * \param iSpace the width of the item - * \return void - */ - void addSpacing(int iSpace); - -protected: - virtual void childEvent(QChildEvent * e); -}; - -#endif // _KVI_TAL_HBOX_H_ diff --git a/src/kvilib/tal/kvi_tal_itemdelegates.cpp b/src/kvilib/tal/kvi_tal_itemdelegates.cpp deleted file mode 100644 index ff2519971..000000000 --- a/src/kvilib/tal/kvi_tal_itemdelegates.cpp +++ /dev/null @@ -1,93 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_itemdelegates.cpp -// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_itemdelegates.h" - -#include -#include -#include -#include - -KviTalIconAndRichTextItemDelegate::KviTalIconAndRichTextItemDelegate(QAbstractItemView * pWidget) -: QStyledItemDelegate(pWidget), m_pParent(pWidget), m_pDefaultPix(0) -{ -} - -KviTalIconAndRichTextItemDelegate::~KviTalIconAndRichTextItemDelegate() -{ -} - -void KviTalIconAndRichTextItemDelegate::paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const -{ - pPainter->save(); - QStyleOptionViewItemV4 opt = option; - initStyleOption(&opt, index); - - if (opt.state & QStyle::State_Selected) - QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem,&opt, pPainter); - - QString szText = index.data(Qt::DisplayRole).toString(); - QPixmap pixmap; - QRect decorationRect; - QVariant value = index.data(Qt::DecorationRole); - - QIcon ico; - if(value.canConvert()) - { - ico = QIcon(value.value()); - if(ico.isNull()) - { - if(m_pDefaultPix) - pPainter->drawPixmap(opt.rect.x()+LVI_BORDER,opt.rect.y()+LVI_BORDER,*m_pDefaultPix); - } else { - pPainter->drawPixmap(opt.rect.x()+LVI_BORDER,opt.rect.y()+LVI_BORDER,ico.pixmap(LVI_ICON_SIZE,LVI_ICON_SIZE)); - } - } else { - if(m_pDefaultPix) - pPainter->drawPixmap(opt.rect.x()+LVI_BORDER,opt.rect.y()+LVI_BORDER,*m_pDefaultPix); - } - - QTextDocument doc; - doc.setHtml(szText); - doc.setDefaultFont(opt.font); - pPainter->translate(opt.rect.x()+LVI_AFTER_ICON,opt.rect.y()+LVI_BORDER); - doc.setTextWidth(opt.rect.width()-LVI_AFTER_ICON); - QRect cliprect = QRect(QPoint(0,0),QSize(opt.rect.width()-LVI_AFTER_ICON,opt.rect.height())); - doc.drawContents(pPainter,cliprect); - pPainter->restore(); -} - -QSize KviTalIconAndRichTextItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex & index) const -{ - QString szText = index.data(Qt::DisplayRole).toString(); - QTextDocument doc; - doc.setHtml(szText); - doc.setDefaultFont(option.font); - doc.setTextWidth(option.rect.width()-LVI_AFTER_ICON); - int iHeight = doc.documentLayout()->documentSize().toSize().height(); - if(iHeight < (LVI_ICON_SIZE+(2 * LVI_BORDER))) - iHeight = LVI_ICON_SIZE; - - return QSize(((QListWidget *)parent())->viewport()->size().width(), iHeight + (2 * LVI_BORDER)); -} diff --git a/src/kvilib/tal/kvi_tal_itemdelegates.h b/src/kvilib/tal/kvi_tal_itemdelegates.h deleted file mode 100644 index 5045a5bbe..000000000 --- a/src/kvilib/tal/kvi_tal_itemdelegates.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef _KVI_TAL_DELEGATES_H_ -#define _KVI_TAL_DELEGATES_H_ - -//============================================================================= -// -// File : kvi_tal_itemdelegates.h -// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -/** -* \file kvi_tal_itemdelegates.h -* \author Szymon Stefanek -* \brief Class for item delegates -*/ - -#include "kvi_settings.h" - -#include -#include -#include -#include - -#define LVI_ICON_SIZE 32 -#define LVI_BORDER 4 -#define LVI_SPACING 8 -#define LVI_MINIMUM_TEXT_WIDTH 300 -#define LVI_MINIMUM_CELL_WIDTH (LVI_MINIMUM_TEXT_WIDTH + LVI_BORDER + LVI_ICON_SIZE + LVI_SPACING + LVI_BORDER) - -#define LVI_AFTER_ICON (LVI_BORDER + LVI_ICON_SIZE + LVI_SPACING) -/** -* \class KviTalIconAndRichTextItemDelegate -* \brief Toolkit Abstraction Layer: itemdelegate class -*/ -class KVILIB_API KviTalIconAndRichTextItemDelegate : public QStyledItemDelegate -{ -public: - /** - * \brief Constructs the icon and rich text item delegate object - * \param pWidget The item which we have to delegate for the paint - * \return KviTalIconAndRichTextItemDelegate - */ - KviTalIconAndRichTextItemDelegate(QAbstractItemView * pWidget = 0); - - /** - * \brief Destroys the icon and rich text item delegate object - */ - ~KviTalIconAndRichTextItemDelegate(); -protected: - QAbstractItemView * m_pParent; - QPixmap * m_pDefaultPix; -public: - /** - * \brief Returns the size hint for the view - * \param option The style options for the item - * \param index The model index for the item - * \return QSize - */ - QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; - - /** - * \brief Paints the view - * \param pPainter The painter to draw the view - * \param option The style options for the item - * \param index The model index for the item - * \return void - */ - void paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const; - - /** - * \brief Sets the default icon - * \param pPix The icon pixmap - * \return void - */ - void setDefaultIcon(QPixmap * pPix){ m_pDefaultPix = pPix; }; -}; - -#endif // _KVI_TAL_LISTWIDGET_H_ diff --git a/src/kvilib/tal/kvi_tal_listwidget.cpp b/src/kvilib/tal/kvi_tal_listwidget.cpp deleted file mode 100644 index dea5bcac6..000000000 --- a/src/kvilib/tal/kvi_tal_listwidget.cpp +++ /dev/null @@ -1,189 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_listwidget.cpp -// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_listwidget.h" -#include "kvi_tal_itemdelegates.h" - -#include -#include -#include -#include - -KviTalListWidget::KviTalListWidget(QWidget * pParent,QString name,Qt::WindowType f) -: QListWidget(pParent) -{ - setObjectName(name); - setWindowFlags(f); -} -bool KviTalListWidget::event(QEvent * e) -{ - - if (e->type() == QEvent::ToolTip) - { - QHelpEvent *helpEvent = static_cast(e); - const QPoint &p=helpEvent->pos(); - QListWidgetItem *item=itemAt(p); - if (item) - { - emit tipRequest(item,p); - } - } - return QListWidget::event(e); -} - -KviTalListWidgetText::KviTalListWidgetText(KviTalListWidget *listbox, const QString &text) -:KviTalListWidgetItem(listbox) -{ - setText(text); -} - -KviTalListWidgetText::KviTalListWidgetText(const QString &text) -:KviTalListWidgetItem() -{ - setText(text); -} -/* -KviTalListWidgetText::KviTalListWidgetText(KviTalListWidget* listbox, const QString &text, KviTalListWidgetItem *after) -: KviTalListWidgetItem(listbox, after) -{ - setText(text); -}*/ - -KviTalListWidgetText::~KviTalListWidgetText() -{ -} - -void KviTalListWidgetText::paint(QPainter *painter) -{ - int itemHeight = height(listWidget()); - QFontMetrics fm = painter->fontMetrics(); - int yPos = ((itemHeight - fm.height()) / 2) + fm.ascent(); - painter->drawText(3, yPos, text()); -} - -int KviTalListWidgetText::height(const KviTalListWidget* lb) const -{ - int h = lb ? lb->fontMetrics().lineSpacing() + 2 : 0; - return qMax(h, QApplication::globalStrut().height()); -} - -int KviTalListWidgetText::width(const KviTalListWidget* lb) const -{ - int w = lb ? lb->fontMetrics().width(text()) + 6 : 0; - return qMax(w, QApplication::globalStrut().width()); -} - -int KviTalListWidgetText::rtti() const -{ - return RTTI; -} - -KviTalListWidgetPixmap::KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap &pixmap) -: KviTalListWidgetItem(listbox) -{ - pm = pixmap; -} - -KviTalListWidgetPixmap::KviTalListWidgetPixmap(const QPixmap &pixmap) -: KviTalListWidgetItem() -{ - pm = pixmap; -} - -// KviTalListWidgetPixmap::KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap &pixmap, KviTalListWidgetItem *after) -// : KviTalListWidgetItem(listbox, after) -// { -// pm = pixmap; -// } - -KviTalListWidgetPixmap::~KviTalListWidgetPixmap() -{ -} - -KviTalListWidgetPixmap::KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap &pix, const QString& text) -: KviTalListWidgetItem(listbox) -{ - pm = pix; - setText(text); - setIcon(QIcon(pix)); -} - -KviTalListWidgetPixmap::KviTalListWidgetPixmap(const QPixmap & pix, const QString& text) -: KviTalListWidgetItem() -{ - pm = pix; - setText(text); -} - -// KviTalListWidgetPixmap::KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap & pix, const QString& text,KviTalListWidgetItem *after) -// : KviTalListWidgetItem(listbox, after) -// { -// pm = pix; -// setText(text); -// } - -void KviTalListWidgetPixmap::paint(QPainter *painter) -{ - int itemHeight = height(listWidget()); - int yPos; - - const QPixmap *pm = pixmap(); - if (pm && ! pm->isNull()) { - yPos = (itemHeight - pm->height()) / 2; - painter->drawPixmap(3, yPos, *pm); - } - - if (!text().isEmpty()) { - QFontMetrics fm = painter->fontMetrics(); - yPos = ((itemHeight - fm.height()) / 2) + fm.ascent(); - painter->drawText(pm->width() + 5, yPos, text()); - } -} - -int KviTalListWidgetPixmap::height(const KviTalListWidget* lb) const -{ - int h; - if (text().isEmpty()) - h = pm.height(); - else - h = qMax(pm.height(), lb->fontMetrics().lineSpacing() + 2); - return qMax(h, QApplication::globalStrut().height()); -} - -int KviTalListWidgetPixmap::width(const KviTalListWidget* lb) const -{ - if (text().isEmpty()) - return qMax(pm.width() + 6, QApplication::globalStrut().width()); - return qMax(pm.width() + lb->fontMetrics().width(text()) + 6, - QApplication::globalStrut().width()); -} - -int KviTalListWidgetPixmap::rtti() const -{ - return RTTI; -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_listwidget.moc" -#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_listwidget.h b/src/kvilib/tal/kvi_tal_listwidget.h deleted file mode 100644 index e3243f72d..000000000 --- a/src/kvilib/tal/kvi_tal_listwidget.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef _KVI_TAL_LISTWIDGET_H_ -#define _KVI_TAL_LISTWIDGET_H_ - -//============================================================================= -// -// File : kvi_tal_listwidget.h -// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" -#include "kvi_tal_itemdelegates.h" - - -#include - -class KviTalListWidgetItem; - - -class KVILIB_API KviTalListWidget : public QListWidget -{ - Q_OBJECT -public: - KviTalListWidget(QWidget * pParent,QString name,Qt::WindowType f = Qt::Widget); - KviTalListWidget(QWidget * pParent) - : QListWidget (pParent){}; - virtual ~KviTalListWidget() {}; - -protected: - virtual bool event(QEvent * e); -signals: - void tipRequest(QListWidgetItem *,const QPoint &); - -}; - -class KVILIB_API KviTalListWidgetItem : public QListWidgetItem -{ -public: - KviTalListWidgetItem() - : QListWidgetItem() {}; - KviTalListWidgetItem(KviTalListWidget * pParent) - : QListWidgetItem(pParent){}; - KviTalListWidgetItem(KviTalListWidget * pParent, QString& label) - : QListWidgetItem(label, pParent){}; - KviTalListWidget* listWidget() { return (KviTalListWidget*) QListWidgetItem::listWidget(); }; - virtual ~KviTalListWidgetItem() {}; - -}; - -class KVILIB_API KviTalListWidgetText : public KviTalListWidgetItem -{ -public: - KviTalListWidgetText(KviTalListWidget* listbox, const QString & text=QString()); - KviTalListWidgetText(const QString & text=QString()); - ~KviTalListWidgetText(); - - int height(const KviTalListWidget *) const; - int width(const KviTalListWidget *) const; - - int rtti() const; - enum { RTTI = 1 }; - -protected: - virtual void paint(QPainter *); - -private: - Q_DISABLE_COPY(KviTalListWidgetText) -}; - - -class KVILIB_API KviTalListWidgetPixmap : public KviTalListWidgetItem -{ -public: - KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap &); - KviTalListWidgetPixmap(const QPixmap &); - KviTalListWidgetPixmap(KviTalListWidget* listbox, const QPixmap &, const QString&); - KviTalListWidgetPixmap(const QPixmap &, const QString&); - ~KviTalListWidgetPixmap(); - - const QPixmap *pixmap() const { return ± } - - int height(const KviTalListWidget *) const; - int width(const KviTalListWidget *) const; - - int rtti() const; - enum { RTTI = 2 }; - -protected: - virtual void paint(QPainter *); - -private: - Q_DISABLE_COPY(KviTalListWidgetPixmap) - QPixmap pm; -}; - -#endif // _KVI_TAL_LISTWIDGET_H_ diff --git a/src/kvilib/tal/kvi_tal_mainwindow.cpp b/src/kvilib/tal/kvi_tal_mainwindow.cpp deleted file mode 100644 index 779ce060d..000000000 --- a/src/kvilib/tal/kvi_tal_mainwindow.cpp +++ /dev/null @@ -1,65 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_mainwindow.coo -// Creation date : Sun Aug 12 2001 04:40:24 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - - -#include "kvi_tal_mainwindow.h" - -#ifdef COMPILE_KDE_SUPPORT - - KviTalMainWindow::KviTalMainWindow(QWidget * pParent, const char * pcName) - : KMainWindow(pParent) - { - //setWindowTitle(pcName); - setObjectName(pcName); - } - -#else - KviTalMainWindow::KviTalMainWindow(QWidget * pParent, const char * pcName) - : QMainWindow(pParent) - { - setObjectName(pcName); - } - -#endif - -KviTalMainWindow::~KviTalMainWindow() -{ -} - -bool KviTalMainWindow::usesBigPixmaps() -{ - return (iconSize().width() > 40); -} - -void KviTalMainWindow::setUsesBigPixmaps(bool bUse) -{ - if(bUse) - setIconSize(QSize(48,48)); - else - setIconSize(QSize(24,24)); -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_mainwindow.moc" -#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_mainwindow.h b/src/kvilib/tal/kvi_tal_mainwindow.h deleted file mode 100644 index 834e8101e..000000000 --- a/src/kvilib/tal/kvi_tal_mainwindow.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef _KVI_TAL_MAINWINDOW_H_ -#define _KVI_TAL_MAINWINDOW_H_ -//============================================================================= -// -// File : kvi_tal_mainwindow.h -// Creation date : Sun Aug 12 2001 04:41:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -/** -* \file kvi_tal_mainwindow.h -* \author Szymon Stefanek -* \brief Toolkit Abstraction Layer class -*/ - -#include "kvi_settings.h" - -/** -* \class KviTalMainWindow -* \brief Toolkit Abstraction Layer: mainwindow class -*/ - -#ifdef COMPILE_KDE_SUPPORT - -#include -#include // statusBar() is overridden to return a KStatusBar - -class KVILIB_API KviTalMainWindow : public KMainWindow - -#else - -#include - -class KVILIB_API KviTalMainWindow : public QMainWindow - -#endif -{ - Q_OBJECT -public: - /** - * \brief Constructs the mainwindow object - * \param pParent The parent object - * \param pcName The name of the object - * \return KviTalMainWindow - */ - KviTalMainWindow(QWidget * pParent, const char * pcName); - - /** - * \brief Destroys the mainwindow object - * \return KviTalMainWindow - */ - ~KviTalMainWindow(); -public: - /** - * \brief Returns true if the mainwindow uses big pixmaps - * \return bool - */ - bool usesBigPixmaps(); - - /** - * \brief Sets the use of big pixmaps - * \param bUse Whether to use big pixmaps - * \return void - */ - void setUsesBigPixmaps(bool bUse); -}; - -#endif // _KVI_TAL_MAINWINDOW_H_ diff --git a/src/kvilib/tal/kvi_tal_menubar.cpp b/src/kvilib/tal/kvi_tal_menubar.cpp deleted file mode 100644 index 8580bba6c..000000000 --- a/src/kvilib/tal/kvi_tal_menubar.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_menubar.cpp -// Creation date : Sun Aug 12 06:35:18 2001 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - - -#include "kvi_tal_menubar.h" - -#ifdef COMPILE_KDE_SUPPORT - - KviTalMenuBar::KviTalMenuBar(QWidget * pParent, const char * pcName) - : KMenuBar(pParent) - { - setWindowTitle(pcName); - } - -#else - - KviTalMenuBar::KviTalMenuBar(QWidget * pParent, const char * pcName) - : QMenuBar(pParent) - { - } - -#endif - -KviTalMenuBar::~KviTalMenuBar() -{ -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_menubar.moc" -#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_menubar.h b/src/kvilib/tal/kvi_tal_menubar.h deleted file mode 100644 index 6415f0aa3..000000000 --- a/src/kvilib/tal/kvi_tal_menubar.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _KVI_TAL_MENUBAR_H_ -#define _KVI_TAL_MENUBAR_H_ -//============================================================================= -// -// File : kvi_tal_menubar.h -// Creation date : Sun Aug 12 06:35:15 2001 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -/** -* \file kvi_tal_menubar.h -* \author Szymon Stefanek -* \brief Toolkit Abstraction Layer class -*/ - -#include "kvi_settings.h" - -/** -* \class KviTalMenuBar -* \brief Toolkit Abstraction Layer: menubar class -*/ - -#ifdef COMPILE_KDE_SUPPORT - -#include - -class KVILIB_API KviTalMenuBar : public KMenuBar - -#else - -#include - -class KVILIB_API KviTalMenuBar : public QMenuBar - -#endif -{ - Q_OBJECT -public: - /** - * \brief Constructs the menubar object - * \param pParent The parent object - * \param pcName The name of the menubar - * \return KviTalMenuBar - */ - KviTalMenuBar(QWidget * pParent, const char * pcName); - - /** - * \brief Destroys the menubar object - */ - ~KviTalMenuBar(); -}; - - -#endif //_KVI_TAL_MENUBAR_H_ diff --git a/src/kvilib/tal/kvi_tal_popupmenu.cpp b/src/kvilib/tal/kvi_tal_popupmenu.cpp deleted file mode 100644 index f4f321831..000000000 --- a/src/kvilib/tal/kvi_tal_popupmenu.cpp +++ /dev/null @@ -1,215 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_popupmenu.cpp -// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_popupmenu.h" - -#include -#include -#include -#include - -KviTalPopupMenu::KviTalPopupMenu(QWidget * pParent,const QString &szName) -: QMenu(pParent) -{ - connect(this,SIGNAL(triggered(QAction *)),this,SLOT(slottriggered(QAction *))); - setObjectName(szName); - identifier = 0; - -} - -KviTalPopupMenu::~KviTalPopupMenu() -{ - clear(); -} - -QAction * KviTalPopupMenu::getAction(int id) -{ - QAction * a = actionsDict.value(id); - return a ? a : 0; -} - -int KviTalPopupMenu::insertItem(const QString &szText) -{ - QAction * a = addAction(szText); - actionsDict[identifier++] = a; - return identifier-1; -} - -int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText) -{ - QAction * a = addAction(QIcon(pix),szText); - actionsDict[identifier++] = a; - return identifier-1; -} - -int KviTalPopupMenu::insertItem(const QString &szText,int id) -{ - QAction * a = addAction(szText); - actionsDict[id] = a; - return id; -} - -int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText,int id) -{ - QAction * a = addAction(QIcon(pix),szText); - actionsDict[id] = a; - return id; -} - -int KviTalPopupMenu::insertItem(const QString &szText,const QObject * pReceiver,const char * szSlot) -{ - QAction * action = addAction(szText); - - // create a compatible slot - signalMapper[action] = new QSignalMapper(this); - signalMapper[action]->setMapping(action, identifier); - - connect(action, SIGNAL(triggered()), signalMapper[action], SLOT(map())); - connect(signalMapper[action], SIGNAL(mapped(int)), pReceiver, szSlot); - - actionsDict[identifier++]=action; - return identifier-1; -} - -int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText,const QObject * pReceiver,const char * szSlot) -{ - QAction * action = addAction(pix, szText); - - // create a compatible slot - signalMapper[action] = new QSignalMapper(this); - signalMapper[action]->setMapping(action, identifier); - - connect(action, SIGNAL(triggered()), signalMapper[action], SLOT(map())); - connect(signalMapper[action], SIGNAL(mapped(int)), pReceiver, szSlot); - - actionsDict.insert(identifier, action); - actionsDict[identifier++] = action; - return identifier-1; -} - -int KviTalPopupMenu::insertItem(const QPixmap &pix,const QString &szText,QMenu *pMenu) -{ - QAction * a = addMenu(pMenu); - a->setText(szText); - a->setIcon(QIcon(pix)); - actionsDict[identifier++] = a; - return identifier-1; -} - -int KviTalPopupMenu::insertItem(const QString &szText,QMenu *pMenu) -{ - QAction * a = addMenu(pMenu); - a->setText(szText); - actionsDict[identifier++] = a; - return identifier-1; -} - -int KviTalPopupMenu::insertItem(QWidget * pWidget) -{ - QWidgetAction * pAct = new QWidgetAction(this); - pAct->setDefaultWidget(pWidget); - addAction(pAct); - return 0; -} - -void KviTalPopupMenu::setItemChecked(int id,bool check) -{ - QAction * action = actionsDict.value(id); - action->setCheckable(true); - action->setChecked(check); -} - -void KviTalPopupMenu::setItemParameter(int id, int param) -{ - QAction * action = actionsDict.value(id); - - // take care of the slot - if (signalMapper[action]) - { - signalMapper[action]->removeMappings(action); - signalMapper[action]->setMapping(action, param); - } - - QVariant par(param); - if (action) action->setData(par); -} - -int KviTalPopupMenu::itemParameter(int id) -{ - QAction * action = actionsDict.value(id); - if (action) - return action->data().toInt(); - else return 0; -} - -void KviTalPopupMenu::clear() -{ - QMenu::clear(); - identifier = 0; - actionsDict.clear(); - signalMapper.clear(); -} - -QString KviTalPopupMenu::text(int id) -{ - QAction * action = actionsDict.value(id); - return action->text(); -} - -void KviTalPopupMenu::setItemEnabled(int id,bool bFlag) -{ - QAction * action = actionsDict.value(id); - action->setEnabled(bFlag); -} - -int KviTalPopupMenu::insertSeparator() -{ - QAction * a = addSeparator(); - actionsDict[identifier++] = a; - return -1; -} - -void KviTalPopupMenu::slottriggered(QAction * a) -{ - if (signalMapper[a]) return; // When signalmapper is used we don't need this event - - int i = actionsDict.key(a, -1); // See if action exists and get ID - if (i != -1) - { - emit activated(i); - } - - return; -} - -void KviTalPopupMenu::slotActionTriggered(bool) -{ - QAction * action = (QAction *)sender(); - slottriggered(action); -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_popupmenu.moc" -#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES - diff --git a/src/kvilib/tal/kvi_tal_popupmenu.h b/src/kvilib/tal/kvi_tal_popupmenu.h deleted file mode 100644 index e218287af..000000000 --- a/src/kvilib/tal/kvi_tal_popupmenu.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _KVI_TAL_POPUPMENU_H_ -#define _KVI_TAL_POPUPMENU_H_ - -//============================================================================= -// -// File : kvi_tal_popupmenu.h -// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= -#include "kvi_settings.h" -#include "KviQString.h" - -#include -#include -#include - -class KVILIB_API KviTalPopupMenu : public QMenu -{ - Q_OBJECT -protected: - QHash actionsDict; - // We need QSignalMapper to keep slot system for insertItem() - QHash signalMapper; - int identifier; -public: - KviTalPopupMenu(QWidget * pParent=0,const QString &szName = KviQString::Empty); - virtual ~KviTalPopupMenu() ; - int insertItem(const QString &szText); - int insertItem(const QPixmap &pix,const QString &szText); - int insertItem(const QString &szText,int id); - int insertItem(const QPixmap &pix,const QString &szText,int id); - int insertItem(const QString &szText,const QObject * pReceiver,const char * szSlot); - int insertItem(const QPixmap &pix,const QString &szText,const QObject * pReceiver,const char * szSlot); - int insertItem(const QPixmap &pix,const QString &szText,QMenu *pMenu); - int insertItem(const QString &szText,QMenu *pMenu); - int insertItem(QWidget * pWidget); - void setItemChecked(int id,bool check); - void setItemEnabled(int id,bool bFlag); - void setItemParameter(int id, int param); - int itemParameter(int id); - QAction * getAction(int id); - void clear(); - QString text(int); - int insertSeparator(); -protected slots: - void slottriggered(QAction *); - void slotActionTriggered(bool); -signals: - void activated(int); -}; -#endif // _KVI_TAL_POPUPMENU_H_ diff --git a/src/kvilib/tal/kvi_tal_splitter.cpp b/src/kvilib/tal/kvi_tal_splitter.cpp deleted file mode 100644 index f532f10fc..000000000 --- a/src/kvilib/tal/kvi_tal_splitter.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_splitter.cpp -// Creation date : Mon Aug 31 2009 19:47:08 by Fabio Bas -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2009 Fabio Bas (ctrlaltca at libero dot it) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_splitter.h" diff --git a/src/kvilib/tal/kvi_tal_splitter.h b/src/kvilib/tal/kvi_tal_splitter.h deleted file mode 100644 index 59ee29cff..000000000 --- a/src/kvilib/tal/kvi_tal_splitter.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _KVI_TAL_SPLITTER_H_ -#define _KVI_TAL_SPLITTER_H_ - -//============================================================================= -// -// File : kvi_tal_splitter.cpp -// Creation date : Mon Aug 31 2009 19:47:08 by Fabio Bas -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2009 Fabio Bas (ctrlaltca at libero dot it) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -/** -* \file kvi_tal_splitter.h -* \author fabio bas -* \brief Class used to workaround unwanted behaviours in QSplitter -*/ - -#include -#define KviTalSplitter QSplitter - -#endif // _KVI_TAL_SPLITTER_H_ diff --git a/src/kvilib/tal/kvi_tal_tabdialog.cpp b/src/kvilib/tal/kvi_tal_tabdialog.cpp deleted file mode 100644 index a5acd2a1a..000000000 --- a/src/kvilib/tal/kvi_tal_tabdialog.cpp +++ /dev/null @@ -1,82 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_tabdialog.cpp -// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) -// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_tabdialog.h" - -#include -#include -#include -#include - -KviTalTabDialog::KviTalTabDialog(QWidget * pParent,const char * name,bool bModal) -: QDialog(pParent) -{ - setObjectName(name); - setModal(bModal); - - m_pLayout = new QGridLayout(this); - m_pLayout->setColumnStretch(0,10); - setLayout(m_pLayout); - - m_pTabWidget = new QTabWidget(this); - m_pLayout->addWidget(m_pTabWidget,0,0,1,3); -} - -KviTalTabDialog::~KviTalTabDialog() -{ -} - -void KviTalTabDialog::addTab(QWidget * widget, const QString & label) -{ - m_pTabWidget->addTab(widget,label); -} - -void KviTalTabDialog::setOkButton(const QString & text) -{ - QPushButton * pBtnOk = new QPushButton(text,this); - m_pLayout->addWidget(pBtnOk,1,1); - connect(pBtnOk,SIGNAL(clicked()),this,SLOT(okPressed())); -} - -void KviTalTabDialog::setCancelButton(const QString & text) -{ - QPushButton * pBtnCancel = new QPushButton(text,this); - m_pLayout->addWidget(pBtnCancel,1,2); - connect(pBtnCancel,SIGNAL(clicked()),this,SLOT(cancelPressed())); -} - -void KviTalTabDialog::okPressed() -{ - emit applyButtonPressed(); -} - -void KviTalTabDialog::cancelPressed() -{ - emit cancelButtonPressed(); -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_tabdialog.moc" -#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_tabdialog.h b/src/kvilib/tal/kvi_tal_tabdialog.h deleted file mode 100644 index 98f3203eb..000000000 --- a/src/kvilib/tal/kvi_tal_tabdialog.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _KVI_TAL_TABDIALOG_H_ -#define _KVI_TAL_TABDIALOG_H_ - -//============================================================================= -// -// File : kvi_tal_tabdialog.h -// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) -// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" - -#include - -class QGridLayout; -class QTabWidget; - -class KVILIB_API KviTalTabDialog : public QDialog -{ - Q_OBJECT -public: - KviTalTabDialog(QWidget * pParent = 0,const char * name = 0,bool bModal = false); - ~KviTalTabDialog(); -protected: - void setOkButton(const QString &); - void setCancelButton(const QString &); - void addTab(QWidget *,const QString &); -protected slots: - void okPressed(); - void cancelPressed(); -private: - QGridLayout * m_pLayout; - QTabWidget * m_pTabWidget; -signals: - void applyButtonPressed(); - void cancelButtonPressed(); -}; - -#endif // _KVI_TAL_TABDIALOG_H_ diff --git a/src/kvilib/tal/kvi_tal_tablewidget.cpp b/src/kvilib/tal/kvi_tal_tablewidget.cpp deleted file mode 100644 index 21a6dca96..000000000 --- a/src/kvilib/tal/kvi_tal_tablewidget.cpp +++ /dev/null @@ -1,101 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_tablewidget.cpp -// Creation date : Fri Jun 27 2008 10:00:08 by Fabio Bas -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2008 Fabio Bas (ctrlaltca at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - - -#include "kvi_tal_tablewidget.h" -/* -#include "KviPointerHashTable.h" - -#include -#include -#include -#include -#include -#include -#include -*/ -KviTalTableWidget::KviTalTableWidget(QWidget * pParent) -: QTableWidget(pParent) -{ -/* - connect(this,SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),this,SLOT(redirect_currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *))); - connect(this,SIGNAL(itemActivated(QTreeWidgetItem *,int)),this,SLOT(redirect_itemActivated(QTreeWidgetItem *,int))); - connect(this,SIGNAL(itemChanged(QTreeWidgetItem *,int)),this,SLOT(redirect_itemChanged(QTreeWidgetItem *,int))); - connect(this,SIGNAL(itemClicked(QTreeWidgetItem *,int)),this,SLOT(redirect_itemClicked(QTreeWidgetItem *,int))); - connect(this,SIGNAL(itemCollapsed(QTreeWidgetItem *)),this,SLOT(redirect_itemCollapsed(QTreeWidgetItem *))); - connect(this,SIGNAL(itemExpanded(QTreeWidgetItem *)),this,SLOT(redirect_itemExpanded(QTreeWidgetItem *))); - connect(this,SIGNAL(itemDoubleClicked(QTreeWidgetItem *,int)),this,SLOT(redirect_itemDoubleClicked(QTreeWidgetItem *,int))); - connect(this,SIGNAL(itemEntered(QTreeWidgetItem *,int)),this,SLOT(redirect_itemEntered(QTreeWidgetItem *,int))); - connect(this,SIGNAL(itemPressed(QTreeWidgetItem *,int)),this,SLOT(redirect_itemPressed(QTreeWidgetItem *,int))); -*/ -} -/* -void KviTalTreeWidget::redirect_currentItemChanged(QTreeWidgetItem *pItemCurr,QTreeWidgetItem *pItemPrev) -{ - emit currentItemChanged((KviTalTreeWidgetItem *)pItemCurr,(KviTalTreeWidgetItem *)pItemPrev); -} - -void KviTalTreeWidget::redirect_itemActivated(QTreeWidgetItem *pItem,int col) -{ - emit itemActivated((KviTalTreeWidgetItem *)pItem,col); -} - -void KviTalTreeWidget::redirect_itemChanged(QTreeWidgetItem *pItem,int col) -{ - emit itemChanged((KviTalTreeWidgetItem *)pItem,col); -} - - -void KviTalTreeWidget::redirect_itemClicked(QTreeWidgetItem *pItem,int col) -{ - emit itemClicked((KviTalTreeWidgetItem *)pItem,col); -} - -void KviTalTreeWidget::redirect_itemCollapsed(QTreeWidgetItem *pItem) -{ - emit itemCollapsed((KviTalTreeWidgetItem *)pItem); -} - -void KviTalTreeWidget::redirect_itemExpanded(QTreeWidgetItem *pItem) -{ - emit itemExpanded((KviTalTreeWidgetItem *)pItem); -} - -void KviTalTreeWidget::redirect_itemDoubleClicked(QTreeWidgetItem *pItem,int col) -{ - emit itemDoubleClicked((KviTalTreeWidgetItem *)pItem,col); -} - -void KviTalTreeWidget::redirect_itemEntered(QTreeWidgetItem *pItem,int col) -{ - emit itemEntered((KviTalTreeWidgetItem *)pItem,col); -} -void KviTalTreeWidget::redirect_itemPressed(QTreeWidgetItem *pItem,int col) -{ - emit itemPressed((KviTalTreeWidgetItem *)pItem,col); -} -*/ -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_tablewidget.moc" -#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_tablewidget.h b/src/kvilib/tal/kvi_tal_tablewidget.h deleted file mode 100644 index 42a1ed494..000000000 --- a/src/kvilib/tal/kvi_tal_tablewidget.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef _KVI_TAL_TABLEWIDGET_H_ -#define _KVI_TAL_TABLEWIDGET_H_ - -//============================================================================= -// -// File : kvi_tal_tablewidget.h -// Creation date : Fri Jun 27 2008 10:00:08 by Fabio Bas -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2008 Fabio Bas (ctrlaltca at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" -#include "KviQString.h" - -#include -#include - -class KviTalTableWidgetItem; - -class KVILIB_API KviTalTableWidget : public QTableWidget -{ - friend class KviTalTableWidgetItem; - Q_OBJECT -public: - KviTalTableWidget(QWidget * pParent); - virtual ~KviTalTableWidget() {}; -public: -}; - - -class KVILIB_API KviTalTableWidgetItem : public QTableWidgetItem -{ -public: - KviTalTableWidgetItem(KviTalTableWidget * pParent) - : QTableWidgetItem() - { - pParent->insertRow(pParent->rowCount()); - pParent->setItem(pParent->rowCount()-1, 0, this); - }; - - KviTalTableWidgetItem(KviTalTableWidget * pParent, int row, int column) - : QTableWidgetItem() - { - pParent->setItem(row, column, this); - }; - - KviTalTableWidgetItem(const KviTalTableWidgetItem & other) - : QTableWidgetItem(other) {}; -}; - -class KVILIB_API KviTalTableWidgetItemEx : public KviTalTableWidgetItem -{ -public: - KviTalTableWidgetItemEx(KviTalTableWidget * pParent) - : KviTalTableWidgetItem(pParent) {}; - - KviTalTableWidgetItemEx(KviTalTableWidget * pParent, int row, int column) - : KviTalTableWidgetItem(pParent, row, column) {}; - - KviTalTableWidgetItemEx(const KviTalTableWidgetItem & other) - : KviTalTableWidgetItem(other) {}; - virtual void displayUpdate() = 0; -}; - -#endif // _KVI_TAL_TABLEWIDGET_H_ diff --git a/src/kvilib/tal/kvi_tal_toolbar.cpp b/src/kvilib/tal/kvi_tal_toolbar.cpp deleted file mode 100644 index 1d465ae4d..000000000 --- a/src/kvilib/tal/kvi_tal_toolbar.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_toolbar.cpp -// Creation date : Mon Aug 13 05:05:45 2001 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_toolbar.h" - -#ifdef COMPILE_KDE_SUPPORT - KviTalToolBar::KviTalToolBar(const QString & szLabel, QMainWindow * pWnd, Qt::ToolBarArea type, bool bNewLine, const char * pcName) - : KToolBar(pcName,pWnd,type,bNewLine) - { - setWindowTitle(szLabel); - //toolbars are locked by default - setToolBarsLocked(false); - } -#else - KviTalToolBar::KviTalToolBar(const QString & szLabel, QMainWindow * pWnd, Qt::ToolBarArea type, bool bNewLine, const char * pcName) - : QToolBar(szLabel,pWnd) - { - //setFrameStyle(QFrame::NoFrame); - setObjectName(pcName); - if(!layout()) - this->setLayout(new QBoxLayout(QBoxLayout::LeftToRight)); - pWnd->addToolBar(type,this); - } - - KviTalToolBar::KviTalToolBar(QMainWindow * pWnd, const char * pcName) - : QToolBar(pWnd) - { - //setFrameStyle(QFrame::NoFrame); - setObjectName(pcName); - if(!layout()) - this->setLayout(new QBoxLayout(QBoxLayout::LeftToRight)); - pWnd->addToolBar(this); - } - - QBoxLayout * KviTalToolBar::boxLayout() - { - return (QBoxLayout*)this->layout(); - } - - void KviTalToolBar::setBoxLayout(QBoxLayout * pLayout) - { - this->setLayout(pLayout); - } -#endif // COMPILE_KDE_SUPPORT - - bool KviTalToolBar::usesBigPixmaps() - { - return (iconSize().width() > 40); - } - - void KviTalToolBar::setUsesBigPixmaps(bool bUse) - { - if(bUse) - setIconSize(QSize(48,48)); - else - setIconSize(QSize(22,22)); - } - -KviTalToolBar::~KviTalToolBar() -{ -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_toolbar.moc" -#endif // COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_toolbar.h b/src/kvilib/tal/kvi_tal_toolbar.h deleted file mode 100644 index 70115714f..000000000 --- a/src/kvilib/tal/kvi_tal_toolbar.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef _KVI_TAL_TOOLBAR_H_ -#define _KVI_TAL_TOOLBAR_H_ -//============================================================================= -// -// File : kvi_tal_toolbar.h -// Creation date : Mon Aug 13 05:05:44 2001 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net) -// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -/** -* \file kvi_tal_toolbar.h -* \author Szymon Stefanek -* \brief Toolkit Abstraction Layer class -*/ - -#include "kvi_settings.h" - -/** -* \class KviTalToolBar -* \brief Toolkit Abstraction Layer: toolbar class -*/ - -#ifdef COMPILE_KDE_SUPPORT - -#include - -class KVILIB_API KviTalToolBar : public KToolBar - -#else // COMPILE_KDE_SUPPORT - -#include -#include -#include - -class KVILIB_API KviTalToolBar : public QToolBar - -#endif // COMPILE_KDE_SUPPORT - -{ - Q_OBJECT -public: - /** - * \brief Constructs a toolbar object - * \param szLabel The label of the toolbar - * \param pWnd The mainwindow where to attach the toolbar - * \param type The type of the toolbar - * \param bNewLine Whether to add a newline - * \param pcName The name of the toolbar - * \return KviTalToolBar - */ - KviTalToolBar(const QString & szLabel, QMainWindow * pWnd, Qt::ToolBarArea type = Qt::TopToolBarArea, bool bNewLine = false, const char * pcName = 0); - - /** - * \brief Destroys a toolbar object - */ - ~KviTalToolBar(); -#ifndef COMPILE_KDE_SUPPORT -public: - /** - * \brief Constructs a toolbar object - * \param pWnd The mainwindow where to attach the toolbar - * \param pcName The name of the toolbar - * \return KviTalToolBar - */ - KviTalToolBar(QMainWindow * pWnd, const char * pcName = 0); -public: - /** - * \brief Returns the box layout object - * \return QBoxLayout * - */ - QBoxLayout * boxLayout(); - - /** - * \brief Sets the box layout - * \param pLayout The box layout - * \return void - */ - void setBoxLayout(QBoxLayout * pLayout); -#endif // COMPILE_KDE_SUPPORT - /** - * \brief Returns true if the toolbar uses big pixmaps - * \return bool - */ - bool usesBigPixmaps(); - - /** - * \brief Sets the use of big pixmaps - * \param bUse Whether to use big pixmaps - * \return void - */ - void setUsesBigPixmaps(bool bUse); -}; - -#endif //_KVI_TAL_TOOLBAR_H_ diff --git a/src/kvilib/tal/kvi_tal_tooltip.cpp b/src/kvilib/tal/kvi_tal_tooltip.cpp deleted file mode 100644 index b4249ec4b..000000000 --- a/src/kvilib/tal/kvi_tal_tooltip.cpp +++ /dev/null @@ -1,112 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_tooltip.cpp -// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_tooltip.h" - -#include -#include - -KviTalToolTipHelper::KviTalToolTipHelper(KviTalToolTip * pToolTip,QWidget * pWidget) -: QObject(pWidget) -{ - m_pToolTip = pToolTip; - pWidget->installEventFilter(this); -} - -KviTalToolTipHelper::~KviTalToolTipHelper() -{ - if(m_pToolTip) - { - m_pToolTip->helperDying(); - delete m_pToolTip; - } -} - -void KviTalToolTipHelper::toolTipDying() -{ - m_pToolTip = 0; -} - -bool KviTalToolTipHelper::eventFilter(QObject *,QEvent * pEvent) -{ - if((pEvent->type() == QEvent::ToolTip) && m_pToolTip) - { -// qDebug("TOOL TIP EVENT WITH POSITION %d,%d",((QHelpEvent *)pEvent)->pos().x(),((QHelpEvent *)pEvent)->pos().y()); - m_pToolTip->maybeTip(((QHelpEvent *)pEvent)->pos()); - return true; - } - return false; -} - - -KviTalToolTip::KviTalToolTip(QWidget * pParent) -{ - m_pHelper = new KviTalToolTipHelper(this,pParent); - m_pParent = pParent; -} - -KviTalToolTip::~KviTalToolTip() -{ - if(m_pHelper) - { - m_pHelper->toolTipDying(); - delete m_pHelper; - } -} - -void KviTalToolTip::helperDying() -{ - m_pHelper = 0; -} - -void KviTalToolTip::add(QWidget * widget,const QString & text) -{ - widget->setToolTip(text); -} - -void KviTalToolTip::remove(QWidget *widget) -{ - - widget->setToolTip(""); -} - -void KviTalToolTip::tip(const QRect & rect,const QString & text) -{ -// qDebug("TOOL TIP AT %d,%d",rect.topLeft().x(),rect.topLeft().y()); - QPoint pnt=m_pParent->mapToGlobal(rect.topLeft()); - pnt.setX(pnt.x()+16); - pnt.setY(pnt.y()+16); - QToolTip::showText(m_pParent->mapToGlobal(rect.topLeft()),text, m_pParent, rect); -} - -void KviTalToolTip::maybeTip(const QPoint &) -{ - // does nothing here.. -} - -#ifndef COMPILE_ON_WINDOWS - #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_tooltip.moc" - #endif //!COMPILE_USE_STANDALONE_MOC_SOURCES -#endif diff --git a/src/kvilib/tal/kvi_tal_tooltip.h b/src/kvilib/tal/kvi_tal_tooltip.h deleted file mode 100644 index 4051696b0..000000000 --- a/src/kvilib/tal/kvi_tal_tooltip.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _KVI_TAL_TOOLTIP_H_ -#define _KVI_TAL_TOOLTIP_H_ - -//============================================================================= -// -// File : kvi_tal_tooltip.h -// Creation date : Mon May 05 2008 11:25:08 by Alessandro Carbone -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2008 Alessandro Carbone (elfonol at gmail dot com) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" - -#include -#include - -class KviTalToolTip; - -// This is useful only with Qt4, but we put it here anyway -// to have both a consistent API and make moc happy -class KviTalToolTipHelper : public QObject -{ - friend class KviTalToolTip; - Q_OBJECT -public: - KviTalToolTipHelper(KviTalToolTip * pToolTip,QWidget * pWidget); - ~KviTalToolTipHelper(); -protected: - KviTalToolTip * m_pToolTip; -protected: - virtual bool eventFilter(QObject * pObject,QEvent * pEvent); - void toolTipDying(); -}; - - -class KVILIB_API KviTalToolTip -{ - friend class KviTalToolTipHelper; -public: - KviTalToolTip(QWidget * pParent); - virtual ~KviTalToolTip(); -protected: - KviTalToolTipHelper * m_pHelper; - QWidget * m_pParent; -public: - static void add(QWidget * widget,const QString & text); - static void remove(QWidget * widget); - virtual void tip(const QRect & rect,const QString & text); -protected: - virtual void maybeTip(const QPoint & p); - void helperDying(); -}; - -#endif // _KVI_TAL_TOOLTIP_H_ diff --git a/src/kvilib/tal/kvi_tal_vbox.cpp b/src/kvilib/tal/kvi_tal_vbox.cpp deleted file mode 100644 index 6517ce03e..000000000 --- a/src/kvilib/tal/kvi_tal_vbox.cpp +++ /dev/null @@ -1,98 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_vbox.cpp -// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) -// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_vbox.h" - -#include - -KviTalVBox::KviTalVBox(QWidget * pParent, char * pcName) -: QWidget(pParent) -{ - setObjectName(pcName); - - m_pLayout = new QVBoxLayout(this); - m_pLayout->setMargin(3); - m_pLayout->setSpacing(2); - - setLayout(m_pLayout); -} - -KviTalVBox::~KviTalVBox() -{ -} - -void KviTalVBox::childEvent(QChildEvent * e) -{ - if(!e->child()->isWidgetType()) - return; - if(e->child()->parent() != this) - return; - - switch(e->type()) - { - case QEvent::ChildAdded: - m_pLayout->addWidget((QWidget *)(e->child())); - break; - case QEvent::ChildRemoved: - m_pLayout->removeWidget((QWidget *)(e->child())); - break; - default: - break; - } -} - -void KviTalVBox::setStretchFactor(QWidget * pChild, int iStretch) -{ - m_pLayout->setStretchFactor(pChild,iStretch); -} - -void KviTalVBox::setSpacing(int iSpacing) -{ - m_pLayout->setSpacing(iSpacing); -} - -void KviTalVBox::addStretch(int iStretch) -{ - m_pLayout->addStretch(iStretch); -} - -void KviTalVBox::setMargin(int iMargin) -{ - m_pLayout->setContentsMargins(iMargin,iMargin,iMargin,iMargin); -} - -void KviTalVBox::setAlignment(Qt::Alignment alignment) -{ - m_pLayout->setAlignment(alignment); -} - -void KviTalVBox::setAlignment(QWidget * pChild, Qt::Alignment alignment) -{ - m_pLayout->setAlignment(pChild,alignment); -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_vbox.moc" -#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_vbox.h b/src/kvilib/tal/kvi_tal_vbox.h deleted file mode 100644 index b38436aab..000000000 --- a/src/kvilib/tal/kvi_tal_vbox.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef _KVI_TAL_VBOX_H_ -#define _KVI_TAL_VBOX_H_ - -//============================================================================= -// -// File : kvi_tal_vbox.h -// Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net) -// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) -// -// 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 opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -/** -* \file kvi_tal_vbox.h -* \author Szymon Stefanek -* \brief Class for vertical box -*/ - -#include "kvi_settings.h" - -#include -#include - -/** -* \class KviTalVBox -* \brief Toolkit Abstraction Layer: vbox class -*/ -class KVILIB_API KviTalVBox : public QWidget -{ - Q_OBJECT -public: - /** - * \brief Constructs a vertical box object - * \param pParent The parent object - * \param pcName The name of the box - * \return KviTalVBox - */ - KviTalVBox(QWidget * pParent, char * pcName = 0); - - /** - * \brief Destroys a vertical box object - */ - ~KviTalVBox(); -private: - QVBoxLayout * m_pLayout; -public: - /** - * \brief Sets the stretch factor for an object - * \param pChild The object to stretch - * \param iStretch The stretch factor to use - * \return void - */ - void setStretchFactor(QWidget * pChild, int iStretch); - - /** - * \brief Sets the spacing of the box - * \param iSpacing The space in pixels - * \return void - */ - void setSpacing(int iSpacing); - - /** - * \brief Sets the margin of the box - * \param iMargin The margin in pixels - * \return void - */ - void setMargin(int iMargin); - - /** - * \brief Sets the alignment of the box - * \param alignment The alignment - * \return void - */ - void setAlignment(Qt::Alignment alignment); - - /** - * \brief Sets the alignment of the box for a child object - * \param pChild The object to align - * \param alignment The alignment - * \return void - */ - void setAlignment(QWidget * pChild, Qt::Alignment alignment); - - /** - * \brief Adds the stretch factor - * \param iStretch The stretch factor - * \return void - */ - void addStretch(int iStretch); -protected: - virtual void childEvent(QChildEvent * e); -}; - -#endif // _KVI_TAL_VBOX_H_ diff --git a/src/kvilib/tal/kvi_tal_wizard.cpp b/src/kvilib/tal/kvi_tal_wizard.cpp deleted file mode 100644 index e72078395..000000000 --- a/src/kvilib/tal/kvi_tal_wizard.cpp +++ /dev/null @@ -1,540 +0,0 @@ -//============================================================================= -// -// File : kvi_tal_wizard.cpp -// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_tal_wizard.h" -#include "kvi_tal_hbox.h" -#include "KviPointerList.h" -#include "KviLocale.h" - -#include -#include -#include -#include -#include -#include -#include - - -class KviTalWizardPageData -{ -public: - enum EnableFlags - { - EnableNext = 1, - EnableBack = 2, - EnableHelp = 4, - EnableCancel = 8, - EnableFinish = 16 - }; -public: - QWidget * pWidget; - QString szTitle; - bool bEnabled; - int iEnableFlags; - int iVisibleIndex; -}; - -class KviTalWizardPrivate -{ -public: - KviPointerList * pPageList; - int iEnabledPageCount; - KviTalWizardPageData * pCurrentPage; - QGridLayout * pLayout; - QLabel * pTitleLabel; - QLabel * pStepsLabel; - QPushButton * pBackButton; - QPushButton * pCancelButton; - QPushButton * pHelpButton; - QPushButton * pNextButton; - QWidget * pNextSpacer; - QPushButton * pFinishButton; - QWidget * pFinishSpacer; - QStackedWidget * pWidgetStack; -public: - KviTalWizardPageData * findPage(QWidget * pWidget) - { - for(KviTalWizardPageData * pData = pPageList->first();pData;pData = pPageList->next()) - { - if(pData->pWidget == pWidget) return pData; - } - return NULL; - } - - KviTalWizardPageData * findFirstEnabledPage() - { - KviTalWizardPageData * pData; - for(pData = pPageList->first();pData;pData = pPageList->next()) - { - if(pData->bEnabled) return pData; - } - return NULL; - } - - KviTalWizardPageData * findLastEnabledPage() - { - KviTalWizardPageData * pData; - for(pData = pPageList->last();pData;pData = pPageList->prev()) - { - if(pData->bEnabled) return pData; - } - return NULL; - } - - KviTalWizardPageData * findNextEnabledPage(QWidget * pReference) - { - if(!pReference) return findFirstEnabledPage(); - KviTalWizardPageData * pData = findPage(pReference); - if(!pData) return NULL; - for(pData = pPageList->next();pData;pData = pPageList->next()) - { - if(pData->bEnabled) return pData; - } - return NULL; - } - - KviTalWizardPageData * findPrevEnabledPage(QWidget * pReference) - { - if(!pReference) return findLastEnabledPage(); - KviTalWizardPageData * pData = findPage(pReference); - if(!pData) return NULL; - for(pData = pPageList->prev();pData;pData = pPageList->prev()) - { - if(pData->bEnabled) return pData; - } - return NULL; - } - - int reindexPages() - { - int iEnabledCount = 0; - for(KviTalWizardPageData * pData = pPageList->first();pData;pData = pPageList->next()) - { - if(pData->bEnabled) - { - iEnabledCount++; - pData->iVisibleIndex = iEnabledCount; - } - } - return iEnabledCount; - } -}; - - -KviTalWizard::KviTalWizard(QWidget * pParent) -: QDialog(pParent) -{ - m_p = new KviTalWizardPrivate; - m_p->pPageList = new KviPointerList; - m_p->pPageList->setAutoDelete(true); - m_p->pCurrentPage = NULL; - m_p->iEnabledPageCount = 0; - m_p->pLayout = new QGridLayout(this); - - m_p->pTitleLabel = new QLabel(this); - m_p->pLayout->addWidget(m_p->pTitleLabel,0,0,1,3); - - m_p->pStepsLabel = new QLabel(this); - m_p->pStepsLabel->setMinimumWidth(80); - m_p->pStepsLabel->setAlignment(Qt::AlignRight); - m_p->pLayout->addWidget(m_p->pStepsLabel,0,4,1,3); - - QFrame * f1 = new QFrame(this); - f1->setFrameStyle(QFrame::Sunken | QFrame::HLine); - m_p->pLayout->addWidget(f1,1,0,1,7); - - m_p->pWidgetStack = new QStackedWidget(this); - m_p->pLayout->addWidget(m_p->pWidgetStack,2,0,1,7); - - QFrame * f2 = new QFrame(this); - f2->setFrameStyle(QFrame::Sunken | QFrame::HLine); - m_p->pLayout->addWidget(f2,3,0,1,7); - - KviTalHBox * pButtonBox = new KviTalHBox(this); - m_p->pLayout->addWidget(pButtonBox,4,0,1,7); - - pButtonBox->setMargin(0); - pButtonBox->setSpacing(0); - - - m_p->pCancelButton = new QPushButton(__tr("Cancel"),pButtonBox); - m_p->pCancelButton->setMinimumWidth(80); - QObject::connect( - m_p->pCancelButton, - SIGNAL(clicked()), - this, - SLOT(cancelButtonClicked()) - ); - - QWidget * pSpacer = new QWidget(pButtonBox); - pSpacer->setFixedWidth(4); - - m_p->pHelpButton = new QPushButton(__tr("Help"),pButtonBox); - m_p->pHelpButton->setMinimumWidth(80); - QObject::connect( - m_p->pHelpButton, - SIGNAL(clicked()), - this, - SLOT(helpButtonClicked()) - ); - - QWidget * pLargeSpacer = new QWidget(pButtonBox); - pLargeSpacer->setMinimumWidth(50); - pButtonBox->setStretchFactor(pLargeSpacer,100); - - QString szText = "< "; - szText += __tr("Back"); - m_p->pBackButton = new QPushButton(szText,pButtonBox); - m_p->pBackButton->setMinimumWidth(80); - QObject::connect( - m_p->pBackButton, - SIGNAL(clicked()), - this, - SLOT(backButtonClicked()) - ); - - m_p->pNextSpacer = new QWidget(pButtonBox); - m_p->pNextSpacer->setFixedWidth(4); - - szText = __tr("Next"); - szText += " >"; - m_p->pNextButton = new QPushButton(szText,pButtonBox); - m_p->pNextButton->setMinimumWidth(80); - QObject::connect( - m_p->pNextButton, - SIGNAL(clicked()), - this, - SLOT(nextButtonClicked()) - ); - - m_p->pFinishSpacer = new QWidget(pButtonBox); - m_p->pFinishSpacer->setFixedWidth(4); - - m_p->pFinishButton = new QPushButton(__tr("Finish"),pButtonBox); - m_p->pFinishButton->setMinimumWidth(80); - QObject::connect( - m_p->pFinishButton, - SIGNAL(clicked()), - this, - SLOT(finishButtonClicked()) - ); - - m_p->pLayout->setMargin(8); - m_p->pLayout->setSpacing(4); - m_p->pLayout->setRowStretch(2,1); - m_p->pLayout->setColumnStretch(0,1); -} - -KviTalWizard::~KviTalWizard() -{ - delete m_p->pPageList; - delete m_p; -} - -void KviTalWizard::insertPage(QWidget * pWidget,const QString &szTitle,int iIndex) -{ - KviTalWizardPageData * pPageData = m_p->findPage(pWidget); - if(!pPageData) - { - pPageData = new KviTalWizardPageData; - pPageData->pWidget = pWidget; - pPageData->iEnableFlags = \ - KviTalWizardPageData::EnableNext | \ - KviTalWizardPageData::EnableCancel | \ - KviTalWizardPageData::EnableBack; - if(iIndex < 0) - { - m_p->pPageList->append(pPageData); - m_p->iEnabledPageCount++; - pPageData->iVisibleIndex = m_p->iEnabledPageCount; - } else { - m_p->pPageList->insert(iIndex,pPageData); - m_p->iEnabledPageCount = m_p->reindexPages(); - } - m_p->pWidgetStack->addWidget(pWidget); - } - pPageData->szTitle = szTitle; - pPageData->bEnabled = true; - -} - -void KviTalWizard::addPage(QWidget * pWidget,const QString &szTitle) -{ - insertPage(pWidget,szTitle,-1); -} - -bool KviTalWizard::setPageEnabled(QWidget * pWidget,bool bEnabled) -{ - KviTalWizardPageData * pData = m_p->findPage(pWidget); - if(!pData) - return false; - pData->bEnabled = bEnabled; - m_p->iEnabledPageCount = m_p->reindexPages(); - setCurrentPage(m_p->pCurrentPage); - return true; -} - -bool KviTalWizard::setPageTitle(QWidget * pWidget,const QString &szTitle) -{ - KviTalWizardPageData * pData = m_p->findPage(pWidget); - if(!pData) - return false; - pData->szTitle = szTitle; - return true; -} - -bool KviTalWizard::setCurrentPage(QWidget * pWidget) -{ - KviTalWizardPageData * pData = m_p->findPage(pWidget); - if(!pData) - return false; - setCurrentPage(pData); - return true; -} - -QWidget * KviTalWizard::currentPage() -{ - if(!m_p->pCurrentPage) - return NULL; - return m_p->pCurrentPage->pWidget; -} - -void KviTalWizard::setCurrentPage(KviTalWizardPageData * pData) -{ - m_p->pCurrentPage = pData; - - bool bCancelEnabled = true; - bool bNextEnabled = false; - bool bBackEnabled = false; - bool bHelpEnabled = false; - bool bFinishEnabled = false; - - QString szTitle; - QString szSteps; - - if(pData) - { - bNextEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableNext) && m_p->findNextEnabledPage(pData->pWidget); - bBackEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableBack) && m_p->findPrevEnabledPage(pData->pWidget); - bCancelEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableCancel); - bFinishEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableFinish); - bHelpEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableHelp); - m_p->pWidgetStack->setCurrentWidget(pData->pWidget); - - szTitle = ""; - szTitle += pData->szTitle; - szTitle += ""; - QPalette pal = m_p->pStepsLabel->palette(); - QColor clrWin = pal.color(QPalette::Normal,QPalette::Window); - QColor clrTxt = pal.color(QPalette::Normal,QPalette::WindowText); - QColor clrMid = qRgb( - (clrWin.red() + clrTxt.red()) / 2, - (clrWin.green() + clrTxt.green()) / 2, - (clrWin.blue() + clrTxt.blue()) / 2 - ); - - szSteps = "["; - szSteps += QString("Step %1 of %2").arg(pData->iVisibleIndex).arg(m_p->iEnabledPageCount); - szSteps += "]"; - } - - m_p->pTitleLabel->setText(szTitle); - m_p->pStepsLabel->setText(szSteps); - - m_p->pNextButton->setEnabled(bNextEnabled); - if(bNextEnabled) - { - m_p->pNextButton->show(); - m_p->pNextSpacer->show(); - m_p->pNextButton->setDefault(true); - } else { - m_p->pNextButton->hide(); - m_p->pNextSpacer->hide(); - m_p->pNextButton->setDefault(false); - } - m_p->pBackButton->setEnabled(bBackEnabled); - m_p->pHelpButton->setEnabled(bHelpEnabled); - if(bHelpEnabled) - m_p->pHelpButton->show(); - else - m_p->pHelpButton->hide(); - m_p->pCancelButton->setEnabled(bCancelEnabled); - m_p->pFinishButton->setEnabled(bFinishEnabled); - if(bFinishEnabled) - { - m_p->pFinishButton->show(); - m_p->pFinishSpacer->show(); - m_p->pFinishButton->setDefault(true); - } else { - m_p->pFinishButton->hide(); - m_p->pFinishSpacer->hide(); - m_p->pFinishButton->setDefault(false); - } -} - -void KviTalWizard::showEvent(QShowEvent * e) -{ - if(!(m_p->pCurrentPage)) - { - // display the first page - KviTalWizardPageData * pData = m_p->findFirstEnabledPage(); - if(pData) - setCurrentPage(pData->pWidget); - } - QDialog::showEvent(e); - emit pageChanged(m_p->pCurrentPage->szTitle); -} - -void KviTalWizard::closeEvent(QCloseEvent * e) -{ - e->ignore(); - cancelButtonClicked(); -} - -void KviTalWizard::backButtonClicked() -{ - if(!m_p->pCurrentPage) - return; - setCurrentPage(m_p->findPrevEnabledPage(m_p->pCurrentPage->pWidget)); - emit pageChanged(m_p->pCurrentPage->szTitle); -} - -void KviTalWizard::nextButtonClicked() -{ - setCurrentPage(m_p->findNextEnabledPage(m_p->pCurrentPage->pWidget)); - emit pageChanged(m_p->pCurrentPage->szTitle); -} - -void KviTalWizard::helpButtonClicked() -{ - emit helpClicked(); -} - -void KviTalWizard::cancelButtonClicked() -{ - reject(); -} - -void KviTalWizard::finishButtonClicked() -{ - accept(); -} - -void KviTalWizard::setHelpEnabled(QWidget * pWidget,bool bEnabled) -{ - KviTalWizardPageData * pData = m_p->findPage(pWidget); - if(!pData) - return; - if(bEnabled) - pData->iEnableFlags |= KviTalWizardPageData::EnableHelp; - else - pData->iEnableFlags &= ~KviTalWizardPageData::EnableHelp; - if(pData == m_p->pCurrentPage) - setCurrentPage(pData); -} - -void KviTalWizard::setCancelEnabled(QWidget * pWidget,bool bEnabled) -{ - KviTalWizardPageData * pData = m_p->findPage(pWidget); - if(!pData) - return; - if(bEnabled) - pData->iEnableFlags |= KviTalWizardPageData::EnableCancel; - else - pData->iEnableFlags &= ~KviTalWizardPageData::EnableCancel; - if(pData == m_p->pCurrentPage) - setCurrentPage(pData); -} - -void KviTalWizard::setFinishEnabled(QWidget * pWidget,bool bEnabled) -{ - KviTalWizardPageData * pData = m_p->findPage(pWidget); - if(!pData) - return; - if(bEnabled) - pData->iEnableFlags |= KviTalWizardPageData::EnableFinish; - else - pData->iEnableFlags &= ~KviTalWizardPageData::EnableFinish; - if(pData == m_p->pCurrentPage) - setCurrentPage(pData); -} - -void KviTalWizard::setNextEnabled(QWidget * pWidget,bool bEnabled) -{ - KviTalWizardPageData * pData = m_p->findPage(pWidget); - if(!pData) - return; - if(bEnabled) - pData->iEnableFlags |= KviTalWizardPageData::EnableNext; - else - pData->iEnableFlags &= ~KviTalWizardPageData::EnableNext; - if(pData == m_p->pCurrentPage) - setCurrentPage(pData); -} - -void KviTalWizard::setBackEnabled(QWidget * pWidget,bool bEnabled) -{ - KviTalWizardPageData * pData = m_p->findPage(pWidget); - if(!pData) - return; - if(bEnabled) - pData->iEnableFlags |= KviTalWizardPageData::EnableBack; - else - pData->iEnableFlags &= ~KviTalWizardPageData::EnableBack; - if(pData == m_p->pCurrentPage) - setCurrentPage(pData); -} - -QPushButton * KviTalWizard::cancelButton() -{ - return m_p->pCancelButton; -} - -QPushButton * KviTalWizard::helpButton() -{ - return m_p->pHelpButton; -} - -QPushButton * KviTalWizard::finishButton() -{ - return m_p->pFinishButton; -} - -QPushButton * KviTalWizard::nextButton() -{ - return m_p->pNextButton; -} - -QPushButton * KviTalWizard::backButton() -{ - return m_p->pBackButton; -} - -#ifdef COMPILE_ON_WINDOWS - #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_wizard.moc" - #endif //!COMPILE_USE_STANDALONE_MOC_SOURCES -#endif diff --git a/src/kvilib/tal/kvi_tal_wizard.h b/src/kvilib/tal/kvi_tal_wizard.h deleted file mode 100644 index 0cba628d5..000000000 --- a/src/kvilib/tal/kvi_tal_wizard.h +++ /dev/null @@ -1,168 +0,0 @@ -#ifndef _KVI_TAL_WIZARD_H_ -#define _KVI_TAL_WIZARD_H_ - -//============================================================================= -// -// File : kvi_tal_wizard.h -// Creation date : Tue Feb 06 2007 14:35:08 by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007-2010 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -//============================================================================= - -#include "kvi_settings.h" - -#include - - -class QShowEvent; -class QPushButton; -class KviTalWizardPrivate; -class KviTalWizardPageData; - -/// -/// \class KviTalWizard -/// -/// \brief Provides a wizard-style dialog with steps -/// -class KVILIB_API KviTalWizard : public QDialog -{ - Q_OBJECT -public: - KviTalWizard(QWidget * pParent); - ~KviTalWizard(); -protected: - KviTalWizardPrivate * m_p; -public: - /// - /// Adds a page to the wizard with the specified title. - /// The pages are displayed in order they're added. - /// Adding a page a second time is equivalent to calling - /// setPageTitle() and enabling the page. - /// - void addPage(QWidget * pWidget,const QString &szTitle); - /// - /// Adds a page to the wizard with the specified title - /// and in the specified position. - /// Adding a page a second time is equivalent to calling - /// setPageTitle() and enabling the page. - /// - void insertPage(QWidget * pWidget,const QString &szTitle,int iIndex); - /// - /// Enables or disables a page. A disabled page - /// is skipped when the user presses "Next" in the - /// previous page or "Back" in the page after. - /// Disabling the current page has no effect. - /// - /// Returns true on success or false if the pWidget - /// does not identify a page that has been added to this wizard. - /// - bool setPageEnabled(QWidget * pWidget,bool bEnabled); - /// - /// Changes a page title. - /// - /// Returns true on success or false if the pWidget - /// does not identify a page that has been added to this wizard. - /// - bool setPageTitle(QWidget * pWidget,const QString &szTitle); - /// - /// Switches the wizard to the specified page. - /// Please note that this class handles page switching - /// automatically so you usually don't need to call this function. - /// - /// Returns true on success or false if the pWidget - /// does not identify a page that has been added to this wizard. - /// - bool setCurrentPage(QWidget * pWidget); - /// - /// Returns a pointer to the current page - /// - QWidget * currentPage(); - /// - /// Enables or disables the help button for the specified page. - /// By default the help button is always disabled. - /// - void setHelpEnabled(QWidget * pWidget,bool bEnabled); - /// - /// Enables or disables the cancel button for the specified page. - /// By default the cancel button is always enabled. - /// - void setCancelEnabled(QWidget * pWidget,bool bEnabled); - /// - /// Enables or disables the finish button for the specified page. - /// By default the finish button is always disabled. - /// - void setFinishEnabled(QWidget * pWidget,bool bEnabled); - /// - /// Enables or disables the next button for the specified page. - /// By default the next button is always enabled. - /// - void setNextEnabled(QWidget * pWidget,bool bEnabled); - /// - /// Enables or disables the prev button for the specified page. - /// By default the prev button is always enabled. - /// - void setBackEnabled(QWidget * pWidget,bool bEnabled); - /// - /// Returns a pointer to the cancel button displayed in the dialog. - /// - QPushButton * cancelButton(); - /// - /// Returns a pointer to the help button displayed in the dialog. - /// - QPushButton * helpButton(); - /// - /// Returns a pointer to the finish button displayed in the dialog. - /// - QPushButton * finishButton(); - /// - /// Returns a pointer to the next button displayed in the dialog. - /// - QPushButton * nextButton(); - /// - /// Returns a pointer to the back button displayed in the dialog. - /// - QPushButton * backButton(); -signals: - /// - /// Emitted when the help button is clicked. - /// - void helpClicked(); - void pageChanged(QString title); -protected: - /// - /// Displays the first page if no other page is shown yet. - /// - virtual void showEvent(QShowEvent * e); - - /// - /// Handles redirects the close button to the "cancel" operation. - /// - virtual void closeEvent(QCloseEvent * e); -protected: - void setCurrentPage(KviTalWizardPageData * pData); -protected slots: - void backButtonClicked(); - void nextButtonClicked(); - void helpButtonClicked(); - void cancelButtonClicked(); - void finishButtonClicked(); -}; - - -#endif // _KVI_TAL_WIZARD_H_ diff --git a/src/kvirc/kernel/kvi_action.cpp b/src/kvirc/kernel/kvi_action.cpp index 427b55385..37f041290 100644 --- a/src/kvirc/kernel/kvi_action.cpp +++ b/src/kvirc/kernel/kvi_action.cpp @@ -31,7 +31,7 @@ #include "kvi_window.h" #include "kvi_channel.h" #include "kvi_query.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include diff --git a/src/kvirc/kernel/kvi_app.cpp b/src/kvirc/kernel/kvi_app.cpp index 95170fe87..e891e8ca8 100644 --- a/src/kvirc/kernel/kvi_app.cpp +++ b/src/kvirc/kernel/kvi_app.cpp @@ -54,7 +54,7 @@ #include "KviNickServRuleSet.h" #include "KviIdentityProfile.h" #include "kvi_defaultscript.h" -#include "kvi_xlib.h" +#include "KviXlib.h" #include "kvi_texticonmanager.h" #include "kvi_texticonwin.h" #include "kvi_historywin.h" @@ -83,14 +83,14 @@ #include "kvi_kvs_eventtriggers.h" #include "kvi_sourcesdate.h" #include "KviPointerHashTable.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #ifndef COMPILE_NO_IPC #include "kvi_ipc.h" #endif #ifdef COMPILE_SSL_SUPPORT - #include "kvi_ssl.h" + #include "KviSSL.h" #endif #include diff --git a/src/kvirc/kernel/kvi_app.h b/src/kvirc/kernel/kvi_app.h index c034b0cd3..9f3eac555 100644 --- a/src/kvirc/kernel/kvi_app.h +++ b/src/kvirc/kernel/kvi_app.h @@ -28,7 +28,7 @@ #include "kvi_settings.h" #include "KviCString.h" #include "KviQString.h" -#include "kvi_tal_application.h" +#include "KviTalApplication.h" #include "KviPointerList.h" #include "KviTimeUtils.h" #include "KviPointerHashTable.h" // ? diff --git a/src/kvirc/kernel/kvi_coreactions.cpp b/src/kvirc/kernel/kvi_coreactions.cpp index 8ce351051..44e5f9569 100644 --- a/src/kvirc/kernel/kvi_coreactions.cpp +++ b/src/kvirc/kernel/kvi_coreactions.cpp @@ -44,7 +44,7 @@ #include "kvi_coreactionnames.h" #include "kvi_ircconnectionserverinfo.h" #include "kvi_kvs_script.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include diff --git a/src/kvirc/kernel/kvi_filetransfer.cpp b/src/kvirc/kernel/kvi_filetransfer.cpp index 1bb617cbf..b3860b658 100644 --- a/src/kvirc/kernel/kvi_filetransfer.cpp +++ b/src/kvirc/kernel/kvi_filetransfer.cpp @@ -28,7 +28,7 @@ #include "kvi_app.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" static KviFileTransferManager * g_pFileTransferManager = 0; diff --git a/src/kvirc/kernel/kvi_filetransfer.h b/src/kvirc/kernel/kvi_filetransfer.h index 5ae77cbc2..45f64cddb 100644 --- a/src/kvirc/kernel/kvi_filetransfer.h +++ b/src/kvirc/kernel/kvi_filetransfer.h @@ -27,7 +27,7 @@ #include "kvi_settings.h" #include "KviPointerList.h" -#include "kvi_tal_tablewidget.h" +#include "KviTalTableWidget.h" #include diff --git a/src/kvirc/kernel/kvi_ipc.h b/src/kvirc/kernel/kvi_ipc.h index 508373f01..e3d68071e 100644 --- a/src/kvirc/kernel/kvi_ipc.h +++ b/src/kvirc/kernel/kvi_ipc.h @@ -39,7 +39,7 @@ #else #ifdef COMPILE_X11_SUPPORT #include - #include "kvi_xlib.h" // for XEvent + #include "KviXlib.h" // for XEvent #endif //!COMPILE_X11_SUPPORT #endif diff --git a/src/kvirc/kernel/kvi_ircconnection.cpp b/src/kvirc/kernel/kvi_ircconnection.cpp index 3e4aa040b..958902b46 100644 --- a/src/kvirc/kernel/kvi_ircconnection.cpp +++ b/src/kvirc/kernel/kvi_ircconnection.cpp @@ -45,7 +45,7 @@ #include "kvi_out.h" #include "kvi_options.h" #include "kvi_console.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_internalcmd.h" #include "kvi_frame.h" #include "kvi_mexlinkfilter.h" @@ -57,7 +57,7 @@ #include "kvi_app.h" #include "KviDataBuffer.h" #include "kvi_notifylist.h" -#include "kvi_dns.h" +#include "KviDnsResolver.h" #include "kvi_defaults.h" #include "kvi_sparser.h" #include "kvi_ircdatastreammonitor.h" @@ -68,7 +68,7 @@ #include "KviMircCntrl.h" #include "KviUserIdentity.h" #include "KviIdentityProfile.h" -#include "kvi_sasl.h" +#include "KviSASL.h" #include "KviNickColors.h" #include @@ -116,7 +116,7 @@ KviIrcConnection::~KviIrcConnection() m_bIdentdAttached = false; if(m_pLocalhostDns) { - QObject::disconnect(m_pLocalhostDns,SIGNAL(lookupDone(KviDns *)),0,0); + QObject::disconnect(m_pLocalhostDns,SIGNAL(lookupDone(KviDnsResolver *)),0,0); if(m_pLocalhostDns->isRunning()) { m_pLocalhostDns->deleteLater(); @@ -1037,10 +1037,10 @@ void KviIrcConnection::userInfoReceived(const QString & szUserName, const QStrin // look it up too if(m_pLocalhostDns) delete m_pLocalhostDns; // it could be only another local host lookup - m_pLocalhostDns = new KviDns(); - connect(m_pLocalhostDns,SIGNAL(lookupDone(KviDns *)),this,SLOT(hostNameLookupTerminated(KviDns *))); + m_pLocalhostDns = new KviDnsResolver(); + connect(m_pLocalhostDns,SIGNAL(lookupDone(KviDnsResolver *)),this,SLOT(hostNameLookupTerminated(KviDnsResolver *))); - if(!m_pLocalhostDns->lookup(szHostName,KviDns::Any)) + if(!m_pLocalhostDns->lookup(szHostName,KviDnsResolver::Any)) { if(!_OUTPUT_MUTE) { @@ -1058,7 +1058,7 @@ void KviIrcConnection::userInfoReceived(const QString & szUserName, const QStrin } } -void KviIrcConnection::hostNameLookupTerminated(KviDns *) +void KviIrcConnection::hostNameLookupTerminated(KviDnsResolver *) { if(!m_pLocalhostDns) { @@ -1066,7 +1066,7 @@ void KviIrcConnection::hostNameLookupTerminated(KviDns *) return; } - if(m_pLocalhostDns->state() != KviDns::Success) + if(m_pLocalhostDns->state() != KviDnsResolver::Success) { QString szErr = KviError::getDescription(m_pLocalhostDns->error()); if(!m_pUserInfo->hostIp().isEmpty()) diff --git a/src/kvirc/kernel/kvi_ircconnection.h b/src/kvirc/kernel/kvi_ircconnection.h index b0ce0d4b1..e89eff30f 100644 --- a/src/kvirc/kernel/kvi_ircconnection.h +++ b/src/kvirc/kernel/kvi_ircconnection.h @@ -63,7 +63,7 @@ class KviIrcConnectionStatistics; class KviRequestQueue; class KviLagMeter; class KviNotifyListManager; -class KviDns; +class KviDnsResolver; class KviUserIdentity; class KviIdentityProfileSet; class KviCString; @@ -172,7 +172,7 @@ private: KviIrcConnectionStatistics * m_pStatistics; // owned, never null - KviDns * m_pLocalhostDns; // FIXME: this should go to an aux structure + KviDnsResolver * m_pLocalhostDns; // FIXME: this should go to an aux structure QTextCodec * m_pSrvCodec; // connection codec: never null QTextCodec * m_pTextCodec; // connection codec: never null @@ -900,7 +900,7 @@ private slots: * \brief Called when the hostname lookup is finished * \return void */ - void hostNameLookupTerminated(KviDns * pDns); + void hostNameLookupTerminated(KviDnsResolver * pDns); signals: /** * \brief Emitted when the away state changes diff --git a/src/kvirc/kernel/kvi_ircconnectiontargetresolver.cpp b/src/kvirc/kernel/kvi_ircconnectiontargetresolver.cpp index 07fb0a424..0bde7324b 100644 --- a/src/kvirc/kernel/kvi_ircconnectiontargetresolver.cpp +++ b/src/kvirc/kernel/kvi_ircconnectiontargetresolver.cpp @@ -25,7 +25,7 @@ #include "kvi_ircconnectiontargetresolver.h" -#include "kvi_dns.h" +#include "KviDnsResolver.h" #include "KviLocale.h" #include "KviIrcServerDataBase.h" #include "KviProxyDataBase.h" @@ -34,7 +34,7 @@ #include "kvi_options.h" #include "kvi_ircsocket.h" #include "kvi_console.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_internalcmd.h" #include "kvi_frame.h" #include "kvi_mexlinkfilter.h" @@ -229,11 +229,11 @@ void KviIrcConnectionTargetResolver::lookupProxyHostname() m_pProxyDns = 0; } - m_pProxyDns = new KviDns(); - connect(m_pProxyDns,SIGNAL(lookupDone(KviDns *)),this,SLOT(proxyLookupTerminated(KviDns *))); + m_pProxyDns = new KviDnsResolver(); + connect(m_pProxyDns,SIGNAL(lookupDone(KviDnsResolver *)),this,SLOT(proxyLookupTerminated(KviDnsResolver *))); if(!m_pProxyDns->lookup(m_pTarget->proxy()->m_szHostname, - m_pTarget->proxy()->isIPv6() ? KviDns::IPv6 : KviDns::IPv4)) + m_pTarget->proxy()->isIPv6() ? KviDnsResolver::IPv6 : KviDnsResolver::IPv4)) { m_pConsole->outputNoFmt(KVI_OUT_SYSTEMWARNING, __tr2qs("Unable to look up the IRC proxy hostname: Can't start the DNS slave")); @@ -254,9 +254,9 @@ void KviIrcConnectionTargetResolver::lookupProxyHostname() } } -void KviIrcConnectionTargetResolver::proxyLookupTerminated(KviDns *) +void KviIrcConnectionTargetResolver::proxyLookupTerminated(KviDnsResolver *) { - if(m_pProxyDns->state() != KviDns::Success) + if(m_pProxyDns->state() != KviDnsResolver::Success) { QString szErr = KviError::getDescription(m_pProxyDns->error()); m_pConsole->output(KVI_OUT_SYSTEMERROR, @@ -346,11 +346,11 @@ void KviIrcConnectionTargetResolver::lookupServerHostname() delete m_pServerDns; m_pServerDns = 0; } - m_pServerDns = new KviDns(); - connect(m_pServerDns,SIGNAL(lookupDone(KviDns *)),this, - SLOT(serverLookupTerminated(KviDns *))); + m_pServerDns = new KviDnsResolver(); + connect(m_pServerDns,SIGNAL(lookupDone(KviDnsResolver *)),this, + SLOT(serverLookupTerminated(KviDnsResolver *))); if(!m_pServerDns->lookup(m_pTarget->server()->m_szHostname, - m_pTarget->server()->isIPv6() ? KviDns::IPv6 : KviDns::IPv4)) + m_pTarget->server()->isIPv6() ? KviDnsResolver::IPv6 : KviDnsResolver::IPv4)) { m_pConsole->outputNoFmt(KVI_OUT_SYSTEMERROR, __tr2qs("Unable to look up the server hostname: Can't start the DNS slave")); @@ -366,9 +366,9 @@ void KviIrcConnectionTargetResolver::lookupServerHostname() } -void KviIrcConnectionTargetResolver::serverLookupTerminated(KviDns *) +void KviIrcConnectionTargetResolver::serverLookupTerminated(KviDnsResolver *) { - if(m_pServerDns->state() != KviDns::Success) + if(m_pServerDns->state() != KviDnsResolver::Success) { QString szErr = KviError::getDescription(m_pServerDns->error()); m_pConsole->output(KVI_OUT_SYSTEMERROR, diff --git a/src/kvirc/kernel/kvi_ircconnectiontargetresolver.h b/src/kvirc/kernel/kvi_ircconnectiontargetresolver.h index b6d140117..ee5021880 100644 --- a/src/kvirc/kernel/kvi_ircconnectiontargetresolver.h +++ b/src/kvirc/kernel/kvi_ircconnectiontargetresolver.h @@ -30,7 +30,7 @@ #include class KviConsole; -class KviDns; +class KviDnsResolver; class KviIrcConnection; class KviIrcConnectionTarget; @@ -55,8 +55,8 @@ private: // Auxiliary stuff QTimer * m_pStartTimer; // timer used to start the connection - KviDns * m_pProxyDns; // the dns object for the proxy hostnames - KviDns * m_pServerDns; // the dns object for the server hostnames + KviDnsResolver * m_pProxyDns; // the dns object for the proxy hostnames + KviDnsResolver * m_pServerDns; // the dns object for the server hostnames char * m_pReadBuffer; unsigned int m_uReadBufferLen; @@ -73,8 +73,8 @@ public: void abort(); protected slots: void asyncStartResolve(); - void serverLookupTerminated(KviDns *); - void proxyLookupTerminated(KviDns *); + void serverLookupTerminated(KviDnsResolver *); + void proxyLookupTerminated(KviDnsResolver *); private: void cleanup(); void lookupProxyHostname(); diff --git a/src/kvirc/kernel/kvi_irccontext.cpp b/src/kvirc/kernel/kvi_irccontext.cpp index a97589952..fb453d711 100644 --- a/src/kvirc/kernel/kvi_irccontext.cpp +++ b/src/kvirc/kernel/kvi_irccontext.cpp @@ -50,7 +50,7 @@ #include "kvi_app.h" #include "kvi_kvs_eventtriggers.h" #include "kvi_kvs_script.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_ircurl.h" #include "KviUserIdentity.h" diff --git a/src/kvirc/kernel/kvi_irclink.cpp b/src/kvirc/kernel/kvi_irclink.cpp index 919941106..e9d5ad11f 100644 --- a/src/kvirc/kernel/kvi_irclink.cpp +++ b/src/kvirc/kernel/kvi_irclink.cpp @@ -24,7 +24,7 @@ #include "kvi_irclink.h" -#include "kvi_dns.h" +#include "KviDnsResolver.h" #include "KviLocale.h" #include "KviIrcServerDataBase.h" #include "KviProxyDataBase.h" @@ -33,7 +33,7 @@ #include "kvi_options.h" #include "kvi_ircsocket.h" #include "kvi_console.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_internalcmd.h" #include "kvi_frame.h" #include "kvi_mexlinkfilter.h" diff --git a/src/kvirc/kernel/kvi_irclink.h b/src/kvirc/kernel/kvi_irclink.h index fc58deae9..9989fd81b 100644 --- a/src/kvirc/kernel/kvi_irclink.h +++ b/src/kvirc/kernel/kvi_irclink.h @@ -39,7 +39,7 @@ class KviConsole; class KviServer; class KviProxy; class KviIrcSocket; -class KviDns; +class KviDnsResolver; class KviIrcConnection; class KviIrcConnectionTarget; class KviIrcConnectionTargetResolver; diff --git a/src/kvirc/kernel/kvi_ircsocket.cpp b/src/kvirc/kernel/kvi_ircsocket.cpp index 68b6f5514..9803316d9 100644 --- a/src/kvirc/kernel/kvi_ircsocket.cpp +++ b/src/kvirc/kernel/kvi_ircsocket.cpp @@ -26,7 +26,7 @@ #include "kvi_ircsocket.h" #include "KviIrcServer.h" #include "KviProxyDataBase.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_settings.h" #include "kvi_error.h" #include "KviLocale.h" diff --git a/src/kvirc/kernel/kvi_sslmaster.cpp b/src/kvirc/kernel/kvi_sslmaster.cpp index 0acae6285..83fc67519 100644 --- a/src/kvirc/kernel/kvi_sslmaster.cpp +++ b/src/kvirc/kernel/kvi_sslmaster.cpp @@ -1,6 +1,6 @@ //============================================================================= // -// File : kvi_sslmanager.cpp +// File : KviSSLmanager.cpp // Creation date : Mon Jun 17 2002 20:34:00 by Szymon Stefanek // // This file is part of the KVirc irc client distribution diff --git a/src/kvirc/kernel/kvi_sslmaster.h b/src/kvirc/kernel/kvi_sslmaster.h index 1725cfde3..6fb4a5cfe 100644 --- a/src/kvirc/kernel/kvi_sslmaster.h +++ b/src/kvirc/kernel/kvi_sslmaster.h @@ -28,7 +28,7 @@ #ifdef COMPILE_SSL_SUPPORT -#include "kvi_ssl.h" +#include "KviSSL.h" #include "kvi_sockettype.h" class KviWindow; diff --git a/src/kvirc/kvs/kvi_kvs_asyncdnsoperation.cpp b/src/kvirc/kvs/kvi_kvs_asyncdnsoperation.cpp index d4963d9c2..c06bb0c9d 100644 --- a/src/kvirc/kvs/kvi_kvs_asyncdnsoperation.cpp +++ b/src/kvirc/kvs/kvi_kvs_asyncdnsoperation.cpp @@ -25,7 +25,7 @@ #include "kvi_kvs_asyncdnsoperation.h" -#include "kvi_dns.h" +#include "KviDnsResolver.h" #include "kvi_kvs_script.h" #include "kvi_kvs_variant.h" #include "kvi_app.h" @@ -37,15 +37,15 @@ #include -KviKvsAsyncDnsOperation::KviKvsAsyncDnsOperation(KviWindow * pWnd,QString &szQuery,KviDns::QueryType eType,KviKvsScript * pCallback,KviKvsVariant * pMagic) +KviKvsAsyncDnsOperation::KviKvsAsyncDnsOperation(KviWindow * pWnd,QString &szQuery,KviDnsResolver::QueryType eType,KviKvsScript * pCallback,KviKvsVariant * pMagic) : KviKvsAsyncOperation(pWnd) { - m_pDns = new KviDns(); + m_pDns = new KviDnsResolver(); m_szQuery = szQuery; m_eType = eType; m_pCallback = pCallback; m_pMagic = pMagic; - connect(m_pDns,SIGNAL(lookupDone(KviDns *)),this,SLOT(lookupTerminated(KviDns *))); + connect(m_pDns,SIGNAL(lookupDone(KviDnsResolver *)),this,SLOT(lookupTerminated(KviDnsResolver *))); if(!m_pDns->lookup(szQuery,eType)) QTimer::singleShot(10,this,SLOT(dnsStartFailed())); } @@ -62,7 +62,7 @@ void KviKvsAsyncDnsOperation::dnsStartFailed() lookupTerminated(m_pDns); } -void KviKvsAsyncDnsOperation::lookupTerminated(KviDns *) +void KviKvsAsyncDnsOperation::lookupTerminated(KviDnsResolver *) { KviWindow * pWnd = window(); if(!g_pApp->windowExists(pWnd))pWnd = g_pActiveWindow; @@ -71,7 +71,7 @@ void KviKvsAsyncDnsOperation::lookupTerminated(KviDns *) { KviKvsVariantList params; params.setAutoDelete(true); - if(m_pDns->state() == KviDns::Failure) + if(m_pDns->state() == KviDnsResolver::Failure) { params.append(new KviKvsVariant(m_szQuery)); params.append(new KviKvsVariant((kvs_int_t)0)); @@ -99,7 +99,7 @@ void KviKvsAsyncDnsOperation::lookupTerminated(KviDns *) QString szQuery = m_pDns->query(); pWnd->output(KVI_OUT_HOSTLOOKUP,__tr2qs_ctx("DNS Lookup result for query \"%Q\"","kvs"),&szQuery); - if(m_pDns->state() == KviDns::Failure) + if(m_pDns->state() == KviDnsResolver::Failure) { QString strDescription(KviError::getDescription(m_pDns->error())); pWnd->output(KVI_OUT_HOSTLOOKUP,__tr2qs_ctx("Error: %Q","kvs"),&strDescription); diff --git a/src/kvirc/kvs/kvi_kvs_asyncdnsoperation.h b/src/kvirc/kvs/kvi_kvs_asyncdnsoperation.h index 97a4f615f..001a17cd8 100644 --- a/src/kvirc/kvs/kvi_kvs_asyncdnsoperation.h +++ b/src/kvirc/kvs/kvi_kvs_asyncdnsoperation.h @@ -27,7 +27,7 @@ #include "kvi_settings.h" #include "kvi_kvs_asyncoperation.h" #include "KviQString.h" -#include "kvi_dns.h" +#include "KviDnsResolver.h" class KviWindow; class KviKvsScript; @@ -37,16 +37,16 @@ class KVIRC_API KviKvsAsyncDnsOperation : public KviKvsAsyncOperation { Q_OBJECT public: - KviKvsAsyncDnsOperation(KviWindow * pWnd,QString &szQuery,KviDns::QueryType eType,KviKvsScript * pCallback = 0,KviKvsVariant * pMagic = 0); + KviKvsAsyncDnsOperation(KviWindow * pWnd,QString &szQuery,KviDnsResolver::QueryType eType,KviKvsScript * pCallback = 0,KviKvsVariant * pMagic = 0); virtual ~KviKvsAsyncDnsOperation(); protected: - KviDns * m_pDns; - KviDns::QueryType m_eType; + KviDnsResolver * m_pDns; + KviDnsResolver::QueryType m_eType; KviKvsVariant * m_pMagic; KviKvsScript * m_pCallback; QString m_szQuery; protected slots: - void lookupTerminated(KviDns *); + void lookupTerminated(KviDnsResolver *); void dnsStartFailed(); }; diff --git a/src/kvirc/kvs/kvi_kvs_corecallbackcommands.cpp b/src/kvirc/kvs/kvi_kvs_corecallbackcommands.cpp index 83c7e8947..cde1e5733 100644 --- a/src/kvirc/kvs/kvi_kvs_corecallbackcommands.cpp +++ b/src/kvirc/kvs/kvi_kvs_corecallbackcommands.cpp @@ -42,7 +42,7 @@ #include "kvi_iconmanager.h" #include "KviLocale.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include @@ -143,9 +143,9 @@ namespace KviKvsCoreCallbackCommands KVSCCC_PARAMETER("magic",KVS_PT_VARIANT,KVS_PF_OPTIONAL,pMagicPtr) KVSCCC_PARAMETERS_END - KviDns::QueryType queryType = KviDns::IPv4; - if(KVSCCC_pSwitches->find('i',"ipv6"))queryType = KviDns::IPv6; - if(KVSCCC_pSwitches->find('a',"any"))queryType = KviDns::Any; + KviDnsResolver::QueryType queryType = KviDnsResolver::IPv4; + if(KVSCCC_pSwitches->find('i',"ipv6"))queryType = KviDnsResolver::IPv6; + if(KVSCCC_pSwitches->find('a',"any"))queryType = KviDnsResolver::Any; KviKvsVariant * pMagic = pMagicPtr ? new KviKvsVariant(*pMagicPtr) : new KviKvsVariant(); diff --git a/src/kvirc/kvs/kvi_kvs_coresimplecommands_af.cpp b/src/kvirc/kvs/kvi_kvs_coresimplecommands_af.cpp index 200b622a9..c40677a11 100644 --- a/src/kvirc/kvs/kvi_kvs_coresimplecommands_af.cpp +++ b/src/kvirc/kvs/kvi_kvs_coresimplecommands_af.cpp @@ -42,14 +42,14 @@ #ifdef COMPILE_X11_SUPPORT #ifndef COMPILE_NO_X_BELL - #include "kvi_xlib.h" // XBell : THIS SHOULD BE INCLUDED AS LAST! + #include "KviXlib.h" // XBell : THIS SHOULD BE INCLUDED AS LAST! #include // for usleep(); #include #define get_xdisplay QX11Info::display #endif #endif -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" // kvi_app.cpp extern KviPointerHashTable * g_pGlobalWindowDict; diff --git a/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp b/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp index 0d85bd8ba..49a20bd0f 100644 --- a/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp +++ b/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp @@ -208,9 +208,9 @@ namespace KviKvsCoreSimpleCommands KVSCSC_PARAMETER("dnsquery",KVS_PT_NONEMPTYSTRING,0,szQuery) KVSCSC_PARAMETERS_END - KviDns::QueryType queryType = KviDns::IPv4; - if(KVSCSC_pSwitches->find('i',"ipv6"))queryType = KviDns::IPv6; - if(KVSCSC_pSwitches->find('a',"any"))queryType = KviDns::Any; + KviDnsResolver::QueryType queryType = KviDnsResolver::IPv4; + if(KVSCSC_pSwitches->find('i',"ipv6"))queryType = KviDnsResolver::IPv6; + if(KVSCSC_pSwitches->find('a',"any"))queryType = KviDnsResolver::Any; new KviKvsAsyncDnsOperation( KVSCSC_pContext->window(), diff --git a/src/kvirc/kvs/kvi_kvs_coresimplecommands_sz.cpp b/src/kvirc/kvs/kvi_kvs_coresimplecommands_sz.cpp index 7acaddded..ec63ba773 100644 --- a/src/kvirc/kvs/kvi_kvs_coresimplecommands_sz.cpp +++ b/src/kvirc/kvs/kvi_kvs_coresimplecommands_sz.cpp @@ -33,7 +33,7 @@ #include "kvi_app.h" #include "kvi_asynchronousconnectiondata.h" #include "kvi_frame.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_menubar.h" #include "kvi_userinput.h" #include "kvi_out.h" diff --git a/src/kvirc/kvs/kvi_kvs_dnsmanager.cpp b/src/kvirc/kvs/kvi_kvs_dnsmanager.cpp index 440c7f95c..217b18fec 100644 --- a/src/kvirc/kvs/kvi_kvs_dnsmanager.cpp +++ b/src/kvirc/kvs/kvi_kvs_dnsmanager.cpp @@ -23,7 +23,7 @@ //============================================================================= #include "kvi_kvs_dnsmanager.h" -#include "kvi_dns.h" +#include "KviDnsResolver.h" #include "kvi_app.h" #include "kvi_window.h" #include "kvi_out.h" @@ -37,7 +37,7 @@ KviKvsDnsManager * KviKvsDnsManager::m_pInstance = 0; -KviKvsDnsObject::KviKvsDnsObject(KviDns * pDns,KviWindow * pWnd,const QString &szQuery,bool bRebindOnWindowClose,KviKvsScript * pCallback,KviKvsVariantList * pParameterList) +KviKvsDnsObject::KviKvsDnsObject(KviDnsResolver * pDns,KviWindow * pWnd,const QString &szQuery,bool bRebindOnWindowClose,KviKvsScript * pCallback,KviKvsVariantList * pParameterList) { m_pDns = pDns; m_pWindow = pWnd; @@ -102,10 +102,10 @@ void KviKvsDnsManager::addDns(KviKvsDnsObject * pObject) m_pDnsObjects->setAutoDelete(true); } m_pDnsObjects->replace(pObject->dns(),pObject); - connect(pObject->dns(),SIGNAL(lookupDone(KviDns *)),this,SLOT(dnsLookupTerminated(KviDns *))); + connect(pObject->dns(),SIGNAL(lookupDone(KviDnsResolver *)),this,SLOT(dnsLookupTerminated(KviDnsResolver *))); } -void KviKvsDnsManager::dnsLookupTerminated(KviDns * pDns) +void KviKvsDnsManager::dnsLookupTerminated(KviDnsResolver * pDns) { KviKvsDnsObject * o = m_pDnsObjects->find(pDns); if(!o) @@ -132,7 +132,7 @@ void KviKvsDnsManager::dnsLookupTerminated(KviDns * pDns) if(!o->parameterList()) o->setParameterList(new KviKvsVariantList()); - if(o->dns()->state() == KviDns::Failure) + if(o->dns()->state() == KviDnsResolver::Failure) { // $4... is the magic data o->parameterList()->prepend(new KviKvsVariant()); // $3 @@ -155,7 +155,7 @@ void KviKvsDnsManager::dnsLookupTerminated(KviDns * pDns) QString szQuery = o->dns()->query(); o->window()->output(KVI_OUT_HOSTLOOKUP,__tr2qs_ctx("DNS Lookup result for query \"%Q\"","kvs"),&szQuery); - if(o->dns()->state() == KviDns::Failure) + if(o->dns()->state() == KviDnsResolver::Failure) { QString szErr = KviError::getDescription(o->dns()->error()); o->window()->output(KVI_OUT_HOSTLOOKUP,__tr2qs_ctx("Error: %Q","kvs"),&szErr); diff --git a/src/kvirc/kvs/kvi_kvs_dnsmanager.h b/src/kvirc/kvs/kvi_kvs_dnsmanager.h index 147b24c41..77b57515c 100644 --- a/src/kvirc/kvs/kvi_kvs_dnsmanager.h +++ b/src/kvirc/kvs/kvi_kvs_dnsmanager.h @@ -30,7 +30,7 @@ #include #include -class KviDns; +class KviDnsResolver; class KviWindow; class KviKvsScript; class KviKvsVariantList; @@ -38,7 +38,7 @@ class KviKvsVariantList; class KviKvsDnsObject { public: - KviKvsDnsObject(KviDns * pDns, + KviKvsDnsObject(KviDnsResolver * pDns, KviWindow * pWnd, const QString &szQuery, bool bRebindOnWindowClose = true, @@ -46,14 +46,14 @@ public: KviKvsVariantList * pParameterList = 0); ~KviKvsDnsObject(); protected: - KviDns * m_pDns; + KviDnsResolver * m_pDns; KviWindow * m_pWindow; QString m_szQuery; KviKvsScript * m_pCallback; // callback to be executed when the dns terminates KviKvsVariantList * m_pParameterList; // parameter list (magic) bool m_bRebindOnWindowClose; // should we trigger the callback even if m_pWindow no longer exists ? public: - KviDns * dns(){ return m_pDns; }; + KviDnsResolver * dns(){ return m_pDns; }; KviWindow * window(){ return m_pWindow; }; KviKvsScript * callback(){ return m_pCallback; }; KviKvsVariantList * parameterList(){ return m_pParameterList; }; @@ -79,7 +79,7 @@ public: void addDns(KviKvsDnsObject * pObject); protected slots: - void dnsLookupTerminated(KviDns * pDns); + void dnsLookupTerminated(KviDnsResolver * pDns); private: void abortAll(); }; diff --git a/src/kvirc/kvs/kvi_kvs_popupmenu.h b/src/kvirc/kvs/kvi_kvs_popupmenu.h index 390ddbf8a..ed0e89d74 100644 --- a/src/kvirc/kvs/kvi_kvs_popupmenu.h +++ b/src/kvirc/kvs/kvi_kvs_popupmenu.h @@ -32,7 +32,7 @@ #include "kvi_kvs_script.h" #include "kvi_kvs_runtimecontext.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/kvirc/ui/kvi_actiondrawer.cpp b/src/kvirc/ui/kvi_actiondrawer.cpp index a041d55e5..f35d82f65 100644 --- a/src/kvirc/ui/kvi_actiondrawer.cpp +++ b/src/kvirc/ui/kvi_actiondrawer.cpp @@ -30,7 +30,7 @@ #include "kvi_actionmanager.h" #include "kvi_iconmanager.h" #include "KviLocale.h" -#include "kvi_tal_listwidget.h" +#include "KviTalListWidget.h" #include #include diff --git a/src/kvirc/ui/kvi_actiondrawer.h b/src/kvirc/ui/kvi_actiondrawer.h index 970666ccf..bfa96443c 100644 --- a/src/kvirc/ui/kvi_actiondrawer.h +++ b/src/kvirc/ui/kvi_actiondrawer.h @@ -32,7 +32,7 @@ #include "kvi_settings.h" #include "KviQString.h" -#include "kvi_tal_listwidget.h" +#include "KviTalListWidget.h" #include #include diff --git a/src/kvirc/ui/kvi_channel.cpp b/src/kvirc/ui/kvi_channel.cpp index dfa617d00..7d95efdd4 100644 --- a/src/kvirc/ui/kvi_channel.cpp +++ b/src/kvirc/ui/kvi_channel.cpp @@ -55,7 +55,7 @@ #include "KviPointerHashTable.h" #include "kvi_kvs_script.h" #include "kvi_kvs_eventtriggers.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #ifdef COMPILE_CRYPT_SUPPORT #include "KviCryptEngine.h" diff --git a/src/kvirc/ui/kvi_console.cpp b/src/kvirc/ui/kvi_console.cpp index c53aff8cc..6866982a0 100644 --- a/src/kvirc/ui/kvi_console.cpp +++ b/src/kvirc/ui/kvi_console.cpp @@ -36,10 +36,10 @@ #include "kvi_input.h" #include "kvi_error.h" #include "KviProxyDataBase.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "KviIrcServer.h" #include "KviIrcServerDataBase.h" -#include "kvi_dns.h" +#include "KviDnsResolver.h" #include "kvi_defaults.h" #include "KviIrcUserDataBase.h" #include "kvi_channel.h" @@ -69,8 +69,8 @@ #include "kvi_msgbox.h" #include "kvi_kvs_script.h" #include "kvi_kvs_eventtriggers.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalHBox.h" +#include "KviTalPopupMenu.h" #include "KviNickColors.h" #ifdef COMPILE_SSL_SUPPORT diff --git a/src/kvirc/ui/kvi_console.h b/src/kvirc/ui/kvi_console.h index 7f3295c0e..1dc43dcd9 100644 --- a/src/kvirc/ui/kvi_console.h +++ b/src/kvirc/ui/kvi_console.h @@ -43,7 +43,7 @@ class QToolBar; class KviAvatar; -class KviDns; +class KviDnsResolver; class KviIrcUserDataBase; class KviIrcUserEntry; class KviServer; diff --git a/src/kvirc/ui/kvi_cryptcontroller.h b/src/kvirc/ui/kvi_cryptcontroller.h index 154f554e5..f63f75735 100644 --- a/src/kvirc/ui/kvi_cryptcontroller.h +++ b/src/kvirc/ui/kvi_cryptcontroller.h @@ -30,7 +30,7 @@ #include "KviCryptEngine.h" #include "KviHeapObject.h" #include "kvi_toolwindows_container.h" - #include "kvi_tal_listwidget.h" + #include "KviTalListWidget.h" #include #include diff --git a/src/kvirc/ui/kvi_customtoolbar.cpp b/src/kvirc/ui/kvi_customtoolbar.cpp index 1b5521393..5bb10534b 100644 --- a/src/kvirc/ui/kvi_customtoolbar.cpp +++ b/src/kvirc/ui/kvi_customtoolbar.cpp @@ -30,7 +30,7 @@ #include "kvi_app.h" #include "kvi_actionmanager.h" #include "kvi_customtoolbardescriptor.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/kvirc/ui/kvi_dynamictooltip.h b/src/kvirc/ui/kvi_dynamictooltip.h index 65480e0a5..3a3e1e4dd 100644 --- a/src/kvirc/ui/kvi_dynamictooltip.h +++ b/src/kvirc/ui/kvi_dynamictooltip.h @@ -25,7 +25,7 @@ //============================================================================= #include "kvi_settings.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include diff --git a/src/kvirc/ui/kvi_filedialog.cpp b/src/kvirc/ui/kvi_filedialog.cpp index e262b40d5..9cda81d10 100644 --- a/src/kvirc/ui/kvi_filedialog.cpp +++ b/src/kvirc/ui/kvi_filedialog.cpp @@ -30,7 +30,7 @@ #include "KviFileUtils.h" #include "kvi_frame.h" #include "KviQString.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/kvirc/ui/kvi_filedialog.h b/src/kvirc/ui/kvi_filedialog.h index 827e80f8a..9b0ef465a 100644 --- a/src/kvirc/ui/kvi_filedialog.h +++ b/src/kvirc/ui/kvi_filedialog.h @@ -36,7 +36,7 @@ #include "kvi_settings.h" #include "KviCString.h" -#include "kvi_tal_filedialog.h" +#include "KviTalFileDialog.h" #include diff --git a/src/kvirc/ui/kvi_frame.cpp b/src/kvirc/ui/kvi_frame.cpp index a5800bc14..778d1bcf1 100644 --- a/src/kvirc/ui/kvi_frame.cpp +++ b/src/kvirc/ui/kvi_frame.cpp @@ -58,7 +58,7 @@ #include "kvi_ircview.h" #include "kvi_kvs_script.h" #include "kvi_kvs_eventtriggers.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "kvi_texticonmanager.h" #include "kvi_shortcuts.h" diff --git a/src/kvirc/ui/kvi_frame.h b/src/kvirc/ui/kvi_frame.h index a1b46bf6f..d3eade256 100644 --- a/src/kvirc/ui/kvi_frame.h +++ b/src/kvirc/ui/kvi_frame.h @@ -33,7 +33,7 @@ #include "kvi_settings.h" -#include "kvi_tal_mainwindow.h" +#include "KviTalMainWindow.h" #include "KviQString.h" #include "KviPointerList.h" diff --git a/src/kvirc/ui/kvi_imagedialog.h b/src/kvirc/ui/kvi_imagedialog.h index 2ca37c120..0b0c78ebb 100644 --- a/src/kvirc/ui/kvi_imagedialog.h +++ b/src/kvirc/ui/kvi_imagedialog.h @@ -26,7 +26,7 @@ #include "kvi_settings.h" #include "kvi_dynamictooltip.h" -#include "kvi_tal_listwidget.h" +#include "KviTalListWidget.h" #include #include diff --git a/src/kvirc/ui/kvi_input.cpp b/src/kvirc/ui/kvi_input.cpp index 8760129e3..5566813b1 100644 --- a/src/kvirc/ui/kvi_input.cpp +++ b/src/kvirc/ui/kvi_input.cpp @@ -41,9 +41,9 @@ #include "kvi_historywin.h" #include "kvi_userinput.h" #include "kvi_shortcuts.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_tooltip.h" +#include "KviTalPopupMenu.h" +#include "KviTalHBox.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/kvirc/ui/kvi_input_editor.cpp b/src/kvirc/ui/kvi_input_editor.cpp index fae285928..a341e9530 100644 --- a/src/kvirc/ui/kvi_input_editor.cpp +++ b/src/kvirc/ui/kvi_input_editor.cpp @@ -41,7 +41,7 @@ #include "kvi_options.h" #include "KviQString.h" #include "kvi_out.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "kvi_texticonwin.h" #include "kvi_texticonmanager.h" #include "kvi_userinput.h" diff --git a/src/kvirc/ui/kvi_irctoolbar.cpp b/src/kvirc/ui/kvi_irctoolbar.cpp index 014f7c0ce..797981c68 100644 --- a/src/kvirc/ui/kvi_irctoolbar.cpp +++ b/src/kvirc/ui/kvi_irctoolbar.cpp @@ -40,7 +40,7 @@ #include "kvi_ircconnectionuserinfo.h" #include "kvi_irccontext.h" #include "kvi_lagmeter.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "kvi_mdimanager.h" #include diff --git a/src/kvirc/ui/kvi_ircview.cpp b/src/kvirc/ui/kvi_ircview.cpp index 82a5dd573..8f16bc801 100644 --- a/src/kvirc/ui/kvi_ircview.cpp +++ b/src/kvirc/ui/kvi_ircview.cpp @@ -96,7 +96,7 @@ #include "kvi_ircconnection.h" #include "kvi_mdimanager.h" #include "kvi_userinput.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "KviAnimatedPixmap.h" #include diff --git a/src/kvirc/ui/kvi_ircviewtools.h b/src/kvirc/ui/kvi_ircviewtools.h index 9fdf87821..d38d32f2d 100644 --- a/src/kvirc/ui/kvi_ircviewtools.h +++ b/src/kvirc/ui/kvi_ircviewtools.h @@ -25,7 +25,7 @@ //============================================================================= #include "kvi_settings.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/kvirc/ui/kvi_mdichild.cpp b/src/kvirc/ui/kvi_mdichild.cpp index 190eaa3a6..4c3418eb8 100644 --- a/src/kvirc/ui/kvi_mdichild.cpp +++ b/src/kvirc/ui/kvi_mdichild.cpp @@ -38,7 +38,7 @@ #include "kvi_settings.h" #include "kvi_iconmanager.h" #include "kvi_window.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "kvi_ircconnection.h" #include "kvi_ircconnectiontarget.h" #include "kvi_irccontext.h" diff --git a/src/kvirc/ui/kvi_mdimanager.cpp b/src/kvirc/ui/kvi_mdimanager.cpp index 82cbdee88..74e79dd51 100644 --- a/src/kvirc/ui/kvi_mdimanager.cpp +++ b/src/kvirc/ui/kvi_mdimanager.cpp @@ -39,8 +39,8 @@ #include "kvi_frame.h" #include "kvi_menubar.h" #include "kvi_app.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_hbox.h" +#include "KviTalPopupMenu.h" +#include "KviTalHBox.h" #include #include diff --git a/src/kvirc/ui/kvi_menubar.cpp b/src/kvirc/ui/kvi_menubar.cpp index cfe782917..5554023ad 100644 --- a/src/kvirc/ui/kvi_menubar.cpp +++ b/src/kvirc/ui/kvi_menubar.cpp @@ -39,7 +39,7 @@ #include "kvi_actionmanager.h" #include "kvi_coreactionnames.h" #include "kvi_kvs_script.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" KviMenuBar::KviMenuBar(KviFrame * par,const char * name) : KviTalMenuBar(par,name) diff --git a/src/kvirc/ui/kvi_menubar.h b/src/kvirc/ui/kvi_menubar.h index debbea53b..7f2e17669 100644 --- a/src/kvirc/ui/kvi_menubar.h +++ b/src/kvirc/ui/kvi_menubar.h @@ -28,7 +28,7 @@ #include "kvi_settings.h" #include "KviPointerList.h" #include "KviCString.h" -#include "kvi_tal_menubar.h" +#include "KviTalMenuBar.h" class KviFrame; class KviTalPopupMenu; diff --git a/src/kvirc/ui/kvi_modew.cpp b/src/kvirc/ui/kvi_modew.cpp index 847dfde57..a6ac2c992 100644 --- a/src/kvirc/ui/kvi_modew.cpp +++ b/src/kvirc/ui/kvi_modew.cpp @@ -26,7 +26,7 @@ #include "kvi_options.h" #include "kvi_ircconnectionserverinfo.h" #include "kvi_ircconnectionuserinfo.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include #include diff --git a/src/kvirc/ui/kvi_optionswidget.cpp b/src/kvirc/ui/kvi_optionswidget.cpp index 8c944189d..ccadb5163 100644 --- a/src/kvirc/ui/kvi_optionswidget.cpp +++ b/src/kvirc/ui/kvi_optionswidget.cpp @@ -31,7 +31,7 @@ #include "KviLocale.h" #include "kvi_app.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #define KVI_OPTIONSWIDGET_GRIDLAYOUT_BORDER 4 #define KVI_OPTIONSWIDGET_GRIDLAYOUT_SPACE 6 diff --git a/src/kvirc/ui/kvi_optionswidget.h b/src/kvirc/ui/kvi_optionswidget.h index 890f13303..18fc9ba69 100644 --- a/src/kvirc/ui/kvi_optionswidget.h +++ b/src/kvirc/ui/kvi_optionswidget.h @@ -28,7 +28,7 @@ #include "kvi_settings.h" #include "kvi_selectors.h" #include "KviPointerList.h" -#include "kvi_tal_groupbox.h" +#include "KviTalGroupBox.h" #include #include diff --git a/src/kvirc/ui/kvi_query.cpp b/src/kvirc/ui/kvi_query.cpp index 2436eb7d8..2b6577116 100644 --- a/src/kvirc/ui/kvi_query.cpp +++ b/src/kvirc/ui/kvi_query.cpp @@ -46,7 +46,7 @@ #include "KviMircCntrl.h" #include "kvi_toolwindows_container.h" #include "kvi_kvs_eventtriggers.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #ifdef COMPILE_CRYPT_SUPPORT #include "KviCryptEngine.h" diff --git a/src/kvirc/ui/kvi_selectors.cpp b/src/kvirc/ui/kvi_selectors.cpp index f77678c7b..c822813d6 100644 --- a/src/kvirc/ui/kvi_selectors.cpp +++ b/src/kvirc/ui/kvi_selectors.cpp @@ -31,7 +31,7 @@ #include "KviMircCntrl.h" #include "kvi_filedialog.h" #include "kvi_kvs_script.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/kvirc/ui/kvi_selectors.h b/src/kvirc/ui/kvi_selectors.h index c0c4a5e20..ee4a7de01 100644 --- a/src/kvirc/ui/kvi_selectors.h +++ b/src/kvirc/ui/kvi_selectors.h @@ -29,9 +29,9 @@ #include "kvi_settings.h" #include "KviCString.h" #include "KviPixmap.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_vbox.h" -#include "kvi_tal_listwidget.h" +#include "KviTalHBox.h" +#include "KviTalVBox.h" +#include "KviTalListWidget.h" #include #include diff --git a/src/kvirc/ui/kvi_statusbar.cpp b/src/kvirc/ui/kvi_statusbar.cpp index a00c65aff..32c1449b5 100644 --- a/src/kvirc/ui/kvi_statusbar.cpp +++ b/src/kvirc/ui/kvi_statusbar.cpp @@ -37,7 +37,7 @@ #include "kvi_modulemanager.h" #include "kvi_statusbarapplet.h" #include "kvi_dynamictooltip.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/kvirc/ui/kvi_statusbar.h b/src/kvirc/ui/kvi_statusbar.h index ebca92d3c..6bf056122 100644 --- a/src/kvirc/ui/kvi_statusbar.h +++ b/src/kvirc/ui/kvi_statusbar.h @@ -39,7 +39,7 @@ #include "KviPointerList.h" #include "KviHeapObject.h" #include "KviPointerHashTable.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include #include diff --git a/src/kvirc/ui/kvi_statusbarapplet.cpp b/src/kvirc/ui/kvi_statusbarapplet.cpp index d81ac9048..0f70ee8d1 100644 --- a/src/kvirc/ui/kvi_statusbarapplet.cpp +++ b/src/kvirc/ui/kvi_statusbarapplet.cpp @@ -46,10 +46,10 @@ #include "kvi_buildinfo.h" #include "kvi_settings.h" #include "KviMiscUtils.h" -#include "kvi_http.h" -#include "kvi_url.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_tooltip.h" +#include "KviHttpRequest.h" +#include "KviUrl.h" +#include "KviTalPopupMenu.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/kvirc/ui/kvi_statusbarapplet.h b/src/kvirc/ui/kvi_statusbarapplet.h index 8d163cb5c..82b3f4d06 100644 --- a/src/kvirc/ui/kvi_statusbarapplet.h +++ b/src/kvirc/ui/kvi_statusbarapplet.h @@ -30,7 +30,7 @@ #include "KviHeapObject.h" #include "kvi_statusbar.h" #include "KviPointerHashTable.h" -#include "kvi_http.h" +#include "KviHttpRequest.h" #include #include diff --git a/src/kvirc/ui/kvi_toolbar.cpp b/src/kvirc/ui/kvi_toolbar.cpp index 69cd9ee8c..f8361c3ee 100644 --- a/src/kvirc/ui/kvi_toolbar.cpp +++ b/src/kvirc/ui/kvi_toolbar.cpp @@ -26,7 +26,7 @@ #include "kvi_frame.h" #include "KviLocale.h" #include "kvi_app.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/kvirc/ui/kvi_toolbar.h b/src/kvirc/ui/kvi_toolbar.h index ddaa3976f..0fdcff460 100644 --- a/src/kvirc/ui/kvi_toolbar.h +++ b/src/kvirc/ui/kvi_toolbar.h @@ -24,7 +24,7 @@ // //============================================================================= -#include "kvi_tal_toolbar.h" +#include "KviTalToolBar.h" class KVIRC_API KviToolBar : public KviTalToolBar { diff --git a/src/kvirc/ui/kvi_toolwindows_container.cpp b/src/kvirc/ui/kvi_toolwindows_container.cpp index 39908dbd3..7cd32703c 100644 --- a/src/kvirc/ui/kvi_toolwindows_container.cpp +++ b/src/kvirc/ui/kvi_toolwindows_container.cpp @@ -26,7 +26,7 @@ #include "kvi_toolwindows_container.h" #include "kvi_iconmanager.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" #include #include diff --git a/src/kvirc/ui/kvi_topicw.cpp b/src/kvirc/ui/kvi_topicw.cpp index 1157ecfb7..e003fe84b 100644 --- a/src/kvirc/ui/kvi_topicw.cpp +++ b/src/kvirc/ui/kvi_topicw.cpp @@ -42,8 +42,8 @@ #include "kvi_ircconnectionuserinfo.h" #include "kvi_htmlgenerator.h" #include "KviMircCntrl.h" -#include "kvi_tal_tooltip.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalToolTip.h" +#include "KviTalPopupMenu.h" #include "kvi_themedlabel.h" #include diff --git a/src/kvirc/ui/kvi_topicw.h b/src/kvirc/ui/kvi_topicw.h index 5fbe21ef3..228b18347 100644 --- a/src/kvirc/ui/kvi_topicw.h +++ b/src/kvirc/ui/kvi_topicw.h @@ -28,8 +28,8 @@ #include "KviCString.h" #include "kvi_app.h" #include "kvi_input_editor.h" -#include "kvi_tal_listwidget.h" -#include "kvi_tal_itemdelegates.h" +#include "KviTalListWidget.h" +#include "KviTalIconAndRichTextItemDelegate.h" #include #include diff --git a/src/kvirc/ui/kvi_userlistview.h b/src/kvirc/ui/kvi_userlistview.h index 6ff046738..5b51ac21f 100644 --- a/src/kvirc/ui/kvi_userlistview.h +++ b/src/kvirc/ui/kvi_userlistview.h @@ -45,7 +45,7 @@ #include "KviIrcUserDataBase.h" #include "KviIrcMask.h" #include "KviTimeUtils.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include diff --git a/src/kvirc/ui/kvi_window.cpp b/src/kvirc/ui/kvi_window.cpp index 745e81018..f71f67eb5 100644 --- a/src/kvirc/ui/kvi_window.cpp +++ b/src/kvirc/ui/kvi_window.cpp @@ -55,8 +55,8 @@ #include "KviMircCntrl.h" #include "kvi_toolwindows_container.h" #include "kvi_kvs_script.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_tooltip.h" +#include "KviTalPopupMenu.h" +#include "KviTalToolTip.h" #include "kvi_kvs_script.h" #include "kvi_kvs_eventtriggers.h" diff --git a/src/kvirc/ui/kvi_window.h b/src/kvirc/ui/kvi_window.h index a7482729f..03a92e412 100644 --- a/src/kvirc/ui/kvi_window.h +++ b/src/kvirc/ui/kvi_window.h @@ -37,8 +37,8 @@ #include "kvi_irccontext.h" #include "kvi_ircconnection.h" #include "kvi_input.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_splitter.h" +#include "KviTalHBox.h" +#include "KviTalSplitter.h" #ifdef COMPILE_ON_WINDOWS // The brain-damaged MSVC compiler can't instantiate QList templates without a destructor definition diff --git a/src/kvirc/ui/kvi_windowlist.h b/src/kvirc/ui/kvi_windowlist.h index b6741bc00..7f6615c10 100644 --- a/src/kvirc/ui/kvi_windowlist.h +++ b/src/kvirc/ui/kvi_windowlist.h @@ -26,7 +26,7 @@ #include "kvi_settings.h" #include "KviPointerList.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/kvirc/ui/kvi_windowlist_tree.cpp b/src/kvirc/ui/kvi_windowlist_tree.cpp index 0e68e098f..3e5dc2f61 100644 --- a/src/kvirc/ui/kvi_windowlist_tree.cpp +++ b/src/kvirc/ui/kvi_windowlist_tree.cpp @@ -29,7 +29,7 @@ #include "kvi_frame.h" #include "KviLocale.h" #include "kvi_options.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "kvi_window.h" #include "kvi_windowlist_tree.h" diff --git a/src/modules/about/aboutdialog.h b/src/modules/about/aboutdialog.h index 9fd444907..198a193e6 100644 --- a/src/modules/about/aboutdialog.h +++ b/src/modules/about/aboutdialog.h @@ -24,7 +24,7 @@ // //============================================================================= -#include "kvi_tal_tabdialog.h" +#include "KviTalTabDialog.h" class KviAboutDialog : public KviTalTabDialog { diff --git a/src/modules/actioneditor/actioneditor.cpp b/src/modules/actioneditor/actioneditor.cpp index 17948b033..44cc175bb 100644 --- a/src/modules/actioneditor/actioneditor.cpp +++ b/src/modules/actioneditor/actioneditor.cpp @@ -39,9 +39,9 @@ #include "kvi_action.h" #include "kvi_kvs_useraction.h" #include "kvi_customtoolbarmanager.h" -#include "kvi_tal_vbox.h" -#include -#include "kvi_tal_itemdelegates.h" +#include "KviTalVBox.h" +#include +#include "KviTalIconAndRichTextItemDelegate.h" #include "kvi_fileextensions.h" #include diff --git a/src/modules/addon/managementdialog.cpp b/src/modules/addon/managementdialog.cpp index fc8542714..107d115c3 100644 --- a/src/modules/addon/managementdialog.cpp +++ b/src/modules/addon/managementdialog.cpp @@ -37,8 +37,8 @@ #include "kvi_fileextensions.h" #include "kvi_kvs_script.h" #include "kvi_sourcesdate.h" -#include "kvi_tal_listwidget.h" -#include "kvi_tal_tooltip.h" +#include "KviTalListWidget.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/modules/addon/managementdialog.h b/src/modules/addon/managementdialog.h index 8288363e5..45a6b8656 100644 --- a/src/modules/addon/managementdialog.h +++ b/src/modules/addon/managementdialog.h @@ -25,7 +25,7 @@ //============================================================================= #include "kvi_settings.h" -#include "kvi_tal_listwidget.h" +#include "KviTalListWidget.h" #include #include diff --git a/src/modules/aliaseditor/aliaseditor.cpp b/src/modules/aliaseditor/aliaseditor.cpp index a701bcdd0..a4757f1fd 100644 --- a/src/modules/aliaseditor/aliaseditor.cpp +++ b/src/modules/aliaseditor/aliaseditor.cpp @@ -41,7 +41,7 @@ #include "kvi_filedialog.h" #include "KviCommandFormatter.h" #include "kvi_module.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" #include "kvi_fileextensions.h" #include diff --git a/src/modules/aliaseditor/aliaseditor.h b/src/modules/aliaseditor/aliaseditor.h index 95309481c..ed4d6a4ff 100644 --- a/src/modules/aliaseditor/aliaseditor.h +++ b/src/modules/aliaseditor/aliaseditor.h @@ -27,7 +27,7 @@ #include "kvi_window.h" #include "KviCString.h" #include "KviPointerList.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "KviHeapObject.h" #include diff --git a/src/modules/avatar/libkviavatar.cpp b/src/modules/avatar/libkviavatar.cpp index 5a576c9f8..6b9fef501 100644 --- a/src/modules/avatar/libkviavatar.cpp +++ b/src/modules/avatar/libkviavatar.cpp @@ -30,7 +30,7 @@ #include "KviMemory.h" #include "kvi_app.h" #include "kvi_options.h" -#include "kvi_http.h" +#include "KviHttpRequest.h" #include "kvi_iconmanager.h" #include "KviAvatar.h" #include "KviIrcUserDataBase.h" @@ -44,7 +44,7 @@ #include "kvi_sparser.h" #include "kvi_out.h" #include "KviIrcMask.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include #include diff --git a/src/modules/channelsjoin/channelsjoinwindow.cpp b/src/modules/channelsjoin/channelsjoinwindow.cpp index b5a75e1d4..da9026a69 100644 --- a/src/modules/channelsjoin/channelsjoinwindow.cpp +++ b/src/modules/channelsjoin/channelsjoinwindow.cpp @@ -34,7 +34,7 @@ #include "kvi_console.h" #include "KviRegisteredChannel.h" #include "kvi_kvs_script.h" -#include "kvi_tal_groupbox.h" +#include "KviTalGroupBox.h" #include #include diff --git a/src/modules/classeditor/classeditor.cpp b/src/modules/classeditor/classeditor.cpp index 6c0e59ea2..eada4b4ed 100644 --- a/src/modules/classeditor/classeditor.cpp +++ b/src/modules/classeditor/classeditor.cpp @@ -43,7 +43,7 @@ #include "kvi_filedialog.h" #include "KviCommandFormatter.h" #include "kvi_module.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" #include "kvi_fileextensions.h" #include "kvi_modulemanager.h" diff --git a/src/modules/classeditor/classeditor.h b/src/modules/classeditor/classeditor.h index b1418cdcc..6b98f5e3f 100644 --- a/src/modules/classeditor/classeditor.h +++ b/src/modules/classeditor/classeditor.h @@ -33,7 +33,7 @@ #include "kvi_window.h" #include "KviCString.h" #include "KviPointerList.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "KviHeapObject.h" #include "kvi_kvs_object_class.h" diff --git a/src/modules/codetester/codetester.cpp b/src/modules/codetester/codetester.cpp index 13ad8ab21..bdc856812 100644 --- a/src/modules/codetester/codetester.cpp +++ b/src/modules/codetester/codetester.cpp @@ -36,7 +36,7 @@ #include "KviParameterList.h" #include "kvi_kvs_script.h" #include "kvi_kvs_variantlist.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/dcc/canvas.cpp b/src/modules/dcc/canvas.cpp index ee9fb4b62..01bbf8e3b 100644 --- a/src/modules/dcc/canvas.cpp +++ b/src/modules/dcc/canvas.cpp @@ -41,7 +41,7 @@ #include "KviLocale.h" #include "kvi_error.h" #include "kvi_out.h" - #include "kvi_netutils.h" + #include "KviNetUtils.h" #include "kvi_console.h" #include "kvi_frame.h" #include "KviMemory.h" diff --git a/src/modules/dcc/canvaswidget.cpp b/src/modules/dcc/canvaswidget.cpp index aa1095b34..79012192b 100644 --- a/src/modules/dcc/canvaswidget.cpp +++ b/src/modules/dcc/canvaswidget.cpp @@ -27,7 +27,7 @@ #ifdef COMPILE_DCC_CANVAS #include "KviCString.h" #include "KviLocale.h" - #include "kvi_tal_popupmenu.h" + #include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/dcc/chat.cpp b/src/modules/dcc/chat.cpp index 3ce235aaf..6ac90a686 100644 --- a/src/modules/dcc/chat.cpp +++ b/src/modules/dcc/chat.cpp @@ -39,7 +39,7 @@ #include "KviLocale.h" #include "kvi_error.h" #include "kvi_out.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_console.h" #include "kvi_frame.h" #include "KviMemory.h" @@ -54,7 +54,7 @@ #include "kvi_ircconnectionuserinfo.h" #include "kvi_kvs_eventtriggers.h" #include "KviMircCntrl.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" #include #include diff --git a/src/modules/dcc/libkvidcc.cpp b/src/modules/dcc/libkvidcc.cpp index 61d8b27cc..b3ca78111 100644 --- a/src/modules/dcc/libkvidcc.cpp +++ b/src/modules/dcc/libkvidcc.cpp @@ -38,7 +38,7 @@ #include "KviLocale.h" #include "kvi_out.h" #include "kvi_console.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_frame.h" #include "kvi_console.h" #include "kvi_error.h" diff --git a/src/modules/dcc/marshal.cpp b/src/modules/dcc/marshal.cpp index b97d0ee55..8464c94a7 100644 --- a/src/modules/dcc/marshal.cpp +++ b/src/modules/dcc/marshal.cpp @@ -25,7 +25,7 @@ #include "marshal.h" #include "kvi_settings.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_error.h" #include "kvi_options.h" #include "KviLocale.h" diff --git a/src/modules/dcc/requests.cpp b/src/modules/dcc/requests.cpp index dbb8ebb93..d550c114c 100644 --- a/src/modules/dcc/requests.cpp +++ b/src/modules/dcc/requests.cpp @@ -43,7 +43,7 @@ #include "KviLocale.h" #include "kvi_out.h" #include "kvi_console.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_frame.h" #include "kvi_console.h" #include "kvi_error.h" diff --git a/src/modules/dcc/send.cpp b/src/modules/dcc/send.cpp index 437890d3c..bbad7d198 100644 --- a/src/modules/dcc/send.cpp +++ b/src/modules/dcc/send.cpp @@ -38,7 +38,7 @@ #include "KviLocale.h" #include "kvi_error.h" #include "kvi_out.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_console.h" #include "kvi_frame.h" #include "KviMemory.h" diff --git a/src/modules/dcc/send.h b/src/modules/dcc/send.h index 260a28948..3c6cd2abc 100644 --- a/src/modules/dcc/send.h +++ b/src/modules/dcc/send.h @@ -34,9 +34,9 @@ #include "KviPointerList.h" #include "kvi_filetransfer.h" #include "KviTimeUtils.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_vbox.h" +#include "KviTalPopupMenu.h" +#include "KviTalHBox.h" +#include "KviTalVBox.h" #include #include diff --git a/src/modules/dcc/thread.cpp b/src/modules/dcc/thread.cpp index dc712791d..09f0b49dc 100644 --- a/src/modules/dcc/thread.cpp +++ b/src/modules/dcc/thread.cpp @@ -29,7 +29,7 @@ #include "kvi_error.h" #include "kvi_memmove.h" #include "KviMemory.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_socket.h" #ifdef COMPILE_SSL_SUPPORT diff --git a/src/modules/dcc/thread.h b/src/modules/dcc/thread.h index 877ea56bb..109ec3a9c 100644 --- a/src/modules/dcc/thread.h +++ b/src/modules/dcc/thread.h @@ -32,7 +32,7 @@ #include #ifdef COMPILE_SSL_SUPPORT - #include "kvi_ssl.h" + #include "KviSSL.h" #endif // KviThreadDataEvent diff --git a/src/modules/dcc/utils.cpp b/src/modules/dcc/utils.cpp index 9c90fe151..e9c1864e4 100644 --- a/src/modules/dcc/utils.cpp +++ b/src/modules/dcc/utils.cpp @@ -28,7 +28,7 @@ #include "kvi_options.h" #include "KviLocale.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_ircsocket.h" #include "kvi_irclink.h" #include "KviQString.h" diff --git a/src/modules/dcc/video.cpp b/src/modules/dcc/video.cpp index 91e875c15..896d7b98b 100644 --- a/src/modules/dcc/video.cpp +++ b/src/modules/dcc/video.cpp @@ -34,13 +34,13 @@ #include "KviLocale.h" #include "kvi_out.h" #include "kvi_error.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_options.h" #include "kvi_console.h" #include "KviMemory.h" #include "kvi_socket.h" #include "kvi_ircconnection.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" #include "KviMircCntrl.h" #include "kvi_frame.h" diff --git a/src/modules/dcc/video.h b/src/modules/dcc/video.h index 1213bc369..31588ab7e 100644 --- a/src/modules/dcc/video.h +++ b/src/modules/dcc/video.h @@ -32,7 +32,7 @@ #include "kvi_window.h" #include "KviDataBuffer.h" #include "kvi_sockettype.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include "kvi_themedlabel.h" #include diff --git a/src/modules/dcc/voice.cpp b/src/modules/dcc/voice.cpp index e59ad40fd..df84c9127 100644 --- a/src/modules/dcc/voice.cpp +++ b/src/modules/dcc/voice.cpp @@ -34,13 +34,13 @@ #include "KviLocale.h" #include "kvi_out.h" #include "kvi_error.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_options.h" #include "kvi_console.h" #include "KviMemory.h" #include "kvi_socket.h" #include "kvi_ircconnection.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" #include #include diff --git a/src/modules/dcc/voice.h b/src/modules/dcc/voice.h index 35c726d3f..11e5cb31a 100644 --- a/src/modules/dcc/voice.h +++ b/src/modules/dcc/voice.h @@ -32,7 +32,7 @@ #include "kvi_window.h" #include "KviDataBuffer.h" #include "kvi_sockettype.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include #include diff --git a/src/modules/dcc/window.cpp b/src/modules/dcc/window.cpp index b08cbf2c4..9b86b483c 100644 --- a/src/modules/dcc/window.cpp +++ b/src/modules/dcc/window.cpp @@ -24,7 +24,7 @@ #include "window.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" KviDccWindow::KviDccWindow(int type,KviFrame * lpFrm,const char * name,KviDccDescriptor * d) : KviWindow(type,lpFrm,name, d->console()) diff --git a/src/modules/dialog/libkvidialog.cpp b/src/modules/dialog/libkvidialog.cpp index 7bc51493a..7e85774b5 100644 --- a/src/modules/dialog/libkvidialog.cpp +++ b/src/modules/dialog/libkvidialog.cpp @@ -35,7 +35,7 @@ #include "kvi_iconmanager.h" #include "kvi_kvs_script.h" #include "kvi_msgbox.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include #include diff --git a/src/modules/editor/scripteditor.cpp b/src/modules/editor/scripteditor.cpp index 2d2247ff5..6a81bbda2 100644 --- a/src/modules/editor/scripteditor.cpp +++ b/src/modules/editor/scripteditor.cpp @@ -41,9 +41,9 @@ #include "kvi_kvs_kernel.h" #include "kvi_modulemanager.h" #include "KviConfigurationFile.h" -#include "kvi_tal_vbox.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_groupbox.h" +#include "KviTalVBox.h" +#include "KviTalHBox.h" +#include "KviTalGroupBox.h" #include #include diff --git a/src/modules/editor/scripteditor.h b/src/modules/editor/scripteditor.h index 58db627b5..1398b6469 100644 --- a/src/modules/editor/scripteditor.h +++ b/src/modules/editor/scripteditor.h @@ -28,7 +28,7 @@ #include "kvi_scripteditor.h" #include "KviPointerList.h" #include "kvi_selectors.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/eventeditor/eventeditor.cpp b/src/modules/eventeditor/eventeditor.cpp index 00f15aefa..c31d444a3 100644 --- a/src/modules/eventeditor/eventeditor.cpp +++ b/src/modules/eventeditor/eventeditor.cpp @@ -39,8 +39,8 @@ #include "KviQString.h" #include "kvi_filedialog.h" #include "kvi_kvs_eventmanager.h" -#include "kvi_tal_vbox.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalVBox.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/eventeditor/eventeditor.h b/src/modules/eventeditor/eventeditor.h index eadd127ba..ee9118903 100644 --- a/src/modules/eventeditor/eventeditor.h +++ b/src/modules/eventeditor/eventeditor.h @@ -26,7 +26,7 @@ #include "kvi_window.h" #include "KviCString.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/filetransferwindow/filetransferwindow.cpp b/src/modules/filetransferwindow/filetransferwindow.cpp index 720c5a43c..239f23cc8 100644 --- a/src/modules/filetransferwindow/filetransferwindow.cpp +++ b/src/modules/filetransferwindow/filetransferwindow.cpp @@ -35,7 +35,7 @@ #include "kvi_themedlabel.h" #include "kvi_input.h" #include "KviQString.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include "kvi_frame.h" #include "kvi_mdimanager.h" diff --git a/src/modules/filetransferwindow/filetransferwindow.h b/src/modules/filetransferwindow/filetransferwindow.h index df96484fb..fb6108bc0 100644 --- a/src/modules/filetransferwindow/filetransferwindow.h +++ b/src/modules/filetransferwindow/filetransferwindow.h @@ -32,9 +32,9 @@ #include "kvi_moduleextension.h" #include "kvi_filetransfer.h" #include "kvi_dynamictooltip.h" -#include "kvi_tal_tablewidget.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_itemdelegates.h" +#include "KviTalTableWidget.h" +#include "KviTalPopupMenu.h" +#include "KviTalIconAndRichTextItemDelegate.h" #include #include diff --git a/src/modules/help/helpwidget.h b/src/modules/help/helpwidget.h index 956aed4ae..567d25348 100644 --- a/src/modules/help/helpwidget.h +++ b/src/modules/help/helpwidget.h @@ -26,7 +26,7 @@ #include "index.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include #include diff --git a/src/modules/help/helpwindow.h b/src/modules/help/helpwindow.h index 7852e99d0..31b526531 100644 --- a/src/modules/help/helpwindow.h +++ b/src/modules/help/helpwindow.h @@ -26,8 +26,8 @@ #include "kvi_window.h" #include "KviCString.h" -#include "kvi_tal_vbox.h" -#include "kvi_tal_listwidget.h" +#include "KviTalVBox.h" +#include "KviTalListWidget.h" #include #include diff --git a/src/modules/http/httpfiletransfer.cpp b/src/modules/http/httpfiletransfer.cpp index 7c53191b8..feda63127 100644 --- a/src/modules/http/httpfiletransfer.cpp +++ b/src/modules/http/httpfiletransfer.cpp @@ -29,11 +29,11 @@ #include "KviLocale.h" #include "kvi_window.h" #include "kvi_iconmanager.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_kvs_eventtriggers.h" #include "kvi_console.h" #include "kvi_kvs_script.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include @@ -335,7 +335,7 @@ void KviHttpFileTransfer::init() g_pHttpFileTransfers = new KviPointerList; g_pHttpFileTransfers->setAutoDelete(false); - QPixmap * pix = g_pIconManager->getImage("kvi_httpicons.png", false); + QPixmap * pix = g_pIconManager->getImage("KviHttpRequesticons.png", false); if(pix)g_pHttpIcon = new QPixmap(*pix); else g_pHttpIcon = 0; } diff --git a/src/modules/http/httpfiletransfer.h b/src/modules/http/httpfiletransfer.h index af904a47a..f1449ee60 100644 --- a/src/modules/http/httpfiletransfer.h +++ b/src/modules/http/httpfiletransfer.h @@ -25,7 +25,7 @@ //============================================================================= #include "kvi_filetransfer.h" -#include "kvi_http.h" +#include "KviHttpRequest.h" #include "KviTimeUtils.h" #include "kvi_kvs_variant.h" diff --git a/src/modules/ident/libkviident.cpp b/src/modules/ident/libkviident.cpp index f9c12a4c1..f071a0cf6 100644 --- a/src/modules/ident/libkviident.cpp +++ b/src/modules/ident/libkviident.cpp @@ -28,7 +28,7 @@ #include "kvi_socket.h" #include "kvi_app.h" #include "kvi_out.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "KviLocale.h" #include "kvi_window.h" #include "kvi_options.h" diff --git a/src/modules/links/linkswindow.cpp b/src/modules/links/linkswindow.cpp index 215e0674d..f733ed099 100644 --- a/src/modules/links/linkswindow.cpp +++ b/src/modules/links/linkswindow.cpp @@ -36,7 +36,7 @@ #include "kvi_themedlabel.h" #include "kvi_irccontext.h" #include "kvi_ircconnection.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include #include diff --git a/src/modules/links/linkswindow.h b/src/modules/links/linkswindow.h index 3b9dcc62a..5c92ffaf7 100644 --- a/src/modules/links/linkswindow.h +++ b/src/modules/links/linkswindow.h @@ -30,7 +30,7 @@ #include "kvi_sparser.h" #include "kvi_console.h" #include "kvi_irccontext.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "kvi_themedtreewidget.h" #include diff --git a/src/modules/list/listwindow.cpp b/src/modules/list/listwindow.cpp index 0ec8ab125..9b8a5748a 100644 --- a/src/modules/list/listwindow.cpp +++ b/src/modules/list/listwindow.cpp @@ -42,7 +42,7 @@ #include "kvi_filedialog.h" #include "kvi_msgbox.h" #include "kvi_fileextensions.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include "kvi_htmlgenerator.h" #include "kvi_themedlineedit.h" diff --git a/src/modules/list/listwindow.h b/src/modules/list/listwindow.h index a5ab7e9ed..5725d59ff 100644 --- a/src/modules/list/listwindow.h +++ b/src/modules/list/listwindow.h @@ -31,7 +31,7 @@ #include "kvi_sparser.h" #include "kvi_console.h" #include "kvi_irccontext.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "kvi_themedtreewidget.h" #include diff --git a/src/modules/logview/logviewmdiwindow.cpp b/src/modules/logview/logviewmdiwindow.cpp index b56523cac..62ca73513 100644 --- a/src/modules/logview/logviewmdiwindow.cpp +++ b/src/modules/logview/logviewmdiwindow.cpp @@ -35,7 +35,7 @@ #include "KviQString.h" #include "kvi_app.h" #include "KviFileUtils.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/logview/logviewmdiwindow.h b/src/modules/logview/logviewmdiwindow.h index 7e8ec68f5..a9e03799b 100644 --- a/src/modules/logview/logviewmdiwindow.h +++ b/src/modules/logview/logviewmdiwindow.h @@ -28,7 +28,7 @@ #include "kvi_settings.h" #include "kvi_window.h" #include "kvi_moduleextension.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" #include #include "KviPointerList.h" diff --git a/src/modules/mircimport/libkvimircimport.cpp b/src/modules/mircimport/libkvimircimport.cpp index fb761d535..3b30d6a62 100644 --- a/src/modules/mircimport/libkvimircimport.cpp +++ b/src/modules/mircimport/libkvimircimport.cpp @@ -32,7 +32,7 @@ #include "KviConfigurationFile.h" #include "kvi_app.h" #include "KviQString.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" #include #include diff --git a/src/modules/mircimport/libkvimircimport.h b/src/modules/mircimport/libkvimircimport.h index 5f37eebe0..091273830 100644 --- a/src/modules/mircimport/libkvimircimport.h +++ b/src/modules/mircimport/libkvimircimport.h @@ -26,8 +26,8 @@ #include "kvi_mexserverimport.h" #include "KviCString.h" -#include "kvi_http.h" -#include +#include "KviHttpRequest.h" +#include #include #include diff --git a/src/modules/notifier/notifierwindow.h b/src/modules/notifier/notifierwindow.h index 5b41b0fec..e659784c2 100644 --- a/src/modules/notifier/notifierwindow.h +++ b/src/modules/notifier/notifierwindow.h @@ -30,7 +30,7 @@ #include "kvi_settings.h" #include "KviQString.h" #include "KviPointerList.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "KviTimeUtils.h" #include diff --git a/src/modules/objects/class_groupbox.cpp b/src/modules/objects/class_groupbox.cpp index 89c714025..6633bbad6 100644 --- a/src/modules/objects/class_groupbox.cpp +++ b/src/modules/objects/class_groupbox.cpp @@ -23,7 +23,7 @@ // //============================================================================= -#include +#include #include "class_groupbox.h" #include "kvi_error.h" #include "kvi_debug.h" diff --git a/src/modules/objects/class_groupbox.h b/src/modules/objects/class_groupbox.h index b1447e749..07320df56 100644 --- a/src/modules/objects/class_groupbox.h +++ b/src/modules/objects/class_groupbox.h @@ -27,7 +27,7 @@ -#include +#include #include "class_widget.h" #include "object_macros.h" diff --git a/src/modules/objects/class_hbox.cpp b/src/modules/objects/class_hbox.cpp index e224b95ec..b38310c65 100644 --- a/src/modules/objects/class_hbox.cpp +++ b/src/modules/objects/class_hbox.cpp @@ -26,7 +26,7 @@ #include "kvi_debug.h" #include "KviLocale.h" #include "class_hbox.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" const char * const align_tbl[] = { "Left", diff --git a/src/modules/objects/class_mainwindow.cpp b/src/modules/objects/class_mainwindow.cpp index 5621b87c1..c1a58580d 100644 --- a/src/modules/objects/class_mainwindow.cpp +++ b/src/modules/objects/class_mainwindow.cpp @@ -23,7 +23,7 @@ // //============================================================================= -#include "kvi_tal_mainwindow.h" +#include "KviTalMainWindow.h" #include "class_mainwindow.h" #include "kvi_error.h" #include "kvi_debug.h" diff --git a/src/modules/objects/class_popupmenu.cpp b/src/modules/objects/class_popupmenu.cpp index 013fa945e..6c1b78fa7 100644 --- a/src/modules/objects/class_popupmenu.cpp +++ b/src/modules/objects/class_popupmenu.cpp @@ -30,7 +30,7 @@ #include "kvi_debug.h" #include "KviLocale.h" #include "kvi_iconmanager.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/objects/class_socket.cpp b/src/modules/objects/class_socket.cpp index e35c62654..a22082902 100644 --- a/src/modules/objects/class_socket.cpp +++ b/src/modules/objects/class_socket.cpp @@ -36,8 +36,8 @@ #include "KviFileUtils.h" #include "KviLocale.h" #include "kvi_error.h" -#include "kvi_netutils.h" -#include "kvi_dns.h" +#include "KviNetUtils.h" +#include "KviDnsResolver.h" #include "kvi_error.h" #include "kvi_socket.h" #include "KviMemory.h" @@ -1000,9 +1000,9 @@ void KviKvsObject_socket::lookupRemoteIp() if(m_pDelayTimer)delete m_pDelayTimer; m_pDelayTimer = 0; if(m_pDns)delete m_pDns; - m_pDns = new KviDns(); - connect(m_pDns,SIGNAL(lookupDone(KviDns *)),this,SLOT(lookupDone(KviDns *))); - if(!m_pDns->lookup(m_szRemoteIp,KviDns::Any)) + m_pDns = new KviDnsResolver(); + connect(m_pDns,SIGNAL(lookupDone(KviDnsResolver *)),this,SLOT(lookupDone(KviDnsResolver *))); + if(!m_pDns->lookup(m_szRemoteIp,KviDnsResolver::Any)) { unsigned int uOldConnectionId = m_uConnectionId; KviKvsVariantList lParams; @@ -1013,10 +1013,10 @@ void KviKvsObject_socket::lookupRemoteIp() } } -void KviKvsObject_socket::lookupDone(KviDns *pDns) +void KviKvsObject_socket::lookupDone(KviDnsResolver *pDns) { - if(pDns->state() != KviDns::Success) + if(pDns->state() != KviDnsResolver::Success) { unsigned int uOldConnectionId = m_uConnectionId; KviKvsVariantList lParams; diff --git a/src/modules/objects/class_socket.h b/src/modules/objects/class_socket.h index a4e252693..40ac42d47 100644 --- a/src/modules/objects/class_socket.h +++ b/src/modules/objects/class_socket.h @@ -36,7 +36,7 @@ #define KVI_SCRIPT_SOCKET_STATUS_LISTENING 3 #define KVI_SCRIPT_SOCKET_STATUS_CONNECTED 4 -class KviDns; +class KviDnsResolver; class KviDataBuffer; #include "object_macros.h" @@ -56,7 +56,7 @@ protected: kvi_u32_t m_uLocalPort; unsigned int m_uConnectTimeout; QSocketNotifier * m_pSn; - KviDns * m_pDns; + KviDnsResolver * m_pDns; QTimer * m_pDelayTimer; char * m_pInBuffer; unsigned int m_uInBufferLen; @@ -103,7 +103,7 @@ protected: protected slots: void doConnect(); void lookupRemoteIp(); - void lookupDone(KviDns * pDns); + void lookupDone(KviDnsResolver * pDns); void connectTimeoutSlot(); void writeNotifierFired(int); void readNotifierFired(int); diff --git a/src/modules/objects/class_toolbar.cpp b/src/modules/objects/class_toolbar.cpp index b650d38b8..b572bbb08 100644 --- a/src/modules/objects/class_toolbar.cpp +++ b/src/modules/objects/class_toolbar.cpp @@ -26,8 +26,8 @@ #include "class_toolbar.h" #include "kvi_error.h" #include "kvi_debug.h" -#include "kvi_tal_toolbar.h" -#include "kvi_tal_mainwindow.h" +#include "KviTalToolBar.h" +#include "KviTalMainWindow.h" #include "KviLocale.h" #include "kvi_iconmanager.h" #include "class_mainwindow.h" diff --git a/src/modules/objects/class_toolbutton.cpp b/src/modules/objects/class_toolbutton.cpp index 0de288057..4e44c8efa 100644 --- a/src/modules/objects/class_toolbutton.cpp +++ b/src/modules/objects/class_toolbutton.cpp @@ -29,7 +29,7 @@ #include "KviLocale.h" #include "kvi_iconmanager.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" /* @doc: toolbutton @keyterms: diff --git a/src/modules/objects/class_vbox.cpp b/src/modules/objects/class_vbox.cpp index 5ac157775..dbf172b5a 100644 --- a/src/modules/objects/class_vbox.cpp +++ b/src/modules/objects/class_vbox.cpp @@ -29,7 +29,7 @@ #include "class_vbox.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" // Tables used in $setAlignment & $alignment diff --git a/src/modules/objects/class_widget.h b/src/modules/objects/class_widget.h index f2575793c..3debaef5d 100644 --- a/src/modules/objects/class_widget.h +++ b/src/modules/objects/class_widget.h @@ -27,7 +27,7 @@ #include "kvi_settings.h" #include "KviCString.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include "object_macros.h" #ifdef COMPILE_WEBKIT_SUPPORT diff --git a/src/modules/objects/class_wizard.cpp b/src/modules/objects/class_wizard.cpp index 5d7d5559e..b2b5b2127 100644 --- a/src/modules/objects/class_wizard.cpp +++ b/src/modules/objects/class_wizard.cpp @@ -23,7 +23,7 @@ // //============================================================================= -#include +#include #include "class_wizard.h" #include "kvi_error.h" diff --git a/src/modules/objects/class_wizard.h b/src/modules/objects/class_wizard.h index 5b5ba6e63..1b71cd06e 100644 --- a/src/modules/objects/class_wizard.h +++ b/src/modules/objects/class_wizard.h @@ -25,7 +25,7 @@ // //============================================================================= -#include +#include #include "class_widget.h" #include "object_macros.h" diff --git a/src/modules/options/container.cpp b/src/modules/options/container.cpp index d37e47f6b..5c4ea7e0d 100644 --- a/src/modules/options/container.cpp +++ b/src/modules/options/container.cpp @@ -28,7 +28,7 @@ #include "KviLocale.h" #include "kvi_iconmanager.h" #include "kvi_app.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/modules/options/dialog.cpp b/src/modules/options/dialog.cpp index 47081bc79..a83a2d66e 100644 --- a/src/modules/options/dialog.cpp +++ b/src/modules/options/dialog.cpp @@ -31,10 +31,10 @@ #include "kvi_iconmanager.h" #include "kvi_module.h" #include "KviPointerHashTable.h" -#include "kvi_tal_vbox.h" -#include "kvi_tal_tooltip.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_groupbox.h" +#include "KviTalVBox.h" +#include "KviTalToolTip.h" +#include "KviTalPopupMenu.h" +#include "KviTalGroupBox.h" #include #include diff --git a/src/modules/options/optw_avatar.cpp b/src/modules/options/optw_avatar.cpp index 03f96ef4f..7e2bc9d46 100644 --- a/src/modules/options/optw_avatar.cpp +++ b/src/modules/options/optw_avatar.cpp @@ -27,7 +27,7 @@ #include "KviLocale.h" #include "kvi_selectors.h" #include "kvi_options.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" KviAvatarAdvancedOptionsWidget::KviAvatarAdvancedOptionsWidget(QWidget * parent) : KviOptionsWidget(parent) diff --git a/src/modules/options/optw_highlighting.cpp b/src/modules/options/optw_highlighting.cpp index 6836601da..af86ea88d 100644 --- a/src/modules/options/optw_highlighting.cpp +++ b/src/modules/options/optw_highlighting.cpp @@ -32,7 +32,7 @@ #include #include -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" KviAlertHighlightingOptionsWidget::KviAlertHighlightingOptionsWidget(QWidget * parent) : KviOptionsWidget(parent) diff --git a/src/modules/options/optw_identity.cpp b/src/modules/options/optw_identity.cpp index a793660bc..120c7d545 100644 --- a/src/modules/options/optw_identity.cpp +++ b/src/modules/options/optw_identity.cpp @@ -35,10 +35,10 @@ #include "kvi_filedialog.h" #include "kvi_fileextensions.h" #include "kvi_iconmanager.h" -#include "kvi_http.h" +#include "KviHttpRequest.h" #include "KviIdentityProfile.h" -#include "kvi_tal_tooltip.h" -#include "kvi_tal_hbox.h" +#include "KviTalToolTip.h" +#include "KviTalHBox.h" #include #include diff --git a/src/modules/options/optw_interfacelookglobal.cpp b/src/modules/options/optw_interfacelookglobal.cpp index bc532583c..1265a5bb7 100644 --- a/src/modules/options/optw_interfacelookglobal.cpp +++ b/src/modules/options/optw_interfacelookglobal.cpp @@ -28,7 +28,7 @@ #include "kvi_options.h" #include "KviLocale.h" #include "kvi_app.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include diff --git a/src/modules/options/optw_ircoutput.cpp b/src/modules/options/optw_ircoutput.cpp index 21de881c1..5fcdbfd2b 100644 --- a/src/modules/options/optw_ircoutput.cpp +++ b/src/modules/options/optw_ircoutput.cpp @@ -27,7 +27,7 @@ #include "kvi_settings.h" #include "kvi_options.h" #include "KviLocale.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/modules/options/optw_lag.cpp b/src/modules/options/optw_lag.cpp index 8619b22b9..8aaa893e3 100644 --- a/src/modules/options/optw_lag.cpp +++ b/src/modules/options/optw_lag.cpp @@ -27,7 +27,7 @@ #include "kvi_options.h" #include "KviLocale.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include diff --git a/src/modules/options/optw_mediatypes.cpp b/src/modules/options/optw_mediatypes.cpp index 2a4a631bf..114be5bf5 100644 --- a/src/modules/options/optw_mediatypes.cpp +++ b/src/modules/options/optw_mediatypes.cpp @@ -26,7 +26,7 @@ #include "kvi_options.h" #include "KviLocale.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/modules/options/optw_messages.cpp b/src/modules/options/optw_messages.cpp index 8329a621d..8a4e794ea 100644 --- a/src/modules/options/optw_messages.cpp +++ b/src/modules/options/optw_messages.cpp @@ -34,7 +34,7 @@ #include "KviMircCntrl.h" #include "KviConfigurationFile.h" #include "kvi_filedialog.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" #include #include diff --git a/src/modules/options/optw_messages.h b/src/modules/options/optw_messages.h index e66556f67..90093a8d2 100644 --- a/src/modules/options/optw_messages.h +++ b/src/modules/options/optw_messages.h @@ -26,7 +26,7 @@ #include "kvi_optionswidget.h" #include "KviMessageTypeSettings.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/options/optw_nickserv.cpp b/src/modules/options/optw_nickserv.cpp index 0cd0caa97..cd3e49a86 100644 --- a/src/modules/options/optw_nickserv.cpp +++ b/src/modules/options/optw_nickserv.cpp @@ -29,7 +29,7 @@ #include "KviLocale.h" #include "KviNickServRuleSet.h" #include "KviIrcMask.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/modules/options/optw_proxy.cpp b/src/modules/options/optw_proxy.cpp index 5454f8140..79c9e1dfe 100644 --- a/src/modules/options/optw_proxy.cpp +++ b/src/modules/options/optw_proxy.cpp @@ -28,12 +28,12 @@ #include "kvi_iconmanager.h" #include "KviProxyDataBase.h" #include "kvi_ipeditor.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_settings.h" #include "kvi_options.h" -#include "kvi_tal_groupbox.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_tooltip.h" +#include "KviTalGroupBox.h" +#include "KviTalPopupMenu.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/modules/options/optw_servers.cpp b/src/modules/options/optw_servers.cpp index 1cb23f13c..e742cfa9d 100644 --- a/src/modules/options/optw_servers.cpp +++ b/src/modules/options/optw_servers.cpp @@ -34,7 +34,7 @@ #include "kvi_iconmanager.h" #include "KviIrcServerDataBase.h" #include "kvi_ipeditor.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "kvi_settings.h" #include "kvi_filedialog.h" #include "KviConfigurationFile.h" @@ -52,8 +52,8 @@ #include "KviProxyDataBase.h" #include "kvi_kvs_script.h" #include "KviPointerHashTable.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_tooltip.h" +#include "KviTalPopupMenu.h" +#include "KviTalToolTip.h" #include #include diff --git a/src/modules/options/optw_sound.cpp b/src/modules/options/optw_sound.cpp index 54c49ae84..04632afcd 100644 --- a/src/modules/options/optw_sound.cpp +++ b/src/modules/options/optw_sound.cpp @@ -30,8 +30,8 @@ #include "kvi_modulemanager.h" #include "KviPointerList.h" #include "KviCString.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_tooltip.h" +#include "KviTalHBox.h" +#include "KviTalToolTip.h" #include "kvi_app.h" #include diff --git a/src/modules/options/optw_texticons.cpp b/src/modules/options/optw_texticons.cpp index 4bbae171a..d38e19ed4 100644 --- a/src/modules/options/optw_texticons.cpp +++ b/src/modules/options/optw_texticons.cpp @@ -29,7 +29,7 @@ #include "KviLocale.h" #include "kvi_filedialog.h" #include "kvi_fileextensions.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include #include diff --git a/src/modules/options/optw_texticons.h b/src/modules/options/optw_texticons.h index 611bc9aee..167975d7c 100644 --- a/src/modules/options/optw_texticons.h +++ b/src/modules/options/optw_texticons.h @@ -26,8 +26,8 @@ #include "kvi_optionswidget.h" #include "kvi_texticonmanager.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_hbox.h" +#include "KviTalPopupMenu.h" +#include "KviTalHBox.h" #include #include diff --git a/src/modules/options/optw_tray.cpp b/src/modules/options/optw_tray.cpp index 55a6e8854..40dc73a47 100644 --- a/src/modules/options/optw_tray.cpp +++ b/src/modules/options/optw_tray.cpp @@ -28,7 +28,7 @@ #include "kvi_internalcmd.h" #include "kvi_options.h" #include "KviLocale.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include diff --git a/src/modules/popupeditor/popupeditor.cpp b/src/modules/popupeditor/popupeditor.cpp index c4a35c17b..31ff44e4c 100644 --- a/src/modules/popupeditor/popupeditor.cpp +++ b/src/modules/popupeditor/popupeditor.cpp @@ -39,7 +39,7 @@ #include "kvi_kvs_popupmenu.h" #include "kvi_kvs_variantlist.h" #include "KviPointerHashTable.h" -#include "kvi_tal_vbox.h" +#include "KviTalVBox.h" #include "kvi_fileextensions.h" #include diff --git a/src/modules/popupeditor/popupeditor.h b/src/modules/popupeditor/popupeditor.h index 75a0d8fa3..37f29817e 100644 --- a/src/modules/popupeditor/popupeditor.h +++ b/src/modules/popupeditor/popupeditor.h @@ -27,7 +27,7 @@ #include "kvi_window.h" #include "KviCString.h" #include -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/raweditor/raweditor.cpp b/src/modules/raweditor/raweditor.cpp index e6c3cc1c7..0b56d4ef9 100644 --- a/src/modules/raweditor/raweditor.cpp +++ b/src/modules/raweditor/raweditor.cpp @@ -39,8 +39,8 @@ #include "KviCommandFormatter.h" #include "kvi_kvs_eventmanager.h" #include "kvi_kvs_eventhandler.h" -#include "kvi_tal_vbox.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalVBox.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/reguser/dialog.cpp b/src/modules/reguser/dialog.cpp index 4d2325d02..6df0a77fb 100644 --- a/src/modules/reguser/dialog.cpp +++ b/src/modules/reguser/dialog.cpp @@ -43,8 +43,8 @@ #include "KviStringConversion.h" #include "kvi_options.h" #include "KviPointerHashTable.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_vbox.h" +#include "KviTalHBox.h" +#include "KviTalVBox.h" #include #include diff --git a/src/modules/reguser/dialog.h b/src/modules/reguser/dialog.h index 5e3cb8d47..e3eff6420 100644 --- a/src/modules/reguser/dialog.h +++ b/src/modules/reguser/dialog.h @@ -29,8 +29,8 @@ #include "kvi_selectors.h" #include "KviPointerHashTable.h" #include -#include "kvi_tal_listwidget.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalListWidget.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/reguser/edituser.cpp b/src/modules/reguser/edituser.cpp index 633458046..d49c2404f 100644 --- a/src/modules/reguser/edituser.cpp +++ b/src/modules/reguser/edituser.cpp @@ -43,8 +43,8 @@ #include "KviStringConversion.h" #include "kvi_options.h" #include "KviPointerHashTable.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_vbox.h" +#include "KviTalHBox.h" +#include "KviTalVBox.h" #include #include diff --git a/src/modules/reguser/edituser.h b/src/modules/reguser/edituser.h index e453b9b84..aa5d6fece 100644 --- a/src/modules/reguser/edituser.h +++ b/src/modules/reguser/edituser.h @@ -29,8 +29,8 @@ #include "kvi_selectors.h" #include "KviPointerHashTable.h" #include -#include "kvi_tal_popupmenu.h" -#include +#include "KviTalPopupMenu.h" +#include #include #include diff --git a/src/modules/reguser/wizard.h b/src/modules/reguser/wizard.h index 27481475d..4b9b23afa 100644 --- a/src/modules/reguser/wizard.h +++ b/src/modules/reguser/wizard.h @@ -25,7 +25,7 @@ //============================================================================= #include "KviCString.h" -#include "kvi_tal_wizard.h" +#include "KviTalWizard.h" #include diff --git a/src/modules/setup/setupwizard.cpp b/src/modules/setup/setupwizard.cpp index 2a14b5291..df291feee 100644 --- a/src/modules/setup/setupwizard.cpp +++ b/src/modules/setup/setupwizard.cpp @@ -31,12 +31,12 @@ bool g_bFoundMirc; #include "KviFileUtils.h" #include "kvi_defaults.h" #include "kvi_msgbox.h" -#include "kvi_tal_filedialog.h" +#include "KviTalFileDialog.h" #include "KviQString.h" #include "KviEnvironment.h" #include "kvi_options.h" #include "KviConfigurationFile.h" -#include "kvi_tal_hbox.h" +#include "KviTalHBox.h" #include #include diff --git a/src/modules/setup/setupwizard.h b/src/modules/setup/setupwizard.h index f2d0fdd71..f7085cfc4 100644 --- a/src/modules/setup/setupwizard.h +++ b/src/modules/setup/setupwizard.h @@ -27,10 +27,10 @@ #include "kvi_settings.h" #include "KviCString.h" #include "kvi_selectors.h" -#include "kvi_tal_wizard.h" -#include "kvi_tal_vbox.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_groupbox.h" +#include "KviTalWizard.h" +#include "KviTalVBox.h" +#include "KviTalHBox.h" +#include "KviTalGroupBox.h" #include #include diff --git a/src/modules/sharedfileswindow/sharedfileswindow.cpp b/src/modules/sharedfileswindow/sharedfileswindow.cpp index 6027be480..3ee9b76f8 100644 --- a/src/modules/sharedfileswindow/sharedfileswindow.cpp +++ b/src/modules/sharedfileswindow/sharedfileswindow.cpp @@ -35,8 +35,8 @@ #include "kvi_themedlabel.h" #include "kvi_input.h" #include "kvi_filedialog.h" -#include "kvi_tal_hbox.h" -#include "kvi_tal_vbox.h" +#include "KviTalHBox.h" +#include "KviTalVBox.h" #include #include diff --git a/src/modules/str/libkvistr.cpp b/src/modules/str/libkvistr.cpp index 8696709b3..6f908dc68 100644 --- a/src/modules/str/libkvistr.cpp +++ b/src/modules/str/libkvistr.cpp @@ -40,7 +40,7 @@ #if defined( COMPILE_SSL_SUPPORT ) && !defined( COMPILE_NO_EMBEDDED_CODE ) // The current implementation - #include + #include #include #include #elif defined(COMPILE_NO_EMBEDDED_CODE) diff --git a/src/modules/term/termwidget.h b/src/modules/term/termwidget.h index 4c2c076c3..d8ec94900 100644 --- a/src/modules/term/termwidget.h +++ b/src/modules/term/termwidget.h @@ -30,7 +30,7 @@ #include #include #include - #include "kvi_tal_hbox.h" + #include "KviTalHBox.h" #include "kparts/part.h" diff --git a/src/modules/theme/managementdialog.cpp b/src/modules/theme/managementdialog.cpp index 49116bcc8..4d92276d6 100644 --- a/src/modules/theme/managementdialog.cpp +++ b/src/modules/theme/managementdialog.cpp @@ -41,8 +41,8 @@ #include "kvi_dynamictooltip.h" #include "kvi_iconmanager.h" #include "kvi_msgbox.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_listwidget.h" +#include "KviTalPopupMenu.h" +#include "KviTalListWidget.h" #include diff --git a/src/modules/theme/managementdialog.h b/src/modules/theme/managementdialog.h index 3df640222..0b69960c0 100644 --- a/src/modules/theme/managementdialog.h +++ b/src/modules/theme/managementdialog.h @@ -27,9 +27,9 @@ #include "kvi_optionswidget.h" #include "KviPointerList.h" #include "kvi_theme.h" -#include "kvi_tal_popupmenu.h" -#include "kvi_tal_wizard.h" -#include "kvi_tal_listwidget.h" +#include "KviTalPopupMenu.h" +#include "KviTalWizard.h" +#include "KviTalListWidget.h" #include #include diff --git a/src/modules/theme/savethemedialog.h b/src/modules/theme/savethemedialog.h index 145ffdcbf..9d2140727 100644 --- a/src/modules/theme/savethemedialog.h +++ b/src/modules/theme/savethemedialog.h @@ -27,7 +27,7 @@ #include "kvi_settings.h" #include "KviPointerList.h" #include "kvi_theme.h" -#include "kvi_tal_wizard.h" +#include "KviTalWizard.h" #include diff --git a/src/modules/toolbareditor/toolbareditor.cpp b/src/modules/toolbareditor/toolbareditor.cpp index fdc61fc93..08a3c19dd 100644 --- a/src/modules/toolbareditor/toolbareditor.cpp +++ b/src/modules/toolbareditor/toolbareditor.cpp @@ -37,7 +37,7 @@ #include "KviFileUtils.h" #include "kvi_filedialog.h" #include "kvi_kvs_useraction.h" -#include "kvi_tal_tooltip.h" +#include "KviTalToolTip.h" #include "kvi_fileextensions.h" #include diff --git a/src/modules/trayicon/libkvitrayicon.cpp b/src/modules/trayicon/libkvitrayicon.cpp index c2ea870a4..c11d6bda8 100644 --- a/src/modules/trayicon/libkvitrayicon.cpp +++ b/src/modules/trayicon/libkvitrayicon.cpp @@ -41,7 +41,7 @@ #include "kvi_ircconnectionuserinfo.h" #include "kvi_options.h" #include "kvi_ircview.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include #include diff --git a/src/modules/upnp/libkviupnp.cpp b/src/modules/upnp/libkviupnp.cpp index 10a69864d..c3eacb17c 100644 --- a/src/modules/upnp/libkviupnp.cpp +++ b/src/modules/upnp/libkviupnp.cpp @@ -25,7 +25,7 @@ #include "kvi_settings.h" #include "kvi_module.h" #include "KviCString.h" -#include "kvi_netutils.h" +#include "KviNetUtils.h" #include "manager.h" diff --git a/src/modules/url/libkviurl.cpp b/src/modules/url/libkviurl.cpp index abcb31819..3ad3d2ef6 100644 --- a/src/modules/url/libkviurl.cpp +++ b/src/modules/url/libkviurl.cpp @@ -36,7 +36,7 @@ #include "kvi_windowlist.h" #include "KviPointerList.h" #include "kvi_kvs_eventmanager.h" -#include "kvi_tal_popupmenu.h" +#include "KviTalPopupMenu.h" #include "kvi_window.h" #include "kvi_options.h" #include "KviQString.h" diff --git a/src/modules/url/libkviurl.h b/src/modules/url/libkviurl.h index e180b2290..a5b1fbc53 100644 --- a/src/modules/url/libkviurl.h +++ b/src/modules/url/libkviurl.h @@ -28,7 +28,7 @@ #include "KviConfigurationFile.h" #include "kvi_irctoolbar.h" #include "kvi_window.h" -#include "kvi_tal_menubar.h" +#include "KviTalMenuBar.h" #include "kvi_mextoolbar.h" #include "kvi_kvs_action.h" #include -- cgit v1.3.1-10-gc9f91