Reformat ALL the source!
authorManuel Nickschas <sputnick@quassel-irc.org>
Fri, 25 May 2012 14:05:34 +0000 (16:05 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Fri, 25 May 2012 14:05:34 +0000 (16:05 +0200)
Yes, yes. After stubborningly refusing to switch to a more readable coding style for
years, I finally give in. Our old, quite compact, 2-indent style was born from my time
with homecomputers, where every whitespace was a waste. Later (and mostly thanks to EgS),
I did see the light, e.g. changed from one-letter variable names to useful ones, but
still shied away from reformatting the whole source, touching every line, destroying the
historical context as shown by svn and git blame.

However, since I'm now doing Qt-related programming as my day job, and use a proper
(Qt-like) coding style there, it has become increasingly annoying for myself to switch to
another style in those long hacking nights working on Quassel, and so I decided to
Just Do Itâ„¢. Helps that Git nowadays can ignore whitespace changes when blaming, or
diffing, or patching, so this shouldn't be too much of an annoyance for existing patches.
Feedback from the community was also positive...

So now we use a style that should be pretty close to the Qt Coding Style [1], which not
only covers the indentation, but also things like newline-after-function-head.

Reformatting was done automagically using uncrustify [2], a script and config file is in
scripts/manage/. Please don't run it over the whole codebase again, as there are some
false positives and weird formattings that will have to be manually fixed over time.
You can use it for reformatting existing patches or MRs, though.

[1] http://qt-project.org/wiki/Qt_Coding_Style
[2] http://uncrustify.sourceforge.net/

404 files changed:
scripts/manage/format_source.cfg [new file with mode: 0644]
scripts/manage/format_source.sh [new file with mode: 0755]
src/client/abstractmessageprocessor.cpp
src/client/abstractmessageprocessor.h
src/client/abstractui.h
src/client/backlogrequester.cpp
src/client/backlogrequester.h
src/client/backlogsettings.h
src/client/buffermodel.cpp
src/client/buffermodel.h
src/client/buffersettings.cpp
src/client/buffersettings.h
src/client/bufferviewoverlay.cpp
src/client/bufferviewoverlay.h
src/client/client.cpp
src/client/client.h
src/client/clientaliasmanager.cpp
src/client/clientaliasmanager.h
src/client/clientbacklogmanager.cpp
src/client/clientbacklogmanager.h
src/client/clientbufferviewconfig.cpp
src/client/clientbufferviewconfig.h
src/client/clientbufferviewmanager.cpp
src/client/clientbufferviewmanager.h
src/client/clientcoreinfo.h
src/client/clientidentity.cpp
src/client/clientidentity.h
src/client/clientignorelistmanager.cpp
src/client/clientignorelistmanager.h
src/client/clientirclisthelper.cpp
src/client/clientirclisthelper.h
src/client/clientsettings.cpp
src/client/clientsettings.h
src/client/clientuserinputhandler.cpp
src/client/clientuserinputhandler.h
src/client/coreaccount.cpp
src/client/coreaccount.h
src/client/coreaccountmodel.cpp
src/client/coreaccountmodel.h
src/client/coreconnection.cpp
src/client/coreconnection.h
src/client/execwrapper.cpp
src/client/execwrapper.h
src/client/irclistmodel.cpp
src/client/irclistmodel.h
src/client/messagefilter.cpp
src/client/messagefilter.h
src/client/messagemodel.cpp
src/client/messagemodel.h
src/client/networkmodel.cpp
src/client/networkmodel.h
src/client/selectionmodelsynchronizer.cpp
src/client/selectionmodelsynchronizer.h
src/client/treemodel.cpp
src/client/treemodel.h
src/common/abstractcliparser.h
src/common/aliasmanager.cpp
src/common/aliasmanager.h
src/common/backlogmanager.cpp
src/common/backlogmanager.h
src/common/basichandler.cpp
src/common/basichandler.h
src/common/bufferinfo.cpp
src/common/bufferinfo.h
src/common/buffersyncer.cpp
src/common/buffersyncer.h
src/common/bufferviewconfig.cpp
src/common/bufferviewconfig.h
src/common/bufferviewmanager.cpp
src/common/bufferviewmanager.h
src/common/cliparser.cpp
src/common/cliparser.h
src/common/coreinfo.h
src/common/ctcpevent.cpp
src/common/ctcpevent.h
src/common/event.cpp
src/common/event.h
src/common/eventmanager.cpp
src/common/eventmanager.h
src/common/genversion.cpp
src/common/identity.cpp
src/common/identity.h
src/common/ignorelistmanager.cpp
src/common/ignorelistmanager.h
src/common/ircchannel.cpp
src/common/ircchannel.h
src/common/ircevent.cpp
src/common/ircevent.h
src/common/irclisthelper.h
src/common/ircuser.cpp
src/common/ircuser.h
src/common/logbacktrace_unix.cpp
src/common/logbacktrace_win.cpp
src/common/logger.cpp
src/common/logger.h
src/common/mac_utils.cpp
src/common/main.cpp
src/common/message.cpp
src/common/message.h
src/common/messageevent.cpp
src/common/messageevent.h
src/common/network.cpp
src/common/network.h
src/common/networkconfig.cpp
src/common/networkconfig.h
src/common/networkevent.cpp
src/common/networkevent.h
src/common/quassel.cpp
src/common/quassel.h
src/common/settings.cpp
src/common/settings.h
src/common/signalproxy.cpp
src/common/signalproxy.h
src/common/syncableobject.cpp
src/common/syncableobject.h
src/common/types.h
src/common/util.cpp
src/common/util.h
src/core/abstractsqlstorage.cpp
src/core/abstractsqlstorage.h
src/core/cipher.cpp
src/core/cipher.h
src/core/core.cpp
src/core/core.h
src/core/corealiasmanager.cpp
src/core/corealiasmanager.h
src/core/coreapplication.cpp
src/core/coreapplication.h
src/core/corebacklogmanager.cpp
src/core/corebacklogmanager.h
src/core/corebasichandler.cpp
src/core/corebasichandler.h
src/core/corebuffersyncer.cpp
src/core/corebuffersyncer.h
src/core/corebufferviewconfig.cpp
src/core/corebufferviewconfig.h
src/core/corebufferviewmanager.cpp
src/core/corebufferviewmanager.h
src/core/corecoreinfo.cpp
src/core/corecoreinfo.h
src/core/coreeventmanager.h
src/core/coreidentity.cpp
src/core/coreidentity.h
src/core/coreignorelistmanager.cpp
src/core/coreignorelistmanager.h
src/core/coreircchannel.cpp
src/core/coreircchannel.h
src/core/coreirclisthelper.cpp
src/core/coreirclisthelper.h
src/core/coreircuser.cpp
src/core/coreircuser.h
src/core/corenetwork.cpp
src/core/corenetwork.h
src/core/corenetworkconfig.cpp
src/core/corenetworkconfig.h
src/core/coresession.cpp
src/core/coresession.h
src/core/coresessioneventprocessor.cpp
src/core/coresessioneventprocessor.h
src/core/coresettings.cpp
src/core/coresettings.h
src/core/coreuserinputhandler.cpp
src/core/coreuserinputhandler.h
src/core/coreusersettings.cpp
src/core/coreusersettings.h
src/core/ctcpparser.cpp
src/core/ctcpparser.h
src/core/eventstringifier.cpp
src/core/eventstringifier.h
src/core/ircparser.cpp
src/core/ircparser.h
src/core/netsplit.cpp
src/core/netsplit.h
src/core/oidentdconfiggenerator.cpp
src/core/oidentdconfiggenerator.h
src/core/postgresqlstorage.cpp
src/core/postgresqlstorage.h
src/core/sessionthread.cpp
src/core/sessionthread.h
src/core/sqlitestorage.cpp
src/core/sqlitestorage.h
src/core/sslserver.cpp
src/core/sslserver.h
src/core/storage.cpp
src/core/storage.h
src/qtui/aboutdlg.cpp
src/qtui/aboutdlg.h
src/qtui/awaylogfilter.cpp
src/qtui/awaylogfilter.h
src/qtui/awaylogview.cpp
src/qtui/awaylogview.h
src/qtui/bufferwidget.cpp
src/qtui/bufferwidget.h
src/qtui/channellistdlg.cpp
src/qtui/channellistdlg.h
src/qtui/chatitem.cpp
src/qtui/chatitem.h
src/qtui/chatline.cpp
src/qtui/chatline.h
src/qtui/chatlinemodel.cpp
src/qtui/chatlinemodel.h
src/qtui/chatlinemodelitem.cpp
src/qtui/chatlinemodelitem.h
src/qtui/chatmonitorfilter.cpp
src/qtui/chatmonitorfilter.h
src/qtui/chatmonitorview.cpp
src/qtui/chatmonitorview.h
src/qtui/chatscene.cpp
src/qtui/chatscene.h
src/qtui/chatview.cpp
src/qtui/chatview.h
src/qtui/chatviewsearchbar.cpp
src/qtui/chatviewsearchbar.h
src/qtui/chatviewsearchcontroller.cpp
src/qtui/chatviewsearchcontroller.h
src/qtui/chatviewsettings.cpp
src/qtui/chatviewsettings.h
src/qtui/columnhandleitem.cpp
src/qtui/columnhandleitem.h
src/qtui/coreconfigwizard.cpp
src/qtui/coreconfigwizard.h
src/qtui/coreconnectdlg.cpp
src/qtui/coreconnectdlg.h
src/qtui/coreconnectionstatuswidget.cpp
src/qtui/coreconnectionstatuswidget.h
src/qtui/coreinfodlg.cpp
src/qtui/coreinfodlg.h
src/qtui/debugbufferviewoverlay.cpp
src/qtui/debugbufferviewoverlay.h
src/qtui/debugconsole.cpp
src/qtui/debugconsole.h
src/qtui/debuglogwidget.cpp
src/qtui/debuglogwidget.h
src/qtui/debugmessagemodelfilter.cpp
src/qtui/debugmessagemodelfilter.h
src/qtui/indicatornotificationbackend.cpp
src/qtui/indicatornotificationbackend.h
src/qtui/inputwidget.cpp
src/qtui/inputwidget.h
src/qtui/ircconnectionwizard.cpp
src/qtui/ircconnectionwizard.h
src/qtui/knotificationbackend.cpp
src/qtui/knotificationbackend.h
src/qtui/legacysystemtray.cpp
src/qtui/legacysystemtray.h
src/qtui/mainpage.cpp
src/qtui/mainpage.h
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/qtui/markerlineitem.cpp
src/qtui/markerlineitem.h
src/qtui/monoapplication.cpp
src/qtui/monoapplication.h
src/qtui/msgprocessorstatuswidget.cpp
src/qtui/msgprocessorstatuswidget.h
src/qtui/nicklistwidget.cpp
src/qtui/nicklistwidget.h
src/qtui/phononnotificationbackend.cpp
src/qtui/phononnotificationbackend.h
src/qtui/qtui.cpp
src/qtui/qtui.h
src/qtui/qtuiapplication.cpp
src/qtui/qtuiapplication.h
src/qtui/qtuimessageprocessor.cpp
src/qtui/qtuimessageprocessor.h
src/qtui/qtuisettings.cpp
src/qtui/qtuisettings.h
src/qtui/qtuistyle.cpp
src/qtui/qtuistyle.h
src/qtui/settingsdlg.cpp
src/qtui/settingsdlg.h
src/qtui/settingspagedlg.cpp
src/qtui/settingspagedlg.h
src/qtui/settingspages/aliasesmodel.cpp
src/qtui/settingspages/aliasesmodel.h
src/qtui/settingspages/aliasessettingspage.cpp
src/qtui/settingspages/aliasessettingspage.h
src/qtui/settingspages/appearancesettingspage.cpp
src/qtui/settingspages/appearancesettingspage.h
src/qtui/settingspages/backlogsettingspage.cpp
src/qtui/settingspages/backlogsettingspage.h
src/qtui/settingspages/bufferviewsettingspage.cpp
src/qtui/settingspages/bufferviewsettingspage.h
src/qtui/settingspages/chatmonitorsettingspage.cpp
src/qtui/settingspages/chatmonitorsettingspage.h
src/qtui/settingspages/chatviewsettingspage.cpp
src/qtui/settingspages/chatviewsettingspage.h
src/qtui/settingspages/connectionsettingspage.cpp
src/qtui/settingspages/connectionsettingspage.h
src/qtui/settingspages/coreaccountsettingspage.cpp
src/qtui/settingspages/coreaccountsettingspage.h
src/qtui/settingspages/coreconnectionsettingspage.cpp
src/qtui/settingspages/coreconnectionsettingspage.h
src/qtui/settingspages/highlightsettingspage.cpp
src/qtui/settingspages/highlightsettingspage.h
src/qtui/settingspages/identitiessettingspage.cpp
src/qtui/settingspages/identitiessettingspage.h
src/qtui/settingspages/identityeditwidget.cpp
src/qtui/settingspages/identityeditwidget.h
src/qtui/settingspages/ignorelistmodel.cpp
src/qtui/settingspages/ignorelistmodel.h
src/qtui/settingspages/ignorelistsettingspage.cpp
src/qtui/settingspages/ignorelistsettingspage.h
src/qtui/settingspages/inputwidgetsettingspage.cpp
src/qtui/settingspages/inputwidgetsettingspage.h
src/qtui/settingspages/itemviewsettingspage.cpp
src/qtui/settingspages/itemviewsettingspage.h
src/qtui/settingspages/keysequencewidget.cpp
src/qtui/settingspages/keysequencewidget.h
src/qtui/settingspages/networkssettingspage.cpp
src/qtui/settingspages/networkssettingspage.h
src/qtui/settingspages/notificationssettingspage.cpp
src/qtui/settingspages/notificationssettingspage.h
src/qtui/settingspages/previewbufferview.h
src/qtui/settingspages/shortcutsmodel.cpp
src/qtui/settingspages/shortcutsmodel.h
src/qtui/settingspages/shortcutssettingspage.cpp
src/qtui/settingspages/shortcutssettingspage.h
src/qtui/settingspages/topicwidgetsettingspage.cpp
src/qtui/settingspages/topicwidgetsettingspage.h
src/qtui/simplenetworkeditor.cpp
src/qtui/simplenetworkeditor.h
src/qtui/sslinfodlg.cpp
src/qtui/sslinfodlg.h
src/qtui/statusnotifieritem.cpp
src/qtui/statusnotifieritem.h
src/qtui/statusnotifieritemdbus.cpp
src/qtui/systemtray.cpp
src/qtui/systemtray.h
src/qtui/systraynotificationbackend.cpp
src/qtui/systraynotificationbackend.h
src/qtui/taskbarnotificationbackend.cpp
src/qtui/taskbarnotificationbackend.h
src/qtui/titlesetter.cpp
src/qtui/titlesetter.h
src/qtui/topicwidget.cpp
src/qtui/topicwidget.h
src/qtui/verticaldock.cpp
src/qtui/verticaldock.h
src/qtui/webpreviewitem.cpp
src/qtui/webpreviewitem.h
src/uisupport/abstractbuffercontainer.cpp
src/uisupport/abstractbuffercontainer.h
src/uisupport/abstractitemview.cpp
src/uisupport/abstractitemview.h
src/uisupport/abstractnotificationbackend.h
src/uisupport/action.cpp
src/uisupport/action.h
src/uisupport/actioncollection.cpp
src/uisupport/actioncollection.h
src/uisupport/bufferhotlistfilter.cpp
src/uisupport/bufferhotlistfilter.h
src/uisupport/bufferview.cpp
src/uisupport/bufferview.h
src/uisupport/bufferviewfilter.cpp
src/uisupport/bufferviewfilter.h
src/uisupport/bufferviewoverlayfilter.cpp
src/uisupport/bufferviewoverlayfilter.h
src/uisupport/clearablelineedit.cpp
src/uisupport/clearablelineedit.h
src/uisupport/clickable.cpp
src/uisupport/clickable.h
src/uisupport/clickablelabel.cpp
src/uisupport/clickablelabel.h
src/uisupport/colorbutton.cpp
src/uisupport/colorbutton.h
src/uisupport/contextmenuactionprovider.cpp
src/uisupport/contextmenuactionprovider.h
src/uisupport/flatproxymodel.cpp
src/uisupport/flatproxymodel.h
src/uisupport/fontselector.cpp
src/uisupport/fontselector.h
src/uisupport/graphicalui.cpp
src/uisupport/graphicalui.h
src/uisupport/icon.cpp
src/uisupport/icon.h
src/uisupport/iconloader.cpp
src/uisupport/iconloader.h
src/uisupport/kcmdlinewrapper.cpp
src/uisupport/kcmdlinewrapper.h
src/uisupport/multilineedit.cpp
src/uisupport/multilineedit.h
src/uisupport/networkmodelcontroller.cpp
src/uisupport/networkmodelcontroller.h
src/uisupport/nickview.cpp
src/uisupport/nickview.h
src/uisupport/nickviewfilter.cpp
src/uisupport/nickviewfilter.h
src/uisupport/qssparser.cpp
src/uisupport/qssparser.h
src/uisupport/resizingstackedwidget.cpp
src/uisupport/resizingstackedwidget.h
src/uisupport/settingspage.cpp
src/uisupport/settingspage.h
src/uisupport/styledlabel.cpp
src/uisupport/styledlabel.h
src/uisupport/tabcompleter.cpp
src/uisupport/tabcompleter.h
src/uisupport/toolbaractionprovider.cpp
src/uisupport/toolbaractionprovider.h
src/uisupport/uisettings.cpp
src/uisupport/uisettings.h
src/uisupport/uistyle.cpp
src/uisupport/uistyle.h

diff --git a/scripts/manage/format_source.cfg b/scripts/manage/format_source.cfg
new file mode 100644 (file)
index 0000000..4af3870
--- /dev/null
@@ -0,0 +1,176 @@
+tok_split_gte=false
+utf8_byte=false
+utf8_force=false
+indent_cmt_with_tabs=false
+indent_align_string=true
+indent_braces=false
+indent_braces_no_func=false
+indent_braces_no_class=false
+indent_braces_no_struct=false
+indent_brace_parent=false
+indent_namespace=false
+indent_extern=false
+indent_class=true
+indent_class_colon=false
+indent_else_if=false
+indent_var_def_cont=false
+indent_func_call_param=true
+indent_func_def_param=true
+indent_func_proto_param=true
+indent_func_class_param=true
+indent_func_ctor_var_param=true
+indent_template_param=true
+indent_func_param_double=false
+indent_relative_single_line_comments=false
+indent_col1_comment=false
+indent_access_spec_body=false
+indent_paren_nl=false
+indent_comma_paren=false
+indent_bool_paren=false
+indent_first_bool_expr=false
+indent_square_nl=false
+indent_preserve_sql=false
+indent_align_assign=true
+sp_balance_nested_parens=false
+align_keep_tabs=false
+align_with_tabs=false
+align_on_tabstop=false
+align_number_left=false
+align_func_params=false
+align_same_func_call_params=false
+align_var_def_colon=false
+align_var_def_attribute=false
+align_var_def_inline=false
+align_right_cmt_mix=true
+align_on_operator=false
+align_mix_var_proto=false
+align_single_line_func=false
+align_single_line_brace=false
+align_nl_cont=false
+align_left_shift=true
+align_oc_decl_colon=false
+nl_collapse_empty_body=false
+nl_assign_leave_one_liners=true
+nl_class_leave_one_liners=true
+nl_enum_leave_one_liners=true
+nl_getset_leave_one_liners=true
+nl_func_leave_one_liners=true
+nl_if_leave_one_liners=false
+nl_multi_line_cond=true
+nl_multi_line_define=false
+nl_before_case=false
+nl_after_case=true
+nl_after_return=false
+nl_after_semicolon=false
+nl_after_brace_open=false
+nl_after_brace_open_cmt=false
+nl_after_vbrace_open=false
+nl_after_vbrace_open_empty=false
+nl_after_brace_close=true
+nl_after_vbrace_close=true
+nl_define_macro=false
+nl_squeeze_ifdef=false
+nl_ds_struct_enum_cmt=false
+nl_ds_struct_enum_close_brace=false
+nl_create_if_one_liner=false
+nl_create_for_one_liner=false
+nl_create_while_one_liner=false
+ls_for_split_full=false
+ls_func_split_full=false
+nl_after_multiline_comment=false
+eat_blanks_after_open_brace=true
+eat_blanks_before_close_brace=true
+mod_full_brace_if_chain=false
+mod_pawn_semicolon=false
+mod_full_paren_if_bool=false
+mod_remove_extra_semicolon=false
+mod_sort_import=false
+mod_sort_using=false
+mod_sort_include=false
+mod_move_case_break=false
+mod_remove_empty_return=false
+cmt_indent_multi=false
+cmt_c_group=false
+cmt_c_nl_start=false
+cmt_c_nl_end=false
+cmt_cpp_group=false
+cmt_cpp_nl_start=false
+cmt_cpp_nl_end=false
+cmt_cpp_to_c=false
+cmt_star_cont=false
+cmt_multi_check_last=true
+cmt_insert_before_preproc=false
+pp_indent_at_level=false
+pp_region_indent_code=false
+pp_if_indent_code=false
+pp_define_at_level=false
+indent_columns=4
+nl_end_of_file_min=1
+nl_max=2
+nl_after_func_body=3
+nl_after_class=3
+indent_with_tabs=0
+sp_assign=add
+sp_assign_default=add
+sp_before_assign=add
+sp_after_assign=add
+sp_enum_assign=add
+sp_enum_before_assign=add
+sp_enum_after_assign=add
+sp_pp_concat=ignore
+sp_pp_stringify=ignore
+sp_bool=add
+sp_compare=add
+sp_inside_paren=remove
+sp_paren_paren=remove
+sp_paren_brace=add
+sp_before_ptr_star=add
+sp_before_unnamed_ptr_star=add
+sp_between_ptr_star=remove
+sp_after_ptr_star=remove
+sp_before_byref=add
+sp_after_byref=remove
+sp_template_angle=remove
+sp_before_angle=remove
+sp_inside_angle=remove
+sp_after_angle=add
+sp_angle_paren=remove
+sp_before_sparen=add
+sp_inside_sparen=remove
+sp_after_sparen=add
+sp_sparen_brace=add
+sp_after_semi_for_empty=remove
+sp_before_square=remove
+sp_before_squares=remove
+sp_inside_square=remove
+sp_after_comma=add
+sp_before_comma=remove
+sp_after_class_colon=add
+sp_before_class_colon=add
+sp_before_case_colon=remove
+sp_after_operator=remove
+sp_after_operator_sym=remove
+sp_after_cast=remove
+sp_inside_paren_cast=remove
+sp_cpp_cast_paren=remove
+sp_sizeof_paren=remove
+sp_inside_braces_enum=add
+sp_inside_braces_struct=add
+sp_inside_braces=add
+sp_inside_braces_empty=remove
+sp_func_proto_paren=remove
+sp_func_def_paren=remove
+sp_inside_fparens=remove
+sp_inside_fparen=remove
+sp_square_fparen=remove
+sp_fparen_brace=add
+sp_func_call_paren=remove
+sp_else_brace=add
+sp_brace_else=add
+sp_case_label=force
+nl_start_of_file=remove
+nl_end_of_file=add
+nl_case_colon_brace=ignore
+nl_class_brace=add
+nl_fdef_brace=add
+pos_class_comma=lead
diff --git a/scripts/manage/format_source.sh b/scripts/manage/format_source.sh
new file mode 100755 (executable)
index 0000000..5d40752
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh 
+
+# format_source.sh dirname  - indent the whole source tree
+# format_source.sh filename - indent a single file
+
+if [ -d "$1" ]; then
+#echo "Dir ${1} exists"
+
+file_list=`find ${1} -name "*.cpp" -or -name "*.h" -type f`
+for file2indent in $file_list
+do 
+echo "Indenting file $file2indent"
+#!/bin/bash
+uncrustify -f "$file2indent" -c "./format_source.cfg" -o indentoutput.tmp
+mv indentoutput.tmp "$file2indent"
+
+done
+else
+if [ -f "$1" ]; then
+echo "Indenting one file $1"
+#!/bin/bash
+uncrustify -f "$1" -c "./format_source.cfg" -o indentoutput.tmp
+mv indentoutput.tmp "$1"
+
+else
+echo "ERROR: As parameter given directory or file does not exist!"
+echo "Syntax is: format_source.sh dirname filesuffix"
+echo "Syntax is: format_source.sh filename"
+echo "Example: format_source.sh temp cpp"
+exit 1
+fi
+fi
index 2419c31..025789f 100644 (file)
@@ -23,6 +23,6 @@
 #include "client.h"
 
 AbstractMessageProcessor::AbstractMessageProcessor(QObject *parent)
-  : QObject(parent)
+    : QObject(parent)
 {
 }
index b38138e..7725a4b 100644 (file)
 #include "message.h"
 #include "networkmodel.h"
 
-class AbstractMessageProcessor : public QObject {
-  Q_OBJECT
+class AbstractMessageProcessor : public QObject
+{
+    Q_OBJECT
 
 public:
-  AbstractMessageProcessor(QObject *parent);
-  virtual void reset() = 0;
+    AbstractMessageProcessor(QObject *parent);
+    virtual void reset() = 0;
 
 public slots:
-  virtual void process(Message &msg) = 0;
-  virtual void process(QList<Message> &msgs) = 0;
+    virtual void process(Message &msg) = 0;
+    virtual void process(QList<Message> &msgs) = 0;
 
 protected:
-  // updateBufferActivity also sets the Message::Redirected flag which is later used
-  // to determine where a message should be displayed. therefore it's crucial that it
-  // is called before inserting the message into the model
-  inline void preProcess(Message &msg) { Client::networkModel()->updateBufferActivity(msg); }
+    // updateBufferActivity also sets the Message::Redirected flag which is later used
+    // to determine where a message should be displayed. therefore it's crucial that it
+    // is called before inserting the message into the model
+    inline void preProcess(Message &msg) { Client::networkModel()->updateBufferActivity(msg); }
 };
 
+
 #endif
index 54ae430..4f63b69 100644 (file)
@@ -33,23 +33,25 @@ class AbstractActionProvider;
 class QAction;
 class QMenu;
 
-class AbstractUi : public QObject {
-  Q_OBJECT
+class AbstractUi : public QObject
+{
+    Q_OBJECT
 
 public:
-  AbstractUi(QObject *parent = 0) : QObject(parent) {}
-  virtual ~AbstractUi() {}
-  virtual void init() = 0;  // called after the client is initialized
-  virtual MessageModel *createMessageModel(QObject *parent) = 0;
-  virtual AbstractMessageProcessor *createMessageProcessor(QObject *parent) = 0;
+    AbstractUi(QObject *parent = 0) : QObject(parent) {}
+    virtual ~AbstractUi() {}
+    virtual void init() = 0; // called after the client is initialized
+    virtual MessageModel *createMessageModel(QObject *parent) = 0;
+    virtual AbstractMessageProcessor *createMessageProcessor(QObject *parent) = 0;
 
 protected slots:
-  virtual void connectedToCore() {}
-  virtual void disconnectedFromCore() {}
+    virtual void connectedToCore() {}
+    virtual void disconnectedFromCore() {}
 
 signals:
-  void connectToCore(const QVariantMap &connInfo);
-  void disconnectFromCore();
+    void connectToCore(const QVariantMap &connInfo);
+    void disconnectFromCore();
 };
 
+
 #endif
index 4a6524c..23ce696 100644 (file)
 #include "clientbacklogmanager.h"
 
 BacklogRequester::BacklogRequester(bool buffering, RequesterType requesterType, ClientBacklogManager *backlogManager)
-  : backlogManager(backlogManager),
+    : backlogManager(backlogManager),
     _isBuffering(buffering),
     _requesterType(requesterType),
     _totalBuffers(0)
 {
-  Q_ASSERT(backlogManager);
+    Q_ASSERT(backlogManager);
 }
 
-void BacklogRequester::setWaitingBuffers(const QSet<BufferId> &buffers) {
-  _buffersWaiting = buffers;
-  _totalBuffers = _buffersWaiting.count();
+
+void BacklogRequester::setWaitingBuffers(const QSet<BufferId> &buffers)
+{
+    _buffersWaiting = buffers;
+    _totalBuffers = _buffersWaiting.count();
 }
 
-void BacklogRequester::addWaitingBuffer(BufferId buffer) {
-  _buffersWaiting << buffer;
-  _totalBuffers++;
+
+void BacklogRequester::addWaitingBuffer(BufferId buffer)
+{
+    _buffersWaiting << buffer;
+    _totalBuffers++;
 }
 
-bool BacklogRequester::buffer(BufferId bufferId, const MessageList &messages) {
-  _bufferedMessages << messages;
-  _buffersWaiting.remove(bufferId);
-  return !_buffersWaiting.isEmpty();
+
+bool BacklogRequester::buffer(BufferId bufferId, const MessageList &messages)
+{
+    _bufferedMessages << messages;
+    _buffersWaiting.remove(bufferId);
+    return !_buffersWaiting.isEmpty();
 }
 
-BufferIdList BacklogRequester::allBufferIds() const {
-  QSet<BufferId> bufferIds = Client::bufferViewOverlay()->bufferIds();
-  bufferIds += Client::bufferViewOverlay()->tempRemovedBufferIds();
-  return bufferIds.toList();
+
+BufferIdList BacklogRequester::allBufferIds() const
+{
+    QSet<BufferId> bufferIds = Client::bufferViewOverlay()->bufferIds();
+    bufferIds += Client::bufferViewOverlay()->tempRemovedBufferIds();
+    return bufferIds.toList();
 }
 
-void BacklogRequester::flushBuffer() {
-  if(!_buffersWaiting.isEmpty()) {
-    qWarning() << Q_FUNC_INFO << "was called before all backlog was received:"
-               << _buffersWaiting.count() << "buffers are waiting.";
-  }
-  _bufferedMessages.clear();
-  _totalBuffers = 0;
-  _buffersWaiting.clear();
+
+void BacklogRequester::flushBuffer()
+{
+    if (!_buffersWaiting.isEmpty()) {
+        qWarning() << Q_FUNC_INFO << "was called before all backlog was received:"
+                   << _buffersWaiting.count() << "buffers are waiting.";
+    }
+    _bufferedMessages.clear();
+    _totalBuffers = 0;
+    _buffersWaiting.clear();
 }
 
+
 // ========================================
 //  FIXED BACKLOG REQUESTER
 // ========================================
 FixedBacklogRequester::FixedBacklogRequester(ClientBacklogManager *backlogManager)
-  : BacklogRequester(true, BacklogRequester::PerBufferFixed, backlogManager)
+    : BacklogRequester(true, BacklogRequester::PerBufferFixed, backlogManager)
 {
-  BacklogSettings backlogSettings;
-  _backlogCount = backlogSettings.fixedBacklogAmount();
+    BacklogSettings backlogSettings;
+    _backlogCount = backlogSettings.fixedBacklogAmount();
 }
 
-void FixedBacklogRequester::requestBacklog(const BufferIdList &bufferIds) {
-  setWaitingBuffers(bufferIds);
-  backlogManager->emitMessagesRequested(QObject::tr("Requesting a total of up to %1 backlog messages for %2 buffers").arg(_backlogCount * bufferIds.count()).arg(bufferIds.count()));
-  foreach(BufferId bufferId, bufferIds) {
-    backlogManager->requestBacklog(bufferId, -1, -1, _backlogCount);
-  }
+
+void FixedBacklogRequester::requestBacklog(const BufferIdList &bufferIds)
+{
+    setWaitingBuffers(bufferIds);
+    backlogManager->emitMessagesRequested(QObject::tr("Requesting a total of up to %1 backlog messages for %2 buffers").arg(_backlogCount * bufferIds.count()).arg(bufferIds.count()));
+    foreach(BufferId bufferId, bufferIds) {
+        backlogManager->requestBacklog(bufferId, -1, -1, _backlogCount);
+    }
 }
 
+
 // ========================================
 //  GLOBAL UNREAD BACKLOG REQUESTER
 // ========================================
 GlobalUnreadBacklogRequester::GlobalUnreadBacklogRequester(ClientBacklogManager *backlogManager)
-  : BacklogRequester(false, BacklogRequester::GlobalUnread, backlogManager)
+    : BacklogRequester(false, BacklogRequester::GlobalUnread, backlogManager)
 {
-  BacklogSettings backlogSettings;
-  _limit = backlogSettings.globalUnreadBacklogLimit();
-  _additional = backlogSettings.globalUnreadBacklogAdditional();
+    BacklogSettings backlogSettings;
+    _limit = backlogSettings.globalUnreadBacklogLimit();
+    _additional = backlogSettings.globalUnreadBacklogAdditional();
 }
 
-void GlobalUnreadBacklogRequester::requestInitialBacklog() {
-  MsgId oldestUnreadMessage;
-  foreach(BufferId bufferId, allBufferIds()) {
-    MsgId msgId = Client::networkModel()->lastSeenMsgId(bufferId);
-    if(!oldestUnreadMessage.isValid() || oldestUnreadMessage > msgId)
-      oldestUnreadMessage = msgId;
-  }
-  backlogManager->emitMessagesRequested(QObject::tr("Requesting up to %1 of all unread backlog messages (plus additional %2)").arg(_limit).arg(_additional));
-  backlogManager->requestBacklogAll(oldestUnreadMessage, -1, _limit, _additional);
+
+void GlobalUnreadBacklogRequester::requestInitialBacklog()
+{
+    MsgId oldestUnreadMessage;
+    foreach(BufferId bufferId, allBufferIds()) {
+        MsgId msgId = Client::networkModel()->lastSeenMsgId(bufferId);
+        if (!oldestUnreadMessage.isValid() || oldestUnreadMessage > msgId)
+            oldestUnreadMessage = msgId;
+    }
+    backlogManager->emitMessagesRequested(QObject::tr("Requesting up to %1 of all unread backlog messages (plus additional %2)").arg(_limit).arg(_additional));
+    backlogManager->requestBacklogAll(oldestUnreadMessage, -1, _limit, _additional);
 }
 
+
 // ========================================
 //  PER BUFFER UNREAD BACKLOG REQUESTER
 // ========================================
 PerBufferUnreadBacklogRequester::PerBufferUnreadBacklogRequester(ClientBacklogManager *backlogManager)
-  : BacklogRequester(true, BacklogRequester::PerBufferUnread, backlogManager)
+    : BacklogRequester(true, BacklogRequester::PerBufferUnread, backlogManager)
 {
-  BacklogSettings backlogSettings;
-  _limit = backlogSettings.perBufferUnreadBacklogLimit();
-  _additional = backlogSettings.perBufferUnreadBacklogAdditional();
+    BacklogSettings backlogSettings;
+    _limit = backlogSettings.perBufferUnreadBacklogLimit();
+    _additional = backlogSettings.perBufferUnreadBacklogAdditional();
 }
 
-void PerBufferUnreadBacklogRequester::requestBacklog(const BufferIdList &bufferIds) {
-  setWaitingBuffers(bufferIds);
-  backlogManager->emitMessagesRequested(QObject::tr("Requesting a total of up to %1 unread backlog messages for %2 buffers").arg((_limit + _additional) * bufferIds.count()).arg(bufferIds.count()));
-  foreach(BufferId bufferId, bufferIds) {
-    backlogManager->requestBacklog(bufferId, Client::networkModel()->lastSeenMsgId(bufferId), -1, _limit, _additional);
-  }
+
+void PerBufferUnreadBacklogRequester::requestBacklog(const BufferIdList &bufferIds)
+{
+    setWaitingBuffers(bufferIds);
+    backlogManager->emitMessagesRequested(QObject::tr("Requesting a total of up to %1 unread backlog messages for %2 buffers").arg((_limit + _additional) * bufferIds.count()).arg(bufferIds.count()));
+    foreach(BufferId bufferId, bufferIds) {
+        backlogManager->requestBacklog(bufferId, Client::networkModel()->lastSeenMsgId(bufferId), -1, _limit, _additional);
+    }
 }
index e813c6c..06d0c2b 100644 (file)
 
 class ClientBacklogManager;
 
-class BacklogRequester {
+class BacklogRequester
+{
 public:
-  enum RequesterType {
-    InvalidRequester = 0,
-    PerBufferFixed,
-    PerBufferUnread,
-    GlobalUnread
-  };
+    enum RequesterType {
+        InvalidRequester = 0,
+        PerBufferFixed,
+        PerBufferUnread,
+        GlobalUnread
+    };
 
-  BacklogRequester(bool buffering, RequesterType requesterType, ClientBacklogManager *backlogManger);
-  virtual inline ~BacklogRequester() {}
+    BacklogRequester(bool buffering, RequesterType requesterType, ClientBacklogManager *backlogManger);
+    virtual inline ~BacklogRequester() {}
 
-  inline bool isBuffering() { return _isBuffering; }
-  inline RequesterType type() { return _requesterType; }
-  inline const QList<Message> &bufferedMessages() { return _bufferedMessages; }
+    inline bool isBuffering() { return _isBuffering; }
+    inline RequesterType type() { return _requesterType; }
+    inline const QList<Message> &bufferedMessages() { return _bufferedMessages; }
 
-  inline int buffersWaiting() const { return _buffersWaiting.count(); }
-  inline int totalBuffers() const { return _totalBuffers; }
+    inline int buffersWaiting() const { return _buffersWaiting.count(); }
+    inline int totalBuffers() const { return _totalBuffers; }
 
-  bool buffer(BufferId bufferId, const MessageList &messages); //! returns false if it was the last missing backlogpart
+    bool buffer(BufferId bufferId, const MessageList &messages); //! returns false if it was the last missing backlogpart
 
-  virtual void requestBacklog(const BufferIdList &bufferIds) = 0;
-  virtual inline void requestInitialBacklog() { requestBacklog(allBufferIds()); }
+    virtual void requestBacklog(const BufferIdList &bufferIds) = 0;
+    virtual inline void requestInitialBacklog() { requestBacklog(allBufferIds()); }
 
-  virtual void flushBuffer();
+    virtual void flushBuffer();
 
 protected:
-  BufferIdList allBufferIds() const;
-  inline void setWaitingBuffers(const QList<BufferId> &buffers) { setWaitingBuffers(buffers.toSet()); }
-  void setWaitingBuffers(const QSet<BufferId> &buffers);
-  void addWaitingBuffer(BufferId buffer);
+    BufferIdList allBufferIds() const;
+    inline void setWaitingBuffers(const QList<BufferId> &buffers) { setWaitingBuffers(buffers.toSet()); }
+    void setWaitingBuffers(const QSet<BufferId> &buffers);
+    void addWaitingBuffer(BufferId buffer);
 
-  ClientBacklogManager *backlogManager;
+    ClientBacklogManager *backlogManager;
 
 private:
-  bool _isBuffering;
-  RequesterType _requesterType;
-  MessageList _bufferedMessages;
-  int _totalBuffers;
-  QSet<BufferId> _buffersWaiting;
+    bool _isBuffering;
+    RequesterType _requesterType;
+    MessageList _bufferedMessages;
+    int _totalBuffers;
+    QSet<BufferId> _buffersWaiting;
 };
 
+
 // ========================================
 //  FIXED BACKLOG REQUESTER
 // ========================================
-class FixedBacklogRequester : public BacklogRequester {
+class FixedBacklogRequester : public BacklogRequester
+{
 public:
-  FixedBacklogRequester(ClientBacklogManager *backlogManager);
-  virtual void requestBacklog(const BufferIdList &bufferIds);
+    FixedBacklogRequester(ClientBacklogManager *backlogManager);
+    virtual void requestBacklog(const BufferIdList &bufferIds);
 
 private:
-  int _backlogCount;
+    int _backlogCount;
 };
 
+
 // ========================================
 //  GLOBAL UNREAD BACKLOG REQUESTER
 // ========================================
-class GlobalUnreadBacklogRequester : public BacklogRequester {
+class GlobalUnreadBacklogRequester : public BacklogRequester
+{
 public:
-  GlobalUnreadBacklogRequester(ClientBacklogManager *backlogManager);
-  virtual void requestInitialBacklog();
-  virtual void requestBacklog(const BufferIdList &) {}
+    GlobalUnreadBacklogRequester(ClientBacklogManager *backlogManager);
+    virtual void requestInitialBacklog();
+    virtual void requestBacklog(const BufferIdList &) {}
 
 private:
-  int _limit;
-  int _additional;
+    int _limit;
+    int _additional;
 };
 
+
 // ========================================
 //  PER BUFFER UNREAD BACKLOG REQUESTER
 // ========================================
-class PerBufferUnreadBacklogRequester : public BacklogRequester {
+class PerBufferUnreadBacklogRequester : public BacklogRequester
+{
 public:
-  PerBufferUnreadBacklogRequester(ClientBacklogManager *backlogManager);
-  virtual void requestBacklog(const BufferIdList &bufferIds);
+    PerBufferUnreadBacklogRequester(ClientBacklogManager *backlogManager);
+    virtual void requestBacklog(const BufferIdList &bufferIds);
 
 private:
-  int _limit;
-  int _additional;
+    int _limit;
+    int _additional;
 };
 
+
 #endif //BACKLOGREQUESTER_H
index 21f946f..7de0eef 100644 (file)
 
 #include "clientsettings.h"
 
-class BacklogSettings : public ClientSettings {
+class BacklogSettings : public ClientSettings
+{
 public:
-  BacklogSettings() : ClientSettings("Backlog") {}
-  inline int requesterType() { return localValue("RequesterType", 1).toInt(); }
-  inline void setRequesterType(int requesterType) { setLocalValue("RequesterType", requesterType); }
+    BacklogSettings() : ClientSettings("Backlog") {}
+    inline int requesterType() { return localValue("RequesterType", 1).toInt(); }
+    inline void setRequesterType(int requesterType) { setLocalValue("RequesterType", requesterType); }
 
-  inline int dynamicBacklogAmount() { return localValue("DynamicBacklogAmount", 200).toInt(); }
-  inline void setDynamicBacklogAmount(int amount) { return setLocalValue("DynamicBacklogAmount", amount); }
+    inline int dynamicBacklogAmount() { return localValue("DynamicBacklogAmount", 200).toInt(); }
+    inline void setDynamicBacklogAmount(int amount) { return setLocalValue("DynamicBacklogAmount", amount); }
 
-  inline int fixedBacklogAmount() { return localValue("FixedBacklogAmount", 500).toInt(); }
-  inline void setFixedBacklogAmount(int amount) { return setLocalValue("FixedBacklogAmount", amount); }
+    inline int fixedBacklogAmount() { return localValue("FixedBacklogAmount", 500).toInt(); }
+    inline void setFixedBacklogAmount(int amount) { return setLocalValue("FixedBacklogAmount", amount); }
 
-  inline int globalUnreadBacklogLimit() { return localValue("GlobalUnreadBacklogLimit", 5000).toInt(); }
-  inline void setGlobalUnreadBacklogLimit(int limit) { return setLocalValue("GlobalUnreadBacklogLimit", limit); }
-  inline int globalUnreadBacklogAdditional() { return localValue("GlobalUnreadBacklogAdditional", 100).toInt(); }
-  inline void setGlobalUnreadBacklogAdditional(int Additional) { return setLocalValue("GlobalUnreadBacklogAdditional", Additional); }
+    inline int globalUnreadBacklogLimit() { return localValue("GlobalUnreadBacklogLimit", 5000).toInt(); }
+    inline void setGlobalUnreadBacklogLimit(int limit) { return setLocalValue("GlobalUnreadBacklogLimit", limit); }
+    inline int globalUnreadBacklogAdditional() { return localValue("GlobalUnreadBacklogAdditional", 100).toInt(); }
+    inline void setGlobalUnreadBacklogAdditional(int Additional) { return setLocalValue("GlobalUnreadBacklogAdditional", Additional); }
 
-  inline int perBufferUnreadBacklogLimit() { return localValue("PerBufferUnreadBacklogLimit", 200).toInt(); }
-  inline void setPerBufferUnreadBacklogLimit(int limit) { return setLocalValue("PerBufferUnreadBacklogLimit", limit); }
-  inline int perBufferUnreadBacklogAdditional() { return localValue("PerBufferUnreadBacklogAdditional", 50).toInt(); }
-  inline void setPerBufferUnreadBacklogAdditional(int Additional) { return setLocalValue("PerBufferUnreadBacklogAdditional", Additional); }
+    inline int perBufferUnreadBacklogLimit() { return localValue("PerBufferUnreadBacklogLimit", 200).toInt(); }
+    inline void setPerBufferUnreadBacklogLimit(int limit) { return setLocalValue("PerBufferUnreadBacklogLimit", limit); }
+    inline int perBufferUnreadBacklogAdditional() { return localValue("PerBufferUnreadBacklogAdditional", 50).toInt(); }
+    inline void setPerBufferUnreadBacklogAdditional(int Additional) { return setLocalValue("PerBufferUnreadBacklogAdditional", Additional); }
 };
 
+
 #endif //BACKLOGSETTINGS_H
index 57441a9..959df8a 100644 (file)
 #include "quassel.h"
 
 BufferModel::BufferModel(NetworkModel *parent)
-  : QSortFilterProxyModel(parent),
+    : QSortFilterProxyModel(parent),
     _selectionModelSynchronizer(this)
 {
-  setSourceModel(parent);
-  if(Quassel::isOptionSet("debugbufferswitches")) {
-    connect(_selectionModelSynchronizer.selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
-           this, SLOT(debug_currentChanged(const QModelIndex &, const QModelIndex &)));
-  }
-  connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(newNetwork(NetworkId)));
-  connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(newBuffers(const QModelIndex &, int, int)));
+    setSourceModel(parent);
+    if (Quassel::isOptionSet("debugbufferswitches")) {
+        connect(_selectionModelSynchronizer.selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
+            this, SLOT(debug_currentChanged(const QModelIndex &, const QModelIndex &)));
+    }
+    connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(newNetwork(NetworkId)));
+    connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(newBuffers(const QModelIndex &, int, int)));
 }
 
-bool BufferModel::filterAcceptsRow(int sourceRow, const QModelIndex &parent) const {
-  Q_UNUSED(sourceRow);
-  // only networks and buffers are allowed
-  if(!parent.isValid())
-    return true;
-  if(parent.data(NetworkModel::ItemTypeRole) == NetworkModel::NetworkItemType)
-    return true;
 
-  return false;
+bool BufferModel::filterAcceptsRow(int sourceRow, const QModelIndex &parent) const
+{
+    Q_UNUSED(sourceRow);
+    // only networks and buffers are allowed
+    if (!parent.isValid())
+        return true;
+    if (parent.data(NetworkModel::ItemTypeRole) == NetworkModel::NetworkItemType)
+        return true;
+
+    return false;
 }
 
-void BufferModel::newNetwork(NetworkId id) {
-  const Network *net = Client::network(id);
-  Q_ASSERT(net);
-  connect(net, SIGNAL(connectionStateSet(Network::ConnectionState)),
-         this, SLOT(networkConnectionChanged(Network::ConnectionState)));
+
+void BufferModel::newNetwork(NetworkId id)
+{
+    const Network *net = Client::network(id);
+    Q_ASSERT(net);
+    connect(net, SIGNAL(connectionStateSet(Network::ConnectionState)),
+        this, SLOT(networkConnectionChanged(Network::ConnectionState)));
 }
 
-void BufferModel::networkConnectionChanged(Network::ConnectionState state) {
-  switch(state) {
-  case Network::Connecting:
-  case Network::Initializing:
-    if(currentIndex().isValid())
-      return;
-    {
-      Network *net = qobject_cast<Network *>(sender());
-      Q_ASSERT(net);
-      setCurrentIndex(mapFromSource(Client::networkModel()->networkIndex(net->networkId())));
+
+void BufferModel::networkConnectionChanged(Network::ConnectionState state)
+{
+    switch (state) {
+    case Network::Connecting:
+    case Network::Initializing:
+        if (currentIndex().isValid())
+            return;
+        {
+            Network *net = qobject_cast<Network *>(sender());
+            Q_ASSERT(net);
+            setCurrentIndex(mapFromSource(Client::networkModel()->networkIndex(net->networkId())));
+        }
+        break;
+    default:
+        return;
     }
-    break;
-  default:
-    return;
-  }
 }
 
-void BufferModel::synchronizeView(QAbstractItemView *view) {
-  _selectionModelSynchronizer.synchronizeSelectionModel(view->selectionModel());
+
+void BufferModel::synchronizeView(QAbstractItemView *view)
+{
+    _selectionModelSynchronizer.synchronizeSelectionModel(view->selectionModel());
 }
 
-void BufferModel::setCurrentIndex(const QModelIndex &newCurrent) {
-  _selectionModelSynchronizer.selectionModel()->setCurrentIndex(newCurrent, QItemSelectionModel::Current);
-  _selectionModelSynchronizer.selectionModel()->select(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+
+void BufferModel::setCurrentIndex(const QModelIndex &newCurrent)
+{
+    _selectionModelSynchronizer.selectionModel()->setCurrentIndex(newCurrent, QItemSelectionModel::Current);
+    _selectionModelSynchronizer.selectionModel()->select(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
 }
 
-void BufferModel::switchToBuffer(const BufferId &bufferId) {
-  QModelIndex source_index = Client::networkModel()->bufferIndex(bufferId);
-  setCurrentIndex(mapFromSource(source_index));
+
+void BufferModel::switchToBuffer(const BufferId &bufferId)
+{
+    QModelIndex source_index = Client::networkModel()->bufferIndex(bufferId);
+    setCurrentIndex(mapFromSource(source_index));
 }
 
-void BufferModel::switchToBufferIndex(const QModelIndex &bufferIdx) {
-  // we accept indexes that directly belong to us or our parent - nothing else
-  if(bufferIdx.model() == this) {
-    setCurrentIndex(bufferIdx);
-    return;
-  }
 
-  if(bufferIdx.model() == sourceModel()) {
-    setCurrentIndex(mapFromSource(bufferIdx));
-    return;
-  }
+void BufferModel::switchToBufferIndex(const QModelIndex &bufferIdx)
+{
+    // we accept indexes that directly belong to us or our parent - nothing else
+    if (bufferIdx.model() == this) {
+        setCurrentIndex(bufferIdx);
+        return;
+    }
 
-  qWarning() << "BufferModel::switchToBufferIndex(const QModelIndex &):" << bufferIdx << "does not belong to BufferModel or NetworkModel";
+    if (bufferIdx.model() == sourceModel()) {
+        setCurrentIndex(mapFromSource(bufferIdx));
+        return;
+    }
+
+    qWarning() << "BufferModel::switchToBufferIndex(const QModelIndex &):" << bufferIdx << "does not belong to BufferModel or NetworkModel";
 }
 
-void BufferModel::switchToOrJoinBuffer(NetworkId networkId, const QString &name, bool isQuery) {
-  BufferId bufId = Client::networkModel()->bufferId(networkId, name);
-  if(bufId.isValid()) {
-    QModelIndex targetIdx = Client::networkModel()->bufferIndex(bufId);
-    switchToBuffer(bufId);
-    if(!targetIdx.data(NetworkModel::ItemActiveRole).toBool()) {
-      qDebug() << "switchToOrJoinBuffer failed to switch even though bufId:" << bufId << "is valid.";
-      Client::userInput(BufferInfo::fakeStatusBuffer(networkId), QString(isQuery ? "/QUERY %1" : "/JOIN %1").arg(name));
+
+void BufferModel::switchToOrJoinBuffer(NetworkId networkId, const QString &name, bool isQuery)
+{
+    BufferId bufId = Client::networkModel()->bufferId(networkId, name);
+    if (bufId.isValid()) {
+        QModelIndex targetIdx = Client::networkModel()->bufferIndex(bufId);
+        switchToBuffer(bufId);
+        if (!targetIdx.data(NetworkModel::ItemActiveRole).toBool()) {
+            qDebug() << "switchToOrJoinBuffer failed to switch even though bufId:" << bufId << "is valid.";
+            Client::userInput(BufferInfo::fakeStatusBuffer(networkId), QString(isQuery ? "/QUERY %1" : "/JOIN %1").arg(name));
+        }
+    }
+    else {
+        _bufferToSwitchTo = qMakePair(networkId, name);
+        Client::userInput(BufferInfo::fakeStatusBuffer(networkId), QString(isQuery ? "/QUERY %1" : "/JOIN %1").arg(name));
     }
-  } else {
-    _bufferToSwitchTo = qMakePair(networkId, name);
-    Client::userInput(BufferInfo::fakeStatusBuffer(networkId), QString(isQuery ? "/QUERY %1" : "/JOIN %1").arg(name));
-  }
 }
 
-void BufferModel::debug_currentChanged(QModelIndex current, QModelIndex previous) {
-  Q_UNUSED(previous);
-  qDebug() << "Switched current Buffer: " << current << current.data().toString() << "Buffer:" << current.data(NetworkModel::BufferIdRole).value<BufferId>();
+
+void BufferModel::debug_currentChanged(QModelIndex current, QModelIndex previous)
+{
+    Q_UNUSED(previous);
+    qDebug() << "Switched current Buffer: " << current << current.data().toString() << "Buffer:" << current.data(NetworkModel::BufferIdRole).value<BufferId>();
 }
 
-void BufferModel::newBuffers(const QModelIndex &parent, int start, int end) {
-  if(parent.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
-    return;
 
-  for(int row = start; row <= end; row++) {
-    QModelIndex child = parent.child(row, 0);
-    newBuffer(child.data(NetworkModel::BufferIdRole).value<BufferId>());
-  }
+void BufferModel::newBuffers(const QModelIndex &parent, int start, int end)
+{
+    if (parent.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
+        return;
+
+    for (int row = start; row <= end; row++) {
+        QModelIndex child = parent.child(row, 0);
+        newBuffer(child.data(NetworkModel::BufferIdRole).value<BufferId>());
+    }
 }
 
-void BufferModel::newBuffer(BufferId bufferId) {
-  BufferInfo bufferInfo = Client::networkModel()->bufferInfo(bufferId);
-  if(_bufferToSwitchTo.first == bufferInfo.networkId()
-      && _bufferToSwitchTo.second == bufferInfo.bufferName()) {
-    _bufferToSwitchTo.first = 0;
-    _bufferToSwitchTo.second.clear();
-    switchToBuffer(bufferId);
-  }
+
+void BufferModel::newBuffer(BufferId bufferId)
+{
+    BufferInfo bufferInfo = Client::networkModel()->bufferInfo(bufferId);
+    if (_bufferToSwitchTo.first == bufferInfo.networkId()
+        && _bufferToSwitchTo.second == bufferInfo.bufferName()) {
+        _bufferToSwitchTo.first = 0;
+        _bufferToSwitchTo.second.clear();
+        switchToBuffer(bufferId);
+    }
 }
 
-void BufferModel::switchToBufferAfterCreation(NetworkId network, const QString &name) {
-  _bufferToSwitchTo = qMakePair(network, name);
+
+void BufferModel::switchToBufferAfterCreation(NetworkId network, const QString &name)
+{
+    _bufferToSwitchTo = qMakePair(network, name);
 }
index d1390c9..8fe780b 100644 (file)
 
 class QAbstractItemView;
 
-class BufferModel : public QSortFilterProxyModel {
-  Q_OBJECT
+class BufferModel : public QSortFilterProxyModel
+{
+    Q_OBJECT
 
 public:
-  BufferModel(NetworkModel *parent = 0);
+    BufferModel(NetworkModel *parent = 0);
 
-  bool filterAcceptsRow(int sourceRow, const QModelIndex &parent) const;
+    bool filterAcceptsRow(int sourceRow, const QModelIndex &parent) const;
 
-  inline const SelectionModelSynchronizer *selectionModelSynchronizer() const { return &_selectionModelSynchronizer; }
-  inline QItemSelectionModel *standardSelectionModel() const { return _selectionModelSynchronizer.selectionModel(); }
+    inline const SelectionModelSynchronizer *selectionModelSynchronizer() const { return &_selectionModelSynchronizer; }
+    inline QItemSelectionModel *standardSelectionModel() const { return _selectionModelSynchronizer.selectionModel(); }
 
-  inline void synchronizeSelectionModel(QItemSelectionModel *selectionModel) { _selectionModelSynchronizer.synchronizeSelectionModel(selectionModel); }
-  void synchronizeView(QAbstractItemView *view);
+    inline void synchronizeSelectionModel(QItemSelectionModel *selectionModel) { _selectionModelSynchronizer.synchronizeSelectionModel(selectionModel); }
+    void synchronizeView(QAbstractItemView *view);
 
-  inline QModelIndex currentIndex() { return standardSelectionModel()->currentIndex(); }
-  inline BufferId currentBuffer() { return currentIndex().data(NetworkModel::BufferIdRole).value<BufferId>(); }
+    inline QModelIndex currentIndex() { return standardSelectionModel()->currentIndex(); }
+    inline BufferId currentBuffer() { return currentIndex().data(NetworkModel::BufferIdRole).value<BufferId>(); }
 
 public slots:
-  void setCurrentIndex(const QModelIndex &newCurrent);
-  void switchToBuffer(const BufferId &bufferId);
-  void switchToBufferIndex(const QModelIndex &bufferIdx);
-  void switchToOrJoinBuffer(NetworkId network, const QString &bufferName, bool isQuery = false);
-  void switchToOrStartQuery(NetworkId network, const QString &nick) {
-    switchToOrJoinBuffer(network, nick, true);
-  }
-  void switchToBufferAfterCreation(NetworkId network, const QString &name);
+    void setCurrentIndex(const QModelIndex &newCurrent);
+    void switchToBuffer(const BufferId &bufferId);
+    void switchToBufferIndex(const QModelIndex &bufferIdx);
+    void switchToOrJoinBuffer(NetworkId network, const QString &bufferName, bool isQuery = false);
+    void switchToOrStartQuery(NetworkId network, const QString &nick)
+    {
+        switchToOrJoinBuffer(network, nick, true);
+    }
+
+
+    void switchToBufferAfterCreation(NetworkId network, const QString &name);
 
 private slots:
-  void debug_currentChanged(QModelIndex current, QModelIndex previous);
-  void newNetwork(NetworkId id);
-  void networkConnectionChanged(Network::ConnectionState state);
-  void newBuffers(const QModelIndex &parent, int start, int end);
+    void debug_currentChanged(QModelIndex current, QModelIndex previous);
+    void newNetwork(NetworkId id);
+    void networkConnectionChanged(Network::ConnectionState state);
+    void newBuffers(const QModelIndex &parent, int start, int end);
 
 private:
-  void newBuffer(BufferId bufferId);
+    void newBuffer(BufferId bufferId);
 
-  SelectionModelSynchronizer _selectionModelSynchronizer;
-  QPair<NetworkId, QString> _bufferToSwitchTo;
+    SelectionModelSynchronizer _selectionModelSynchronizer;
+    QPair<NetworkId, QString> _bufferToSwitchTo;
 };
 
+
 #endif // BUFFERMODEL_H
index aebca0d..f99e52e 100644 (file)
 #include "buffersettings.h"
 
 BufferSettings::BufferSettings(BufferId bufferId)
-  : ClientSettings(QString("Buffer/%1").arg(bufferId.toInt()))
+    : ClientSettings(QString("Buffer/%1").arg(bufferId.toInt()))
 {
 }
 
+
 BufferSettings::BufferSettings(const QString &idString)
-  : ClientSettings(QString("Buffer/%1").arg(idString))
+    : ClientSettings(QString("Buffer/%1").arg(idString))
 {
 }
 
-void BufferSettings::filterMessage(Message::Type msgType, bool filter) {
-  if(!hasFilter())
-    setLocalValue("hasMessageTypeFilter", true);
-  if(filter)
-    setLocalValue("MessageTypeFilter", localValue("MessageTypeFilter", 0).toInt() | msgType);
-  else
-    setLocalValue("MessageTypeFilter", localValue("MessageTypeFilter", 0).toInt() & ~msgType);
+
+void BufferSettings::filterMessage(Message::Type msgType, bool filter)
+{
+    if (!hasFilter())
+        setLocalValue("hasMessageTypeFilter", true);
+    if (filter)
+        setLocalValue("MessageTypeFilter", localValue("MessageTypeFilter", 0).toInt() | msgType);
+    else
+        setLocalValue("MessageTypeFilter", localValue("MessageTypeFilter", 0).toInt() & ~msgType);
 }
 
-void BufferSettings::setMessageFilter(int filter) {
-  if(!hasFilter())
-    setLocalValue("hasMessageTypeFilter", true);
-  setLocalValue("MessageTypeFilter", filter);
+
+void BufferSettings::setMessageFilter(int filter)
+{
+    if (!hasFilter())
+        setLocalValue("hasMessageTypeFilter", true);
+    setLocalValue("MessageTypeFilter", filter);
 }
 
-void BufferSettings::removeFilter() {
-  setLocalValue("hasMessageTypeFilter", false);
-  removeLocalKey("MessageTypeFilter");
+
+void BufferSettings::removeFilter()
+{
+    setLocalValue("hasMessageTypeFilter", false);
+    removeLocalKey("MessageTypeFilter");
 }
index 546406a..1766d0d 100644 (file)
 #include "message.h"
 #include "types.h"
 
-class BufferSettings : public ClientSettings {
+class BufferSettings : public ClientSettings
+{
 public:
-  enum RedirectTarget {
-    DefaultBuffer = 0x01,
-    StatusBuffer  = 0x02,
-    CurrentBuffer = 0x04
-  };
+    enum RedirectTarget {
+        DefaultBuffer = 0x01,
+        StatusBuffer  = 0x02,
+        CurrentBuffer = 0x04
+    };
 
-  BufferSettings(const QString &idString = "__default__");
-  BufferSettings(BufferId bufferId);
+    BufferSettings(const QString &idString = "__default__");
+    BufferSettings(BufferId bufferId);
 
-  inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
-  inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
+    inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
+    inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
 
-  // Message Filter (default and per view)
-  inline bool hasFilter() { return localValue("hasMessageTypeFilter", false).toBool(); }
-  inline int messageFilter() { return localValue("MessageTypeFilter", 0).toInt(); }
-  void setMessageFilter(int filter);
-  void filterMessage(Message::Type msgType, bool filter);
-  void removeFilter();
+    // Message Filter (default and per view)
+    inline bool hasFilter() { return localValue("hasMessageTypeFilter", false).toBool(); }
+    inline int messageFilter() { return localValue("MessageTypeFilter", 0).toInt(); }
+    void setMessageFilter(int filter);
+    void filterMessage(Message::Type msgType, bool filter);
+    void removeFilter();
 
-  // user state icons for query buffers (default)
-  inline bool showUserStateIcons() { return localValue("ShowUserStateIcons", true).toBool(); }
-  inline void enableUserStateIcons(bool enabled) { setLocalValue("ShowUserStateIcons", enabled); }
+    // user state icons for query buffers (default)
+    inline bool showUserStateIcons() { return localValue("ShowUserStateIcons", true).toBool(); }
+    inline void enableUserStateIcons(bool enabled) { setLocalValue("ShowUserStateIcons", enabled); }
 
-
-  // redirection settings (default)
-  inline int userNoticesTarget() { return localValue("UserNoticesTarget", DefaultBuffer | CurrentBuffer).toInt(); }
-  inline void setUserNoticesTarget(int target) { setLocalValue("UserNoticesTarget", target); }
-  inline int serverNoticesTarget() { return localValue("ServerNoticesTarget", StatusBuffer).toInt(); }
-  inline void setServerNoticesTarget(int target) { setLocalValue("ServerNoticesTarget", target); }
-  inline int errorMsgsTarget() { return localValue("ErrorMsgsTarget", DefaultBuffer).toInt(); }
-  inline void setErrorMsgsTarget(int target) { setLocalValue("ErrorMsgsTarget", target); }
+    // redirection settings (default)
+    inline int userNoticesTarget() { return localValue("UserNoticesTarget", DefaultBuffer | CurrentBuffer).toInt(); }
+    inline void setUserNoticesTarget(int target) { setLocalValue("UserNoticesTarget", target); }
+    inline int serverNoticesTarget() { return localValue("ServerNoticesTarget", StatusBuffer).toInt(); }
+    inline void setServerNoticesTarget(int target) { setLocalValue("ServerNoticesTarget", target); }
+    inline int errorMsgsTarget() { return localValue("ErrorMsgsTarget", DefaultBuffer).toInt(); }
+    inline void setErrorMsgsTarget(int target) { setLocalValue("ErrorMsgsTarget", target); }
 };
 
 
index ee5fab0..3cf5877 100644 (file)
@@ -31,7 +31,7 @@
 const int BufferViewOverlay::_updateEventId = QEvent::registerEventType();
 
 BufferViewOverlay::BufferViewOverlay(QObject *parent)
-  : QObject(parent),
+    : QObject(parent),
     _aboutToUpdate(false),
     _uninitializedViewCount(0),
     _allowedBufferTypes(0),
@@ -39,264 +39,300 @@ BufferViewOverlay::BufferViewOverlay(QObject *parent)
 {
 }
 
-void BufferViewOverlay::reset() {
-  _aboutToUpdate = false;
 
-  _bufferViewIds.clear();
-  _uninitializedViewCount = 0;
+void BufferViewOverlay::reset()
+{
+    _aboutToUpdate = false;
 
-  _networkIds.clear();
-  _allowedBufferTypes = 0;
-  _minimumActivity = 0;
+    _bufferViewIds.clear();
+    _uninitializedViewCount = 0;
 
-  _buffers.clear();
-  _removedBuffers.clear();
-  _tempRemovedBuffers.clear();
-}
+    _networkIds.clear();
+    _allowedBufferTypes = 0;
+    _minimumActivity = 0;
 
-void BufferViewOverlay::save() {
-  CoreAccountSettings().setBufferViewOverlay(_bufferViewIds);
+    _buffers.clear();
+    _removedBuffers.clear();
+    _tempRemovedBuffers.clear();
 }
 
-void BufferViewOverlay::restore() {
-  QSet<int> currentIds = _bufferViewIds;
-  reset();
-  currentIds += CoreAccountSettings().bufferViewOverlay();
 
-  QSet<int>::const_iterator iter;
-  for(iter = currentIds.constBegin(); iter != currentIds.constEnd(); iter++) {
-    addView(*iter);
-  }
+void BufferViewOverlay::save()
+{
+    CoreAccountSettings().setBufferViewOverlay(_bufferViewIds);
 }
 
-void BufferViewOverlay::addView(int viewId) {
-  if(_bufferViewIds.contains(viewId))
-    return;
 
-  BufferViewConfig *config = Client::bufferViewManager()->bufferViewConfig(viewId);
-  if(!config) {
-    qDebug() << "BufferViewOverlay::addView(): no such buffer view:" << viewId;
-    return;
-  }
+void BufferViewOverlay::restore()
+{
+    QSet<int> currentIds = _bufferViewIds;
+    reset();
+    currentIds += CoreAccountSettings().bufferViewOverlay();
 
-  _bufferViewIds << viewId;
-  bool wasInitialized = isInitialized();
-  _uninitializedViewCount++;
+    QSet<int>::const_iterator iter;
+    for (iter = currentIds.constBegin(); iter != currentIds.constEnd(); iter++) {
+        addView(*iter);
+    }
+}
 
-  if(config->isInitialized()) {
-    viewInitialized(config);
 
-    if(wasInitialized) {
-      BufferIdList buffers;
-      if(config->networkId().isValid()) {
-        foreach(BufferId bufferId, config->bufferList()) {
-          if(Client::networkModel()->networkId(bufferId) == config->networkId())
-            buffers << bufferId;
-        }
-        foreach(BufferId bufferId, config->temporarilyRemovedBuffers().toList()) {
-          if(Client::networkModel()->networkId(bufferId) == config->networkId())
-            buffers << bufferId;
-        }
-      } else {
-        buffers = BufferIdList::fromSet(config->bufferList().toSet() + config->temporarilyRemovedBuffers());
-      }
-      Client::backlogManager()->checkForBacklog(buffers);
+void BufferViewOverlay::addView(int viewId)
+{
+    if (_bufferViewIds.contains(viewId))
+        return;
+
+    BufferViewConfig *config = Client::bufferViewManager()->bufferViewConfig(viewId);
+    if (!config) {
+        qDebug() << "BufferViewOverlay::addView(): no such buffer view:" << viewId;
+        return;
     }
 
-  } else {
-    disconnect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()));
-    // we use a queued connection here since manipulating the connection list of a sending object
-    // doesn't seem to be such a good idea while executing a connected slots.
-    connect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()), Qt::QueuedConnection);
-  }
-  save();
+    _bufferViewIds << viewId;
+    bool wasInitialized = isInitialized();
+    _uninitializedViewCount++;
+
+    if (config->isInitialized()) {
+        viewInitialized(config);
+
+        if (wasInitialized) {
+            BufferIdList buffers;
+            if (config->networkId().isValid()) {
+                foreach(BufferId bufferId, config->bufferList()) {
+                    if (Client::networkModel()->networkId(bufferId) == config->networkId())
+                        buffers << bufferId;
+                }
+                foreach(BufferId bufferId, config->temporarilyRemovedBuffers().toList()) {
+                    if (Client::networkModel()->networkId(bufferId) == config->networkId())
+                        buffers << bufferId;
+                }
+            }
+            else {
+                buffers = BufferIdList::fromSet(config->bufferList().toSet() + config->temporarilyRemovedBuffers());
+            }
+            Client::backlogManager()->checkForBacklog(buffers);
+        }
+    }
+    else {
+        disconnect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()));
+        // we use a queued connection here since manipulating the connection list of a sending object
+        // doesn't seem to be such a good idea while executing a connected slots.
+        connect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()), Qt::QueuedConnection);
+    }
+    save();
 }
 
-void BufferViewOverlay::removeView(int viewId) {
-  if(!_bufferViewIds.contains(viewId))
-    return;
-
-  _bufferViewIds.remove(viewId);
-  BufferViewConfig *config = Client::bufferViewManager()->bufferViewConfig(viewId);
-  if(config)
-    disconnect(config, 0, this, 0);
-
-  // update initialized State:
-  bool wasInitialized = isInitialized();
-  _uninitializedViewCount = 0;
-  QSet<int>::iterator viewIter = _bufferViewIds.begin();
-  while(viewIter != _bufferViewIds.end()) {
-    config = Client::bufferViewManager()->bufferViewConfig(*viewIter);
-    if(!config) {
-      viewIter = _bufferViewIds.erase(viewIter);
-    } else {
-      if(!config->isInitialized())
-        _uninitializedViewCount++;
-      viewIter++;
+
+void BufferViewOverlay::removeView(int viewId)
+{
+    if (!_bufferViewIds.contains(viewId))
+        return;
+
+    _bufferViewIds.remove(viewId);
+    BufferViewConfig *config = Client::bufferViewManager()->bufferViewConfig(viewId);
+    if (config)
+        disconnect(config, 0, this, 0);
+
+    // update initialized State:
+    bool wasInitialized = isInitialized();
+    _uninitializedViewCount = 0;
+    QSet<int>::iterator viewIter = _bufferViewIds.begin();
+    while (viewIter != _bufferViewIds.end()) {
+        config = Client::bufferViewManager()->bufferViewConfig(*viewIter);
+        if (!config) {
+            viewIter = _bufferViewIds.erase(viewIter);
+        }
+        else {
+            if (!config->isInitialized())
+                _uninitializedViewCount++;
+            viewIter++;
+        }
     }
-  }
 
-  update();
-  if(!wasInitialized && isInitialized())
-    emit initDone();
-  save();
+    update();
+    if (!wasInitialized && isInitialized())
+        emit initDone();
+    save();
 }
 
-void BufferViewOverlay::viewInitialized(BufferViewConfig *config) {
-  if(!config) {
-    qWarning() << "BufferViewOverlay::viewInitialized() received invalid view!";
-    return;
-  }
-  disconnect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()));
 
-  connect(config, SIGNAL(configChanged()), this, SLOT(update()));
+void BufferViewOverlay::viewInitialized(BufferViewConfig *config)
+{
+    if (!config) {
+        qWarning() << "BufferViewOverlay::viewInitialized() received invalid view!";
+        return;
+    }
+    disconnect(config, SIGNAL(initDone()), this, SLOT(viewInitialized()));
 
-  // check if the view was removed in the meantime...
-  if(_bufferViewIds.contains(config->bufferViewId()))
-    update();
+    connect(config, SIGNAL(configChanged()), this, SLOT(update()));
+
+    // check if the view was removed in the meantime...
+    if (_bufferViewIds.contains(config->bufferViewId()))
+        update();
 
-  _uninitializedViewCount--;
-  if(isInitialized())
-    emit initDone();
+    _uninitializedViewCount--;
+    if (isInitialized())
+        emit initDone();
 }
 
-void BufferViewOverlay::viewInitialized() {
-  BufferViewConfig *config = qobject_cast<BufferViewConfig *>(sender());
-  Q_ASSERT(config);
 
-  viewInitialized(config);
-}
+void BufferViewOverlay::viewInitialized()
+{
+    BufferViewConfig *config = qobject_cast<BufferViewConfig *>(sender());
+    Q_ASSERT(config);
 
-void BufferViewOverlay::update() {
-  if(_aboutToUpdate) {
-    return;
-  }
-  _aboutToUpdate = true;
-  QCoreApplication::postEvent(this, new QEvent((QEvent::Type)_updateEventId));
+    viewInitialized(config);
 }
 
-void BufferViewOverlay::updateHelper() {
-  if(!_aboutToUpdate)
-    return;
 
-  bool changed = false;
+void BufferViewOverlay::update()
+{
+    if (_aboutToUpdate) {
+        return;
+    }
+    _aboutToUpdate = true;
+    QCoreApplication::postEvent(this, new QEvent((QEvent::Type)_updateEventId));
+}
 
-  int allowedBufferTypes = 0;
-  int minimumActivity = -1;
-  QSet<NetworkId> networkIds;
-  QSet<BufferId> buffers;
-  QSet<BufferId> removedBuffers;
-  QSet<BufferId> tempRemovedBuffers;
 
-  if(Client::bufferViewManager()) {
-    BufferViewConfig *config = 0;
-    QSet<int>::const_iterator viewIter;
-    for(viewIter = _bufferViewIds.constBegin(); viewIter != _bufferViewIds.constEnd(); viewIter++) {
-      config = Client::bufferViewManager()->bufferViewConfig(*viewIter);
-      if(!config)
-        continue;
+void BufferViewOverlay::updateHelper()
+{
+    if (!_aboutToUpdate)
+        return;
+
+    bool changed = false;
+
+    int allowedBufferTypes = 0;
+    int minimumActivity = -1;
+    QSet<NetworkId> networkIds;
+    QSet<BufferId> buffers;
+    QSet<BufferId> removedBuffers;
+    QSet<BufferId> tempRemovedBuffers;
+
+    if (Client::bufferViewManager()) {
+        BufferViewConfig *config = 0;
+        QSet<int>::const_iterator viewIter;
+        for (viewIter = _bufferViewIds.constBegin(); viewIter != _bufferViewIds.constEnd(); viewIter++) {
+            config = Client::bufferViewManager()->bufferViewConfig(*viewIter);
+            if (!config)
+                continue;
+
+            allowedBufferTypes |= config->allowedBufferTypes();
+            if (minimumActivity == -1 || config->minimumActivity() < minimumActivity)
+                minimumActivity = config->minimumActivity();
+
+            networkIds << config->networkId();
+
+            // we have to apply several filters before we can add a buffer to a category (visible, removed, ...)
+            buffers += filterBuffersByConfig(config->bufferList(), config);
+            tempRemovedBuffers += filterBuffersByConfig(config->temporarilyRemovedBuffers().toList(), config);
+            removedBuffers += config->removedBuffers();
+        }
 
-      allowedBufferTypes |= config->allowedBufferTypes();
-      if(minimumActivity == -1 || config->minimumActivity() < minimumActivity)
-        minimumActivity = config->minimumActivity();
+        // prune the sets from overlap
+        QSet<BufferId> availableBuffers = Client::networkModel()->allBufferIds().toSet();
 
-      networkIds << config->networkId();
+        buffers.intersect(availableBuffers);
 
+        tempRemovedBuffers.intersect(availableBuffers);
+        tempRemovedBuffers.subtract(buffers);
 
-      // we have to apply several filters before we can add a buffer to a category (visible, removed, ...)
-      buffers += filterBuffersByConfig(config->bufferList(), config);
-      tempRemovedBuffers += filterBuffersByConfig(config->temporarilyRemovedBuffers().toList(), config);
-      removedBuffers += config->removedBuffers();
+        removedBuffers.intersect(availableBuffers);
+        removedBuffers.subtract(tempRemovedBuffers);
+        removedBuffers.subtract(buffers);
     }
 
-    // prune the sets from overlap
-    QSet<BufferId> availableBuffers = Client::networkModel()->allBufferIds().toSet();
-
-    buffers.intersect(availableBuffers);
+    changed |= (allowedBufferTypes != _allowedBufferTypes);
+    changed |= (minimumActivity != _minimumActivity);
+    changed |= (networkIds != _networkIds);
+    changed |= (buffers != _buffers);
+    changed |= (removedBuffers != _removedBuffers);
+    changed |= (tempRemovedBuffers != _tempRemovedBuffers);
 
-    tempRemovedBuffers.intersect(availableBuffers);
-    tempRemovedBuffers.subtract(buffers);
+    _allowedBufferTypes = allowedBufferTypes;
+    _minimumActivity = minimumActivity;
+    _networkIds = networkIds;
+    _buffers = buffers;
+    _removedBuffers = removedBuffers;
+    _tempRemovedBuffers = tempRemovedBuffers;
 
-    removedBuffers.intersect(availableBuffers);
-    removedBuffers.subtract(tempRemovedBuffers);
-    removedBuffers.subtract(buffers);
-  }
+    _aboutToUpdate = false;
 
-  changed |= (allowedBufferTypes != _allowedBufferTypes);
-  changed |= (minimumActivity != _minimumActivity);
-  changed |= (networkIds != _networkIds);
-  changed |= (buffers != _buffers);
-  changed |= (removedBuffers != _removedBuffers);
-  changed |= (tempRemovedBuffers != _tempRemovedBuffers);
+    if (changed)
+        emit hasChanged();
+}
 
-  _allowedBufferTypes = allowedBufferTypes;
-  _minimumActivity = minimumActivity;
-  _networkIds = networkIds;
-  _buffers = buffers;
-  _removedBuffers = removedBuffers;
-  _tempRemovedBuffers = tempRemovedBuffers;
 
-  _aboutToUpdate = false;
+QSet<BufferId> BufferViewOverlay::filterBuffersByConfig(const QList<BufferId> &buffers, const BufferViewConfig *config)
+{
+    Q_ASSERT(config);
+
+    QSet<BufferId> bufferIds;
+    BufferInfo bufferInfo;
+    foreach(BufferId bufferId, buffers) {
+        bufferInfo = Client::networkModel()->bufferInfo(bufferId);
+        if (!(bufferInfo.type() & config->allowedBufferTypes()))
+            continue;
+        if (config->networkId().isValid() && bufferInfo.networkId() != config->networkId())
+            continue;
+        bufferIds << bufferId;
+    }
 
-  if(changed)
-    emit hasChanged();
+    return bufferIds;
 }
 
-QSet<BufferId> BufferViewOverlay::filterBuffersByConfig(const QList<BufferId> &buffers, const BufferViewConfig *config) {
-  Q_ASSERT(config);
-
-  QSet<BufferId> bufferIds;
-  BufferInfo bufferInfo;
-  foreach(BufferId bufferId, buffers) {
-    bufferInfo = Client::networkModel()->bufferInfo(bufferId);
-    if(!(bufferInfo.type() & config->allowedBufferTypes()))
-      continue;
-    if(config->networkId().isValid() && bufferInfo.networkId() != config->networkId())
-      continue;
-    bufferIds << bufferId;
-  }
-
-  return bufferIds;
+
+void BufferViewOverlay::customEvent(QEvent *event)
+{
+    if (event->type() == _updateEventId) {
+        updateHelper();
+    }
 }
 
 
-void BufferViewOverlay::customEvent(QEvent *event) {
-  if(event->type() == _updateEventId) {
+bool BufferViewOverlay::allNetworks()
+{
     updateHelper();
-  }
+    return _networkIds.contains(NetworkId());
 }
 
-bool BufferViewOverlay::allNetworks() {
-  updateHelper();
-  return _networkIds.contains(NetworkId());
-}
 
-const QSet<NetworkId> &BufferViewOverlay::networkIds() {
-  updateHelper();
-  return _networkIds;
+const QSet<NetworkId> &BufferViewOverlay::networkIds()
+{
+    updateHelper();
+    return _networkIds;
 }
 
-const QSet<BufferId> &BufferViewOverlay::bufferIds() {
-  updateHelper();
-  return _buffers;
+
+const QSet<BufferId> &BufferViewOverlay::bufferIds()
+{
+    updateHelper();
+    return _buffers;
 }
 
-const QSet<BufferId> &BufferViewOverlay::removedBufferIds() {
-  updateHelper();
-  return _removedBuffers;
+
+const QSet<BufferId> &BufferViewOverlay::removedBufferIds()
+{
+    updateHelper();
+    return _removedBuffers;
 }
 
-const QSet<BufferId> &BufferViewOverlay::tempRemovedBufferIds() {
-  updateHelper();
-  return _tempRemovedBuffers;
+
+const QSet<BufferId> &BufferViewOverlay::tempRemovedBufferIds()
+{
+    updateHelper();
+    return _tempRemovedBuffers;
 }
 
-int BufferViewOverlay::allowedBufferTypes() {
-  updateHelper();
-  return _allowedBufferTypes;
+
+int BufferViewOverlay::allowedBufferTypes()
+{
+    updateHelper();
+    return _allowedBufferTypes;
 }
 
-int BufferViewOverlay::minimumActivity() {
-  updateHelper();
-  return _minimumActivity;
+
+int BufferViewOverlay::minimumActivity()
+{
+    updateHelper();
+    return _minimumActivity;
 }
index 313a2e3..1b85216 100644 (file)
 class BufferViewConfig;
 class ClientBufferViewConfig;
 
-class BufferViewOverlay : public QObject {
-  Q_OBJECT
+class BufferViewOverlay : public QObject
+{
+    Q_OBJECT
 
 public:
-  BufferViewOverlay(QObject *parent = 0);
+    BufferViewOverlay(QObject *parent = 0);
 
-  inline const QSet<int> &bufferViewIds() { return _bufferViewIds; }
-  bool allNetworks();
+    inline const QSet<int> &bufferViewIds() { return _bufferViewIds; }
+    bool allNetworks();
 
-  const QSet<NetworkId> &networkIds();
-  const QSet<BufferId> &bufferIds();
-  const QSet<BufferId> &removedBufferIds();
-  const QSet<BufferId> &tempRemovedBufferIds();
+    const QSet<NetworkId> &networkIds();
+    const QSet<BufferId> &bufferIds();
+    const QSet<BufferId> &removedBufferIds();
+    const QSet<BufferId> &tempRemovedBufferIds();
 
-  int allowedBufferTypes();
-  int minimumActivity();
+    int allowedBufferTypes();
+    int minimumActivity();
 
-  inline bool isInitialized() { return _uninitializedViewCount == 0; }
+    inline bool isInitialized() { return _uninitializedViewCount == 0; }
 
 public slots:
-  void addView(int viewId);
-  void removeView(int viewId);
+    void addView(int viewId);
+    void removeView(int viewId);
 
-  void reset();
-  void save();
-  void restore();
+    void reset();
+    void save();
+    void restore();
 
-  // updates propagated from the actual views
-  void update();
+    // updates propagated from the actual views
+    void update();
 
 signals:
-  void hasChanged();
-  void initDone();
+    void hasChanged();
+    void initDone();
 
 protected:
-  virtual void customEvent(QEvent *event);
+    virtual void customEvent(QEvent *event);
 
 private slots:
-  void viewInitialized();
-  void viewInitialized(BufferViewConfig *config);
+    void viewInitialized();
+    void viewInitialized(BufferViewConfig *config);
 
 private:
-  void updateHelper();
-  QSet<BufferId> filterBuffersByConfig(const QList<BufferId> &buffers, const BufferViewConfig *config);
+    void updateHelper();
+    QSet<BufferId> filterBuffersByConfig(const QList<BufferId> &buffers, const BufferViewConfig *config);
 
-  bool _aboutToUpdate;
+    bool _aboutToUpdate;
 
-  QSet<int> _bufferViewIds;
-  int _uninitializedViewCount;
+    QSet<int> _bufferViewIds;
+    int _uninitializedViewCount;
 
-  QSet<NetworkId> _networkIds;
-  int _allowedBufferTypes;
-  int _minimumActivity;
+    QSet<NetworkId> _networkIds;
+    int _allowedBufferTypes;
+    int _minimumActivity;
 
-  QSet<BufferId> _buffers;
-  QSet<BufferId> _removedBuffers;
-  QSet<BufferId> _tempRemovedBuffers;
+    QSet<BufferId> _buffers;
+    QSet<BufferId> _removedBuffers;
+    QSet<BufferId> _tempRemovedBuffers;
 
-  static const int _updateEventId;
+    static const int _updateEventId;
 };
 
+
 #endif //BUFFERVIEWOVERLAY_H
index 21beda0..e1a7a05 100644 (file)
@@ -58,30 +58,37 @@ Quassel::Features Client::_coreFeatures = 0;
 
 bool Client::instanceExists()
 {
-  return instanceptr;
+    return instanceptr;
 }
 
-Client *Client::instance() {
-  if(!instanceptr)
-    instanceptr = new Client();
-  return instanceptr;
+
+Client *Client::instance()
+{
+    if (!instanceptr)
+        instanceptr = new Client();
+    return instanceptr;
 }
 
-void Client::destroy() {
-  if(instanceptr) {
-    delete instanceptr->mainUi();
-    instanceptr->deleteLater();
-    instanceptr = 0;
-  }
+
+void Client::destroy()
+{
+    if (instanceptr) {
+        delete instanceptr->mainUi();
+        instanceptr->deleteLater();
+        instanceptr = 0;
+    }
 }
 
-void Client::init(AbstractUi *ui) {
-  instance()->_mainUi = ui;
-  instance()->init();
+
+void Client::init(AbstractUi *ui)
+{
+    instance()->_mainUi = ui;
+    instance()->init();
 }
 
+
 Client::Client(QObject *parent)
-  : QObject(parent),
+    : QObject(parent),
     _signalProxy(new SignalProxy(SignalProxy::Client, this)),
     _mainUi(0),
     _networkModel(0),
@@ -102,458 +109,547 @@ Client::Client(QObject *parent)
     _connected(false),
     _debugLog(&_debugLogBuffer)
 {
-  _signalProxy->synchronize(_ircListHelper);
+    _signalProxy->synchronize(_ircListHelper);
 }
 
-Client::~Client() {
-  disconnectFromCore();
+
+Client::~Client()
+{
+    disconnectFromCore();
 }
 
-void Client::init() {
-  _networkModel = new NetworkModel(this);
 
-  connect(this, SIGNAL(networkRemoved(NetworkId)),
-          _networkModel, SLOT(networkRemoved(NetworkId)));
+void Client::init()
+{
+    _networkModel = new NetworkModel(this);
+
+    connect(this, SIGNAL(networkRemoved(NetworkId)),
+        _networkModel, SLOT(networkRemoved(NetworkId)));
 
-  _bufferModel = new BufferModel(_networkModel);
-  _messageModel = mainUi()->createMessageModel(this);
-  _messageProcessor = mainUi()->createMessageProcessor(this);
-  _inputHandler = new ClientUserInputHandler(this);
+    _bufferModel = new BufferModel(_networkModel);
+    _messageModel = mainUi()->createMessageModel(this);
+    _messageProcessor = mainUi()->createMessageProcessor(this);
+    _inputHandler = new ClientUserInputHandler(this);
 
-  SignalProxy *p = signalProxy();
+    SignalProxy *p = signalProxy();
 
-  p->attachSlot(SIGNAL(displayMsg(const Message &)), this, SLOT(recvMessage(const Message &)));
-  p->attachSlot(SIGNAL(displayStatusMsg(QString, QString)), this, SLOT(recvStatusMsg(QString, QString)));
+    p->attachSlot(SIGNAL(displayMsg(const Message &)), this, SLOT(recvMessage(const Message &)));
+    p->attachSlot(SIGNAL(displayStatusMsg(QString, QString)), this, SLOT(recvStatusMsg(QString, QString)));
 
-  p->attachSlot(SIGNAL(bufferInfoUpdated(BufferInfo)), _networkModel, SLOT(bufferUpdated(BufferInfo)));
-  p->attachSignal(inputHandler(), SIGNAL(sendInput(BufferInfo, QString)));
-  p->attachSignal(this, SIGNAL(requestNetworkStates()));
+    p->attachSlot(SIGNAL(bufferInfoUpdated(BufferInfo)), _networkModel, SLOT(bufferUpdated(BufferInfo)));
+    p->attachSignal(inputHandler(), SIGNAL(sendInput(BufferInfo, QString)));
+    p->attachSignal(this, SIGNAL(requestNetworkStates()));
 
-  p->attachSignal(this, SIGNAL(requestCreateIdentity(const Identity &, const QVariantMap &)), SIGNAL(createIdentity(const Identity &, const QVariantMap &)));
-  p->attachSignal(this, SIGNAL(requestRemoveIdentity(IdentityId)), SIGNAL(removeIdentity(IdentityId)));
-  p->attachSlot(SIGNAL(identityCreated(const Identity &)), this, SLOT(coreIdentityCreated(const Identity &)));
-  p->attachSlot(SIGNAL(identityRemoved(IdentityId)), this, SLOT(coreIdentityRemoved(IdentityId)));
+    p->attachSignal(this, SIGNAL(requestCreateIdentity(const Identity &, const QVariantMap &)), SIGNAL(createIdentity(const Identity &, const QVariantMap &)));
+    p->attachSignal(this, SIGNAL(requestRemoveIdentity(IdentityId)), SIGNAL(removeIdentity(IdentityId)));
+    p->attachSlot(SIGNAL(identityCreated(const Identity &)), this, SLOT(coreIdentityCreated(const Identity &)));
+    p->attachSlot(SIGNAL(identityRemoved(IdentityId)), this, SLOT(coreIdentityRemoved(IdentityId)));
 
-  p->attachSignal(this, SIGNAL(requestCreateNetwork(const NetworkInfo &, const QStringList &)), SIGNAL(createNetwork(const NetworkInfo &, const QStringList &)));
-  p->attachSignal(this, SIGNAL(requestRemoveNetwork(NetworkId)), SIGNAL(removeNetwork(NetworkId)));
-  p->attachSlot(SIGNAL(networkCreated(NetworkId)), this, SLOT(coreNetworkCreated(NetworkId)));
-  p->attachSlot(SIGNAL(networkRemoved(NetworkId)), this, SLOT(coreNetworkRemoved(NetworkId)));
+    p->attachSignal(this, SIGNAL(requestCreateNetwork(const NetworkInfo &, const QStringList &)), SIGNAL(createNetwork(const NetworkInfo &, const QStringList &)));
+    p->attachSignal(this, SIGNAL(requestRemoveNetwork(NetworkId)), SIGNAL(removeNetwork(NetworkId)));
+    p->attachSlot(SIGNAL(networkCreated(NetworkId)), this, SLOT(coreNetworkCreated(NetworkId)));
+    p->attachSlot(SIGNAL(networkRemoved(NetworkId)), this, SLOT(coreNetworkRemoved(NetworkId)));
 
-  //connect(mainUi(), SIGNAL(connectToCore(const QVariantMap &)), this, SLOT(connectToCore(const QVariantMap &)));
-  connect(mainUi(), SIGNAL(disconnectFromCore()), this, SLOT(disconnectFromCore()));
-  connect(this, SIGNAL(connected()), mainUi(), SLOT(connectedToCore()));
-  connect(this, SIGNAL(disconnected()), mainUi(), SLOT(disconnectedFromCore()));
+    //connect(mainUi(), SIGNAL(connectToCore(const QVariantMap &)), this, SLOT(connectToCore(const QVariantMap &)));
+    connect(mainUi(), SIGNAL(disconnectFromCore()), this, SLOT(disconnectFromCore()));
+    connect(this, SIGNAL(connected()), mainUi(), SLOT(connectedToCore()));
+    connect(this, SIGNAL(disconnected()), mainUi(), SLOT(disconnectedFromCore()));
 
-  // attach backlog manager
-  p->synchronize(backlogManager());
-  connect(backlogManager(), SIGNAL(messagesReceived(BufferId, int)), _messageModel, SLOT(messagesReceived(BufferId, int)));
+    // attach backlog manager
+    p->synchronize(backlogManager());
+    connect(backlogManager(), SIGNAL(messagesReceived(BufferId, int)), _messageModel, SLOT(messagesReceived(BufferId, int)));
 
-  coreAccountModel()->load();
+    coreAccountModel()->load();
 
-  connect(coreConnection(), SIGNAL(stateChanged(CoreConnection::ConnectionState)), SLOT(connectionStateChanged(CoreConnection::ConnectionState)));
-  coreConnection()->init();
+    connect(coreConnection(), SIGNAL(stateChanged(CoreConnection::ConnectionState)), SLOT(connectionStateChanged(CoreConnection::ConnectionState)));
+    coreConnection()->init();
 }
 
+
 /*** public static methods ***/
 
-AbstractUi *Client::mainUi() {
-  return instance()->_mainUi;
+AbstractUi *Client::mainUi()
+{
+    return instance()->_mainUi;
 }
 
-void Client::setCoreFeatures(Quassel::Features features) {
-  _coreFeatures = features;
+
+void Client::setCoreFeatures(Quassel::Features features)
+{
+    _coreFeatures = features;
 }
 
-bool Client::isConnected() {
-  return instance()->_connected;
+
+bool Client::isConnected()
+{
+    return instance()->_connected;
 }
 
-bool Client::internalCore() {
-  return currentCoreAccount().isInternal();
+
+bool Client::internalCore()
+{
+    return currentCoreAccount().isInternal();
 }
 
+
 /*** Network handling ***/
 
-QList<NetworkId> Client::networkIds() {
-  return instance()->_networks.keys();
+QList<NetworkId> Client::networkIds()
+{
+    return instance()->_networks.keys();
 }
 
-const Network * Client::network(NetworkId networkid) {
-  if(instance()->_networks.contains(networkid)) return instance()->_networks[networkid];
-  else return 0;
+
+const Network *Client::network(NetworkId networkid)
+{
+    if (instance()->_networks.contains(networkid)) return instance()->_networks[networkid];
+    else return 0;
 }
 
-void Client::createNetwork(const NetworkInfo &info, const QStringList &persistentChannels) {
-  emit instance()->requestCreateNetwork(info, persistentChannels);
+
+void Client::createNetwork(const NetworkInfo &info, const QStringList &persistentChannels)
+{
+    emit instance()->requestCreateNetwork(info, persistentChannels);
 }
 
-void Client::removeNetwork(NetworkId id) {
-  emit instance()->requestRemoveNetwork(id);
+
+void Client::removeNetwork(NetworkId id)
+{
+    emit instance()->requestRemoveNetwork(id);
 }
 
-void Client::updateNetwork(const NetworkInfo &info) {
-  Network *netptr = instance()->_networks.value(info.networkId, 0);
-  if(!netptr) {
-    qWarning() << "Update for unknown network requested:" << info;
-    return;
-  }
-  netptr->requestSetNetworkInfo(info);
+
+void Client::updateNetwork(const NetworkInfo &info)
+{
+    Network *netptr = instance()->_networks.value(info.networkId, 0);
+    if (!netptr) {
+        qWarning() << "Update for unknown network requested:" << info;
+        return;
+    }
+    netptr->requestSetNetworkInfo(info);
 }
 
-void Client::addNetwork(Network *net) {
-  net->setProxy(signalProxy());
-  signalProxy()->synchronize(net);
-  networkModel()->attachNetwork(net);
-  connect(net, SIGNAL(destroyed()), instance(), SLOT(networkDestroyed()));
-  instance()->_networks[net->networkId()] = net;
-  emit instance()->networkCreated(net->networkId());
+
+void Client::addNetwork(Network *net)
+{
+    net->setProxy(signalProxy());
+    signalProxy()->synchronize(net);
+    networkModel()->attachNetwork(net);
+    connect(net, SIGNAL(destroyed()), instance(), SLOT(networkDestroyed()));
+    instance()->_networks[net->networkId()] = net;
+    emit instance()->networkCreated(net->networkId());
 }
 
-void Client::coreNetworkCreated(NetworkId id) {
-  if(_networks.contains(id)) {
-    qWarning() << "Creation of already existing network requested!";
-    return;
-  }
-  Network *net = new Network(id, this);
-  addNetwork(net);
+
+void Client::coreNetworkCreated(NetworkId id)
+{
+    if (_networks.contains(id)) {
+        qWarning() << "Creation of already existing network requested!";
+        return;
+    }
+    Network *net = new Network(id, this);
+    addNetwork(net);
 }
 
-void Client::coreNetworkRemoved(NetworkId id) {
-  if(!_networks.contains(id))
-    return;
-  Network *net = _networks.take(id);
-  emit networkRemoved(net->networkId());
-  net->deleteLater();
+
+void Client::coreNetworkRemoved(NetworkId id)
+{
+    if (!_networks.contains(id))
+        return;
+    Network *net = _networks.take(id);
+    emit networkRemoved(net->networkId());
+    net->deleteLater();
 }
 
+
 /*** Identity handling ***/
 
-QList<IdentityId> Client::identityIds() {
-  return instance()->_identities.keys();
+QList<IdentityId> Client::identityIds()
+{
+    return instance()->_identities.keys();
 }
 
-const Identity *Client::identity(IdentityId id) {
-  if(instance()->_identities.contains(id)) return instance()->_identities[id];
-  else return 0;
+
+const Identity *Client::identity(IdentityId id)
+{
+    if (instance()->_identities.contains(id)) return instance()->_identities[id];
+    else return 0;
 }
 
-void Client::createIdentity(const CertIdentity &id) {
-  QVariantMap additional;
+
+void Client::createIdentity(const CertIdentity &id)
+{
+    QVariantMap additional;
 #ifdef HAVE_SSL
-  additional["KeyPem"] = id.sslKey().toPem();
-  additional["CertPem"] = id.sslCert().toPem();
+    additional["KeyPem"] = id.sslKey().toPem();
+    additional["CertPem"] = id.sslCert().toPem();
 #endif
-  emit instance()->requestCreateIdentity(id, additional);
+    emit instance()->requestCreateIdentity(id, additional);
 }
 
-void Client::updateIdentity(IdentityId id, const QVariantMap &ser) {
-  Identity *idptr = instance()->_identities.value(id, 0);
-  if(!idptr) {
-    qWarning() << "Update for unknown identity requested:" << id;
-    return;
-  }
-  idptr->requestUpdate(ser);
+
+void Client::updateIdentity(IdentityId id, const QVariantMap &ser)
+{
+    Identity *idptr = instance()->_identities.value(id, 0);
+    if (!idptr) {
+        qWarning() << "Update for unknown identity requested:" << id;
+        return;
+    }
+    idptr->requestUpdate(ser);
 }
 
-void Client::removeIdentity(IdentityId id) {
-  emit instance()->requestRemoveIdentity(id);
+
+void Client::removeIdentity(IdentityId id)
+{
+    emit instance()->requestRemoveIdentity(id);
 }
 
-void Client::coreIdentityCreated(const Identity &other) {
-  if(!_identities.contains(other.id())) {
-    Identity *identity = new Identity(other, this);
-    _identities[other.id()] = identity;
-    identity->setInitialized();
-    signalProxy()->synchronize(identity);
-    emit identityCreated(other.id());
-  } else {
-    qWarning() << tr("Identity already exists in client!");
-  }
+
+void Client::coreIdentityCreated(const Identity &other)
+{
+    if (!_identities.contains(other.id())) {
+        Identity *identity = new Identity(other, this);
+        _identities[other.id()] = identity;
+        identity->setInitialized();
+        signalProxy()->synchronize(identity);
+        emit identityCreated(other.id());
+    }
+    else {
+        qWarning() << tr("Identity already exists in client!");
+    }
 }
 
-void Client::coreIdentityRemoved(IdentityId id) {
-  if(_identities.contains(id)) {
-    emit identityRemoved(id);
-    Identity *i = _identities.take(id);
-    i->deleteLater();
-  }
+
+void Client::coreIdentityRemoved(IdentityId id)
+{
+    if (_identities.contains(id)) {
+        emit identityRemoved(id);
+        Identity *i = _identities.take(id);
+        i->deleteLater();
+    }
 }
 
+
 /*** User input handling ***/
 
-void Client::userInput(const BufferInfo &bufferInfo, const QString &message) {
-  // we need to make sure that AliasManager is ready before processing input
-  if(aliasManager() && aliasManager()->isInitialized())
-    inputHandler()->handleUserInput(bufferInfo, message);
-  else
-   instance()-> _userInputBuffer.append(qMakePair(bufferInfo, message));
+void Client::userInput(const BufferInfo &bufferInfo, const QString &message)
+{
+    // we need to make sure that AliasManager is ready before processing input
+    if (aliasManager() && aliasManager()->isInitialized())
+        inputHandler()->handleUserInput(bufferInfo, message);
+    else
+        instance()->_userInputBuffer.append(qMakePair(bufferInfo, message));
 }
 
-void Client::sendBufferedUserInput() {
-  for(int i = 0; i < _userInputBuffer.count(); i++)
-    userInput(_userInputBuffer.at(i).first, _userInputBuffer.at(i).second);
 
-  _userInputBuffer.clear();
+void Client::sendBufferedUserInput()
+{
+    for (int i = 0; i < _userInputBuffer.count(); i++)
+        userInput(_userInputBuffer.at(i).first, _userInputBuffer.at(i).second);
+
+    _userInputBuffer.clear();
 }
 
-/*** core connection stuff ***/
 
-void Client::connectionStateChanged(CoreConnection::ConnectionState state) {
-  switch(state) {
-  case CoreConnection::Disconnected:
-    setDisconnectedFromCore();
-    break;
-  case CoreConnection::Synchronized:
-    setSyncedToCore();
-    break;
-  default:
-    break;
-  }
-}
-
-void Client::setSyncedToCore() {
-  // create buffersyncer
-  Q_ASSERT(!_bufferSyncer);
-  _bufferSyncer = new BufferSyncer(this);
-  connect(bufferSyncer(), SIGNAL(lastSeenMsgSet(BufferId, MsgId)), _networkModel, SLOT(setLastSeenMsgId(BufferId, MsgId)));
-  connect(bufferSyncer(), SIGNAL(markerLineSet(BufferId,MsgId)), _networkModel, SLOT(setMarkerLineMsgId(BufferId,MsgId)));
-  connect(bufferSyncer(), SIGNAL(bufferRemoved(BufferId)), this, SLOT(bufferRemoved(BufferId)));
-  connect(bufferSyncer(), SIGNAL(bufferRenamed(BufferId, QString)), this, SLOT(bufferRenamed(BufferId, QString)));
-  connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), this, SLOT(buffersPermanentlyMerged(BufferId, BufferId)));
-  connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), _messageModel, SLOT(buffersPermanentlyMerged(BufferId, BufferId)));
-  connect(bufferSyncer(), SIGNAL(bufferMarkedAsRead(BufferId)), SIGNAL(bufferMarkedAsRead(BufferId)));
-  connect(networkModel(), SIGNAL(requestSetLastSeenMsg(BufferId, MsgId)), bufferSyncer(), SLOT(requestSetLastSeenMsg(BufferId, const MsgId &)));
-  signalProxy()->synchronize(bufferSyncer());
-
-  // create a new BufferViewManager
-  Q_ASSERT(!_bufferViewManager);
-  _bufferViewManager = new ClientBufferViewManager(signalProxy(), this);
-  connect(_bufferViewManager, SIGNAL(initDone()), _bufferViewOverlay, SLOT(restore()));
-
-  // create AliasManager
-  Q_ASSERT(!_aliasManager);
-  _aliasManager = new ClientAliasManager(this);
-  connect(aliasManager(), SIGNAL(initDone()), SLOT(sendBufferedUserInput()));
-  signalProxy()->synchronize(aliasManager());
-
-  // create NetworkConfig
-  Q_ASSERT(!_networkConfig);
-  _networkConfig = new NetworkConfig("GlobalNetworkConfig", this);
-  signalProxy()->synchronize(networkConfig());
-
-  // create IgnoreListManager
-  Q_ASSERT(!_ignoreListManager);
-  _ignoreListManager = new ClientIgnoreListManager(this);
-  signalProxy()->synchronize(ignoreListManager());
-
-  // trigger backlog request once all active bufferviews are initialized
-  connect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
-
-  _connected = true;
-  emit connected();
-  emit coreConnectionStateChanged(true);
-}
-
-void Client::requestInitialBacklog() {
-  // usually it _should_ take longer until the bufferViews are initialized, so that's what
-  // triggers this slot. But we have to make sure that we know all buffers yet.
-  // so we check the BufferSyncer and in case it wasn't initialized we wait for that instead
-  if(!bufferSyncer()->isInitialized()) {
-    disconnect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
-    connect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
-    return;
-  }
-  disconnect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
-  disconnect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
+/*** core connection stuff ***/
 
-  _backlogManager->requestInitialBacklog();
+void Client::connectionStateChanged(CoreConnection::ConnectionState state)
+{
+    switch (state) {
+    case CoreConnection::Disconnected:
+        setDisconnectedFromCore();
+        break;
+    case CoreConnection::Synchronized:
+        setSyncedToCore();
+        break;
+    default:
+        break;
+    }
 }
 
-void Client::disconnectFromCore() {
-  if(!coreConnection()->isConnected())
-    return;
 
-  coreConnection()->disconnectFromCore();
+void Client::setSyncedToCore()
+{
+    // create buffersyncer
+    Q_ASSERT(!_bufferSyncer);
+    _bufferSyncer = new BufferSyncer(this);
+    connect(bufferSyncer(), SIGNAL(lastSeenMsgSet(BufferId, MsgId)), _networkModel, SLOT(setLastSeenMsgId(BufferId, MsgId)));
+    connect(bufferSyncer(), SIGNAL(markerLineSet(BufferId, MsgId)), _networkModel, SLOT(setMarkerLineMsgId(BufferId, MsgId)));
+    connect(bufferSyncer(), SIGNAL(bufferRemoved(BufferId)), this, SLOT(bufferRemoved(BufferId)));
+    connect(bufferSyncer(), SIGNAL(bufferRenamed(BufferId, QString)), this, SLOT(bufferRenamed(BufferId, QString)));
+    connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), this, SLOT(buffersPermanentlyMerged(BufferId, BufferId)));
+    connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), _messageModel, SLOT(buffersPermanentlyMerged(BufferId, BufferId)));
+    connect(bufferSyncer(), SIGNAL(bufferMarkedAsRead(BufferId)), SIGNAL(bufferMarkedAsRead(BufferId)));
+    connect(networkModel(), SIGNAL(requestSetLastSeenMsg(BufferId, MsgId)), bufferSyncer(), SLOT(requestSetLastSeenMsg(BufferId, const MsgId &)));
+    signalProxy()->synchronize(bufferSyncer());
+
+    // create a new BufferViewManager
+    Q_ASSERT(!_bufferViewManager);
+    _bufferViewManager = new ClientBufferViewManager(signalProxy(), this);
+    connect(_bufferViewManager, SIGNAL(initDone()), _bufferViewOverlay, SLOT(restore()));
+
+    // create AliasManager
+    Q_ASSERT(!_aliasManager);
+    _aliasManager = new ClientAliasManager(this);
+    connect(aliasManager(), SIGNAL(initDone()), SLOT(sendBufferedUserInput()));
+    signalProxy()->synchronize(aliasManager());
+
+    // create NetworkConfig
+    Q_ASSERT(!_networkConfig);
+    _networkConfig = new NetworkConfig("GlobalNetworkConfig", this);
+    signalProxy()->synchronize(networkConfig());
+
+    // create IgnoreListManager
+    Q_ASSERT(!_ignoreListManager);
+    _ignoreListManager = new ClientIgnoreListManager(this);
+    signalProxy()->synchronize(ignoreListManager());
+
+    // trigger backlog request once all active bufferviews are initialized
+    connect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
+
+    _connected = true;
+    emit connected();
+    emit coreConnectionStateChanged(true);
+}
+
+
+void Client::requestInitialBacklog()
+{
+    // usually it _should_ take longer until the bufferViews are initialized, so that's what
+    // triggers this slot. But we have to make sure that we know all buffers yet.
+    // so we check the BufferSyncer and in case it wasn't initialized we wait for that instead
+    if (!bufferSyncer()->isInitialized()) {
+        disconnect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
+        connect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
+        return;
+    }
+    disconnect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
+    disconnect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
+
+    _backlogManager->requestInitialBacklog();
 }
 
-void Client::setDisconnectedFromCore() {
-  _connected = false;
-  _coreFeatures = 0;
 
-  emit disconnected();
-  emit coreConnectionStateChanged(false);
+void Client::disconnectFromCore()
+{
+    if (!coreConnection()->isConnected())
+        return;
+
+    coreConnection()->disconnectFromCore();
+}
 
-  backlogManager()->reset();
-  messageProcessor()->reset();
 
-  // Clear internal data. Hopefully nothing relies on it at this point.
+void Client::setDisconnectedFromCore()
+{
+    _connected = false;
+    _coreFeatures = 0;
 
-  if(_bufferSyncer) {
-    _bufferSyncer->deleteLater();
-    _bufferSyncer = 0;
-  }
+    emit disconnected();
+    emit coreConnectionStateChanged(false);
 
-  if(_bufferViewManager) {
-    _bufferViewManager->deleteLater();
-    _bufferViewManager = 0;
-  }
+    backlogManager()->reset();
+    messageProcessor()->reset();
 
-  _bufferViewOverlay->reset();
+    // Clear internal data. Hopefully nothing relies on it at this point.
 
-  if(_aliasManager) {
-    _aliasManager->deleteLater();
-    _aliasManager = 0;
-  }
+    if (_bufferSyncer) {
+        _bufferSyncer->deleteLater();
+        _bufferSyncer = 0;
+    }
 
-  if(_ignoreListManager) {
-    _ignoreListManager->deleteLater();
-    _ignoreListManager = 0;
-  }
-  // we probably don't want to save pending input for reconnect
-  _userInputBuffer.clear();
+    if (_bufferViewManager) {
+        _bufferViewManager->deleteLater();
+        _bufferViewManager = 0;
+    }
 
-  _messageModel->clear();
-  _networkModel->clear();
+    _bufferViewOverlay->reset();
 
-  QHash<NetworkId, Network*>::iterator netIter = _networks.begin();
-  while(netIter != _networks.end()) {
-    Network *net = netIter.value();
-    emit networkRemoved(net->networkId());
-    disconnect(net, SIGNAL(destroyed()), this, 0);
-    netIter = _networks.erase(netIter);
-    net->deleteLater();
-  }
-  Q_ASSERT(_networks.isEmpty());
+    if (_aliasManager) {
+        _aliasManager->deleteLater();
+        _aliasManager = 0;
+    }
 
-  QHash<IdentityId, Identity *>::iterator idIter = _identities.begin();
-  while(idIter != _identities.end()) {
-    emit identityRemoved(idIter.key());
-    Identity *id = idIter.value();
-    idIter = _identities.erase(idIter);
-    id->deleteLater();
-  }
-  Q_ASSERT(_identities.isEmpty());
+    if (_ignoreListManager) {
+        _ignoreListManager->deleteLater();
+        _ignoreListManager = 0;
+    }
+    // we probably don't want to save pending input for reconnect
+    _userInputBuffer.clear();
+
+    _messageModel->clear();
+    _networkModel->clear();
+
+    QHash<NetworkId, Network *>::iterator netIter = _networks.begin();
+    while (netIter != _networks.end()) {
+        Network *net = netIter.value();
+        emit networkRemoved(net->networkId());
+        disconnect(net, SIGNAL(destroyed()), this, 0);
+        netIter = _networks.erase(netIter);
+        net->deleteLater();
+    }
+    Q_ASSERT(_networks.isEmpty());
+
+    QHash<IdentityId, Identity *>::iterator idIter = _identities.begin();
+    while (idIter != _identities.end()) {
+        emit identityRemoved(idIter.key());
+        Identity *id = idIter.value();
+        idIter = _identities.erase(idIter);
+        id->deleteLater();
+    }
+    Q_ASSERT(_identities.isEmpty());
 
-  if(_networkConfig) {
-    _networkConfig->deleteLater();
-    _networkConfig = 0;
-  }
+    if (_networkConfig) {
+        _networkConfig->deleteLater();
+        _networkConfig = 0;
+    }
 }
 
+
 /*** ***/
 
-void Client::networkDestroyed() {
-  Network *net = static_cast<Network *>(sender());
-  QHash<NetworkId, Network *>::iterator netIter = _networks.begin();
-  while(netIter != _networks.end()) {
-    if(*netIter == net) {
-      netIter = _networks.erase(netIter);
-      break;
-    } else {
-      netIter++;
+void Client::networkDestroyed()
+{
+    Network *net = static_cast<Network *>(sender());
+    QHash<NetworkId, Network *>::iterator netIter = _networks.begin();
+    while (netIter != _networks.end()) {
+        if (*netIter == net) {
+            netIter = _networks.erase(netIter);
+            break;
+        }
+        else {
+            netIter++;
+        }
     }
-  }
 }
 
+
 // Hmm... we never used this...
-void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) {
-  //recvMessage(net, Message::server("", QString("[STATUS] %1").arg(msg)));
+void Client::recvStatusMsg(QString /*net*/, QString /*msg*/)
+{
+    //recvMessage(net, Message::server("", QString("[STATUS] %1").arg(msg)));
 }
 
-void Client::recvMessage(const Message &msg) {
-  Message msg_ = msg;
-  messageProcessor()->process(msg_);
+
+void Client::recvMessage(const Message &msg)
+{
+    Message msg_ = msg;
+    messageProcessor()->process(msg_);
 }
 
-void Client::setBufferLastSeenMsg(BufferId id, const MsgId &msgId) {
-  if(bufferSyncer())
-    bufferSyncer()->requestSetLastSeenMsg(id, msgId);
+
+void Client::setBufferLastSeenMsg(BufferId id, const MsgId &msgId)
+{
+    if (bufferSyncer())
+        bufferSyncer()->requestSetLastSeenMsg(id, msgId);
 }
 
-void Client::setMarkerLine(BufferId id, const MsgId &msgId) {
-  if(bufferSyncer())
-    bufferSyncer()->requestSetMarkerLine(id, msgId);
+
+void Client::setMarkerLine(BufferId id, const MsgId &msgId)
+{
+    if (bufferSyncer())
+        bufferSyncer()->requestSetMarkerLine(id, msgId);
 }
 
-MsgId Client::markerLine(BufferId id) {
-  if(id.isValid() && networkModel())
-    return networkModel()->markerLineMsgId(id);
-  return MsgId();
+
+MsgId Client::markerLine(BufferId id)
+{
+    if (id.isValid() && networkModel())
+        return networkModel()->markerLineMsgId(id);
+    return MsgId();
 }
 
-void Client::removeBuffer(BufferId id) {
-  if(!bufferSyncer()) return;
-  bufferSyncer()->requestRemoveBuffer(id);
+
+void Client::removeBuffer(BufferId id)
+{
+    if (!bufferSyncer()) return;
+    bufferSyncer()->requestRemoveBuffer(id);
 }
 
-void Client::renameBuffer(BufferId bufferId, const QString &newName) {
-  if(!bufferSyncer())
-    return;
-  bufferSyncer()->requestRenameBuffer(bufferId, newName);
+
+void Client::renameBuffer(BufferId bufferId, const QString &newName)
+{
+    if (!bufferSyncer())
+        return;
+    bufferSyncer()->requestRenameBuffer(bufferId, newName);
 }
 
-void Client::mergeBuffersPermanently(BufferId bufferId1, BufferId bufferId2) {
-  if(!bufferSyncer())
-    return;
-  bufferSyncer()->requestMergeBuffersPermanently(bufferId1, bufferId2);
+
+void Client::mergeBuffersPermanently(BufferId bufferId1, BufferId bufferId2)
+{
+    if (!bufferSyncer())
+        return;
+    bufferSyncer()->requestMergeBuffersPermanently(bufferId1, bufferId2);
 }
 
-void Client::purgeKnownBufferIds() {
-  if(!bufferSyncer())
-    return;
-  bufferSyncer()->requestPurgeBufferIds();
+
+void Client::purgeKnownBufferIds()
+{
+    if (!bufferSyncer())
+        return;
+    bufferSyncer()->requestPurgeBufferIds();
 }
 
-void Client::bufferRemoved(BufferId bufferId) {
-  // select a sane buffer (status buffer)
-  /* we have to manually select a buffer because otherwise inconsitent changes
-   * to the model might occur:
-   * the result of a buffer removal triggers a change in the selection model.
-   * the newly selected buffer might be a channel that hasn't been selected yet
-   * and a new nickview would be created (which never heard of the "rowsAboutToBeRemoved").
-   * this new view (and/or) its sort filter will then only receive a "rowsRemoved" signal.
-   */
-  QModelIndex current = bufferModel()->currentIndex();
-  if(current.data(NetworkModel::BufferIdRole).value<BufferId>() == bufferId) {
-    bufferModel()->setCurrentIndex(current.sibling(0,0));
-  }
 
-  // and remove it from the model
-  networkModel()->removeBuffer(bufferId);
+void Client::bufferRemoved(BufferId bufferId)
+{
+    // select a sane buffer (status buffer)
+    /* we have to manually select a buffer because otherwise inconsitent changes
+     * to the model might occur:
+     * the result of a buffer removal triggers a change in the selection model.
+     * the newly selected buffer might be a channel that hasn't been selected yet
+     * and a new nickview would be created (which never heard of the "rowsAboutToBeRemoved").
+     * this new view (and/or) its sort filter will then only receive a "rowsRemoved" signal.
+     */
+    QModelIndex current = bufferModel()->currentIndex();
+    if (current.data(NetworkModel::BufferIdRole).value<BufferId>() == bufferId) {
+        bufferModel()->setCurrentIndex(current.sibling(0, 0));
+    }
+
+    // and remove it from the model
+    networkModel()->removeBuffer(bufferId);
 }
 
-void Client::bufferRenamed(BufferId bufferId, const QString &newName) {
-  QModelIndex bufferIndex = networkModel()->bufferIndex(bufferId);
-  if(bufferIndex.isValid()) {
-    networkModel()->setData(bufferIndex, newName, Qt::DisplayRole);
-  }
+
+void Client::bufferRenamed(BufferId bufferId, const QString &newName)
+{
+    QModelIndex bufferIndex = networkModel()->bufferIndex(bufferId);
+    if (bufferIndex.isValid()) {
+        networkModel()->setData(bufferIndex, newName, Qt::DisplayRole);
+    }
 }
 
-void Client::buffersPermanentlyMerged(BufferId bufferId1, BufferId bufferId2) {
-  QModelIndex idx = networkModel()->bufferIndex(bufferId1);
-  bufferModel()->setCurrentIndex(bufferModel()->mapFromSource(idx));
-  networkModel()->removeBuffer(bufferId2);
+
+void Client::buffersPermanentlyMerged(BufferId bufferId1, BufferId bufferId2)
+{
+    QModelIndex idx = networkModel()->bufferIndex(bufferId1);
+    bufferModel()->setCurrentIndex(bufferModel()->mapFromSource(idx));
+    networkModel()->removeBuffer(bufferId2);
 }
 
-void Client::markBufferAsRead(BufferId id) {
-  if(bufferSyncer() && id.isValid())
-    bufferSyncer()->requestMarkBufferAsRead(id);
+
+void Client::markBufferAsRead(BufferId id)
+{
+    if (bufferSyncer() && id.isValid())
+        bufferSyncer()->requestMarkBufferAsRead(id);
 }
 
-void Client::logMessage(QtMsgType type, const char *msg) {
-  fprintf(stderr, "%s\n", msg);
-  fflush(stderr);
-  if(type == QtFatalMsg) {
-    Quassel::logFatalMessage(msg);
-  } else {
-    QString msgString = QString("%1\n").arg(msg);
 
-    //Check to see if there is an instance around, else we risk recursions
-    //when calling instance() and creating new ones.
-    if (!instanceExists())
-      return;
+void Client::logMessage(QtMsgType type, const char *msg)
+{
+    fprintf(stderr, "%s\n", msg);
+    fflush(stderr);
+    if (type == QtFatalMsg) {
+        Quassel::logFatalMessage(msg);
+    }
+    else {
+        QString msgString = QString("%1\n").arg(msg);
+
+        //Check to see if there is an instance around, else we risk recursions
+        //when calling instance() and creating new ones.
+        if (!instanceExists())
+            return;
 
-    instance()->_debugLog << msgString;
-    emit instance()->logUpdated(msgString);
-  }
+        instance()->_debugLog << msgString;
+        emit instance()->logUpdated(msgString);
+    }
 }
index cc3803b..a6e5622 100644 (file)
@@ -57,201 +57,203 @@ class NetworkConfig;
 class SignalProxy;
 struct NetworkInfo;
 
-class Client : public QObject {
-  Q_OBJECT
+class Client : public QObject
+{
+    Q_OBJECT
 
 public:
-  enum ClientMode {
-    LocalCore,
-    RemoteCore
-  };
-
-  static bool instanceExists();
-  static Client *instance();
-  static void destroy();
-  static void init(AbstractUi *);
-  static AbstractUi *mainUi();
-
-  static QList<NetworkId> networkIds();
-  static const Network * network(NetworkId);
-
-  static QList<IdentityId> identityIds();
-  static const Identity *identity(IdentityId);
-
-  //! Request creation of an identity with the given data.
-  /** The request will be sent to the core, and will be propagated back to all the clients
-   *  with a new valid IdentityId.
-   *  \param identity The identity template for the new identity. It does not need to have a valid ID.
-   */
-  static void createIdentity(const CertIdentity &identity);
-
-  //! Request update of an identity with the given data.
-  /** The request will be sent to the core, and will be propagated back to all the clients.
-   *  \param id The identity to be updated.
-   *  \param serializedData The identity's content (cf. SyncableObject::toVariantMap())
-   */
-  static void updateIdentity(IdentityId id, const QVariantMap &serializedData);
-
-  //! Request removal of the identity with the given ID from the core (and all the clients, of course).
-  /** \param id The ID of the identity to be removed.
-   */
-  static void removeIdentity(IdentityId id);
-
-  static void createNetwork(const NetworkInfo &info, const QStringList &persistentChannels = QStringList());
-  static void updateNetwork(const NetworkInfo &info);
-  static void removeNetwork(NetworkId id);
-
-  static inline NetworkModel *networkModel() { return instance()->_networkModel; }
-  static inline BufferModel *bufferModel() { return instance()->_bufferModel; }
-  static inline MessageModel *messageModel() { return instance()->_messageModel; }
-  static inline AbstractMessageProcessor *messageProcessor() { return instance()->_messageProcessor; }
-  static inline SignalProxy *signalProxy() { return instance()->_signalProxy; }
-
-  static inline ClientAliasManager *aliasManager() { return instance()->_aliasManager; }
-  static inline ClientBacklogManager *backlogManager() { return instance()->_backlogManager; }
-  static inline ClientIrcListHelper *ircListHelper() { return instance()->_ircListHelper; }
-  static inline ClientBufferViewManager *bufferViewManager() { return instance()->_bufferViewManager; }
-  static inline BufferViewOverlay *bufferViewOverlay() { return instance()->_bufferViewOverlay; }
-  static inline ClientUserInputHandler *inputHandler() { return instance()->_inputHandler; }
-  static inline NetworkConfig *networkConfig() { return instance()->_networkConfig; }
-  static inline ClientIgnoreListManager *ignoreListManager() { return instance()->_ignoreListManager; }
-
-  static inline CoreAccountModel *coreAccountModel() { return instance()->_coreAccountModel; }
-  static inline CoreConnection *coreConnection() { return instance()->_coreConnection; }
-  static inline CoreAccount currentCoreAccount() { return coreConnection()->currentAccount(); }
-  static inline Quassel::Features coreFeatures() { return _coreFeatures; }
-
-  static bool isConnected();
-  static bool internalCore();
-
-  static void userInput(const BufferInfo &bufferInfo, const QString &message);
-
-  static void setBufferLastSeenMsg(BufferId id, const MsgId &msgId); // this is synced to core and other clients
-  static void setMarkerLine(BufferId id, const MsgId &msgId); // this is synced to core and other clients
-  static MsgId markerLine(BufferId id);
-
-  static void removeBuffer(BufferId id);
-  static void renameBuffer(BufferId bufferId, const QString &newName);
-  static void mergeBuffersPermanently(BufferId bufferId1, BufferId bufferId2);
-  static void purgeKnownBufferIds();
-
-  static void logMessage(QtMsgType type, const char *msg);
-  static inline const QString &debugLog() { return instance()->_debugLogBuffer; }
+    enum ClientMode {
+        LocalCore,
+        RemoteCore
+    };
+
+    static bool instanceExists();
+    static Client *instance();
+    static void destroy();
+    static void init(AbstractUi *);
+    static AbstractUi *mainUi();
+
+    static QList<NetworkId> networkIds();
+    static const Network *network(NetworkId);
+
+    static QList<IdentityId> identityIds();
+    static const Identity *identity(IdentityId);
+
+    //! Request creation of an identity with the given data.
+    /** The request will be sent to the core, and will be propagated back to all the clients
+     *  with a new valid IdentityId.
+     *  \param identity The identity template for the new identity. It does not need to have a valid ID.
+     */
+    static void createIdentity(const CertIdentity &identity);
+
+    //! Request update of an identity with the given data.
+    /** The request will be sent to the core, and will be propagated back to all the clients.
+     *  \param id The identity to be updated.
+     *  \param serializedData The identity's content (cf. SyncableObject::toVariantMap())
+     */
+    static void updateIdentity(IdentityId id, const QVariantMap &serializedData);
+
+    //! Request removal of the identity with the given ID from the core (and all the clients, of course).
+    /** \param id The ID of the identity to be removed.
+     */
+    static void removeIdentity(IdentityId id);
+
+    static void createNetwork(const NetworkInfo &info, const QStringList &persistentChannels = QStringList());
+    static void updateNetwork(const NetworkInfo &info);
+    static void removeNetwork(NetworkId id);
+
+    static inline NetworkModel *networkModel() { return instance()->_networkModel; }
+    static inline BufferModel *bufferModel() { return instance()->_bufferModel; }
+    static inline MessageModel *messageModel() { return instance()->_messageModel; }
+    static inline AbstractMessageProcessor *messageProcessor() { return instance()->_messageProcessor; }
+    static inline SignalProxy *signalProxy() { return instance()->_signalProxy; }
+
+    static inline ClientAliasManager *aliasManager() { return instance()->_aliasManager; }
+    static inline ClientBacklogManager *backlogManager() { return instance()->_backlogManager; }
+    static inline ClientIrcListHelper *ircListHelper() { return instance()->_ircListHelper; }
+    static inline ClientBufferViewManager *bufferViewManager() { return instance()->_bufferViewManager; }
+    static inline BufferViewOverlay *bufferViewOverlay() { return instance()->_bufferViewOverlay; }
+    static inline ClientUserInputHandler *inputHandler() { return instance()->_inputHandler; }
+    static inline NetworkConfig *networkConfig() { return instance()->_networkConfig; }
+    static inline ClientIgnoreListManager *ignoreListManager() { return instance()->_ignoreListManager; }
+
+    static inline CoreAccountModel *coreAccountModel() { return instance()->_coreAccountModel; }
+    static inline CoreConnection *coreConnection() { return instance()->_coreConnection; }
+    static inline CoreAccount currentCoreAccount() { return coreConnection()->currentAccount(); }
+    static inline Quassel::Features coreFeatures() { return _coreFeatures; }
+
+    static bool isConnected();
+    static bool internalCore();
+
+    static void userInput(const BufferInfo &bufferInfo, const QString &message);
+
+    static void setBufferLastSeenMsg(BufferId id, const MsgId &msgId); // this is synced to core and other clients
+    static void setMarkerLine(BufferId id, const MsgId &msgId); // this is synced to core and other clients
+    static MsgId markerLine(BufferId id);
+
+    static void removeBuffer(BufferId id);
+    static void renameBuffer(BufferId bufferId, const QString &newName);
+    static void mergeBuffersPermanently(BufferId bufferId1, BufferId bufferId2);
+    static void purgeKnownBufferIds();
+
+    static void logMessage(QtMsgType type, const char *msg);
+    static inline const QString &debugLog() { return instance()->_debugLogBuffer; }
 
 signals:
-  void requestNetworkStates();
+    void requestNetworkStates();
 
-  void showConfigWizard(const QVariantMap &coredata);
+    void showConfigWizard(const QVariantMap &coredata);
 
-  void connected();
-  void disconnected();
-  void coreConnectionStateChanged(bool);
+    void connected();
+    void disconnected();
+    void coreConnectionStateChanged(bool);
 
-  //! The identity with the given ID has been newly created in core and client.
-  /** \param id The ID of the newly created identity.
-   */
-  void identityCreated(IdentityId id);
+    //! The identity with the given ID has been newly created in core and client.
+    /** \param id The ID of the newly created identity.
+     */
+    void identityCreated(IdentityId id);
 
-  //! The identity with the given ID has been removed.
-  /** Upon emitting this signal, the identity is already gone from the core, and it will
-   *  be deleted from the client immediately afterwards, so connected slots need to clean
-   *  up their stuff.
-   *  \param id The ID of the identity about to be removed.
-   */
-  void identityRemoved(IdentityId id);
+    //! The identity with the given ID has been removed.
+    /** Upon emitting this signal, the identity is already gone from the core, and it will
+     *  be deleted from the client immediately afterwards, so connected slots need to clean
+     *  up their stuff.
+     *  \param id The ID of the identity about to be removed.
+     */
+    void identityRemoved(IdentityId id);
 
-  //! Sent to the core when an identity shall be created. Should not be used elsewhere.
-  void requestCreateIdentity(const Identity &, const QVariantMap &);
-  //! Sent to the core when an identity shall be removed. Should not be used elsewhere.
-  void requestRemoveIdentity(IdentityId);
+    //! Sent to the core when an identity shall be created. Should not be used elsewhere.
+    void requestCreateIdentity(const Identity &, const QVariantMap &);
+    //! Sent to the core when an identity shall be removed. Should not be used elsewhere.
+    void requestRemoveIdentity(IdentityId);
 
-  void networkCreated(NetworkId id);
-  void networkRemoved(NetworkId id);
+    void networkCreated(NetworkId id);
+    void networkRemoved(NetworkId id);
 
-  void requestCreateNetwork(const NetworkInfo &info, const QStringList &persistentChannels = QStringList());
-  void requestRemoveNetwork(NetworkId);
+    void requestCreateNetwork(const NetworkInfo &info, const QStringList &persistentChannels = QStringList());
+    void requestRemoveNetwork(NetworkId);
 
-  void logUpdated(const QString &msg);
+    void logUpdated(const QString &msg);
 
-  //! Emitted when a buffer has been marked as read
-  /** This is currently triggered by setting lastSeenMsg, either local or remote,
-   *  or by bringing the window to front.
-   *  \param id The buffer that has been marked as read
-   */
-  void bufferMarkedAsRead(BufferId id);
+    //! Emitted when a buffer has been marked as read
+    /** This is currently triggered by setting lastSeenMsg, either local or remote,
+     *  or by bringing the window to front.
+     *  \param id The buffer that has been marked as read
+     */
+    void bufferMarkedAsRead(BufferId id);
 
 public slots:
-  void disconnectFromCore();
+    void disconnectFromCore();
 
-  void bufferRemoved(BufferId bufferId);
-  void bufferRenamed(BufferId bufferId, const QString &newName);
-  void buffersPermanentlyMerged(BufferId bufferId1, BufferId bufferId2);
+    void bufferRemoved(BufferId bufferId);
+    void bufferRenamed(BufferId bufferId, const QString &newName);
+    void buffersPermanentlyMerged(BufferId bufferId1, BufferId bufferId2);
 
-  void markBufferAsRead(BufferId id);
+    void markBufferAsRead(BufferId id);
 
 private slots:
-  void setSyncedToCore();
-  void setDisconnectedFromCore();
-  void connectionStateChanged(CoreConnection::ConnectionState);
+    void setSyncedToCore();
+    void setDisconnectedFromCore();
+    void connectionStateChanged(CoreConnection::ConnectionState);
 
-  void recvMessage(const Message &message);
-  void recvStatusMsg(QString network, QString message);
+    void recvMessage(const Message &message);
+    void recvStatusMsg(QString network, QString message);
 
-  void networkDestroyed();
-  void coreIdentityCreated(const Identity &);
-  void coreIdentityRemoved(IdentityId);
-  void coreNetworkCreated(NetworkId);
-  void coreNetworkRemoved(NetworkId);
+    void networkDestroyed();
+    void coreIdentityCreated(const Identity &);
+    void coreIdentityRemoved(IdentityId);
+    void coreNetworkCreated(NetworkId);
+    void coreNetworkRemoved(NetworkId);
 
-  void requestInitialBacklog();
+    void requestInitialBacklog();
 
-  void sendBufferedUserInput();
+    void sendBufferedUserInput();
 
 private:
-  Client(QObject *parent = 0);
-  virtual ~Client();
-  void init();
+    Client(QObject *parent = 0);
+    virtual ~Client();
+    void init();
 
-  static void addNetwork(Network *);
-  static void setCoreFeatures(Quassel::Features);
-  static inline BufferSyncer *bufferSyncer() { return instance()->_bufferSyncer; }
+    static void addNetwork(Network *);
+    static void setCoreFeatures(Quassel::Features);
+    static inline BufferSyncer *bufferSyncer() { return instance()->_bufferSyncer; }
 
-  static QPointer<Client> instanceptr;
+    static QPointer<Client> instanceptr;
 
-  SignalProxy * _signalProxy;
-  AbstractUi * _mainUi;
-  NetworkModel * _networkModel;
-  BufferModel * _bufferModel;
-  BufferSyncer * _bufferSyncer;
-  ClientAliasManager *_aliasManager;
-  ClientBacklogManager *_backlogManager;
-  ClientBufferViewManager *_bufferViewManager;
-  BufferViewOverlay *_bufferViewOverlay;
-  ClientIrcListHelper *_ircListHelper;
-  ClientUserInputHandler *_inputHandler;
-  NetworkConfig *_networkConfig;
-  ClientIgnoreListManager *_ignoreListManager;
+    SignalProxy *_signalProxy;
+    AbstractUi *_mainUi;
+    NetworkModel *_networkModel;
+    BufferModel *_bufferModel;
+    BufferSyncer *_bufferSyncer;
+    ClientAliasManager *_aliasManager;
+    ClientBacklogManager *_backlogManager;
+    ClientBufferViewManager *_bufferViewManager;
+    BufferViewOverlay *_bufferViewOverlay;
+    ClientIrcListHelper *_ircListHelper;
+    ClientUserInputHandler *_inputHandler;
+    NetworkConfig *_networkConfig;
+    ClientIgnoreListManager *_ignoreListManager;
 
-  MessageModel *_messageModel;
-  AbstractMessageProcessor *_messageProcessor;
+    MessageModel *_messageModel;
+    AbstractMessageProcessor *_messageProcessor;
 
-  CoreAccountModel *_coreAccountModel;
-  CoreConnection *_coreConnection;
+    CoreAccountModel *_coreAccountModel;
+    CoreConnection *_coreConnection;
 
-  ClientMode clientMode;
+    ClientMode clientMode;
 
-  QHash<NetworkId, Network *> _networks;
-  QHash<IdentityId, Identity *> _identities;
+    QHash<NetworkId, Network *> _networks;
+    QHash<IdentityId, Identity *> _identities;
 
-  bool _connected;
-  static Quassel::Features _coreFeatures;
+    bool _connected;
+    static Quassel::Features _coreFeatures;
 
-  QString _debugLogBuffer;
-  QTextStream _debugLog;
+    QString _debugLogBuffer;
+    QTextStream _debugLog;
 
-  QList<QPair<BufferInfo, QString> > _userInputBuffer;
+    QList<QPair<BufferInfo, QString> > _userInputBuffer;
 
-  friend class CoreConnection;
+    friend class CoreConnection;
 };
 
+
 #endif
index 3b4a953..da97f08 100644 (file)
 
 INIT_SYNCABLE_OBJECT(ClientAliasManager)
 ClientAliasManager::ClientAliasManager(QObject *parent)
-  : AliasManager(parent)
+    : AliasManager(parent)
 {
-
 }
 
-const Network *ClientAliasManager::network(NetworkId id) const {
-  return Client::network(id);
+
+const Network *ClientAliasManager::network(NetworkId id) const
+{
+    return Client::network(id);
 }
index 8b6aa37..5598f5f 100644 (file)
 
 #include "aliasmanager.h"
 
-class ClientAliasManager : public AliasManager {
-  SYNCABLE_OBJECT
-  Q_OBJECT
+class ClientAliasManager : public AliasManager
+{
+    SYNCABLE_OBJECT
+        Q_OBJECT
 
 public:
-  explicit ClientAliasManager(QObject *parent = 0);
+    explicit ClientAliasManager(QObject *parent = 0);
 
-  inline virtual const QMetaObject *syncMetaObject() const { return &AliasManager::staticMetaObject; }
+    inline virtual const QMetaObject *syncMetaObject() const { return &AliasManager::staticMetaObject; }
 
 protected:
-  const Network *network(NetworkId) const;
-
+    const Network *network(NetworkId) const;
 };
 
+
 #endif //CLIENTALIASMANAGER_H
index 8b6e2e4..4b4683f 100644 (file)
 
 INIT_SYNCABLE_OBJECT(ClientBacklogManager)
 ClientBacklogManager::ClientBacklogManager(QObject *parent)
-  : BacklogManager(parent),
-  _requester(0),
-  _initBacklogRequested(false)
+    : BacklogManager(parent),
+    _requester(0),
+    _initBacklogRequested(false)
 {
 }
 
-QVariantList ClientBacklogManager::requestBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional) {
-  _buffersRequested << bufferId;
-  return BacklogManager::requestBacklog(bufferId, first, last, limit, additional);
+
+QVariantList ClientBacklogManager::requestBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional)
+{
+    _buffersRequested << bufferId;
+    return BacklogManager::requestBacklog(bufferId, first, last, limit, additional);
 }
 
-void ClientBacklogManager::receiveBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional, QVariantList msgs) {
-  Q_UNUSED(first) Q_UNUSED(last) Q_UNUSED(limit) Q_UNUSED(additional)
 
-  emit messagesReceived(bufferId, msgs.count());
+void ClientBacklogManager::receiveBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional, QVariantList msgs)
+{
+    Q_UNUSED(first) Q_UNUSED(last) Q_UNUSED(limit) Q_UNUSED(additional)
 
-  MessageList msglist;
-  foreach(QVariant v, msgs) {
-    Message msg = v.value<Message>();
-    msg.setFlags(msg.flags() | Message::Backlog);
-    msglist << msg;
-  }
+    emit messagesReceived(bufferId, msgs.count());
 
-  if(isBuffering()) {
-    bool lastPart = !_requester->buffer(bufferId, msglist);
-    updateProgress(_requester->totalBuffers() - _requester->buffersWaiting(), _requester->totalBuffers());
-    if(lastPart) {
-      dispatchMessages(_requester->bufferedMessages(), true);
-      _requester->flushBuffer();
+    MessageList msglist;
+    foreach(QVariant v, msgs) {
+        Message msg = v.value<Message>();
+        msg.setFlags(msg.flags() | Message::Backlog);
+        msglist << msg;
+    }
+
+    if (isBuffering()) {
+        bool lastPart = !_requester->buffer(bufferId, msglist);
+        updateProgress(_requester->totalBuffers() - _requester->buffersWaiting(), _requester->totalBuffers());
+        if (lastPart) {
+            dispatchMessages(_requester->bufferedMessages(), true);
+            _requester->flushBuffer();
+        }
+    }
+    else {
+        dispatchMessages(msglist);
     }
-  } else {
-    dispatchMessages(msglist);
-  }
 }
 
-void ClientBacklogManager::receiveBacklogAll(MsgId first, MsgId last, int limit, int additional, QVariantList msgs) {
-  Q_UNUSED(first) Q_UNUSED(last) Q_UNUSED(limit) Q_UNUSED(additional)
 
-  MessageList msglist;
-  foreach(QVariant v, msgs) {
-    Message msg = v.value<Message>();
-    msg.setFlags(msg.flags() | Message::Backlog);
-    msglist << msg;
-  }
+void ClientBacklogManager::receiveBacklogAll(MsgId first, MsgId last, int limit, int additional, QVariantList msgs)
+{
+    Q_UNUSED(first) Q_UNUSED(last) Q_UNUSED(limit) Q_UNUSED(additional)
 
-  dispatchMessages(msglist);
+    MessageList msglist;
+    foreach(QVariant v, msgs) {
+        Message msg = v.value<Message>();
+        msg.setFlags(msg.flags() | Message::Backlog);
+        msglist << msg;
+    }
+
+    dispatchMessages(msglist);
 }
 
-void ClientBacklogManager::requestInitialBacklog() {
-  if(_initBacklogRequested) {
-    Q_ASSERT(_requester);
-    qWarning() << "ClientBacklogManager::requestInitialBacklog() called twice in the same session! (Backlog has already been requested)";
-    return;
-  }
-
-  BacklogSettings settings;
-  switch(settings.requesterType()) {
-  case BacklogRequester::GlobalUnread:
-    _requester = new GlobalUnreadBacklogRequester(this);
-    break;
-  case BacklogRequester::PerBufferUnread:
-    _requester = new PerBufferUnreadBacklogRequester(this);
-    break;
-  case BacklogRequester::PerBufferFixed:
-  default:
-    _requester = new FixedBacklogRequester(this);
-  };
-
-  _requester->requestInitialBacklog();
-  _initBacklogRequested = true;
-  if(_requester->isBuffering()) {
-    updateProgress(0, _requester->totalBuffers());
-  }
+
+void ClientBacklogManager::requestInitialBacklog()
+{
+    if (_initBacklogRequested) {
+        Q_ASSERT(_requester);
+        qWarning() << "ClientBacklogManager::requestInitialBacklog() called twice in the same session! (Backlog has already been requested)";
+        return;
+    }
+
+    BacklogSettings settings;
+    switch (settings.requesterType()) {
+    case BacklogRequester::GlobalUnread:
+        _requester = new GlobalUnreadBacklogRequester(this);
+        break;
+    case BacklogRequester::PerBufferUnread:
+        _requester = new PerBufferUnreadBacklogRequester(this);
+        break;
+    case BacklogRequester::PerBufferFixed:
+    default:
+        _requester = new FixedBacklogRequester(this);
+    };
+
+    _requester->requestInitialBacklog();
+    _initBacklogRequested = true;
+    if (_requester->isBuffering()) {
+        updateProgress(0, _requester->totalBuffers());
+    }
 }
 
-BufferIdList ClientBacklogManager::filterNewBufferIds(const BufferIdList &bufferIds) {
-  BufferIdList newBuffers;
-  QSet<BufferId> availableBuffers = Client::networkModel()->allBufferIds().toSet();
-  foreach(BufferId bufferId, bufferIds) {
-    if(_buffersRequested.contains(bufferId) || !availableBuffers.contains(bufferId))
-      continue;
-    newBuffers << bufferId;
-  }
-  return newBuffers;
+
+BufferIdList ClientBacklogManager::filterNewBufferIds(const BufferIdList &bufferIds)
+{
+    BufferIdList newBuffers;
+    QSet<BufferId> availableBuffers = Client::networkModel()->allBufferIds().toSet();
+    foreach(BufferId bufferId, bufferIds) {
+        if (_buffersRequested.contains(bufferId) || !availableBuffers.contains(bufferId))
+            continue;
+        newBuffers << bufferId;
+    }
+    return newBuffers;
 }
 
-void ClientBacklogManager::checkForBacklog(const QList<BufferId> &bufferIds) {
-  // we ingore all backlogrequests until we had our initial request
-  if(!_initBacklogRequested) {
-    return;
-  }
-
-  if(!_requester) {
-    // during client start up this message is to be expected in some situations.
-    qDebug() << "ClientBacklogManager::checkForBacklog(): no active backlog requester.";
-    return;
-  }
-  switch(_requester->type()) {
-  case BacklogRequester::GlobalUnread:
-    break;
-  case BacklogRequester::PerBufferUnread:
-  case BacklogRequester::PerBufferFixed:
-  default:
+
+void ClientBacklogManager::checkForBacklog(const QList<BufferId> &bufferIds)
+{
+    // we ingore all backlogrequests until we had our initial request
+    if (!_initBacklogRequested) {
+        return;
+    }
+
+    if (!_requester) {
+        // during client start up this message is to be expected in some situations.
+        qDebug() << "ClientBacklogManager::checkForBacklog(): no active backlog requester.";
+        return;
+    }
+    switch (_requester->type()) {
+    case BacklogRequester::GlobalUnread:
+        break;
+    case BacklogRequester::PerBufferUnread:
+    case BacklogRequester::PerBufferFixed:
+    default:
     {
-      BufferIdList buffers = filterNewBufferIds(bufferIds);
-      if(!buffers.isEmpty())
-        _requester->requestBacklog(buffers);
+        BufferIdList buffers = filterNewBufferIds(bufferIds);
+        if (!buffers.isEmpty())
+            _requester->requestBacklog(buffers);
     }
-  };
+    };
 }
 
-bool ClientBacklogManager::isBuffering() {
-  return _requester && _requester->isBuffering();
+
+bool ClientBacklogManager::isBuffering()
+{
+    return _requester && _requester->isBuffering();
 }
 
-void ClientBacklogManager::dispatchMessages(const MessageList &messages, bool sort) {
-  if(messages.isEmpty())
-    return;
 
-  MessageList msgs = messages;
+void ClientBacklogManager::dispatchMessages(const MessageList &messages, bool sort)
+{
+    if (messages.isEmpty())
+        return;
 
-  clock_t start_t = clock();
-  if(sort)
-    qSort(msgs);
-  Client::messageProcessor()->process(msgs);
-  clock_t end_t = clock();
+    MessageList msgs = messages;
 
-  emit messagesProcessed(tr("Processed %1 messages in %2 seconds.").arg(messages.count()).arg((float)(end_t - start_t) / CLOCKS_PER_SEC));
+    clock_t start_t = clock();
+    if (sort)
+        qSort(msgs);
+    Client::messageProcessor()->process(msgs);
+    clock_t end_t = clock();
+
+    emit messagesProcessed(tr("Processed %1 messages in %2 seconds.").arg(messages.count()).arg((float)(end_t - start_t) / CLOCKS_PER_SEC));
 }
 
-void ClientBacklogManager::reset() {
-  delete _requester;
-  _requester = 0;
-  _initBacklogRequested = false;
-  _buffersRequested.clear();
+
+void ClientBacklogManager::reset()
+{
+    delete _requester;
+    _requester = 0;
+    _initBacklogRequested = false;
+    _buffersRequested.clear();
 }
index f4a7b90..181017b 100644 (file)
 
 class BacklogRequester;
 
-class ClientBacklogManager : public BacklogManager {
-  SYNCABLE_OBJECT
-  Q_OBJECT
+class ClientBacklogManager : public BacklogManager
+{
+    SYNCABLE_OBJECT
+        Q_OBJECT
 
 public:
-  ClientBacklogManager(QObject *parent = 0);
+    ClientBacklogManager(QObject *parent = 0);
 
-  // helper for the backlogRequester, as it isn't a QObject and can't emit itself
-  inline void emitMessagesRequested(const QString &msg) const { emit messagesRequested(msg); }
+    // helper for the backlogRequester, as it isn't a QObject and can't emit itself
+    inline void emitMessagesRequested(const QString &msg) const { emit messagesRequested(msg); }
 
-  void reset();
+    void reset();
 
 public slots:
-  virtual QVariantList requestBacklog(BufferId bufferId, MsgId first = -1, MsgId last = -1, int limit = -1, int additional = 0);
-  virtual void receiveBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional, QVariantList msgs);
-  virtual void receiveBacklogAll(MsgId first, MsgId last, int limit, int additional, QVariantList msgs);
+    virtual QVariantList requestBacklog(BufferId bufferId, MsgId first = -1, MsgId last = -1, int limit = -1, int additional = 0);
+    virtual void receiveBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional, QVariantList msgs);
+    virtual void receiveBacklogAll(MsgId first, MsgId last, int limit, int additional, QVariantList msgs);
 
-  void requestInitialBacklog();
+    void requestInitialBacklog();
 
-  void checkForBacklog(BufferId bufferId);
-  void checkForBacklog(const BufferIdList &bufferIds);
+    void checkForBacklog(BufferId bufferId);
+    void checkForBacklog(const BufferIdList &bufferIds);
 
 signals:
-  void messagesReceived(BufferId bufferId, int count) const;
-  void messagesRequested(const QString &) const;
-  void messagesProcessed(const QString &) const;
+    void messagesReceived(BufferId bufferId, int count) const;
+    void messagesRequested(const QString &) const;
+    void messagesProcessed(const QString &) const;
 
-  void updateProgress(int, int);
+    void updateProgress(int, int);
 
 private:
-  bool isBuffering();
-  BufferIdList filterNewBufferIds(const BufferIdList &bufferIds);
+    bool isBuffering();
+    BufferIdList filterNewBufferIds(const BufferIdList &bufferIds);
 
-  void dispatchMessages(const MessageList &messages, bool sort = false);
+    void dispatchMessages(const MessageList &messages, bool sort = false);
 
-  BacklogRequester *_requester;
-  bool _initBacklogRequested;
-  QSet<BufferId> _buffersRequested;
+    BacklogRequester *_requester;
+    bool _initBacklogRequested;
+    QSet<BufferId> _buffersRequested;
 };
 
+
 // inlines
-inline void ClientBacklogManager::checkForBacklog(BufferId bufferId) {
-  checkForBacklog(BufferIdList() << bufferId);
+inline void ClientBacklogManager::checkForBacklog(BufferId bufferId)
+{
+    checkForBacklog(BufferIdList() << bufferId);
 }
 
+
 #endif // CLIENTBACKLOGMANAGER_H
index 1e7f816..90771a6 100644 (file)
 
 INIT_SYNCABLE_OBJECT(ClientBufferViewConfig)
 ClientBufferViewConfig::ClientBufferViewConfig(int bufferViewId, QObject *parent)
-  : BufferViewConfig(bufferViewId, parent),
+    : BufferViewConfig(bufferViewId, parent),
     _locked(false)
 {
-  connect(this, SIGNAL(initDone()), this, SLOT(ensureDecoration()));
+    connect(this, SIGNAL(initDone()), this, SLOT(ensureDecoration()));
 }
 
+
 // currently we don't have a possibility to configure disableDecoration
 // if we have an old config this value can be true which is... bad.
 // so we upgrade the core stored bufferViewConfig.
 // This can be removed with the next release
-void ClientBufferViewConfig::ensureDecoration() {
-  if(!disableDecoration())
-    return;
-  setDisableDecoration(false);
-  requestUpdate(toVariantMap());
+void ClientBufferViewConfig::ensureDecoration()
+{
+    if (!disableDecoration())
+        return;
+    setDisableDecoration(false);
+    requestUpdate(toVariantMap());
 }
index 5f6c0ed..faf3783 100644 (file)
 
 #include "bufferviewconfig.h"
 
-class ClientBufferViewConfig : public BufferViewConfig {
-  SYNCABLE_OBJECT
-  Q_OBJECT
+class ClientBufferViewConfig : public BufferViewConfig
+{
+    SYNCABLE_OBJECT
+        Q_OBJECT
 
 public:
-  ClientBufferViewConfig(int bufferViewId, QObject *parent = 0);
+    ClientBufferViewConfig(int bufferViewId, QObject *parent = 0);
 
-  inline bool isLocked() { return _locked || sortAlphabetically(); }
-  inline void setLocked(bool locked) { _locked = locked; }
-  inline void lock() { setLocked(true); };
-  inline void unlock() { setLocked(false); };
+    inline bool isLocked() { return _locked || sortAlphabetically(); }
+    inline void setLocked(bool locked) { _locked = locked; }
+    inline void lock() { setLocked(true); };
+    inline void unlock() { setLocked(false); };
 
 private slots:
-  void ensureDecoration(); // remove this in next release
+    void ensureDecoration(); // remove this in next release
 
 private:
-  bool _locked;
+    bool _locked;
 };
 
+
 #endif //CLIENTBUFFERVIEWCONFIG_H
index 504604f..36443c2 100644 (file)
 
 INIT_SYNCABLE_OBJECT(ClientBufferViewManager)
 ClientBufferViewManager::ClientBufferViewManager(SignalProxy *proxy, QObject *parent)
-  : BufferViewManager(proxy, parent)
+    : BufferViewManager(proxy, parent)
 {
 }
 
-BufferViewConfig *ClientBufferViewManager::bufferViewConfigFactory(int bufferViewConfigId) {
-  return new ClientBufferViewConfig(bufferViewConfigId, this);
+
+BufferViewConfig *ClientBufferViewManager::bufferViewConfigFactory(int bufferViewConfigId)
+{
+    return new ClientBufferViewConfig(bufferViewConfigId, this);
 }
 
-QList<ClientBufferViewConfig *> ClientBufferViewManager::clientBufferViewConfigs() const {
-  QList<ClientBufferViewConfig *> clientConfigs;
-  foreach(BufferViewConfig *config, bufferViewConfigs()) {
-    clientConfigs << static_cast<ClientBufferViewConfig *>(config);
-  }
-  return clientConfigs;
+
+QList<ClientBufferViewConfig *> ClientBufferViewManager::clientBufferViewConfigs() const
+{
+    QList<ClientBufferViewConfig *> clientConfigs;
+    foreach(BufferViewConfig *config, bufferViewConfigs()) {
+        clientConfigs << static_cast<ClientBufferViewConfig *>(config);
+    }
+    return clientConfigs;
 }
 
-ClientBufferViewConfig *ClientBufferViewManager::clientBufferViewConfig(int bufferViewId) const {
-  return static_cast<ClientBufferViewConfig *>(bufferViewConfig(bufferViewId));
+
+ClientBufferViewConfig *ClientBufferViewManager::clientBufferViewConfig(int bufferViewId) const
+{
+    return static_cast<ClientBufferViewConfig *>(bufferViewConfig(bufferViewId));
 }
 
-void ClientBufferViewManager::setInitialized() {
-  if(bufferViewConfigs().isEmpty()) {
-    BufferViewConfig config(-1);
-    config.setBufferViewName(tr("All Chats"));
-    config.initSetBufferList(Client::networkModel()->allBufferIdsSorted());
-    requestCreateBufferView(config.toVariantMap());
-  }
-  BufferViewManager::setInitialized();
+
+void ClientBufferViewManager::setInitialized()
+{
+    if (bufferViewConfigs().isEmpty()) {
+        BufferViewConfig config(-1);
+        config.setBufferViewName(tr("All Chats"));
+        config.initSetBufferList(Client::networkModel()->allBufferIdsSorted());
+        requestCreateBufferView(config.toVariantMap());
+    }
+    BufferViewManager::setInitialized();
 }
index a413a8f..17a10c8 100644 (file)
 class ClientBufferViewConfig;
 class BufferViewOverlay;
 
-class ClientBufferViewManager : public BufferViewManager {
-  SYNCABLE_OBJECT
-  Q_OBJECT
+class ClientBufferViewManager : public BufferViewManager
+{
+    SYNCABLE_OBJECT
+        Q_OBJECT
 
 public:
-  ClientBufferViewManager(SignalProxy *proxy, QObject *parent = 0);
+    ClientBufferViewManager(SignalProxy *proxy, QObject *parent = 0);
 
-  QList<ClientBufferViewConfig *> clientBufferViewConfigs() const;
-  ClientBufferViewConfig *clientBufferViewConfig(int bufferViewId) const;
+    QList<ClientBufferViewConfig *> clientBufferViewConfigs() const;
+    ClientBufferViewConfig *clientBufferViewConfig(int bufferViewId) const;
 
 public slots:
-  virtual void setInitialized();
+    virtual void setInitialized();
 
 protected:
-  virtual BufferViewConfig *bufferViewConfigFactory(int bufferViewConfigId);
+    virtual BufferViewConfig *bufferViewConfigFactory(int bufferViewConfigId);
 };
 
+
 #endif //CLIENTBUFFERVIEWMANAGER_H
index 3bd08a4..e32ba97 100644 (file)
 /*
  * Yes this name is somewhat stupid... but it fits the general naming scheme
  * which is prefixing client specific sync objects with "Client"... ;)
- */ 
-class ClientCoreInfo : public CoreInfo {
-  Q_OBJECT
-  SYNCABLE_OBJECT
+ */
+class ClientCoreInfo : public CoreInfo
+{
+    Q_OBJECT
+        SYNCABLE_OBJECT
 
 public:
-  ClientCoreInfo(QObject *parent = 0) : CoreInfo(parent) {}
+    ClientCoreInfo(QObject *parent = 0) : CoreInfo(parent) {}
 
-  inline virtual const QMetaObject *syncMetaObject() const { return &CoreInfo::staticMetaObject; }
+    inline virtual const QMetaObject *syncMetaObject() const { return &CoreInfo::staticMetaObject; }
 
-  inline QVariant &operator[](const QString &key) { return _coreData[key]; }
+    inline QVariant &operator[](const QString &key) { return _coreData[key]; }
 
 public slots:
-  inline virtual void setCoreData(const QVariantMap &data) { _coreData = data; }
+    inline virtual void setCoreData(const QVariantMap &data) { _coreData = data; }
 
 private:
-  QVariantMap _coreData;
+    QVariantMap _coreData;
 };
 
+
 #endif //CLIENTCOREINFO_H
index af3541c..cb34e26 100644 (file)
 
 INIT_SYNCABLE_OBJECT(CertIdentity)
 CertIdentity::CertIdentity(IdentityId id, QObject *parent)
-  : Identity(id, parent)
+    : Identity(id, parent)
 #ifdef HAVE_SSL
-  ,  _certManager(0),
+    ,  _certManager(0),
     _isDirty(false)
 #endif
 {
 }
 
+
 CertIdentity::CertIdentity(const Identity &other, QObject *parent)
-  : Identity(other, parent)
+    : Identity(other, parent)
 #ifdef HAVE_SSL
-  , _certManager(0),
+    , _certManager(0),
     _isDirty(false)
 #endif
 {
 }
 
+
 CertIdentity::CertIdentity(const CertIdentity &other, QObject *parent)
-  : Identity(other, parent)
+    : Identity(other, parent)
 #ifdef HAVE_SSL
-  , _certManager(0),
+    , _certManager(0),
     _isDirty(other._isDirty),
     _sslKey(other._sslKey),
     _sslCert(other._sslCert)
@@ -53,57 +55,71 @@ CertIdentity::CertIdentity(const CertIdentity &other, QObject *parent)
 {
 }
 
+
 #ifdef HAVE_SSL
-void CertIdentity::enableEditSsl(bool enable) {
-  if(!enable || _certManager)
-    return;
-
-  _certManager = new ClientCertManager(id(), this);
-  if(isValid()) { // this means we are not a newly created Identity but have a proper Id
-    Client::signalProxy()->synchronize(_certManager);
-    connect(_certManager, SIGNAL(updated()), this, SLOT(markClean()));
-    connect(_certManager, SIGNAL(initDone()), this, SLOT(markClean()));
-  }
+void CertIdentity::enableEditSsl(bool enable)
+{
+    if (!enable || _certManager)
+        return;
+
+    _certManager = new ClientCertManager(id(), this);
+    if (isValid()) { // this means we are not a newly created Identity but have a proper Id
+        Client::signalProxy()->synchronize(_certManager);
+        connect(_certManager, SIGNAL(updated()), this, SLOT(markClean()));
+        connect(_certManager, SIGNAL(initDone()), this, SLOT(markClean()));
+    }
 }
 
-void CertIdentity::setSslKey(const QSslKey &key) {
-  if(key.toPem() == _sslKey.toPem())
-    return;
-  _sslKey = key;
-  _isDirty = true;
+
+void CertIdentity::setSslKey(const QSslKey &key)
+{
+    if (key.toPem() == _sslKey.toPem())
+        return;
+    _sslKey = key;
+    _isDirty = true;
 }
 
-void CertIdentity::setSslCert(const QSslCertificate &cert) {
-  if(cert.toPem() == _sslCert.toPem())
-    return;
-  _sslCert = cert;
-  _isDirty = true;
+
+void CertIdentity::setSslCert(const QSslCertificate &cert)
+{
+    if (cert.toPem() == _sslCert.toPem())
+        return;
+    _sslCert = cert;
+    _isDirty = true;
 }
 
-void CertIdentity::requestUpdateSslSettings() {
-  if(!_certManager)
-    return;
 
-  _certManager->requestUpdate(_certManager->toVariantMap());
+void CertIdentity::requestUpdateSslSettings()
+{
+    if (!_certManager)
+        return;
+
+    _certManager->requestUpdate(_certManager->toVariantMap());
 }
 
-void CertIdentity::markClean() {
-  _isDirty = false;
-  emit sslSettingsUpdated();
+
+void CertIdentity::markClean()
+{
+    _isDirty = false;
+    emit sslSettingsUpdated();
 }
 
+
 // ========================================
 //  ClientCertManager
 // ========================================
-void ClientCertManager::setSslKey(const QByteArray &encoded) {
-  QSslKey key(encoded, QSsl::Rsa);
-  if(key.isNull())
-    key = QSslKey(encoded, QSsl::Dsa);
-  _certIdentity->setSslKey(key);
+void ClientCertManager::setSslKey(const QByteArray &encoded)
+{
+    QSslKey key(encoded, QSsl::Rsa);
+    if (key.isNull())
+        key = QSslKey(encoded, QSsl::Dsa);
+    _certIdentity->setSslKey(key);
 }
 
-void ClientCertManager::setSslCert(const QByteArray &encoded) {
-  _certIdentity->setSslCert(QSslCertificate(encoded));
+
+void ClientCertManager::setSslCert(const QByteArray &encoded)
+{
+    _certIdentity->setSslCert(QSslCertificate(encoded));
 }
 
 
index 730b662..5ccaf92 100644 (file)
 
 class ClientCertManager;
 
-class CertIdentity : public Identity {
-  SYNCABLE_OBJECT
-  Q_OBJECT
+class CertIdentity : public Identity
+{
+    SYNCABLE_OBJECT
+        Q_OBJECT
 
 public:
-  CertIdentity(IdentityId id = 0, QObject *parent = 0);
-  CertIdentity(const Identity &other, QObject *parent = 0);
-  CertIdentity(const CertIdentity &other, QObject *parent = 0);
+    CertIdentity(IdentityId id = 0, QObject *parent = 0);
+    CertIdentity(const Identity &other, QObject *parent = 0);
+    CertIdentity(const CertIdentity &other, QObject *parent = 0);
 
 #ifdef HAVE_SSL
-  inline bool isDirty() const { return _isDirty; }
+    inline bool isDirty() const { return _isDirty; }
 #else
-  inline bool isDirty() const { return false; }
+    inline bool isDirty() const { return false; }
 #endif
 
 #ifdef HAVE_SSL
-  void enableEditSsl(bool enable = true);
-  inline const QSslKey &sslKey() const { return _sslKey; }
-  inline const QSslCertificate &sslCert() const { return _sslCert; }
+    void enableEditSsl(bool enable = true);
+    inline const QSslKey &sslKey() const { return _sslKey; }
+    inline const QSslCertificate &sslCert() const { return _sslCert; }
 
-  void setSslKey(const QSslKey &key);
-  void setSslCert(const QSslCertificate &cert);
+    void setSslKey(const QSslKey &key);
+    void setSslCert(const QSslCertificate &cert);
 
 public slots:
-  void requestUpdateSslSettings();
+    void requestUpdateSslSettings();
 
 signals:
-  void sslSettingsUpdated();
+    void sslSettingsUpdated();
 
 private slots:
-  void markClean();
+    void markClean();
 
 private:
-  ClientCertManager *_certManager;
-  bool _isDirty;
-  QSslKey _sslKey;
-  QSslCertificate _sslCert;
+    ClientCertManager *_certManager;
+    bool _isDirty;
+    QSslKey _sslKey;
+    QSslCertificate _sslCert;
 #endif //HAVE_SSL
 };
 
+
 // ========================================
 //  ClientCertManager
 // ========================================
 #ifdef HAVE_SSL
-class ClientCertManager : public CertManager {
-  Q_OBJECT
+class ClientCertManager : public CertManager
+{
+    Q_OBJECT
 
 public:
-  ClientCertManager(IdentityId id, CertIdentity *parent) : CertManager(id, parent), _certIdentity(parent) {}
+    ClientCertManager(IdentityId id, CertIdentity *parent) : CertManager(id, parent), _certIdentity(parent) {}
 
-  virtual inline const QSslKey &sslKey() const { return _certIdentity->sslKey(); }
-  virtual inline const QSslCertificate &sslCert() const { return _certIdentity->sslCert(); }
+    virtual inline const QSslKey &sslKey() const { return _certIdentity->sslKey(); }
+    virtual inline const QSslCertificate &sslCert() const { return _certIdentity->sslCert(); }
 
 public slots:
-  virtual void setSslKey(const QByteArray &encoded);
-  virtual void setSslCert(const QByteArray &encoded);
+    virtual void setSslKey(const QByteArray &encoded);
+    virtual void setSslCert(const QByteArray &encoded);
 
 private:
-  CertIdentity *_certIdentity;
+    CertIdentity *_certIdentity;
 };
+
+
 #endif //HAVE_SSL
 
 #endif //CLIENTIDENTITY_H
index f146313..8e91229 100644 (file)
@@ -27,31 +27,34 @@ INIT_SYNCABLE_OBJECT(ClientIgnoreListManager)
 ClientIgnoreListManager::ClientIgnoreListManager(QObject *parent)
     : IgnoreListManager(parent)
 {
-  connect(this, SIGNAL(updatedRemotely()), SIGNAL(ignoreListChanged()));
+    connect(this, SIGNAL(updatedRemotely()), SIGNAL(ignoreListChanged()));
 }
 
-bool ClientIgnoreListManager::pureMatch(const IgnoreListItem &item, const QString &string) const {
-  QRegExp ruleRx = QRegExp(item.ignoreRule);
-  ruleRx.setCaseSensitivity(Qt::CaseInsensitive);
-  if(!item.isRegEx)
-    ruleRx.setPatternSyntax(QRegExp::Wildcard);
 
-  if((!item.isRegEx && ruleRx.exactMatch(string)) ||
-     (item.isRegEx && ruleRx.indexIn(string) != -1))
-    return true;
-  return false;
+bool ClientIgnoreListManager::pureMatch(const IgnoreListItem &item, const QString &string) const
+{
+    QRegExp ruleRx = QRegExp(item.ignoreRule);
+    ruleRx.setCaseSensitivity(Qt::CaseInsensitive);
+    if (!item.isRegEx)
+        ruleRx.setPatternSyntax(QRegExp::Wildcard);
+
+    if ((!item.isRegEx && ruleRx.exactMatch(string)) ||
+        (item.isRegEx && ruleRx.indexIn(string) != -1))
+        return true;
+    return false;
 }
 
-QMap<QString, bool> ClientIgnoreListManager::matchingRulesForHostmask(const QString &hostmask, const QString &network, const QString &channel) const {
-  QMap<QString, bool> result;
-  foreach(IgnoreListItem item, ignoreList()) {
-    if(item.type == SenderIgnore && pureMatch(item, hostmask)
-      && ((network.isEmpty() && channel.isEmpty()) || item.scope == GlobalScope || (item.scope == NetworkScope && scopeMatch(item.scopeRule, network))
-          || (item.scope == ChannelScope && scopeMatch(item.scopeRule, channel)))) {
-      result[item.ignoreRule] = item.isActive;
+
+QMap<QString, bool> ClientIgnoreListManager::matchingRulesForHostmask(const QString &hostmask, const QString &network, const QString &channel) const
+{
+    QMap<QString, bool> result;
+    foreach(IgnoreListItem item, ignoreList()) {
+        if (item.type == SenderIgnore && pureMatch(item, hostmask)
+            && ((network.isEmpty() && channel.isEmpty()) || item.scope == GlobalScope || (item.scope == NetworkScope && scopeMatch(item.scopeRule, network))
+                || (item.scope == ChannelScope && scopeMatch(item.scopeRule, channel)))) {
+            result[item.ignoreRule] = item.isActive;
 //      qDebug() << "matchingRulesForHostmask found: " << item.ignoreRule << "is active: " << item.isActive;
+        }
     }
-
-  }
-  return result;
+    return result;
 }
index 51f0203..9692b83 100644 (file)
 
 class ClientIgnoreListManager : public IgnoreListManager
 {
-  SYNCABLE_OBJECT
-  Q_OBJECT
+    SYNCABLE_OBJECT
+        Q_OBJECT
 
 public:
-  explicit ClientIgnoreListManager(QObject *parent = 0);
-  inline virtual const QMetaObject *syncMetaObject() const { return &IgnoreListManager::staticMetaObject; }
+    explicit ClientIgnoreListManager(QObject *parent = 0);
+    inline virtual const QMetaObject *syncMetaObject() const { return &IgnoreListManager::staticMetaObject; }
 
-  //! Fetch all matching ignore rules for a given hostmask
-  /** \param hostmask The hostmask of the user
-    * \param network The network name
-    * \param channel The channel name
-    * \return Returns a QMap with the rule as key and a bool, representing if the rule is enabled or not, as value
-    */
-  QMap<QString, bool> matchingRulesForHostmask(const QString &hostmask, const QString &network, const QString &channel) const;
+    //! Fetch all matching ignore rules for a given hostmask
+    /** \param hostmask The hostmask of the user
+      * \param network The network name
+      * \param channel The channel name
+      * \return Returns a QMap with the rule as key and a bool, representing if the rule is enabled or not, as value
+      */
+    QMap<QString, bool> matchingRulesForHostmask(const QString &hostmask, const QString &network, const QString &channel) const;
 
 signals:
-  void ignoreListChanged();
+    void ignoreListChanged();
 
 private:
-  // matches an ignore rule against a given string
-  bool pureMatch(const IgnoreListItem &item, const QString &string) const;
+    // matches an ignore rule against a given string
+    bool pureMatch(const IgnoreListItem &item, const QString &string) const;
 };
 
+
 #endif // CLIENTIGNORELISTMANAGER_H
index fd52b9a..2426e8e 100644 (file)
 #include "irclistmodel.h"
 
 INIT_SYNCABLE_OBJECT(ClientIrcListHelper)
-QVariantList ClientIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters) {
-  _netId = netId;
-  return IrcListHelper::requestChannelList(netId, channelFilters);
+QVariantList ClientIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters)
+{
+    _netId = netId;
+    return IrcListHelper::requestChannelList(netId, channelFilters);
 }
 
-void ClientIrcListHelper::receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QVariantList &channels) {
-  QVariantList::const_iterator iter = channels.constBegin();
-  QVariantList::const_iterator iterEnd = channels.constEnd();
 
-  QList<ChannelDescription> channelList;
-  while(iter != iterEnd) {
-    QVariantList channelVar = iter->toList();
-    ChannelDescription channelDescription(channelVar[0].toString(), channelVar[1].toUInt(), channelVar[2].toString());
-    channelList << channelDescription;
-    iter++;
-  }
+void ClientIrcListHelper::receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QVariantList &channels)
+{
+    QVariantList::const_iterator iter = channels.constBegin();
+    QVariantList::const_iterator iterEnd = channels.constEnd();
 
-  emit channelListReceived(netId, channelFilters, channelList);
-}
+    QList<ChannelDescription> channelList;
+    while (iter != iterEnd) {
+        QVariantList channelVar = iter->toList();
+        ChannelDescription channelDescription(channelVar[0].toString(), channelVar[1].toUInt(), channelVar[2].toString());
+        channelList << channelDescription;
+        iter++;
+    }
 
-void ClientIrcListHelper::reportFinishedList(const NetworkId &netId) {
-  if(_netId == netId) {
-    requestChannelList(netId, QStringList());
-    emit finishedListReported(netId);
-  }
+    emit channelListReceived(netId, channelFilters, channelList);
 }
 
+
+void ClientIrcListHelper::reportFinishedList(const NetworkId &netId)
+{
+    if (_netId == netId) {
+        requestChannelList(netId, QStringList());
+        emit finishedListReported(netId);
+    }
+}
index 3cc5b7b..47592c0 100644 (file)
 
 #include "irclisthelper.h"
 
-class ClientIrcListHelper : public IrcListHelper {
-  SYNCABLE_OBJECT
-  Q_OBJECT
+class ClientIrcListHelper : public IrcListHelper
+{
+    SYNCABLE_OBJECT
+        Q_OBJECT
 
 public:
-  inline ClientIrcListHelper(QObject *object = 0) : IrcListHelper(object) {};
+    inline ClientIrcListHelper(QObject *object = 0) : IrcListHelper(object) {};
 
-  inline virtual const QMetaObject *syncMetaObject() const { return &IrcListHelper::staticMetaObject; }
+    inline virtual const QMetaObject *syncMetaObject() const { return &IrcListHelper::staticMetaObject; }
 
 public slots:
-  virtual QVariantList requestChannelList(const NetworkId &netId, const QStringList &channelFilters);
-  virtual void receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QVariantList &channels);
-  virtual void reportFinishedList(const NetworkId &netId);
-  inline virtual void reportError(const QString &error) { emit errorReported(error); }
+    virtual QVariantList requestChannelList(const NetworkId &netId, const QStringList &channelFilters);
+    virtual void receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QVariantList &channels);
+    virtual void reportFinishedList(const NetworkId &netId);
+    inline virtual void reportError(const QString &error) { emit errorReported(error); }
 
 signals:
-  void channelListReceived(const NetworkId &netId, const QStringList &channelFilters, const QList<IrcListHelper::ChannelDescription> &channelList);
-  void finishedListReported(const NetworkId &netId);
-  void errorReported(const QString &error);
+    void channelListReceived(const NetworkId &netId, const QStringList &channelFilters, const QList<IrcListHelper::ChannelDescription> &channelList);
+    void finishedListReported(const NetworkId &netId);
+    void errorReported(const QString &error);
 
 private:
-  NetworkId _netId;
+    NetworkId _netId;
 };
 
+
 #endif //CLIENTIRCLISTHELPER_H
index 045c8e4..72fe369 100644 (file)
@@ -20,7 +20,6 @@
 
 #include <QStringList>
 
-
 #include "clientsettings.h"
 
 #include <QHostAddress>
 #include <QSslSocket>
 #endif
 
-
 #include "client.h"
 #include "quassel.h"
 
-ClientSettings::ClientSettings(QString g) : Settings(g, Quassel::buildInfo().clientApplicationName) {
+ClientSettings::ClientSettings(QString g) : Settings(g, Quassel::buildInfo().clientApplicationName)
+{
 }
 
-ClientSettings::~ClientSettings() {
+
+ClientSettings::~ClientSettings()
+{
 }
 
+
 /***********************************************************************************************/
 
 CoreAccountSettings::CoreAccountSettings(const QString &subgroup)
-  : ClientSettings("CoreAccounts"),
+    : ClientSettings("CoreAccounts"),
     _subgroup(subgroup)
 {
 }
 
-void CoreAccountSettings::notify(const QString &key, QObject *receiver, const char *slot) {
-  ClientSettings::notify(QString("%1/%2/%3").arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key), receiver, slot);
-}
 
-QList<AccountId> CoreAccountSettings::knownAccounts() {
-  QList<AccountId> ids;
-  foreach(const QString &key, localChildGroups()) {
-    AccountId acc = key.toInt();
-    if(acc.isValid())
-      ids << acc;
-  }
-  return ids;
+void CoreAccountSettings::notify(const QString &key, QObject *receiver, const char *slot)
+{
+    ClientSettings::notify(QString("%1/%2/%3").arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key), receiver, slot);
 }
 
-AccountId CoreAccountSettings::lastAccount() {
-  return localValue("LastAccount", 0).toInt();
-}
 
-void CoreAccountSettings::setLastAccount(AccountId account) {
-  setLocalValue("LastAccount", account.toInt());
+QList<AccountId> CoreAccountSettings::knownAccounts()
+{
+    QList<AccountId> ids;
+    foreach(const QString &key, localChildGroups()) {
+        AccountId acc = key.toInt();
+        if (acc.isValid())
+            ids << acc;
+    }
+    return ids;
 }
 
-AccountId CoreAccountSettings::autoConnectAccount() {
-  return localValue("AutoConnectAccount", 0).toInt();
+
+AccountId CoreAccountSettings::lastAccount()
+{
+    return localValue("LastAccount", 0).toInt();
 }
 
-void CoreAccountSettings::setAutoConnectAccount(AccountId account) {
-  setLocalValue("AutoConnectAccount", account.toInt());
+
+void CoreAccountSettings::setLastAccount(AccountId account)
+{
+    setLocalValue("LastAccount", account.toInt());
 }
 
-bool CoreAccountSettings::autoConnectOnStartup() {
-  return localValue("AutoConnectOnStartup", false).toBool();
+
+AccountId CoreAccountSettings::autoConnectAccount()
+{
+    return localValue("AutoConnectAccount", 0).toInt();
 }
 
-void CoreAccountSettings::setAutoConnectOnStartup(bool b) {
-  setLocalValue("AutoConnectOnStartup", b);
+
+void CoreAccountSettings::setAutoConnectAccount(AccountId account)
+{
+    setLocalValue("AutoConnectAccount", account.toInt());
 }
 
-bool CoreAccountSettings::autoConnectToFixedAccount() {
-  return localValue("AutoConnectToFixedAccount", false).toBool();
+
+bool CoreAccountSettings::autoConnectOnStartup()
+{
+    return localValue("AutoConnectOnStartup", false).toBool();
 }
 
-void CoreAccountSettings::setAutoConnectToFixedAccount(bool b) {
-  setLocalValue("AutoConnectToFixedAccount", b);
+
+void CoreAccountSettings::setAutoConnectOnStartup(bool b)
+{
+    setLocalValue("AutoConnectOnStartup", b);
 }
 
-void CoreAccountSettings::storeAccountData(AccountId id, const QVariantMap &data) {
-  QString base = QString::number(id.toInt());
-  foreach(const QString &key, data.keys()) {
-    setLocalValue(base + "/" + key, data.value(key));
-  }
 
-  // FIXME Migration from 0.5 -> 0.6
-  removeLocalKey(QString("%1/Connection").arg(base));
+bool CoreAccountSettings::autoConnectToFixedAccount()
+{
+    return localValue("AutoConnectToFixedAccount", false).toBool();
 }
 
-QVariantMap CoreAccountSettings::retrieveAccountData(AccountId id) {
-  QVariantMap map;
-  QString base = QString::number(id.toInt());
-  foreach(const QString &key, localChildKeys(base)) {
-    map[key] = localValue(base + "/" + key);
-  }
 
-  // FIXME Migration from 0.5 -> 0.6
-  if(!map.contains("Uuid") && map.contains("Connection")) {
-    QVariantMap oldmap = map.value("Connection").toMap();
-    map["AccountName"] = oldmap.value("AccountName");
-    map["HostName"] = oldmap.value("Host");
-    map["Port"] = oldmap.value("Port");
-    map["User"] = oldmap.value("User");
-    map["Password"] = oldmap.value("Password");
-    map["StorePassword"] = oldmap.value("RememberPasswd");
-    map["UseSSL"] = oldmap.value("useSsl");
-    map["UseProxy"] = oldmap.value("useProxy");
-    map["ProxyHostName"] = oldmap.value("proxyHost");
-    map["ProxyPort"] = oldmap.value("proxyPort");
-    map["ProxyUser"] = oldmap.value("proxyUser");
-    map["ProxyPassword"] = oldmap.value("proxyPassword");
-    map["ProxyType"] = oldmap.value("proxyType");
-    map["Internal"] = oldmap.value("InternalAccount");
+void CoreAccountSettings::setAutoConnectToFixedAccount(bool b)
+{
+    setLocalValue("AutoConnectToFixedAccount", b);
+}
+
 
-    map["AccountId"] = id.toInt();
-    map["Uuid"] = QUuid::createUuid().toString();
-  }
+void CoreAccountSettings::storeAccountData(AccountId id, const QVariantMap &data)
+{
+    QString base = QString::number(id.toInt());
+    foreach(const QString &key, data.keys()) {
+        setLocalValue(base + "/" + key, data.value(key));
+    }
 
-  return map;
+    // FIXME Migration from 0.5 -> 0.6
+    removeLocalKey(QString("%1/Connection").arg(base));
 }
 
-void CoreAccountSettings::setAccountValue(const QString &key, const QVariant &value) {
-  if(!Client::currentCoreAccount().isValid())
-    return;
-  setLocalValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key), value);
+
+QVariantMap CoreAccountSettings::retrieveAccountData(AccountId id)
+{
+    QVariantMap map;
+    QString base = QString::number(id.toInt());
+    foreach(const QString &key, localChildKeys(base)) {
+        map[key] = localValue(base + "/" + key);
+    }
+
+    // FIXME Migration from 0.5 -> 0.6
+    if (!map.contains("Uuid") && map.contains("Connection")) {
+        QVariantMap oldmap = map.value("Connection").toMap();
+        map["AccountName"] = oldmap.value("AccountName");
+        map["HostName"] = oldmap.value("Host");
+        map["Port"] = oldmap.value("Port");
+        map["User"] = oldmap.value("User");
+        map["Password"] = oldmap.value("Password");
+        map["StorePassword"] = oldmap.value("RememberPasswd");
+        map["UseSSL"] = oldmap.value("useSsl");
+        map["UseProxy"] = oldmap.value("useProxy");
+        map["ProxyHostName"] = oldmap.value("proxyHost");
+        map["ProxyPort"] = oldmap.value("proxyPort");
+        map["ProxyUser"] = oldmap.value("proxyUser");
+        map["ProxyPassword"] = oldmap.value("proxyPassword");
+        map["ProxyType"] = oldmap.value("proxyType");
+        map["Internal"] = oldmap.value("InternalAccount");
+
+        map["AccountId"] = id.toInt();
+        map["Uuid"] = QUuid::createUuid().toString();
+    }
+
+    return map;
+}
+
+
+void CoreAccountSettings::setAccountValue(const QString &key, const QVariant &value)
+{
+    if (!Client::currentCoreAccount().isValid())
+        return;
+    setLocalValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key), value);
 }
 
-QVariant CoreAccountSettings::accountValue(const QString &key, const QVariant &def) {
-  if(!Client::currentCoreAccount().isValid())
-    return QVariant();
-  return localValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key), def);
+
+QVariant CoreAccountSettings::accountValue(const QString &key, const QVariant &def)
+{
+    if (!Client::currentCoreAccount().isValid())
+        return QVariant();
+    return localValue(QString("%1/%2/%3").arg(Client::currentCoreAccount().accountId().toInt()).arg(_subgroup).arg(key), def);
 }
 
-void CoreAccountSettings::setJumpKeyMap(const QHash<int, BufferId> &keyMap) {
-  QVariantMap variants;
-  QHash<int, BufferId>::const_iterator mapIter = keyMap.constBegin();
-  while(mapIter != keyMap.constEnd()) {
-    variants[QString::number(mapIter.key())] = qVariantFromValue(mapIter.value());
-    ++mapIter;
-  }
-  setAccountValue("JumpKeyMap", variants);
+
+void CoreAccountSettings::setJumpKeyMap(const QHash<int, BufferId> &keyMap)
+{
+    QVariantMap variants;
+    QHash<int, BufferId>::const_iterator mapIter = keyMap.constBegin();
+    while (mapIter != keyMap.constEnd()) {
+        variants[QString::number(mapIter.key())] = qVariantFromValue(mapIter.value());
+        ++mapIter;
+    }
+    setAccountValue("JumpKeyMap", variants);
 }
 
-QHash<int, BufferId> CoreAccountSettings::jumpKeyMap() {
-  QHash<int, BufferId> keyMap;
-  QVariantMap variants = accountValue("JumpKeyMap", QVariant()).toMap();
-  QVariantMap::const_iterator mapIter = variants.constBegin();
-  while(mapIter != variants.constEnd()) {
-    keyMap[mapIter.key().toInt()] = mapIter.value().value<BufferId>();
-    ++mapIter;
-  }
-  return keyMap;
+
+QHash<int, BufferId> CoreAccountSettings::jumpKeyMap()
+{
+    QHash<int, BufferId> keyMap;
+    QVariantMap variants = accountValue("JumpKeyMap", QVariant()).toMap();
+    QVariantMap::const_iterator mapIter = variants.constBegin();
+    while (mapIter != variants.constEnd()) {
+        keyMap[mapIter.key().toInt()] = mapIter.value().value<BufferId>();
+        ++mapIter;
+    }
+    return keyMap;
 }
 
-void CoreAccountSettings::setBufferViewOverlay(const QSet<int> &viewIds) {
-  QVariantList variants;
-  foreach(int viewId, viewIds) {
-    variants << qVariantFromValue(viewId);
-  }
-  setAccountValue("BufferViewOverlay", variants);
+
+void CoreAccountSettings::setBufferViewOverlay(const QSet<int> &viewIds)
+{
+    QVariantList variants;
+    foreach(int viewId, viewIds) {
+        variants << qVariantFromValue(viewId);
+    }
+    setAccountValue("BufferViewOverlay", variants);
 }
 
-QSet<int> CoreAccountSettings::bufferViewOverlay() {
-  QSet<int> viewIds;
-  QVariantList variants = accountValue("BufferViewOverlay").toList();
-  for(QVariantList::const_iterator iter = variants.constBegin(); iter != variants.constEnd(); iter++) {
-    viewIds << iter->toInt();
-  }
-  return viewIds;
+
+QSet<int> CoreAccountSettings::bufferViewOverlay()
+{
+    QSet<int> viewIds;
+    QVariantList variants = accountValue("BufferViewOverlay").toList();
+    for (QVariantList::const_iterator iter = variants.constBegin(); iter != variants.constEnd(); iter++) {
+        viewIds << iter->toInt();
+    }
+    return viewIds;
 }
 
-void CoreAccountSettings::removeAccount(AccountId id) {
-  removeLocalKey(QString("%1").arg(id.toInt()));
+
+void CoreAccountSettings::removeAccount(AccountId id)
+{
+    removeLocalKey(QString("%1").arg(id.toInt()));
 }
 
-void CoreAccountSettings::clearAccounts() {
-  foreach(const QString &key, localChildGroups())
+
+void CoreAccountSettings::clearAccounts()
+{
+    foreach(const QString &key, localChildGroups())
     removeLocalKey(key);
 }
 
+
 /***********************************************************************************************/
 // CoreConnectionSettings:
 
 CoreConnectionSettings::CoreConnectionSettings() : ClientSettings("CoreConnection") {}
 
-void CoreConnectionSettings::setNetworkDetectionMode(NetworkDetectionMode mode) {
-  setLocalValue("NetworkDetectionMode", mode);
+void CoreConnectionSettings::setNetworkDetectionMode(NetworkDetectionMode mode)
+{
+    setLocalValue("NetworkDetectionMode", mode);
 }
 
-CoreConnectionSettings::NetworkDetectionMode CoreConnectionSettings::networkDetectionMode() {
+
+CoreConnectionSettings::NetworkDetectionMode CoreConnectionSettings::networkDetectionMode()
+{
 #ifdef HAVE_KDE
-  NetworkDetectionMode def = UseSolid;
+    NetworkDetectionMode def = UseSolid;
 #else
-  NetworkDetectionMode def = UsePingTimeout;
+    NetworkDetectionMode def = UsePingTimeout;
 #endif
-  return (NetworkDetectionMode)localValue("NetworkDetectionMode", def).toInt();
+    return (NetworkDetectionMode)localValue("NetworkDetectionMode", def).toInt();
 }
 
-void CoreConnectionSettings::setAutoReconnect(bool autoReconnect) {
-  setLocalValue("AutoReconnect", autoReconnect);
+
+void CoreConnectionSettings::setAutoReconnect(bool autoReconnect)
+{
+    setLocalValue("AutoReconnect", autoReconnect);
 }
 
-bool CoreConnectionSettings::autoReconnect() {
-  return localValue("AutoReconnect", true).toBool();
+
+bool CoreConnectionSettings::autoReconnect()
+{
+    return localValue("AutoReconnect", true).toBool();
 }
 
-void CoreConnectionSettings::setPingTimeoutInterval(int interval) {
-  setLocalValue("PingTimeoutInterval", interval);
+
+void CoreConnectionSettings::setPingTimeoutInterval(int interval)
+{
+    setLocalValue("PingTimeoutInterval", interval);
 }
 
-int CoreConnectionSettings::pingTimeoutInterval() {
-  return localValue("PingTimeoutInterval", 60).toInt();
+
+int CoreConnectionSettings::pingTimeoutInterval()
+{
+    return localValue("PingTimeoutInterval", 60).toInt();
 }
 
-void CoreConnectionSettings::setReconnectInterval(int interval) {
-  setLocalValue("ReconnectInterval", interval);
+
+void CoreConnectionSettings::setReconnectInterval(int interval)
+{
+    setLocalValue("ReconnectInterval", interval);
 }
 
-int CoreConnectionSettings::reconnectInterval() {
-  return localValue("ReconnectInterval", 60).toInt();
+
+int CoreConnectionSettings::reconnectInterval()
+{
+    return localValue("ReconnectInterval", 60).toInt();
 }
 
+
 /***********************************************************************************************/
 // NotificationSettings:
 
-NotificationSettings::NotificationSettings() : ClientSettings("Notification") {
+NotificationSettings::NotificationSettings() : ClientSettings("Notification")
+{
 }
 
-void NotificationSettings::setHighlightList(const QVariantList &highlightList) {
-  setLocalValue("Highlights/CustomList", highlightList);
+
+void NotificationSettings::setHighlightList(const QVariantList &highlightList)
+{
+    setLocalValue("Highlights/CustomList", highlightList);
 }
 
-QVariantList NotificationSettings::highlightList() {
-  return localValue("Highlights/CustomList").toList();
+
+QVariantList NotificationSettings::highlightList()
+{
+    return localValue("Highlights/CustomList").toList();
 }
 
-void NotificationSettings::setHighlightNick(NotificationSettings::HighlightNickType highlightNickType) {
-  setLocalValue("Highlights/HighlightNick", highlightNickType);
+
+void NotificationSettings::setHighlightNick(NotificationSettings::HighlightNickType highlightNickType)
+{
+    setLocalValue("Highlights/HighlightNick", highlightNickType);
 }
 
-NotificationSettings::HighlightNickType NotificationSettings::highlightNick() {
-  return (NotificationSettings::HighlightNickType) localValue("Highlights/HighlightNick", CurrentNick).toInt();
+
+NotificationSettings::HighlightNickType NotificationSettings::highlightNick()
+{
+    return (NotificationSettings::HighlightNickType)localValue("Highlights/HighlightNick", CurrentNick).toInt();
 }
 
-void NotificationSettings::setNicksCaseSensitive(bool cs) {
-  setLocalValue("Highlights/NicksCaseSensitive", cs);
+
+void NotificationSettings::setNicksCaseSensitive(bool cs)
+{
+    setLocalValue("Highlights/NicksCaseSensitive", cs);
 }
 
-bool NotificationSettings::nicksCaseSensitive() {
-  return localValue("Highlights/NicksCaseSensitive", false).toBool();
+
+bool NotificationSettings::nicksCaseSensitive()
+{
+    return localValue("Highlights/NicksCaseSensitive", false).toBool();
 }
 
+
 // ========================================
 //  TabCompletionSettings
 // ========================================
 
-TabCompletionSettings::TabCompletionSettings() : ClientSettings("TabCompletion") {
+TabCompletionSettings::TabCompletionSettings() : ClientSettings("TabCompletion")
+{
 }
 
-void TabCompletionSettings::setCompletionSuffix(const QString &suffix) {
-  setLocalValue("CompletionSuffix", suffix);
+
+void TabCompletionSettings::setCompletionSuffix(const QString &suffix)
+{
+    setLocalValue("CompletionSuffix", suffix);
 }
 
-QString TabCompletionSettings::completionSuffix() {
-  return localValue("CompletionSuffix", ": ").toString();
+
+QString TabCompletionSettings::completionSuffix()
+{
+    return localValue("CompletionSuffix", ": ").toString();
 }
 
-void TabCompletionSettings::setAddSpaceMidSentence(bool space) {
-  setLocalValue("AddSpaceMidSentence", space);
+
+void TabCompletionSettings::setAddSpaceMidSentence(bool space)
+{
+    setLocalValue("AddSpaceMidSentence", space);
 }
 
-bool TabCompletionSettings::addSpaceMidSentence() {
-  return localValue("AddSpaceMidSentence", false).toBool();
+
+bool TabCompletionSettings::addSpaceMidSentence()
+{
+    return localValue("AddSpaceMidSentence", false).toBool();
 }
 
-void TabCompletionSettings::setSortMode(SortMode mode) {
-  setLocalValue("SortMode", mode);
+
+void TabCompletionSettings::setSortMode(SortMode mode)
+{
+    setLocalValue("SortMode", mode);
 }
 
-TabCompletionSettings::SortMode TabCompletionSettings::sortMode() {
-  return static_cast<SortMode>(localValue("SortMode"), LastActivity);
+
+TabCompletionSettings::SortMode TabCompletionSettings::sortMode()
+{
+    return static_cast<SortMode>(localValue("SortMode"), LastActivity);
 }
 
-void TabCompletionSettings::setCaseSensitivity(Qt::CaseSensitivity cs) {
-  setLocalValue("CaseSensitivity", cs);
+
+void TabCompletionSettings::setCaseSensitivity(Qt::CaseSensitivity cs)
+{
+    setLocalValue("CaseSensitivity", cs);
 }
 
-Qt::CaseSensitivity TabCompletionSettings::caseSensitivity() {
-  return (Qt::CaseSensitivity)localValue("CaseSensitivity", Qt::CaseInsensitive).toInt();
+
+Qt::CaseSensitivity TabCompletionSettings::caseSensitivity()
+{
+    return (Qt::CaseSensitivity)localValue("CaseSensitivity", Qt::CaseInsensitive).toInt();
 }
 
-void TabCompletionSettings::setUseLastSpokenTo(bool use) {
-  setLocalValue("UseLastSpokenTo", use);
+
+void TabCompletionSettings::setUseLastSpokenTo(bool use)
+{
+    setLocalValue("UseLastSpokenTo", use);
 }
 
-bool TabCompletionSettings::useLastSpokenTo() {
-  return localValue("UseLastSpokenTo", false).toBool();
+
+bool TabCompletionSettings::useLastSpokenTo()
+{
+    return localValue("UseLastSpokenTo", false).toBool();
 }
 
+
 // ========================================
 //  ItemViewSettings
 // ========================================
 
-ItemViewSettings::ItemViewSettings(const QString &group) : ClientSettings(group) {
-
+ItemViewSettings::ItemViewSettings(const QString &group) : ClientSettings(group)
+{
 }
 
-bool ItemViewSettings::displayTopicInTooltip() {
-  return localValue("DisplayTopicInTooltip", false).toBool();
+
+bool ItemViewSettings::displayTopicInTooltip()
+{
+    return localValue("DisplayTopicInTooltip", false).toBool();
 }
 
-bool ItemViewSettings::mouseWheelChangesBuffer() {
-  return localValue("MouseWheelChangesBuffer", false).toBool();
+
+bool ItemViewSettings::mouseWheelChangesBuffer()
+{
+    return localValue("MouseWheelChangesBuffer", false).toBool();
 }
index 8d87398..b14f009 100644 (file)
 class QHostAddress;
 class QSslSocket;
 
-class ClientSettings : public Settings {
+class ClientSettings : public Settings
+{
 public:
-  virtual ~ClientSettings();
+    virtual ~ClientSettings();
 
 protected:
-  ClientSettings(QString group = "General");
+    ClientSettings(QString group = "General");
 };
 
+
 // ========================================
 //  CoreAccountSettings
 // ========================================
@@ -47,135 +49,144 @@ protected:
 //
 // Note that you'll get invalid data (and setting is ignored) if you are not connected to a core!
 
-class CoreAccountSettings : public ClientSettings {
+class CoreAccountSettings : public ClientSettings
+{
 public:
-  // stores account-specific data in CoreAccounts/$ACCID/$SUBGROUP/$KEY)
-  CoreAccountSettings(const QString &subgroup = "General");
+    // stores account-specific data in CoreAccounts/$ACCID/$SUBGROUP/$KEY)
+    CoreAccountSettings(const QString &subgroup = "General");
 
-  virtual void notify(const QString &key, QObject *receiver, const char *slot);
+    virtual void notify(const QString &key, QObject *receiver, const char *slot);
 
-  QList<AccountId> knownAccounts();
-  AccountId lastAccount();
-  void setLastAccount(AccountId);
-  AccountId autoConnectAccount();
-  void setAutoConnectAccount(AccountId);
-  bool autoConnectOnStartup();
-  void setAutoConnectOnStartup(bool);
-  bool autoConnectToFixedAccount();
-  void setAutoConnectToFixedAccount(bool);
+    QList<AccountId> knownAccounts();
+    AccountId lastAccount();
+    void setLastAccount(AccountId);
+    AccountId autoConnectAccount();
+    void setAutoConnectAccount(AccountId);
+    bool autoConnectOnStartup();
+    void setAutoConnectOnStartup(bool);
+    bool autoConnectToFixedAccount();
+    void setAutoConnectToFixedAccount(bool);
 
-  void clearAccounts();
+    void clearAccounts();
 
-  void storeAccountData(AccountId id, const QVariantMap &data);
-  QVariantMap retrieveAccountData(AccountId);
-  void removeAccount(AccountId);
+    void storeAccountData(AccountId id, const QVariantMap &data);
+    QVariantMap retrieveAccountData(AccountId);
+    void removeAccount(AccountId);
 
-  void setJumpKeyMap(const QHash<int, BufferId> &keyMap);
-  QHash<int, BufferId> jumpKeyMap();
+    void setJumpKeyMap(const QHash<int, BufferId> &keyMap);
+    QHash<int, BufferId> jumpKeyMap();
 
-  void setBufferViewOverlay(const QSet<int> &viewIds);
-  QSet<int> bufferViewOverlay();
+    void setBufferViewOverlay(const QSet<int> &viewIds);
+    QSet<int> bufferViewOverlay();
 
-  void setAccountValue(const QString &key, const QVariant &data);
-  QVariant accountValue(const QString &key, const QVariant &def = QVariant());
+    void setAccountValue(const QString &key, const QVariant &data);
+    QVariant accountValue(const QString &key, const QVariant &def = QVariant());
 
 private:
-  QString _subgroup;
+    QString _subgroup;
 };
 
+
 // ========================================
 //  NotificationSettings
 // ========================================
-class NotificationSettings : public ClientSettings {
+class NotificationSettings : public ClientSettings
+{
 public:
-  enum HighlightNickType {
-    NoNick = 0x00,
-    CurrentNick= 0x01,
-    AllNicks = 0x02
-  };
+    enum HighlightNickType {
+        NoNick = 0x00,
+        CurrentNick = 0x01,
+        AllNicks = 0x02
+    };
 
-  NotificationSettings();
+    NotificationSettings();
 
-  inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
-  inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
-  inline void remove(const QString &key) { removeLocalKey(key); }
+    inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
+    inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
+    inline void remove(const QString &key) { removeLocalKey(key); }
 
-  void setHighlightList(const QVariantList &highlightList);
-  QVariantList highlightList();
+    void setHighlightList(const QVariantList &highlightList);
+    QVariantList highlightList();
 
-  void setHighlightNick(HighlightNickType);
-  HighlightNickType highlightNick();
+    void setHighlightNick(HighlightNickType);
+    HighlightNickType highlightNick();
 
-  void setNicksCaseSensitive(bool);
-  bool nicksCaseSensitive();
+    void setNicksCaseSensitive(bool);
+    bool nicksCaseSensitive();
 };
 
+
 // ========================================
 // CoreConnectionSettings
 // ========================================
 
-class CoreConnectionSettings : public ClientSettings {
+class CoreConnectionSettings : public ClientSettings
+{
 public:
-  enum NetworkDetectionMode {
-    UseSolid,
-    UsePingTimeout,
-    NoActiveDetection
-  };
+    enum NetworkDetectionMode {
+        UseSolid,
+        UsePingTimeout,
+        NoActiveDetection
+    };
 
-  CoreConnectionSettings();
+    CoreConnectionSettings();
 
-  void setNetworkDetectionMode(NetworkDetectionMode mode);
-  NetworkDetectionMode networkDetectionMode();
+    void setNetworkDetectionMode(NetworkDetectionMode mode);
+    NetworkDetectionMode networkDetectionMode();
 
-  void setAutoReconnect(bool autoReconnect);
-  bool autoReconnect();
+    void setAutoReconnect(bool autoReconnect);
+    bool autoReconnect();
 
-  void setPingTimeoutInterval(int interval);
-  int pingTimeoutInterval();
+    void setPingTimeoutInterval(int interval);
+    int pingTimeoutInterval();
 
-  void setReconnectInterval(int interval);
-  int reconnectInterval();
+    void setReconnectInterval(int interval);
+    int reconnectInterval();
 };
 
+
 // ========================================
 // TabCompletionSettings
 // ========================================
 
-class TabCompletionSettings : public ClientSettings {
+class TabCompletionSettings : public ClientSettings
+{
 public:
-  enum SortMode {
-    Alphabetical,
-    LastActivity
-  };
+    enum SortMode {
+        Alphabetical,
+        LastActivity
+    };
 
-  TabCompletionSettings();
+    TabCompletionSettings();
 
-  void setCompletionSuffix(const QString &);
-  QString completionSuffix();
+    void setCompletionSuffix(const QString &);
+    QString completionSuffix();
 
-  void setAddSpaceMidSentence(bool);
-  bool addSpaceMidSentence();
+    void setAddSpaceMidSentence(bool);
+    bool addSpaceMidSentence();
 
-  void setSortMode(SortMode);
-  SortMode sortMode();
+    void setSortMode(SortMode);
+    SortMode sortMode();
 
-  void setCaseSensitivity(Qt::CaseSensitivity);
-  Qt::CaseSensitivity caseSensitivity();
-
-  void setUseLastSpokenTo(bool);
-  bool useLastSpokenTo();
+    void setCaseSensitivity(Qt::CaseSensitivity);
+    Qt::CaseSensitivity caseSensitivity();
 
+    void setUseLastSpokenTo(bool);
+    bool useLastSpokenTo();
 };
 
+
 // ========================================
 // ItemViewSettings
 // ========================================
-class ItemViewSettings : public ClientSettings {
-  public:
-    ItemViewSettings(const QString& group = "ItemViews");
+class ItemViewSettings : public ClientSettings
+{
+public:
+    ItemViewSettings(const QString &group = "ItemViews");
 
     bool displayTopicInTooltip();
     bool mouseWheelChangesBuffer();
 };
 
+
 #endif
index aa614f2..97901cb 100644 (file)
 #include <QDateTime>
 
 ClientUserInputHandler::ClientUserInputHandler(QObject *parent)
-: BasicHandler(parent)
+    : BasicHandler(parent)
 {
-  TabCompletionSettings s;
-  s.notify("CompletionSuffix", this, SLOT(completionSuffixChanged(QVariant)));
-  completionSuffixChanged(s.completionSuffix());
+    TabCompletionSettings s;
+    s.notify("CompletionSuffix", this, SLOT(completionSuffixChanged(QVariant)));
+    completionSuffixChanged(s.completionSuffix());
 }
 
-void ClientUserInputHandler::completionSuffixChanged(const QVariant &v) {
-  QString suffix = v.toString();
-  QString letter = "A-Za-z";
-  QString special = "\x5b-\x60\x7b-\x7d";
-  _nickRx = QRegExp(QString("^([%1%2][%1%2\\d-]*)%3").arg(letter, special, suffix).trimmed());
+
+void ClientUserInputHandler::completionSuffixChanged(const QVariant &v)
+{
+    QString suffix = v.toString();
+    QString letter = "A-Za-z";
+    QString special = "\x5b-\x60\x7b-\x7d";
+    _nickRx = QRegExp(QString("^([%1%2][%1%2\\d-]*)%3").arg(letter, special, suffix).trimmed());
 }
 
+
 // this would be the place for a client-side hook
-void ClientUserInputHandler::handleUserInput(const BufferInfo &bufferInfo, const QString &msg) {
-  if(msg.isEmpty())
-    return;
-
-  if(!msg.startsWith('/')) {
-    if(_nickRx.indexIn(msg) == 0) {
-      const Network *net = Client::network(bufferInfo.networkId());
-      IrcUser *user = net ? net->ircUser(_nickRx.cap(1)) : 0;
-      if(user)
-        user->setLastSpokenTo(bufferInfo.bufferId(), QDateTime::currentDateTime().toUTC());
+void ClientUserInputHandler::handleUserInput(const BufferInfo &bufferInfo, const QString &msg)
+{
+    if (msg.isEmpty())
+        return;
+
+    if (!msg.startsWith('/')) {
+        if (_nickRx.indexIn(msg) == 0) {
+            const Network *net = Client::network(bufferInfo.networkId());
+            IrcUser *user = net ? net->ircUser(_nickRx.cap(1)) : 0;
+            if (user)
+                user->setLastSpokenTo(bufferInfo.bufferId(), QDateTime::currentDateTime().toUTC());
+        }
     }
-  }
 
-  AliasManager::CommandList clist = Client::aliasManager()->processInput(bufferInfo, msg);
+    AliasManager::CommandList clist = Client::aliasManager()->processInput(bufferInfo, msg);
 
-  for(int i = 0; i < clist.count(); i++) {
-    QString cmd = clist.at(i).second.section(' ', 0, 0).remove(0, 1).toUpper();
-    QString payload = clist.at(i).second.section(' ', 1);
-    handle(cmd, Q_ARG(BufferInfo, clist.at(i).first), Q_ARG(QString, payload));
-  }
+    for (int i = 0; i < clist.count(); i++) {
+        QString cmd = clist.at(i).second.section(' ', 0, 0).remove(0, 1).toUpper();
+        QString payload = clist.at(i).second.section(' ', 1);
+        handle(cmd, Q_ARG(BufferInfo, clist.at(i).first), Q_ARG(QString, payload));
+    }
 }
 
-void ClientUserInputHandler::defaultHandler(const QString &cmd, const BufferInfo &bufferInfo, const QString &text) {
-  QString command = QString("/%1 %2").arg(cmd, text);
-  emit sendInput(bufferInfo, command);
+
+void ClientUserInputHandler::defaultHandler(const QString &cmd, const BufferInfo &bufferInfo, const QString &text)
+{
+    QString command = QString("/%1 %2").arg(cmd, text);
+    emit sendInput(bufferInfo, command);
 }
 
-void ClientUserInputHandler::handleExec(const BufferInfo &bufferInfo, const QString &execString) {
-  ExecWrapper *exec = new ExecWrapper(this); // gets suicidal when it's done
-  exec->start(bufferInfo, execString);
+
+void ClientUserInputHandler::handleExec(const BufferInfo &bufferInfo, const QString &execString)
+{
+    ExecWrapper *exec = new ExecWrapper(this); // gets suicidal when it's done
+    exec->start(bufferInfo, execString);
 }
 
-void ClientUserInputHandler::handleJoin(const BufferInfo &bufferInfo, const QString &text) {
-  if(text.isEmpty()) {
-    Client::messageModel()->insertErrorMessage(bufferInfo, tr("/JOIN expects a channel"));
-    return;
-  }
-  switchBuffer(bufferInfo.networkId(), text.section(' ', 0, 0));
-  // send to core
-  defaultHandler("JOIN", bufferInfo, text);
+
+void ClientUserInputHandler::handleJoin(const BufferInfo &bufferInfo, const QString &text)
+{
+    if (text.isEmpty()) {
+        Client::messageModel()->insertErrorMessage(bufferInfo, tr("/JOIN expects a channel"));
+        return;
+    }
+    switchBuffer(bufferInfo.networkId(), text.section(' ', 0, 0));
+    // send to core
+    defaultHandler("JOIN", bufferInfo, text);
 }
 
-void ClientUserInputHandler::handleQuery(const BufferInfo &bufferInfo, const QString &text) {
-  if(text.isEmpty()) {
-    Client::messageModel()->insertErrorMessage(bufferInfo, tr("/QUERY expects at least a nick"));
-    return;
-  }
-  switchBuffer(bufferInfo.networkId(), text.section(' ', 0, 0));
-  // send to core
-  defaultHandler("QUERY", bufferInfo, text);
+
+void ClientUserInputHandler::handleQuery(const BufferInfo &bufferInfo, const QString &text)
+{
+    if (text.isEmpty()) {
+        Client::messageModel()->insertErrorMessage(bufferInfo, tr("/QUERY expects at least a nick"));
+        return;
+    }
+    switchBuffer(bufferInfo.networkId(), text.section(' ', 0, 0));
+    // send to core
+    defaultHandler("QUERY", bufferInfo, text);
 }
 
-void ClientUserInputHandler::switchBuffer(const NetworkId &networkId, const QString &bufferName) {
-  BufferId newBufId = Client::networkModel()->bufferId(networkId, bufferName);
-  if(!newBufId.isValid()) {
-    Client::bufferModel()->switchToBufferAfterCreation(networkId, bufferName);
-  }
-  else {
-    Client::bufferModel()->switchToBuffer(newBufId);
-    // unhide the buffer
-    ClientBufferViewManager *clientBufferViewManager = Client::bufferViewManager();
-    QList<ClientBufferViewConfig*> bufferViewConfigList = clientBufferViewManager->clientBufferViewConfigs();
-    foreach (ClientBufferViewConfig *bufferViewConfig, bufferViewConfigList) {
-      if (bufferViewConfig->temporarilyRemovedBuffers().contains(newBufId)) {
-        bufferViewConfig->addBuffer(newBufId, bufferViewConfig->bufferList().length());
-        //if (bufferViewConfig->sortAlphabetically()) {
-          // TODO we need to trigger a sort here, but can't reach the model required
-          // to get a bufferviewfilter, as the bufferviewmanager only managers configs
-          //BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
-        //}
-      }
+
+void ClientUserInputHandler::switchBuffer(const NetworkId &networkId, const QString &bufferName)
+{
+    BufferId newBufId = Client::networkModel()->bufferId(networkId, bufferName);
+    if (!newBufId.isValid()) {
+        Client::bufferModel()->switchToBufferAfterCreation(networkId, bufferName);
+    }
+    else {
+        Client::bufferModel()->switchToBuffer(newBufId);
+        // unhide the buffer
+        ClientBufferViewManager *clientBufferViewManager = Client::bufferViewManager();
+        QList<ClientBufferViewConfig *> bufferViewConfigList = clientBufferViewManager->clientBufferViewConfigs();
+        foreach(ClientBufferViewConfig *bufferViewConfig, bufferViewConfigList) {
+            if (bufferViewConfig->temporarilyRemovedBuffers().contains(newBufId)) {
+                bufferViewConfig->addBuffer(newBufId, bufferViewConfig->bufferList().length());
+                //if (bufferViewConfig->sortAlphabetically()) {
+                // TODO we need to trigger a sort here, but can't reach the model required
+                // to get a bufferviewfilter, as the bufferviewmanager only managers configs
+                //BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
+                //}
+            }
+        }
     }
-  }
 }
index e27f26e..4b7db83 100644 (file)
 class BufferInfo;
 class NetworkId;
 
-class ClientUserInputHandler : public BasicHandler {
-  Q_OBJECT
+class ClientUserInputHandler : public BasicHandler
+{
+    Q_OBJECT
 
 public:
-  ClientUserInputHandler(QObject *parent = 0);
+    ClientUserInputHandler(QObject *parent = 0);
 
 public slots:
-  void handleUserInput(const BufferInfo &bufferInfo, const QString &msg);
+    void handleUserInput(const BufferInfo &bufferInfo, const QString &msg);
 
 signals:
-  void sendInput(const BufferInfo &, const QString &);
+    void sendInput(const BufferInfo &, const QString &);
 
 private slots:
-  void completionSuffixChanged(const QVariant &);
+    void completionSuffixChanged(const QVariant &);
 
-  void handleExec(const BufferInfo &bufferInfo, const QString &execString);
-  void handleJoin(const BufferInfo &bufferInfo, const QString &text);
-  void handleQuery(const BufferInfo &bufferInfo, const QString &text);
-  void defaultHandler(const QString &cmd, const BufferInfo &bufferInfo, const QString &text);
+    void handleExec(const BufferInfo &bufferInfo, const QString &execString);
+    void handleJoin(const BufferInfo &bufferInfo, const QString &text);
+    void handleQuery(const BufferInfo &bufferInfo, const QString &text);
+    void defaultHandler(const QString &cmd, const BufferInfo &bufferInfo, const QString &text);
 
 private:
-  QRegExp _nickRx;
+    QRegExp _nickRx;
 
-  //! Helper method for switching to new/existing buffers
-  /** Immediately switches to the given buffer or schedules a switch for whenever
-    * the buffer is created
-    */
-  void switchBuffer(const NetworkId &networkId, const QString &bufferName);
+    //! Helper method for switching to new/existing buffers
+    /** Immediately switches to the given buffer or schedules a switch for whenever
+      * the buffer is created
+      */
+    void switchBuffer(const NetworkId &networkId, const QString &bufferName);
 };
 
+
 #endif
index 4fccced..50524c4 100644 (file)
 
 #include "coreaccount.h"
 
-CoreAccount::CoreAccount(AccountId accountId) {
-  _accountId = accountId;
-  _internal = false;
-  _port = 4242;
-  _storePassword = false;
-  _useSsl = true;
-  _useProxy = false;
-  _proxyType = QNetworkProxy::Socks5Proxy;
-  _proxyPort = 8080;
+CoreAccount::CoreAccount(AccountId accountId)
+{
+    _accountId = accountId;
+    _internal = false;
+    _port = 4242;
+    _storePassword = false;
+    _useSsl = true;
+    _useProxy = false;
+    _proxyType = QNetworkProxy::Socks5Proxy;
+    _proxyPort = 8080;
 }
 
-void CoreAccount::setAccountId(AccountId id) {
-  _accountId = id;
+
+void CoreAccount::setAccountId(AccountId id)
+{
+    _accountId = id;
 }
 
-void CoreAccount::setAccountName(const QString &name) {
-  _accountName = name;
+
+void CoreAccount::setAccountName(const QString &name)
+{
+    _accountName = name;
 }
 
-void CoreAccount::setUuid(const QUuid &uuid) {
-  _uuid = uuid;
+
+void CoreAccount::setUuid(const QUuid &uuid)
+{
+    _uuid = uuid;
 }
 
-void CoreAccount::setInternal(bool internal) {
-  _internal = internal;
+
+void CoreAccount::setInternal(bool internal)
+{
+    _internal = internal;
 }
 
-void CoreAccount::setUser(const QString &user) {
-  _user = user;
+
+void CoreAccount::setUser(const QString &user)
+{
+    _user = user;
 }
 
-void CoreAccount::setPassword(const QString &password) {
-  _password = password;
+
+void CoreAccount::setPassword(const QString &password)
+{
+    _password = password;
 }
 
-void CoreAccount::setStorePassword(bool store) {
-  _storePassword = store;
+
+void CoreAccount::setStorePassword(bool store)
+{
+    _storePassword = store;
 }
 
-void CoreAccount::setHostName(const QString &hostname) {
-  _hostName = hostname;
+
+void CoreAccount::setHostName(const QString &hostname)
+{
+    _hostName = hostname;
 }
 
-void CoreAccount::setPort(uint port) {
-  _port = port;
+
+void CoreAccount::setPort(uint port)
+{
+    _port = port;
 }
 
-void CoreAccount::setUseSsl(bool useSsl) {
-  _useSsl = useSsl;
+
+void CoreAccount::setUseSsl(bool useSsl)
+{
+    _useSsl = useSsl;
 }
 
-void CoreAccount::setUseProxy(bool useProxy) {
-  _useProxy = useProxy;
+
+void CoreAccount::setUseProxy(bool useProxy)
+{
+    _useProxy = useProxy;
 }
 
-void CoreAccount::setProxyType(QNetworkProxy::ProxyType type) {
-  _proxyType = type;
+
+void CoreAccount::setProxyType(QNetworkProxy::ProxyType type)
+{
+    _proxyType = type;
 }
 
-void CoreAccount::setProxyUser(const QString &proxyUser) {
-  _proxyUser = proxyUser;
+
+void CoreAccount::setProxyUser(const QString &proxyUser)
+{
+    _proxyUser = proxyUser;
 }
 
-void CoreAccount::setProxyPassword(const QString &proxyPassword) {
-  _proxyPassword = proxyPassword;
+
+void CoreAccount::setProxyPassword(const QString &proxyPassword)
+{
+    _proxyPassword = proxyPassword;
 }
 
-void CoreAccount::setProxyHostName(const QString &proxyHostName) {
-  _proxyHostName = proxyHostName;
+
+void CoreAccount::setProxyHostName(const QString &proxyHostName)
+{
+    _proxyHostName = proxyHostName;
 }
 
-void CoreAccount::setProxyPort(uint proxyPort) {
-  _proxyPort = proxyPort;
+
+void CoreAccount::setProxyPort(uint proxyPort)
+{
+    _proxyPort = proxyPort;
 }
 
-QVariantMap CoreAccount::toVariantMap(bool forcePassword) const {
-  QVariantMap v;
-  v["AccountId"] = accountId().toInt(); // can't use AccountId because then comparison fails
-  v["AccountName"] = accountName();
-  v["Uuid"] = uuid().toString();
-  v["Internal"] = isInternal();
-  v["User"] = user();
-  if(_storePassword || forcePassword)
-    v["Password"] = password();
-  else
-    v["Password"] = QString();
-  v["StorePassword"] = storePassword();
-  v["HostName"] = hostName();
-  v["Port"] = port();
-  v["UseSSL"] = useSsl();
-  v["UseProxy"] = useProxy();
-  v["ProxyType"] = proxyType();
-  v["ProxyUser"] = proxyUser();
-  v["ProxyPassword"] = proxyPassword();
-  v["ProxyHostName"] = proxyHostName();
-  v["ProxyPort"] = proxyPort();
-  return v;
+
+QVariantMap CoreAccount::toVariantMap(bool forcePassword) const
+{
+    QVariantMap v;
+    v["AccountId"] = accountId().toInt(); // can't use AccountId because then comparison fails
+    v["AccountName"] = accountName();
+    v["Uuid"] = uuid().toString();
+    v["Internal"] = isInternal();
+    v["User"] = user();
+    if (_storePassword || forcePassword)
+        v["Password"] = password();
+    else
+        v["Password"] = QString();
+    v["StorePassword"] = storePassword();
+    v["HostName"] = hostName();
+    v["Port"] = port();
+    v["UseSSL"] = useSsl();
+    v["UseProxy"] = useProxy();
+    v["ProxyType"] = proxyType();
+    v["ProxyUser"] = proxyUser();
+    v["ProxyPassword"] = proxyPassword();
+    v["ProxyHostName"] = proxyHostName();
+    v["ProxyPort"] = proxyPort();
+    return v;
 }
 
-void CoreAccount::fromVariantMap(const QVariantMap &v) {
-  setAccountId((AccountId)v.value("AccountId").toInt());
-  setAccountName(v.value("AccountName").toString());
-  setUuid(QUuid(v.value("Uuid").toString()));
-  setInternal(v.value("Internal").toBool());
-  setUser(v.value("User").toString());
-  setPassword(v.value("Password").toString());
-  setStorePassword(v.value("StorePassword").toBool());
-  setHostName(v.value("HostName").toString());
-  setPort(v.value("Port").toUInt());
-  setUseSsl(v.value("UseSSL").toBool());
-  setUseProxy(v.value("UseProxy").toBool());
-  setProxyType((QNetworkProxy::ProxyType)v.value("ProxyType").toInt());
-  setProxyUser(v.value("ProxyUser").toString());
-  setProxyPassword(v.value("ProxyPassword").toString());
-  setProxyHostName(v.value("ProxyHostName").toString());
-  setProxyPort(v.value("ProxyPort").toUInt());
 
-  _storePassword = !password().isEmpty();
+void CoreAccount::fromVariantMap(const QVariantMap &v)
+{
+    setAccountId((AccountId)v.value("AccountId").toInt());
+    setAccountName(v.value("AccountName").toString());
+    setUuid(QUuid(v.value("Uuid").toString()));
+    setInternal(v.value("Internal").toBool());
+    setUser(v.value("User").toString());
+    setPassword(v.value("Password").toString());
+    setStorePassword(v.value("StorePassword").toBool());
+    setHostName(v.value("HostName").toString());
+    setPort(v.value("Port").toUInt());
+    setUseSsl(v.value("UseSSL").toBool());
+    setUseProxy(v.value("UseProxy").toBool());
+    setProxyType((QNetworkProxy::ProxyType)v.value("ProxyType").toInt());
+    setProxyUser(v.value("ProxyUser").toString());
+    setProxyPassword(v.value("ProxyPassword").toString());
+    setProxyHostName(v.value("ProxyHostName").toString());
+    setProxyPort(v.value("ProxyPort").toUInt());
+
+    _storePassword = !password().isEmpty();
 }
 
-bool CoreAccount::operator==(const CoreAccount &o) const {
-  return toVariantMap(true) == o.toVariantMap(true);
+
+bool CoreAccount::operator==(const CoreAccount &o) const
+{
+    return toVariantMap(true) == o.toVariantMap(true);
 }
index f684743..5ea6a1c 100644 (file)
 #include <QVariantMap>
 
 #include "types.h"
-class CoreAccount {
-  Q_DECLARE_TR_FUNCTIONS(CoreAccount)
+class CoreAccount
+{
+    Q_DECLARE_TR_FUNCTIONS(CoreAccount)
 
 public:
-  CoreAccount(AccountId accountId = 0);
-  virtual ~CoreAccount() {};
-
-  inline bool isValid() const { return accountId().isValid(); }
-  inline AccountId accountId() const { return _accountId; }
-  inline QString accountName() const { return isInternal() ? tr("Internal Core") : _accountName; }
-  inline QUuid uuid() const { return _uuid; }
-  inline bool isInternal() const { return _internal; }
-
-  inline QString user() const { return _user; }
-  inline bool storePassword() const { return _storePassword; }
-  inline QString hostName() const { return _hostName; }
-  inline uint port() const { return _port; }
-  inline bool useSsl() const { return _useSsl; }
-
-  inline bool useProxy() const { return _useProxy; }
-  inline QNetworkProxy::ProxyType proxyType() const { return _proxyType; }
-  inline QString proxyUser() const { return _proxyUser; }
-  inline QString proxyHostName() const { return _proxyHostName; }
-  inline uint proxyPort() const { return _proxyPort; }
-
-  void setAccountId(AccountId id);
-  void setAccountName(const QString &accountName);
-  void setUuid(const QUuid &uuid);
-  void setInternal(bool);
-
-  void setUser(const QString &user);
-  void setStorePassword(bool);
-  void setHostName(const QString &hostname);
-  void setPort(uint port);
-  void setUseSsl(bool);
-
-  void setUseProxy(bool);
-  void setProxyType(QNetworkProxy::ProxyType);
-  void setProxyUser(const QString &);
-  void setProxyHostName(const QString &);
-  void setProxyPort(uint);
-
-  /* These might be overridden for KWallet support */
-  virtual inline QString password() const { return _password; }
-  virtual void setPassword(const QString &password);
-  virtual inline QString proxyPassword() const { return _proxyPassword; }
-  virtual void setProxyPassword(const QString &);
-
-  virtual QVariantMap toVariantMap(bool forcePassword = false) const;
-  virtual void fromVariantMap(const QVariantMap &);
-
-  bool operator==(const CoreAccount &other) const;
+    CoreAccount(AccountId accountId = 0);
+    virtual ~CoreAccount() {};
+
+    inline bool isValid() const { return accountId().isValid(); }
+    inline AccountId accountId() const { return _accountId; }
+    inline QString accountName() const { return isInternal() ? tr("Internal Core") : _accountName; }
+    inline QUuid uuid() const { return _uuid; }
+    inline bool isInternal() const { return _internal; }
+
+    inline QString user() const { return _user; }
+    inline bool storePassword() const { return _storePassword; }
+    inline QString hostName() const { return _hostName; }
+    inline uint port() const { return _port; }
+    inline bool useSsl() const { return _useSsl; }
+
+    inline bool useProxy() const { return _useProxy; }
+    inline QNetworkProxy::ProxyType proxyType() const { return _proxyType; }
+    inline QString proxyUser() const { return _proxyUser; }
+    inline QString proxyHostName() const { return _proxyHostName; }
+    inline uint proxyPort() const { return _proxyPort; }
+
+    void setAccountId(AccountId id);
+    void setAccountName(const QString &accountName);
+    void setUuid(const QUuid &uuid);
+    void setInternal(bool);
+
+    void setUser(const QString &user);
+    void setStorePassword(bool);
+    void setHostName(const QString &hostname);
+    void setPort(uint port);
+    void setUseSsl(bool);
+
+    void setUseProxy(bool);
+    void setProxyType(QNetworkProxy::ProxyType);
+    void setProxyUser(const QString &);
+    void setProxyHostName(const QString &);
+    void setProxyPort(uint);
+
+    /* These might be overridden for KWallet support */
+    virtual inline QString password() const { return _password; }
+    virtual void setPassword(const QString &password);
+    virtual inline QString proxyPassword() const { return _proxyPassword; }
+    virtual void setProxyPassword(const QString &);
+
+    virtual QVariantMap toVariantMap(bool forcePassword = false) const;
+    virtual void fromVariantMap(const QVariantMap &);
+
+    bool operator==(const CoreAccount &other) const;
 
 private:
-  AccountId _accountId;
-  QString _accountName;
-  QUuid _uuid;
-  bool _internal;
-  QString _user, _password, _hostName;
-  uint _port;
-  bool _storePassword, _useSsl, _useProxy;
-  QNetworkProxy::ProxyType _proxyType;
-  QString _proxyUser, _proxyPassword, _proxyHostName;
-  uint _proxyPort;
+    AccountId _accountId;
+    QString _accountName;
+    QUuid _uuid;
+    bool _internal;
+    QString _user, _password, _hostName;
+    uint _port;
+    bool _storePassword, _useSsl, _useProxy;
+    QNetworkProxy::ProxyType _proxyType;
+    QString _proxyUser, _proxyPassword, _proxyHostName;
+    uint _proxyPort;
 };
 
+
 #endif
index a7a2f01..a54cd2f 100644 (file)
 #include "quassel.h"
 
 CoreAccountModel::CoreAccountModel(QObject *parent)
-  : QAbstractListModel(parent),
-  _internalAccount(0)
+    : QAbstractListModel(parent),
+    _internalAccount(0)
 {
-
 }
 
+
 CoreAccountModel::CoreAccountModel(const CoreAccountModel *other, QObject *parent)
-  : QAbstractListModel(parent),
-  _internalAccount(0)
+    : QAbstractListModel(parent),
+    _internalAccount(0)
 {
-  update(other);
+    update(other);
 }
 
-void CoreAccountModel::update(const CoreAccountModel *other) {
-  clear();
-  if (other->_accounts.count() > 0) {
-    beginInsertRows(QModelIndex(), 0, other->_accounts.count() -1);
-    _accounts = other->_accounts;
-    endInsertRows();
-  }
-  _internalAccount = other->internalAccount();
-  _removedAccounts = other->_removedAccounts;
-}
-
-void CoreAccountModel::load() {
-  clear();
-  CoreAccountSettings s;
-  foreach(AccountId accId, s.knownAccounts()) {
-    QVariantMap map = s.retrieveAccountData(accId);
-    CoreAccount acc;
-    acc.fromVariantMap(map);  // TODO Hook into kwallet/password saving stuff
-    insertAccount(acc);
-  }
-  if(Quassel::runMode() == Quassel::Monolithic && !internalAccount().isValid()) {
-    // Make sure we have an internal account in monolithic mode
-    CoreAccount intAcc;
-    intAcc.setInternal(true);
-    intAcc.setAccountName(tr("Internal Core"));
-    _internalAccount = createOrUpdateAccount(intAcc);
-  }
-}
-
-void CoreAccountModel::save() {
-  CoreAccountSettings s;
-  foreach(AccountId id, _removedAccounts) {
-    s.removeAccount(id);
-  }
-  _removedAccounts.clear();
-  foreach(const CoreAccount &acc, accounts()) {
-    QVariantMap map = acc.toVariantMap(false);  // TODO Hook into kwallet/password saving stuff
-    s.storeAccountData(acc.accountId(), map);
-  }
-}
-
-void CoreAccountModel::clear() {
-  if(rowCount()) {
-    beginRemoveRows(QModelIndex(), 0, rowCount()-1);
-    _internalAccount = 0;
-    _accounts.clear();
-    endRemoveRows();
-  }
+
+void CoreAccountModel::update(const CoreAccountModel *other)
+{
+    clear();
+    if (other->_accounts.count() > 0) {
+        beginInsertRows(QModelIndex(), 0, other->_accounts.count() -1);
+        _accounts = other->_accounts;
+        endInsertRows();
+    }
+    _internalAccount = other->internalAccount();
+    _removedAccounts = other->_removedAccounts;
 }
 
-QVariant CoreAccountModel::data(const QModelIndex &index, int role) const {
-  if(!index.isValid() || index.row() >= rowCount() || index.column() >= 1)
-    return QVariant();
 
-  const CoreAccount &acc = accounts().at(index.row());
+void CoreAccountModel::load()
+{
+    clear();
+    CoreAccountSettings s;
+    foreach(AccountId accId, s.knownAccounts()) {
+        QVariantMap map = s.retrieveAccountData(accId);
+        CoreAccount acc;
+        acc.fromVariantMap(map); // TODO Hook into kwallet/password saving stuff
+        insertAccount(acc);
+    }
+    if (Quassel::runMode() == Quassel::Monolithic && !internalAccount().isValid()) {
+        // Make sure we have an internal account in monolithic mode
+        CoreAccount intAcc;
+        intAcc.setInternal(true);
+        intAcc.setAccountName(tr("Internal Core"));
+        _internalAccount = createOrUpdateAccount(intAcc);
+    }
+}
 
-  switch(role) {
-  case Qt::DisplayRole:
-    return acc.accountName();
-  case AccountIdRole:
-    return QVariant::fromValue<AccountId>(acc.accountId());
-  case UuidRole:
-    return acc.uuid().toString();
 
-    default:
-      return QVariant();
+void CoreAccountModel::save()
+{
+    CoreAccountSettings s;
+    foreach(AccountId id, _removedAccounts) {
+        s.removeAccount(id);
+    }
+    _removedAccounts.clear();
+    foreach(const CoreAccount &acc, accounts()) {
+        QVariantMap map = acc.toVariantMap(false); // TODO Hook into kwallet/password saving stuff
+        s.storeAccountData(acc.accountId(), map);
+    }
+}
+
 
-  }
+void CoreAccountModel::clear()
+{
+    if (rowCount()) {
+        beginRemoveRows(QModelIndex(), 0, rowCount()-1);
+        _internalAccount = 0;
+        _accounts.clear();
+        endRemoveRows();
+    }
 }
 
-CoreAccount CoreAccountModel::account(AccountId id) const {
-  int idx = findAccountIdx(id);
-  if(idx >= 0)
-    return _accounts.value(idx);
-  return CoreAccount();
+
+QVariant CoreAccountModel::data(const QModelIndex &index, int role) const
+{
+    if (!index.isValid() || index.row() >= rowCount() || index.column() >= 1)
+        return QVariant();
+
+    const CoreAccount &acc = accounts().at(index.row());
+
+    switch (role) {
+    case Qt::DisplayRole:
+        return acc.accountName();
+    case AccountIdRole:
+        return QVariant::fromValue<AccountId>(acc.accountId());
+    case UuidRole:
+        return acc.uuid().toString();
+
+    default:
+        return QVariant();
+    }
+}
+
+
+CoreAccount CoreAccountModel::account(AccountId id) const
+{
+    int idx = findAccountIdx(id);
+    if (idx >= 0)
+        return _accounts.value(idx);
+    return CoreAccount();
 }
 
-CoreAccount CoreAccountModel::account(const QModelIndex &idx) const {
-  if(idx.isValid() && idx.row() < _accounts.count())
-    return _accounts.value(idx.row());
-  return CoreAccount();
+
+CoreAccount CoreAccountModel::account(const QModelIndex &idx) const
+{
+    if (idx.isValid() && idx.row() < _accounts.count())
+        return _accounts.value(idx.row());
+    return CoreAccount();
 }
 
-QList<CoreAccount> CoreAccountModel::accounts() const {
-  return _accounts;
+
+QList<CoreAccount> CoreAccountModel::accounts() const
+{
+    return _accounts;
 }
 
-QList<AccountId> CoreAccountModel::accountIds() const {
-  QList<AccountId> list;
-  foreach(const CoreAccount &acc, accounts())
+
+QList<AccountId> CoreAccountModel::accountIds() const
+{
+    QList<AccountId> list;
+    foreach(const CoreAccount &acc, accounts())
     list << acc.accountId();
-  return list;
+    return list;
 }
 
-bool CoreAccountModel::operator==(const CoreAccountModel &other) const {
-  return _accounts == other._accounts;
+
+bool CoreAccountModel::operator==(const CoreAccountModel &other) const
+{
+    return _accounts == other._accounts;
 }
 
+
 // TODO with Qt 4.6, use QAbstractItemModel move semantics to properly do this
-AccountId CoreAccountModel::createOrUpdateAccount(const CoreAccount &newAcc) {
-  CoreAccount acc = newAcc;
-
-  if(acc.uuid().isNull())
-    acc.setUuid(QUuid::createUuid());
-
-  if(!acc.accountId().isValid()) {
-    // find free Id
-    AccountId newId = 0;
-    const QList<AccountId> &ids = accountIds();
-    for(int i = 1; ; i++) {
-      if(!_removedAccounts.contains(i) && !ids.contains(i)) {
-        newId = i;
-        break;
-      }
-    }
-    acc.setAccountId(newId);
-    insertAccount(acc);
-  } else {
-    int idx = findAccountIdx(acc.accountId());
-    if(idx >= 0) {
-      if(acc.accountName() == accounts().at(idx).accountName()) {
-        _accounts[idx] = acc;
-        emit dataChanged(index(idx, 0), index(idx, 0));
-      } else {
-        takeAccount(acc.accountId());
+AccountId CoreAccountModel::createOrUpdateAccount(const CoreAccount &newAcc)
+{
+    CoreAccount acc = newAcc;
+
+    if (acc.uuid().isNull())
+        acc.setUuid(QUuid::createUuid());
+
+    if (!acc.accountId().isValid()) {
+        // find free Id
+        AccountId newId = 0;
+        const QList<AccountId> &ids = accountIds();
+        for (int i = 1;; i++) {
+            if (!_removedAccounts.contains(i) && !ids.contains(i)) {
+                newId = i;
+                break;
+            }
+        }
+        acc.setAccountId(newId);
         insertAccount(acc);
-      }
-    } else
-      insertAccount(acc);
-  }
-  return acc.accountId();
-}
-
-void CoreAccountModel::insertAccount(const CoreAccount &acc) {
-  if(acc.isInternal()) {
-    if(internalAccount().isValid()) {
-      qWarning() << "Trying to insert a second internal account in CoreAccountModel, ignoring";
-      return;
     }
-    _internalAccount = acc.accountId();
-  }
+    else {
+        int idx = findAccountIdx(acc.accountId());
+        if (idx >= 0) {
+            if (acc.accountName() == accounts().at(idx).accountName()) {
+                _accounts[idx] = acc;
+                emit dataChanged(index(idx, 0), index(idx, 0));
+            }
+            else {
+                takeAccount(acc.accountId());
+                insertAccount(acc);
+            }
+        }
+        else
+            insertAccount(acc);
+    }
+    return acc.accountId();
+}
 
-  // check for Quuid
-  int idx = 0;
-  while(idx < _accounts.count() && acc.accountName() > _accounts.at(idx).accountName() && !acc.isInternal())
-    ++idx;
 
-  beginInsertRows(QModelIndex(), idx, idx);
-  _accounts.insert(idx, acc);
-  endInsertRows();
+void CoreAccountModel::insertAccount(const CoreAccount &acc)
+{
+    if (acc.isInternal()) {
+        if (internalAccount().isValid()) {
+            qWarning() << "Trying to insert a second internal account in CoreAccountModel, ignoring";
+            return;
+        }
+        _internalAccount = acc.accountId();
+    }
+
+    // check for Quuid
+    int idx = 0;
+    while (idx<_accounts.count() && acc.accountName()> _accounts.at(idx).accountName() && !acc.isInternal())
+        ++idx;
+
+    beginInsertRows(QModelIndex(), idx, idx);
+    _accounts.insert(idx, acc);
+    endInsertRows();
 }
 
-CoreAccount CoreAccountModel::takeAccount(AccountId accId) {
-  int idx = findAccountIdx(accId);
-  if(idx < 0)
-    return CoreAccount();
 
-  beginRemoveRows(QModelIndex(), idx, idx);
-  CoreAccount acc = _accounts.takeAt(idx);
-  endRemoveRows();
+CoreAccount CoreAccountModel::takeAccount(AccountId accId)
+{
+    int idx = findAccountIdx(accId);
+    if (idx < 0)
+        return CoreAccount();
+
+    beginRemoveRows(QModelIndex(), idx, idx);
+    CoreAccount acc = _accounts.takeAt(idx);
+    endRemoveRows();
 
-  if(acc.isInternal())
-    _internalAccount = 0;
+    if (acc.isInternal())
+        _internalAccount = 0;
 
-  return acc;
+    return acc;
 }
 
-void CoreAccountModel::removeAccount(AccountId accId) {
-  takeAccount(accId);
-  _removedAccounts.insert(accId);
+
+void CoreAccountModel::removeAccount(AccountId accId)
+{
+    takeAccount(accId);
+    _removedAccounts.insert(accId);
 }
 
-QModelIndex CoreAccountModel::accountIndex(AccountId accId) const {
-  for(int i = 0; i < _accounts.count(); i++) {
-    if(_accounts.at(i).accountId() == accId)
-      return index(i, 0);
-  }
-  return QModelIndex();
+
+QModelIndex CoreAccountModel::accountIndex(AccountId accId) const
+{
+    for (int i = 0; i < _accounts.count(); i++) {
+        if (_accounts.at(i).accountId() == accId)
+            return index(i, 0);
+    }
+    return QModelIndex();
 }
 
-int CoreAccountModel::findAccountIdx(AccountId id) const {
-  QModelIndex idx = accountIndex(id);
-  return idx.isValid() ? idx.row() : -1;
+
+int CoreAccountModel::findAccountIdx(AccountId id) const
+{
+    QModelIndex idx = accountIndex(id);
+    return idx.isValid() ? idx.row() : -1;
 }
index 1c31469..dbcb20e 100644 (file)
 
 #include "coreaccount.h"
 
-class CoreAccountModel : public QAbstractListModel {
-  Q_OBJECT
+class CoreAccountModel : public QAbstractListModel
+{
+    Q_OBJECT
 
 public:
-  enum {
-    AccountIdRole = Qt::UserRole,
-    UuidRole
-  };
+    enum {
+        AccountIdRole = Qt::UserRole,
+        UuidRole
+    };
 
-  CoreAccountModel(QObject *parent = 0);
-  CoreAccountModel(const CoreAccountModel *other, QObject *parent = 0);
+    CoreAccountModel(QObject *parent = 0);
+    CoreAccountModel(const CoreAccountModel *other, QObject *parent = 0);
 
-  inline int rowCount(const QModelIndex &parent = QModelIndex()) const;
-  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+    inline int rowCount(const QModelIndex &parent = QModelIndex()) const;
+    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
-  CoreAccount account(const QModelIndex &) const;
-  CoreAccount account(AccountId) const;
-  QList<CoreAccount> accounts() const;
-  QList<AccountId> accountIds() const;
-  QModelIndex accountIndex(AccountId id) const;
+    CoreAccount account(const QModelIndex &) const;
+    CoreAccount account(AccountId) const;
+    QList<CoreAccount> accounts() const;
+    QList<AccountId> accountIds() const;
+    QModelIndex accountIndex(AccountId id) const;
 
-  inline AccountId internalAccount() const;
+    inline AccountId internalAccount() const;
 
-  AccountId createOrUpdateAccount(const CoreAccount &newAccountData = CoreAccount());
-  CoreAccount takeAccount(AccountId);
-  void removeAccount(AccountId);
+    AccountId createOrUpdateAccount(const CoreAccount &newAccountData = CoreAccount());
+    CoreAccount takeAccount(AccountId);
+    void removeAccount(AccountId);
 
-  void update(const CoreAccountModel *other);
+    void update(const CoreAccountModel *other);
 
-  bool operator==(const CoreAccountModel &other) const;
+    bool operator==(const CoreAccountModel &other) const;
 
 public slots:
-  void save();
-  void load();
-  void clear();
+    void save();
+    void load();
+    void clear();
 
 protected:
-  void insertAccount(const CoreAccount &);
-  int findAccountIdx(AccountId) const;
+    void insertAccount(const CoreAccount &);
+    int findAccountIdx(AccountId) const;
 
 private:
-  int listIndex(AccountId);
+    int listIndex(AccountId);
 
-  QList<CoreAccount> _accounts;
-  QSet<AccountId> _removedAccounts;
-  AccountId _internalAccount;
+    QList<CoreAccount> _accounts;
+    QSet<AccountId> _removedAccounts;
+    AccountId _internalAccount;
 };
 
+
 // Inlines
-int CoreAccountModel::rowCount(const QModelIndex &) const {
-  return _accounts.count();
+int CoreAccountModel::rowCount(const QModelIndex &) const
+{
+    return _accounts.count();
 }
 
-AccountId CoreAccountModel::internalAccount() const {
-  return _internalAccount;
+
+AccountId CoreAccountModel::internalAccount() const
+{
+    return _internalAccount;
 }
 
+
 #endif
index 717fff3..c1ab23c 100644 (file)
 #include "util.h"
 
 CoreConnection::CoreConnection(CoreAccountModel *model, QObject *parent)
-  : QObject(parent),
-  _model(model),
-  _blockSize(0),
-  _state(Disconnected),
-  _wantReconnect(false),
-  _progressMinimum(0),
-  _progressMaximum(-1),
-  _progressValue(-1),
-  _wasReconnect(false),
-  _requestedDisconnect(false)
+    : QObject(parent),
+    _model(model),
+    _blockSize(0),
+    _state(Disconnected),
+    _wantReconnect(false),
+    _progressMinimum(0),
+    _progressMaximum(-1),
+    _progressValue(-1),
+    _wasReconnect(false),
+    _requestedDisconnect(false)
 {
-  qRegisterMetaType<ConnectionState>("CoreConnection::ConnectionState");
+    qRegisterMetaType<ConnectionState>("CoreConnection::ConnectionState");
 }
 
-void CoreConnection::init() {
-  Client::signalProxy()->setHeartBeatInterval(30);
-  connect(Client::signalProxy(), SIGNAL(disconnected()), SLOT(coreSocketDisconnected()));
-  connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), SIGNAL(lagUpdated(int)));
 
-  _reconnectTimer.setSingleShot(true);
-  connect(&_reconnectTimer, SIGNAL(timeout()), SLOT(reconnectTimeout()));
+void CoreConnection::init()
+{
+    Client::signalProxy()->setHeartBeatInterval(30);
+    connect(Client::signalProxy(), SIGNAL(disconnected()), SLOT(coreSocketDisconnected()));
+    connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), SIGNAL(lagUpdated(int)));
+
+    _reconnectTimer.setSingleShot(true);
+    connect(&_reconnectTimer, SIGNAL(timeout()), SLOT(reconnectTimeout()));
 
 #ifdef HAVE_KDE
-  connect(Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)),
-          SLOT(solidNetworkStatusChanged(Solid::Networking::Status)));
+    connect(Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)),
+        SLOT(solidNetworkStatusChanged(Solid::Networking::Status)));
 #endif
 
-  CoreConnectionSettings s;
-  s.initAndNotify("PingTimeoutInterval", this, SLOT(pingTimeoutIntervalChanged(QVariant)), 60);
-  s.initAndNotify("ReconnectInterval", this, SLOT(reconnectIntervalChanged(QVariant)), 60);
-  s.notify("NetworkDetectionMode", this, SLOT(networkDetectionModeChanged(QVariant)));
-  networkDetectionModeChanged(s.networkDetectionMode());
+    CoreConnectionSettings s;
+    s.initAndNotify("PingTimeoutInterval", this, SLOT(pingTimeoutIntervalChanged(QVariant)), 60);
+    s.initAndNotify("ReconnectInterval", this, SLOT(reconnectIntervalChanged(QVariant)), 60);
+    s.notify("NetworkDetectionMode", this, SLOT(networkDetectionModeChanged(QVariant)));
+    networkDetectionModeChanged(s.networkDetectionMode());
 }
 
-void CoreConnection::setProgressText(const QString &text) {
-  if(_progressText != text) {
-    _progressText = text;
-    emit progressTextChanged(text);
-  }
+
+void CoreConnection::setProgressText(const QString &text)
+{
+    if (_progressText != text) {
+        _progressText = text;
+        emit progressTextChanged(text);
+    }
 }
 
-void CoreConnection::setProgressValue(int value) {
-  if(_progressValue != value) {
-    _progressValue = value;
-    emit progressValueChanged(value);
-  }
+
+void CoreConnection::setProgressValue(int value)
+{
+    if (_progressValue != value) {
+        _progressValue = value;
+        emit progressValueChanged(value);
+    }
 }
 
-void CoreConnection::setProgressMinimum(int minimum) {
-  if(_progressMinimum != minimum) {
-    _progressMinimum = minimum;
-    emit progressRangeChanged(minimum, _progressMaximum);
-  }
+
+void CoreConnection::setProgressMinimum(int minimum)
+{
+    if (_progressMinimum != minimum) {
+        _progressMinimum = minimum;
+        emit progressRangeChanged(minimum, _progressMaximum);
+    }
 }
 
-void CoreConnection::setProgressMaximum(int maximum) {
-  if(_progressMaximum != maximum) {
-    _progressMaximum = maximum;
-    emit progressRangeChanged(_progressMinimum, maximum);
-  }
+
+void CoreConnection::setProgressMaximum(int maximum)
+{
+    if (_progressMaximum != maximum) {
+        _progressMaximum = maximum;
+        emit progressRangeChanged(_progressMinimum, maximum);
+    }
 }
 
-void CoreConnection::updateProgress(int value, int max) {
-  if(max != _progressMaximum) {
-    _progressMaximum = max;
-    emit progressRangeChanged(_progressMinimum, _progressMaximum);
-  }
-  setProgressValue(value);
+
+void CoreConnection::updateProgress(int value, int max)
+{
+    if (max != _progressMaximum) {
+        _progressMaximum = max;
+        emit progressRangeChanged(_progressMinimum, _progressMaximum);
+    }
+    setProgressValue(value);
 }
 
-void CoreConnection::reconnectTimeout() {
-  if(!_socket) {
-    CoreConnectionSettings s;
-    if(_wantReconnect && s.autoReconnect()) {
 
+void CoreConnection::reconnectTimeout()
+{
+    if (!_socket) {
+        CoreConnectionSettings s;
+        if (_wantReconnect && s.autoReconnect()) {
 #ifdef HAVE_KDE
-      // If using Solid, we don't want to reconnect if we're offline
-      if(s.networkDetectionMode() == CoreConnectionSettings::UseSolid) {
-        if(Solid::Networking::status() != Solid::Networking::Connected
-           && Solid::Networking::status() != Solid::Networking::Unknown) {
-          return;
-        }
-      }
+            // If using Solid, we don't want to reconnect if we're offline
+            if (s.networkDetectionMode() == CoreConnectionSettings::UseSolid) {
+                if (Solid::Networking::status() != Solid::Networking::Connected
+                    && Solid::Networking::status() != Solid::Networking::Unknown) {
+                    return;
+                }
+            }
 #endif /* HAVE_KDE */
 
-      reconnectToCore();
+            reconnectToCore();
+        }
     }
-  }
 }
 
-void CoreConnection::networkDetectionModeChanged(const QVariant &vmode) {
-  CoreConnectionSettings s;
-  CoreConnectionSettings::NetworkDetectionMode mode = (CoreConnectionSettings::NetworkDetectionMode)vmode.toInt();
-  if(mode == CoreConnectionSettings::UsePingTimeout)
-    Client::signalProxy()->setMaxHeartBeatCount(s.pingTimeoutInterval() / 30);
-  else {
-    Client::signalProxy()->setMaxHeartBeatCount(-1);
-  }
+
+void CoreConnection::networkDetectionModeChanged(const QVariant &vmode)
+{
+    CoreConnectionSettings s;
+    CoreConnectionSettings::NetworkDetectionMode mode = (CoreConnectionSettings::NetworkDetectionMode)vmode.toInt();
+    if (mode == CoreConnectionSettings::UsePingTimeout)
+        Client::signalProxy()->setMaxHeartBeatCount(s.pingTimeoutInterval() / 30);
+    else {
+        Client::signalProxy()->setMaxHeartBeatCount(-1);
+    }
 }
 
-void CoreConnection::pingTimeoutIntervalChanged(const QVariant &interval) {
-  CoreConnectionSettings s;
-  if(s.networkDetectionMode() == CoreConnectionSettings::UsePingTimeout)
-    Client::signalProxy()->setMaxHeartBeatCount(interval.toInt() / 30); // interval is 30 seconds
+
+void CoreConnection::pingTimeoutIntervalChanged(const QVariant &interval)
+{
+    CoreConnectionSettings s;
+    if (s.networkDetectionMode() == CoreConnectionSettings::UsePingTimeout)
+        Client::signalProxy()->setMaxHeartBeatCount(interval.toInt() / 30);  // interval is 30 seconds
 }
 
-void CoreConnection::reconnectIntervalChanged(const QVariant &interval) {
-  _reconnectTimer.setInterval(interval.toInt() * 1000);
+
+void CoreConnection::reconnectIntervalChanged(const QVariant &interval)
+{
+    _reconnectTimer.setInterval(interval.toInt() * 1000);
 }
 
+
 #ifdef HAVE_KDE
 
-void CoreConnection::solidNetworkStatusChanged(Solid::Networking::Status status) {
-  CoreConnectionSettings s;
-  if(s.networkDetectionMode() != CoreConnectionSettings::UseSolid)
-    return;
-
-  switch(status) {
-  case Solid::Networking::Unknown:
-  case Solid::Networking::Connected:
-    //qDebug() << "Solid: Network status changed to connected or unknown";
-    if(state() == Disconnected) {
-      if(_wantReconnect && s.autoReconnect()) {
-        reconnectToCore();
-      }
+void CoreConnection::solidNetworkStatusChanged(Solid::Networking::Status status)
+{
+    CoreConnectionSettings s;
+    if (s.networkDetectionMode() != CoreConnectionSettings::UseSolid)
+        return;
+
+    switch (status) {
+    case Solid::Networking::Unknown:
+    case Solid::Networking::Connected:
+        //qDebug() << "Solid: Network status changed to connected or unknown";
+        if (state() == Disconnected) {
+            if (_wantReconnect && s.autoReconnect()) {
+                reconnectToCore();
+            }
+        }
+        break;
+    case Solid::Networking::Disconnecting:
+    case Solid::Networking::Unconnected:
+        if (state() != Disconnected && !isLocalConnection())
+            disconnectFromCore(tr("Network is down"), true);
+        break;
+    default:
+        break;
     }
-    break;
-  case Solid::Networking::Disconnecting:
-  case Solid::Networking::Unconnected:
-    if(state() != Disconnected && !isLocalConnection())
-      disconnectFromCore(tr("Network is down"), true);
-    break;
-  default:
-    break;
-  }
 }
 
+
 #endif
 
-bool CoreConnection::isEncrypted() const {
+bool CoreConnection::isEncrypted() const
+{
 #ifndef HAVE_SSL
-  return false;
+    return false;
 #else
-  QSslSocket *sock = qobject_cast<QSslSocket *>(_socket);
-  return isConnected() && sock && sock->isEncrypted();
+    QSslSocket *sock = qobject_cast<QSslSocket *>(_socket);
+    return isConnected() && sock && sock->isEncrypted();
 #endif
 }
 
-bool CoreConnection::isLocalConnection() const {
-  if(!isConnected())
+
+bool CoreConnection::isLocalConnection() const
+{
+    if (!isConnected())
+        return false;
+    if (currentAccount().isInternal())
+        return true;
+    if (_socket->peerAddress().isInSubnet(QHostAddress::LocalHost, 0x00ffffff))
+        return true;
+
     return false;
-  if(currentAccount().isInternal())
-    return true;
-  if(_socket->peerAddress().isInSubnet(QHostAddress::LocalHost, 0x00ffffff))
-    return true;
+}
 
-  return false;
-}
-
-void CoreConnection::socketStateChanged(QAbstractSocket::SocketState socketState) {
-  QString text;
-
-  switch(socketState) {
-  case QAbstractSocket::UnconnectedState:
-    text = tr("Disconnected");
-    break;
-  case QAbstractSocket::HostLookupState:
-    text = tr("Looking up %1...").arg(currentAccount().hostName());
-    break;
-  case QAbstractSocket::ConnectingState:
-    text = tr("Connecting to %1...").arg(currentAccount().hostName());
-    break;
-  case QAbstractSocket::ConnectedState:
-    text = tr("Connected to %1").arg(currentAccount().hostName());
-    break;
-  case QAbstractSocket::ClosingState:
-    text = tr("Disconnecting from %1...").arg(currentAccount().hostName());
-    break;
-  default:
-    break;
-  }
-
-  if(!text.isEmpty())
-    emit progressTextChanged(text);
-
-  setState(socketState);
-}
-
-void CoreConnection::setState(QAbstractSocket::SocketState socketState) {
-  ConnectionState state;
-
-  switch(socketState) {
-  case QAbstractSocket::UnconnectedState:
-    state = Disconnected;
-    break;
-  case QAbstractSocket::HostLookupState:
-  case QAbstractSocket::ConnectingState:
-  case QAbstractSocket::ConnectedState:  // we'll set it to Connected in connectionReady()
-    state = Connecting;
-    break;
-  default:
-    state = Disconnected;
-  }
-
-  setState(state);
-}
-
-void CoreConnection::setState(ConnectionState state) {
-  if(state != _state) {
-    _state = state;
-    emit stateChanged(state);
-    if(state == Disconnected)
-      emit disconnected();
-  }
-}
-
-void CoreConnection::coreSocketError(QAbstractSocket::SocketError) {
-  qDebug() << "coreSocketError" << _socket << _socket->errorString();
-  disconnectFromCore(_socket->errorString(), true);
-}
-
-void CoreConnection::coreSocketDisconnected() {
-  // qDebug() << Q_FUNC_INFO;
-  _wasReconnect = !_requestedDisconnect;
-  resetConnection(true);
-  // FIXME handle disconnects gracefully
-}
-
-void CoreConnection::coreHasData() {
-  QVariant item;
-  while(SignalProxy::readDataFromDevice(_socket, _blockSize, item)) {
-    QVariantMap msg = item.toMap();
-    if(!msg.contains("MsgType")) {
-      // This core is way too old and does not even speak our init protocol...
-      emit connectionErrorPopup(tr("The Quassel Core you try to connect to is too old! Please consider upgrading."));
-      disconnectFromCore(QString(), false);
-      return;
+
+void CoreConnection::socketStateChanged(QAbstractSocket::SocketState socketState)
+{
+    QString text;
+
+    switch (socketState) {
+    case QAbstractSocket::UnconnectedState:
+        text = tr("Disconnected");
+        break;
+    case QAbstractSocket::HostLookupState:
+        text = tr("Looking up %1...").arg(currentAccount().hostName());
+        break;
+    case QAbstractSocket::ConnectingState:
+        text = tr("Connecting to %1...").arg(currentAccount().hostName());
+        break;
+    case QAbstractSocket::ConnectedState:
+        text = tr("Connected to %1").arg(currentAccount().hostName());
+        break;
+    case QAbstractSocket::ClosingState:
+        text = tr("Disconnecting from %1...").arg(currentAccount().hostName());
+        break;
+    default:
+        break;
     }
-    if(msg["MsgType"] == "ClientInitAck") {
-      clientInitAck(msg);
-    } else if(msg["MsgType"] == "ClientInitReject") {
-      emit connectionErrorPopup(msg["Error"].toString());
-      disconnectFromCore(QString(), false);
-      return;
-    } else if(msg["MsgType"] == "CoreSetupAck") {
-      emit coreSetupSuccess();
-    } else if(msg["MsgType"] == "CoreSetupReject") {
-      emit coreSetupFailed(msg["Error"].toString());
-    } else if(msg["MsgType"] == "ClientLoginReject") {
-      loginFailed(msg["Error"].toString());
-    } else if(msg["MsgType"] == "ClientLoginAck") {
-      loginSuccess();
-    } else if(msg["MsgType"] == "SessionInit") {
-      // that's it, let's hand over to the signal proxy
-      // if the socket is an orphan, the signalProxy adopts it.
-      // -> we don't need to care about it anymore
-      _socket->setParent(0);
-      Client::signalProxy()->addPeer(_socket);
-
-      sessionStateReceived(msg["SessionState"].toMap());
-      break; // this is definitively the last message we process here!
-    } else {
-      disconnectFromCore(tr("Invalid data received from core"), false);
-      return;
+
+    if (!text.isEmpty())
+        emit progressTextChanged(text);
+
+    setState(socketState);
+}
+
+
+void CoreConnection::setState(QAbstractSocket::SocketState socketState)
+{
+    ConnectionState state;
+
+    switch (socketState) {
+    case QAbstractSocket::UnconnectedState:
+        state = Disconnected;
+        break;
+    case QAbstractSocket::HostLookupState:
+    case QAbstractSocket::ConnectingState:
+    case QAbstractSocket::ConnectedState: // we'll set it to Connected in connectionReady()
+        state = Connecting;
+        break;
+    default:
+        state = Disconnected;
     }
-  }
-  if(_blockSize > 0) {
-    updateProgress(_socket->bytesAvailable(), _blockSize);
-  }
+
+    setState(state);
 }
 
-void CoreConnection::disconnectFromCore() {
-  _requestedDisconnect = true;
-  disconnectFromCore(QString(), false);  // requested disconnect, so don't try to reconnect
+
+void CoreConnection::setState(ConnectionState state)
+{
+    if (state != _state) {
+        _state = state;
+        emit stateChanged(state);
+        if (state == Disconnected)
+            emit disconnected();
+    }
 }
 
-void CoreConnection::disconnectFromCore(const QString &errorString, bool wantReconnect) {
-  if(!wantReconnect)
-    _reconnectTimer.stop();
 
-  _wasReconnect = wantReconnect; // store if disconnect was requested
+void CoreConnection::coreSocketError(QAbstractSocket::SocketError)
+{
+    qDebug() << "coreSocketError" << _socket << _socket->errorString();
+    disconnectFromCore(_socket->errorString(), true);
+}
 
-  if(errorString.isEmpty())
-    emit connectionError(tr("Disconnected"));
-  else
-    emit connectionError(errorString);
 
-  Client::signalProxy()->removeAllPeers();
-  resetConnection(wantReconnect);
+void CoreConnection::coreSocketDisconnected()
+{
+    // qDebug() << Q_FUNC_INFO;
+    _wasReconnect = !_requestedDisconnect;
+    resetConnection(true);
+    // FIXME handle disconnects gracefully
 }
 
-void CoreConnection::resetConnection(bool wantReconnect) {
-  _wantReconnect = wantReconnect;
 
-  if(_socket) {
-    disconnect(_socket, 0, this, 0);
-    _socket->deleteLater();
-    _socket = 0;
-  }
-  _requestedDisconnect = false;
-  _blockSize = 0;
+void CoreConnection::coreHasData()
+{
+    QVariant item;
+    while (SignalProxy::readDataFromDevice(_socket, _blockSize, item)) {
+        QVariantMap msg = item.toMap();
+        if (!msg.contains("MsgType")) {
+            // This core is way too old and does not even speak our init protocol...
+            emit connectionErrorPopup(tr("The Quassel Core you try to connect to is too old! Please consider upgrading."));
+            disconnectFromCore(QString(), false);
+            return;
+        }
+        if (msg["MsgType"] == "ClientInitAck") {
+            clientInitAck(msg);
+        }
+        else if (msg["MsgType"] == "ClientInitReject") {
+            emit connectionErrorPopup(msg["Error"].toString());
+            disconnectFromCore(QString(), false);
+            return;
+        }
+        else if (msg["MsgType"] == "CoreSetupAck") {
+            emit coreSetupSuccess();
+        }
+        else if (msg["MsgType"] == "CoreSetupReject") {
+            emit coreSetupFailed(msg["Error"].toString());
+        }
+        else if (msg["MsgType"] == "ClientLoginReject") {
+            loginFailed(msg["Error"].toString());
+        }
+        else if (msg["MsgType"] == "ClientLoginAck") {
+            loginSuccess();
+        }
+        else if (msg["MsgType"] == "SessionInit") {
+            // that's it, let's hand over to the signal proxy
+            // if the socket is an orphan, the signalProxy adopts it.
+            // -> we don't need to care about it anymore
+            _socket->setParent(0);
+            Client::signalProxy()->addPeer(_socket);
+
+            sessionStateReceived(msg["SessionState"].toMap());
+            break; // this is definitively the last message we process here!
+        }
+        else {
+            disconnectFromCore(tr("Invalid data received from core"), false);
+            return;
+        }
+    }
+    if (_blockSize > 0) {
+        updateProgress(_socket->bytesAvailable(), _blockSize);
+    }
+}
+
 
-  _coreMsgBuffer.clear();
+void CoreConnection::disconnectFromCore()
+{
+    _requestedDisconnect = true;
+    disconnectFromCore(QString(), false); // requested disconnect, so don't try to reconnect
+}
 
-  _netsToSync.clear();
-  _numNetsToSync = 0;
 
-  setProgressMaximum(-1); // disable
-  setState(Disconnected);
-  emit lagUpdated(-1);
+void CoreConnection::disconnectFromCore(const QString &errorString, bool wantReconnect)
+{
+    if (!wantReconnect)
+        _reconnectTimer.stop();
 
-  emit connectionMsg(tr("Disconnected from core."));
-  emit encrypted(false);
+    _wasReconnect = wantReconnect; // store if disconnect was requested
 
-  // initiate if a reconnect if appropriate
-  CoreConnectionSettings s;
-  if(wantReconnect && s.autoReconnect()) {
-    _reconnectTimer.start();
-  }
-}
+    if (errorString.isEmpty())
+        emit connectionError(tr("Disconnected"));
+    else
+        emit connectionError(errorString);
 
-void CoreConnection::reconnectToCore() {
-  if(currentAccount().isValid())
-    connectToCore(currentAccount().accountId());
+    Client::signalProxy()->removeAllPeers();
+    resetConnection(wantReconnect);
 }
 
-bool CoreConnection::connectToCore(AccountId accId) {
-  if(isConnected())
-    return false;
 
-  CoreAccountSettings s;
+void CoreConnection::resetConnection(bool wantReconnect)
+{
+    _wantReconnect = wantReconnect;
 
-  // FIXME: Don't force connection to internal core in mono client
-  if(Quassel::runMode() == Quassel::Monolithic) {
-    _account = accountModel()->account(accountModel()->internalAccount());
-    Q_ASSERT(_account.isValid());
-  } else {
-    if(!accId.isValid()) {
-      // check our settings and figure out what to do
-      if(!s.autoConnectOnStartup())
-        return false;
-      if(s.autoConnectToFixedAccount())
-        accId = s.autoConnectAccount();
-      else
-        accId = s.lastAccount();
-      if(!accId.isValid())
-        return false;
+    if (_socket) {
+        disconnect(_socket, 0, this, 0);
+        _socket->deleteLater();
+        _socket = 0;
     }
-    _account = accountModel()->account(accId);
-    if(!_account.accountId().isValid()) {
-      return false;
+    _requestedDisconnect = false;
+    _blockSize = 0;
+
+    _coreMsgBuffer.clear();
+
+    _netsToSync.clear();
+    _numNetsToSync = 0;
+
+    setProgressMaximum(-1); // disable
+    setState(Disconnected);
+    emit lagUpdated(-1);
+
+    emit connectionMsg(tr("Disconnected from core."));
+    emit encrypted(false);
+
+    // initiate if a reconnect if appropriate
+    CoreConnectionSettings s;
+    if (wantReconnect && s.autoReconnect()) {
+        _reconnectTimer.start();
     }
-    if(Quassel::runMode() != Quassel::Monolithic) {
-      if(_account.isInternal())
+}
+
+
+void CoreConnection::reconnectToCore()
+{
+    if (currentAccount().isValid())
+        connectToCore(currentAccount().accountId());
+}
+
+
+bool CoreConnection::connectToCore(AccountId accId)
+{
+    if (isConnected())
         return false;
+
+    CoreAccountSettings s;
+
+    // FIXME: Don't force connection to internal core in mono client
+    if (Quassel::runMode() == Quassel::Monolithic) {
+        _account = accountModel()->account(accountModel()->internalAccount());
+        Q_ASSERT(_account.isValid());
+    }
+    else {
+        if (!accId.isValid()) {
+            // check our settings and figure out what to do
+            if (!s.autoConnectOnStartup())
+                return false;
+            if (s.autoConnectToFixedAccount())
+                accId = s.autoConnectAccount();
+            else
+                accId = s.lastAccount();
+            if (!accId.isValid())
+                return false;
+        }
+        _account = accountModel()->account(accId);
+        if (!_account.accountId().isValid()) {
+            return false;
+        }
+        if (Quassel::runMode() != Quassel::Monolithic) {
+            if (_account.isInternal())
+                return false;
+        }
     }
-  }
 
-  s.setLastAccount(accId);
-  connectToCurrentAccount();
-  return true;
+    s.setLastAccount(accId);
+    connectToCurrentAccount();
+    return true;
 }
 
-void CoreConnection::connectToCurrentAccount() {
-  resetConnection(false);
 
-  if(currentAccount().isInternal()) {
-    if(Quassel::runMode() != Quassel::Monolithic) {
-      qWarning() << "Cannot connect to internal core in client-only mode!";
-      return;
+void CoreConnection::connectToCurrentAccount()
+{
+    resetConnection(false);
+
+    if (currentAccount().isInternal()) {
+        if (Quassel::runMode() != Quassel::Monolithic) {
+            qWarning() << "Cannot connect to internal core in client-only mode!";
+            return;
+        }
+        emit startInternalCore();
+        emit connectToInternalCore(Client::instance()->signalProxy());
+        return;
     }
-    emit startInternalCore();
-    emit connectToInternalCore(Client::instance()->signalProxy());
-    return;
-  }
 
-  CoreAccountSettings s;
+    CoreAccountSettings s;
 
-  Q_ASSERT(!_socket);
+    Q_ASSERT(!_socket);
 #ifdef HAVE_SSL
-  QSslSocket *sock = new QSslSocket(Client::instance());
-  // make sure the warning is shown if we happen to connect without SSL support later
-  s.setAccountValue("ShowNoClientSslWarning", true);
+    QSslSocket *sock = new QSslSocket(Client::instance());
+    // make sure the warning is shown if we happen to connect without SSL support later
+    s.setAccountValue("ShowNoClientSslWarning", true);
 #else
-  if(_account.useSsl()) {
-    if(s.accountValue("ShowNoClientSslWarning", true).toBool()) {
-      bool accepted = false;
-      emit handleNoSslInClient(&accepted);
-      if(!accepted) {
-        emit connectionError(tr("Unencrypted connection canceled"));
-        return;
-      }
-      s.setAccountValue("ShowNoClientSslWarning", false);
+    if (_account.useSsl()) {
+        if (s.accountValue("ShowNoClientSslWarning", true).toBool()) {
+            bool accepted = false;
+            emit handleNoSslInClient(&accepted);
+            if (!accepted) {
+                emit connectionError(tr("Unencrypted connection canceled"));
+                return;
+            }
+            s.setAccountValue("ShowNoClientSslWarning", false);
+        }
     }
-  }
-  QTcpSocket *sock = new QTcpSocket(Client::instance());
+    QTcpSocket *sock = new QTcpSocket(Client::instance());
 #endif
 
 #ifndef QT_NO_NETWORKPROXY
-  if(_account.useProxy()) {
-    QNetworkProxy proxy(_account.proxyType(), _account.proxyHostName(), _account.proxyPort(), _account.proxyUser(), _account.proxyPassword());
-    sock->setProxy(proxy);
-  }
+    if (_account.useProxy()) {
+        QNetworkProxy proxy(_account.proxyType(), _account.proxyHostName(), _account.proxyPort(), _account.proxyUser(), _account.proxyPassword());
+        sock->setProxy(proxy);
+    }
 #endif
 
-  _socket = sock;
-  connect(sock, SIGNAL(readyRead()), SLOT(coreHasData()));
-  connect(sock, SIGNAL(connected()), SLOT(coreSocketConnected()));
-  connect(sock, SIGNAL(disconnected()), SLOT(coreSocketDisconnected()));
-  connect(sock, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(coreSocketError(QAbstractSocket::SocketError)));
-  connect(sock, SIGNAL(stateChanged(QAbstractSocket::SocketState)), SLOT(socketStateChanged(QAbstractSocket::SocketState)));
+    _socket = sock;
+    connect(sock, SIGNAL(readyRead()), SLOT(coreHasData()));
+    connect(sock, SIGNAL(connected()), SLOT(coreSocketConnected()));
+    connect(sock, SIGNAL(disconnected()), SLOT(coreSocketDisconnected()));
+    connect(sock, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(coreSocketError(QAbstractSocket::SocketError)));
+    connect(sock, SIGNAL(stateChanged(QAbstractSocket::SocketState)), SLOT(socketStateChanged(QAbstractSocket::SocketState)));
 
-  emit connectionMsg(tr("Connecting to %1...").arg(currentAccount().accountName()));
-  sock->connectToHost(_account.hostName(), _account.port());
+    emit connectionMsg(tr("Connecting to %1...").arg(currentAccount().accountName()));
+    sock->connectToHost(_account.hostName(), _account.port());
 }
 
-void CoreConnection::coreSocketConnected() {
-  // Phase One: Send client info and wait for core info
 
-  emit connectionMsg(tr("Synchronizing to core..."));
+void CoreConnection::coreSocketConnected()
+{
+    // Phase One: Send client info and wait for core info
+
+    emit connectionMsg(tr("Synchronizing to core..."));
 
-  QVariantMap clientInit;
-  clientInit["MsgType"] = "ClientInit";
-  clientInit["ClientVersion"] = Quassel::buildInfo().fancyVersionString;
-  clientInit["ClientDate"] = Quassel::buildInfo().buildDate;
-  clientInit["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
-  clientInit["UseSsl"] = _account.useSsl();
+    QVariantMap clientInit;
+    clientInit["MsgType"] = "ClientInit";
+    clientInit["ClientVersion"] = Quassel::buildInfo().fancyVersionString;
+    clientInit["ClientDate"] = Quassel::buildInfo().buildDate;
+    clientInit["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
+    clientInit["UseSsl"] = _account.useSsl();
 #ifndef QT_NO_COMPRESS
-  clientInit["UseCompression"] = true;
+    clientInit["UseCompression"] = true;
 #else
-  clientInit["UseCompression"] = false;
+    clientInit["UseCompression"] = false;
 #endif
 
-  SignalProxy::writeDataToDevice(_socket, clientInit);
+    SignalProxy::writeDataToDevice(_socket, clientInit);
 }
 
-void CoreConnection::clientInitAck(const QVariantMap &msg) {
-  // Core has accepted our version info and sent its own. Let's see if we accept it as well...
-  uint ver = msg["ProtocolVersion"].toUInt();
-  if(ver < Quassel::buildInfo().clientNeedsProtocol) {
-    emit connectionErrorPopup(tr("<b>The Quassel Core you are trying to connect to is too old!</b><br>"
-        "Need at least core/client protocol v%1 to connect.").arg(Quassel::buildInfo().clientNeedsProtocol));
-    disconnectFromCore(QString(), false);
-    return;
-  }
 
-  Client::setCoreFeatures((Quassel::Features)msg["CoreFeatures"].toUInt());
+void CoreConnection::clientInitAck(const QVariantMap &msg)
+{
+    // Core has accepted our version info and sent its own. Let's see if we accept it as well...
+    uint ver = msg["ProtocolVersion"].toUInt();
+    if (ver < Quassel::buildInfo().clientNeedsProtocol) {
+        emit connectionErrorPopup(tr("<b>The Quassel Core you are trying to connect to is too old!</b><br>"
+                                     "Need at least core/client protocol v%1 to connect.").arg(Quassel::buildInfo().clientNeedsProtocol));
+        disconnectFromCore(QString(), false);
+        return;
+    }
+
+    Client::setCoreFeatures((Quassel::Features)msg["CoreFeatures"].toUInt());
 
 #ifndef QT_NO_COMPRESS
-  if(msg["SupportsCompression"].toBool()) {
-    _socket->setProperty("UseCompression", true);
-  }
+    if (msg["SupportsCompression"].toBool()) {
+        _socket->setProperty("UseCompression", true);
+    }
 #endif
 
-  _coreMsgBuffer = msg;
+    _coreMsgBuffer = msg;
 
 #ifdef HAVE_SSL
-  CoreAccountSettings s;
-  if(currentAccount().useSsl()) {
-    if(msg["SupportSsl"].toBool()) {
-      // Make sure the warning is shown next time we don't have SSL in the core
-      s.setAccountValue("ShowNoCoreSslWarning", true);
-
-      QSslSocket *sslSocket = qobject_cast<QSslSocket *>(_socket);
-      Q_ASSERT(sslSocket);
-      connect(sslSocket, SIGNAL(encrypted()), SLOT(sslSocketEncrypted()));
-      connect(sslSocket, SIGNAL(sslErrors(const QList<QSslError> &)), SLOT(sslErrors()));
-      sslSocket->startClientEncryption();
-    } else {
-      if(s.accountValue("ShowNoCoreSslWarning", true).toBool()) {
-        bool accepted = false;
-        emit handleNoSslInCore(&accepted);
-        if(!accepted) {
-          disconnectFromCore(tr("Unencrypted connection canceled"), false);
-          return;
+    CoreAccountSettings s;
+    if (currentAccount().useSsl()) {
+        if (msg["SupportSsl"].toBool()) {
+            // Make sure the warning is shown next time we don't have SSL in the core
+            s.setAccountValue("ShowNoCoreSslWarning", true);
+
+            QSslSocket *sslSocket = qobject_cast<QSslSocket *>(_socket);
+            Q_ASSERT(sslSocket);
+            connect(sslSocket, SIGNAL(encrypted()), SLOT(sslSocketEncrypted()));
+            connect(sslSocket, SIGNAL(sslErrors(const QList<QSslError> &)), SLOT(sslErrors()));
+            sslSocket->startClientEncryption();
+        }
+        else {
+            if (s.accountValue("ShowNoCoreSslWarning", true).toBool()) {
+                bool accepted = false;
+                emit handleNoSslInCore(&accepted);
+                if (!accepted) {
+                    disconnectFromCore(tr("Unencrypted connection canceled"), false);
+                    return;
+                }
+                s.setAccountValue("ShowNoCoreSslWarning", false);
+                s.setAccountValue("SslCert", QString());
+            }
+            connectionReady();
         }
-        s.setAccountValue("ShowNoCoreSslWarning", false);
-        s.setAccountValue("SslCert", QString());
-      }
-      connectionReady();
+        return;
     }
-    return;
-  }
 #endif
-  // if we use SSL we wait for the next step until every SSL warning has been cleared
-  connectionReady();
+    // if we use SSL we wait for the next step until every SSL warning has been cleared
+    connectionReady();
 }
 
-#ifdef HAVE_SSL
 
-void CoreConnection::sslSocketEncrypted() {
-  QSslSocket *socket = qobject_cast<QSslSocket *>(sender());
-  Q_ASSERT(socket);
+#ifdef HAVE_SSL
 
-  if(!socket->sslErrors().count()) {
-    // Cert is valid, so we don't want to store it as known
-    // That way, a warning will appear in case it becomes invalid at some point
-    CoreAccountSettings s;
-    s.setAccountValue("SSLCert", QString());
-  }
+void CoreConnection::sslSocketEncrypted()
+{
+    QSslSocket *socket = qobject_cast<QSslSocket *>(sender());
+    Q_ASSERT(socket);
+
+    if (!socket->sslErrors().count()) {
+        // Cert is valid, so we don't want to store it as known
+        // That way, a warning will appear in case it becomes invalid at some point
+        CoreAccountSettings s;
+        s.setAccountValue("SSLCert", QString());
+    }
 
-  emit encrypted(true);
-  connectionReady();
+    emit encrypted(true);
+    connectionReady();
 }
 
-void CoreConnection::sslErrors() {
-  QSslSocket *socket = qobject_cast<QSslSocket *>(sender());
-  Q_ASSERT(socket);
 
-  CoreAccountSettings s;
-  QByteArray knownDigest = s.accountValue("SslCert").toByteArray();
+void CoreConnection::sslErrors()
+{
+    QSslSocket *socket = qobject_cast<QSslSocket *>(sender());
+    Q_ASSERT(socket);
 
-  if(knownDigest != socket->peerCertificate().digest()) {
-    bool accepted = false;
-    bool permanently = false;
-    emit handleSslErrors(socket, &accepted, &permanently);
+    CoreAccountSettings s;
+    QByteArray knownDigest = s.accountValue("SslCert").toByteArray();
 
-    if(!accepted) {
-      disconnectFromCore(tr("Unencrypted connection canceled"), false);
-      return;
-    }
+    if (knownDigest != socket->peerCertificate().digest()) {
+        bool accepted = false;
+        bool permanently = false;
+        emit handleSslErrors(socket, &accepted, &permanently);
 
-    if(permanently)
-      s.setAccountValue("SslCert", socket->peerCertificate().digest());
-    else
-      s.setAccountValue("SslCert", QString());
-  }
+        if (!accepted) {
+            disconnectFromCore(tr("Unencrypted connection canceled"), false);
+            return;
+        }
 
-  socket->ignoreSslErrors();
+        if (permanently)
+            s.setAccountValue("SslCert", socket->peerCertificate().digest());
+        else
+            s.setAccountValue("SslCert", QString());
+    }
+
+    socket->ignoreSslErrors();
 }
 
+
 #endif /* HAVE_SSL */
 
-void CoreConnection::connectionReady() {
-  setState(Connected);
-  emit connectionMsg(tr("Connected to %1").arg(currentAccount().accountName()));
+void CoreConnection::connectionReady()
+{
+    setState(Connected);
+    emit connectionMsg(tr("Connected to %1").arg(currentAccount().accountName()));
 
-  if(!_coreMsgBuffer["Configured"].toBool()) {
-    // start wizard
-    emit startCoreSetup(_coreMsgBuffer["StorageBackends"].toList());
-  } else if(_coreMsgBuffer["LoginEnabled"].toBool()) {
-    loginToCore();
-  }
-  _coreMsgBuffer.clear();
+    if (!_coreMsgBuffer["Configured"].toBool()) {
+        // start wizard
+        emit startCoreSetup(_coreMsgBuffer["StorageBackends"].toList());
+    }
+    else if (_coreMsgBuffer["LoginEnabled"].toBool()) {
+        loginToCore();
+    }
+    _coreMsgBuffer.clear();
 }
 
-void CoreConnection::loginToCore(const QString &user, const QString &password, bool remember) {
-  _account.setUser(user);
-  _account.setPassword(password);
-  _account.setStorePassword(remember);
-  loginToCore();
+
+void CoreConnection::loginToCore(const QString &user, const QString &password, bool remember)
+{
+    _account.setUser(user);
+    _account.setPassword(password);
+    _account.setStorePassword(remember);
+    loginToCore();
 }
 
-void CoreConnection::loginToCore(const QString &prevError) {
-  emit connectionMsg(tr("Logging in..."));
-  if(currentAccount().user().isEmpty() || currentAccount().password().isEmpty() || !prevError.isEmpty()) {
-    bool valid = false;
-    emit userAuthenticationRequired(&_account, &valid, prevError);  // *must* be a synchronous call
-    if(!valid || currentAccount().user().isEmpty() || currentAccount().password().isEmpty()) {
-      disconnectFromCore(tr("Login canceled"), false);
-      return;
+
+void CoreConnection::loginToCore(const QString &prevError)
+{
+    emit connectionMsg(tr("Logging in..."));
+    if (currentAccount().user().isEmpty() || currentAccount().password().isEmpty() || !prevError.isEmpty()) {
+        bool valid = false;
+        emit userAuthenticationRequired(&_account, &valid, prevError); // *must* be a synchronous call
+        if (!valid || currentAccount().user().isEmpty() || currentAccount().password().isEmpty()) {
+            disconnectFromCore(tr("Login canceled"), false);
+            return;
+        }
     }
-  }
 
-  QVariantMap clientLogin;
-  clientLogin["MsgType"] = "ClientLogin";
-  clientLogin["User"] = currentAccount().user();
-  clientLogin["Password"] = currentAccount().password();
-  SignalProxy::writeDataToDevice(_socket, clientLogin);
+    QVariantMap clientLogin;
+    clientLogin["MsgType"] = "ClientLogin";
+    clientLogin["User"] = currentAccount().user();
+    clientLogin["Password"] = currentAccount().password();
+    SignalProxy::writeDataToDevice(_socket, clientLogin);
 }
 
-void CoreConnection::loginFailed(const QString &error) {
-  loginToCore(error);
+
+void CoreConnection::loginFailed(const QString &error)
+{
+    loginToCore(error);
 }
 
-void CoreConnection::loginSuccess() {
-  updateProgress(0, 0);
 
-  // save current account data
-  _model->createOrUpdateAccount(currentAccount());
-  _model->save();
+void CoreConnection::loginSuccess()
+{
+    updateProgress(0, 0);
 
-  _reconnectTimer.stop();
+    // save current account data
+    _model->createOrUpdateAccount(currentAccount());
+    _model->save();
 
-  setProgressText(tr("Receiving session state"));
-  setState(Synchronizing);
-  emit connectionMsg(tr("Synchronizing to %1...").arg(currentAccount().accountName()));
+    _reconnectTimer.stop();
+
+    setProgressText(tr("Receiving session state"));
+    setState(Synchronizing);
+    emit connectionMsg(tr("Synchronizing to %1...").arg(currentAccount().accountName()));
 }
 
-void CoreConnection::sessionStateReceived(const QVariantMap &state) {
-  updateProgress(100, 100);
 
-  // rest of communication happens through SignalProxy...
-  disconnect(_socket, SIGNAL(readyRead()), this, 0);
-  disconnect(_socket, SIGNAL(connected()), this, 0);
+void CoreConnection::sessionStateReceived(const QVariantMap &state)
+{
+    updateProgress(100, 100);
+
+    // rest of communication happens through SignalProxy...
+    disconnect(_socket, SIGNAL(readyRead()), this, 0);
+    disconnect(_socket, SIGNAL(connected()), this, 0);
 
-  syncToCore(state);
+    syncToCore(state);
 }
 
-void CoreConnection::internalSessionStateReceived(const QVariant &packedState) {
-  updateProgress(100, 100);
 
-  setState(Synchronizing);
-  syncToCore(packedState.toMap());
+void CoreConnection::internalSessionStateReceived(const QVariant &packedState)
+{
+    updateProgress(100, 100);
+
+    setState(Synchronizing);
+    syncToCore(packedState.toMap());
 }
 
-void CoreConnection::syncToCore(const QVariantMap &sessionState) {
-  if(sessionState.contains("CoreFeatures"))
-    Client::setCoreFeatures((Quassel::Features)sessionState["CoreFeatures"].toUInt());
 
-  setProgressText(tr("Receiving network states"));
-  updateProgress(0, 100);
+void CoreConnection::syncToCore(const QVariantMap &sessionState)
+{
+    if (sessionState.contains("CoreFeatures"))
+        Client::setCoreFeatures((Quassel::Features)sessionState["CoreFeatures"].toUInt());
+
+    setProgressText(tr("Receiving network states"));
+    updateProgress(0, 100);
 
-  // create identities
-  foreach(QVariant vid, sessionState["Identities"].toList()) {
-    Client::instance()->coreIdentityCreated(vid.value<Identity>());
-  }
+    // create identities
+    foreach(QVariant vid, sessionState["Identities"].toList()) {
+        Client::instance()->coreIdentityCreated(vid.value<Identity>());
+    }
 
-  // create buffers
-  // FIXME: get rid of this crap -- why?
-  QVariantList bufferinfos = sessionState["BufferInfos"].toList();
-  NetworkModel *networkModel = Client::networkModel();
-  Q_ASSERT(networkModel);
-  foreach(QVariant vinfo, bufferinfos)
+    // create buffers
+    // FIXME: get rid of this crap -- why?
+    QVariantList bufferinfos = sessionState["BufferInfos"].toList();
+    NetworkModel *networkModel = Client::networkModel();
+    Q_ASSERT(networkModel);
+    foreach(QVariant vinfo, bufferinfos)
     networkModel->bufferUpdated(vinfo.value<BufferInfo>());  // create BufferItems
 
-  QVariantList networkids = sessionState["NetworkIds"].toList();
+    QVariantList networkids = sessionState["NetworkIds"].toList();
+
+    // prepare sync progress thingys...
+    // FIXME: Care about removal of networks
+    _numNetsToSync = networkids.count();
+    updateProgress(0, _numNetsToSync);
+
+    // create network objects
+    foreach(QVariant networkid, networkids) {
+        NetworkId netid = networkid.value<NetworkId>();
+        if (Client::network(netid))
+            continue;
+        Network *net = new Network(netid, Client::instance());
+        _netsToSync.insert(net);
+        connect(net, SIGNAL(initDone()), SLOT(networkInitDone()));
+        connect(net, SIGNAL(destroyed()), SLOT(networkInitDone()));
+        Client::addNetwork(net);
+    }
+    checkSyncState();
+}
 
-  // prepare sync progress thingys...
-  // FIXME: Care about removal of networks
-  _numNetsToSync = networkids.count();
-  updateProgress(0, _numNetsToSync);
 
-  // create network objects
-  foreach(QVariant networkid, networkids) {
-    NetworkId netid = networkid.value<NetworkId>();
-    if(Client::network(netid))
-      continue;
-    Network *net = new Network(netid, Client::instance());
-    _netsToSync.insert(net);
-    connect(net, SIGNAL(initDone()), SLOT(networkInitDone()));
-    connect(net, SIGNAL(destroyed()), SLOT(networkInitDone()));
-    Client::addNetwork(net);
-  }
-  checkSyncState();
+// this is also called for destroyed networks!
+void CoreConnection::networkInitDone()
+{
+    QObject *net = sender();
+    Q_ASSERT(net);
+    disconnect(net, 0, this, 0);
+    _netsToSync.remove(net);
+    updateProgress(_numNetsToSync - _netsToSync.count(), _numNetsToSync);
+    checkSyncState();
 }
 
-// this is also called for destroyed networks!
-void CoreConnection::networkInitDone() {
-  QObject *net = sender();
-  Q_ASSERT(net);
-  disconnect(net, 0, this, 0);
-  _netsToSync.remove(net);
-  updateProgress(_numNetsToSync - _netsToSync.count(), _numNetsToSync);
-  checkSyncState();
-}
-
-void CoreConnection::checkSyncState() {
-  if(_netsToSync.isEmpty() && state() >= Synchronizing) {
-    setState(Synchronized);
-    setProgressText(tr("Synchronized to %1").arg(currentAccount().accountName()));
-    setProgressMaximum(-1);
-    emit synchronized();
-  }
-}
-
-void CoreConnection::doCoreSetup(const QVariant &setupData) {
-  QVariantMap setup;
-  setup["MsgType"] = "CoreSetupData";
-  setup["SetupData"] = setupData;
-  SignalProxy::writeDataToDevice(_socket, setup);
+
+void CoreConnection::checkSyncState()
+{
+    if (_netsToSync.isEmpty() && state() >= Synchronizing) {
+        setState(Synchronized);
+        setProgressText(tr("Synchronized to %1").arg(currentAccount().accountName()));
+        setProgressMaximum(-1);
+        emit synchronized();
+    }
+}
+
+
+void CoreConnection::doCoreSetup(const QVariant &setupData)
+{
+    QVariantMap setup;
+    setup["MsgType"] = "CoreSetupData";
+    setup["SetupData"] = setupData;
+    SignalProxy::writeDataToDevice(_socket, setup);
 }
index 11c8d50..699a2db 100644 (file)
@@ -43,156 +43,158 @@ class CoreAccountModel;
 class Network;
 class SignalProxy;
 
-class CoreConnection : public QObject {
-  Q_OBJECT
+class CoreConnection : public QObject
+{
+    Q_OBJECT
 
 public:
-  enum ConnectionState {
-    Disconnected,
-    Connecting,
-    Connected,
-    Synchronizing,
-    Synchronized
-  };
+    enum ConnectionState {
+        Disconnected,
+        Connecting,
+        Connected,
+        Synchronizing,
+        Synchronized
+    };
 
-  CoreConnection(CoreAccountModel *model, QObject *parent = 0);
+    CoreConnection(CoreAccountModel *model, QObject *parent = 0);
 
-  void init();
+    void init();
 
-  inline bool isConnected() const;
-  inline ConnectionState state() const;
-  inline CoreAccount currentAccount() const;
+    inline bool isConnected() const;
+    inline ConnectionState state() const;
+    inline CoreAccount currentAccount() const;
 
-  bool isEncrypted() const;
-  bool isLocalConnection() const;
+    bool isEncrypted() const;
+    bool isLocalConnection() const;
 
-  inline int progressMinimum() const;
-  inline int progressMaximum() const;
-  inline int progressValue() const;
-  inline QString progressText() const;
+    inline int progressMinimum() const;
+    inline int progressMaximum() const;
+    inline int progressValue() const;
+    inline QString progressText() const;
 
-  //! Check if we consider the last connect as reconnect
-  inline bool wasReconnect() const { return _wasReconnect; }
+    //! Check if we consider the last connect as reconnect
+    inline bool wasReconnect() const { return _wasReconnect; }
 
 #ifdef HAVE_SSL
-  inline const QSslSocket *sslSocket() const;
+    inline const QSslSocket *sslSocket() const;
 #endif
 
 public slots:
-  bool connectToCore(AccountId = 0);
-  void reconnectToCore();
-  void disconnectFromCore();
+    bool connectToCore(AccountId = 0);
+    void reconnectToCore();
+    void disconnectFromCore();
 
 signals:
-  void stateChanged(CoreConnection::ConnectionState);
-  void encrypted(bool isEncrypted = true);
-  void synchronized();
-  void lagUpdated(int msecs);
-
-  void connectionError(const QString &errorMsg);
-  void connectionErrorPopup(const QString &errorMsg);
-  void connectionWarnings(const QStringList &warnings);
-  void connectionMsg(const QString &msg);
-  void disconnected();
-
-  void progressRangeChanged(int minimum, int maximum);
-  void progressValueChanged(int value);
-  void progressTextChanged(const QString &);
-
-  void startCoreSetup(const QVariantList &);
-  void coreSetupSuccess();
-  void coreSetupFailed(const QString &error);
-
-  void startInternalCore();
-  void connectToInternalCore(SignalProxy *proxy);
-
-  // These signals MUST be handled synchronously!
-  void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage = QString());
-  void handleNoSslInClient(bool *accepted);
-  void handleNoSslInCore(bool *accepted);
+    void stateChanged(CoreConnection::ConnectionState);
+    void encrypted(bool isEncrypted = true);
+    void synchronized();
+    void lagUpdated(int msecs);
+
+    void connectionError(const QString &errorMsg);
+    void connectionErrorPopup(const QString &errorMsg);
+    void connectionWarnings(const QStringList &warnings);
+    void connectionMsg(const QString &msg);
+    void disconnected();
+
+    void progressRangeChanged(int minimum, int maximum);
+    void progressValueChanged(int value);
+    void progressTextChanged(const QString &);
+
+    void startCoreSetup(const QVariantList &);
+    void coreSetupSuccess();
+    void coreSetupFailed(const QString &error);
+
+    void startInternalCore();
+    void connectToInternalCore(SignalProxy *proxy);
+
+    // These signals MUST be handled synchronously!
+    void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage = QString());
+    void handleNoSslInClient(bool *accepted);
+    void handleNoSslInCore(bool *accepted);
 #ifdef HAVE_SSL
-  void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
+    void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
 #endif
 
 private slots:
-  void connectToCurrentAccount();
-  void disconnectFromCore(const QString &errorString, bool wantReconnect = true);
+    void connectToCurrentAccount();
+    void disconnectFromCore(const QString &errorString, bool wantReconnect = true);
 
-  void socketStateChanged(QAbstractSocket::SocketState);
-  void coreSocketError(QAbstractSocket::SocketError);
-  void coreHasData();
-  void coreSocketConnected();
-  void coreSocketDisconnected();
+    void socketStateChanged(QAbstractSocket::SocketState);
+    void coreSocketError(QAbstractSocket::SocketError);
+    void coreHasData();
+    void coreSocketConnected();
+    void coreSocketDisconnected();
 
-  void clientInitAck(const QVariantMap &msg);
+    void clientInitAck(const QVariantMap &msg);
 
-  // for sync progress
-  void networkInitDone();
-  void checkSyncState();
+    // for sync progress
+    void networkInitDone();
+    void checkSyncState();
 
-  void syncToCore(const QVariantMap &sessionState);
-  void internalSessionStateReceived(const QVariant &packedState);
-  void sessionStateReceived(const QVariantMap &state);
+    void syncToCore(const QVariantMap &sessionState);
+    void internalSessionStateReceived(const QVariant &packedState);
+    void sessionStateReceived(const QVariantMap &state);
 
-  void resetConnection(bool wantReconnect = false);
-  void connectionReady();
+    void resetConnection(bool wantReconnect = false);
+    void connectionReady();
 
-  void loginToCore(const QString &user, const QString &password, bool remember); // for config wizard
-  void loginToCore(const QString &previousError = QString());
-  void loginSuccess();
-  void loginFailed(const QString &errorMessage);
+    void loginToCore(const QString &user, const QString &password, bool remember); // for config wizard
+    void loginToCore(const QString &previousError = QString());
+    void loginSuccess();
+    void loginFailed(const QString &errorMessage);
 
-  void doCoreSetup(const QVariant &setupData);
+    void doCoreSetup(const QVariant &setupData);
 
-  void updateProgress(int value, int maximum);
-  void setProgressText(const QString &text);
-  void setProgressValue(int value);
-  void setProgressMinimum(int minimum);
-  void setProgressMaximum(int maximum);
+    void updateProgress(int value, int maximum);
+    void setProgressText(const QString &text);
+    void setProgressValue(int value);
+    void setProgressMinimum(int minimum);
+    void setProgressMaximum(int maximum);
 
-  void setState(QAbstractSocket::SocketState socketState);
-  void setState(ConnectionState state);
+    void setState(QAbstractSocket::SocketState socketState);
+    void setState(ConnectionState state);
 
 #ifdef HAVE_SSL
-  void sslSocketEncrypted();
-  void sslErrors();
+    void sslSocketEncrypted();
+    void sslErrors();
 #endif
 
-  void networkDetectionModeChanged(const QVariant &mode);
-  void pingTimeoutIntervalChanged(const QVariant &interval);
-  void reconnectIntervalChanged(const QVariant &interval);
-  void reconnectTimeout();
+    void networkDetectionModeChanged(const QVariant &mode);
+    void pingTimeoutIntervalChanged(const QVariant &interval);
+    void reconnectIntervalChanged(const QVariant &interval);
+    void reconnectTimeout();
 
 #ifdef HAVE_KDE
-  void solidNetworkStatusChanged(Solid::Networking::Status status);
+    void solidNetworkStatusChanged(Solid::Networking::Status status);
 #endif
 
 private:
-  CoreAccountModel *_model;
-  CoreAccount _account;
-  QVariantMap _coreMsgBuffer;
+    CoreAccountModel *_model;
+    CoreAccount _account;
+    QVariantMap _coreMsgBuffer;
 
-  QPointer<QAbstractSocket> _socket;
-  quint32 _blockSize;
-  ConnectionState _state;
+    QPointer<QAbstractSocket> _socket;
+    quint32 _blockSize;
+    ConnectionState _state;
 
-  QTimer _reconnectTimer;
-  bool _wantReconnect;
+    QTimer _reconnectTimer;
+    bool _wantReconnect;
 
-  QSet<QObject *> _netsToSync;
-  int _numNetsToSync;
-  int _progressMinimum, _progressMaximum, _progressValue;
-  QString _progressText;
+    QSet<QObject *> _netsToSync;
+    int _numNetsToSync;
+    int _progressMinimum, _progressMaximum, _progressValue;
+    QString _progressText;
 
-  QString _coreInfoString(const QVariantMap &);
-  bool _wasReconnect;
-  bool _requestedDisconnect;
+    QString _coreInfoString(const QVariantMap &);
+    bool _wasReconnect;
+    bool _requestedDisconnect;
 
-  inline CoreAccountModel *accountModel() const;
+    inline CoreAccountModel *accountModel() const;
 
-  friend class CoreConfigWizard;
+    friend class CoreConfigWizard;
 };
 
+
 Q_DECLARE_METATYPE(CoreConnection::ConnectionState)
 
 // Inlines
index e04e094..7c9ce12 100644 (file)
 #include "messagemodel.h"
 #include "quassel.h"
 
-ExecWrapper::ExecWrapper(QObject* parent) : QObject(parent) {
-  connect(&_process, SIGNAL(readyReadStandardOutput()), SLOT(processReadStdout()));
-  connect(&_process, SIGNAL(readyReadStandardError()), SLOT(processReadStderr()));
-  connect(&_process, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processFinished(int, QProcess::ExitStatus)));
-  connect(&_process, SIGNAL(error(QProcess::ProcessError)), SLOT(processError(QProcess::ProcessError)));
-
-  connect(this, SIGNAL(output(QString)), SLOT(postStdout(QString)));
-  connect(this, SIGNAL(error(QString)), SLOT(postStderr(QString)));
+ExecWrapper::ExecWrapper(QObject *parent) : QObject(parent)
+{
+    connect(&_process, SIGNAL(readyReadStandardOutput()), SLOT(processReadStdout()));
+    connect(&_process, SIGNAL(readyReadStandardError()), SLOT(processReadStderr()));
+    connect(&_process, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processFinished(int, QProcess::ExitStatus)));
+    connect(&_process, SIGNAL(error(QProcess::ProcessError)), SLOT(processError(QProcess::ProcessError)));
+
+    connect(this, SIGNAL(output(QString)), SLOT(postStdout(QString)));
+    connect(this, SIGNAL(error(QString)), SLOT(postStderr(QString)));
 }
 
-void ExecWrapper::start(const BufferInfo &info, const QString &command) {
-  _bufferInfo = info;
-  QString params;
-
-  QRegExp rx("^\\s*(\\S+)(\\s+(.*))?$");
-  if(!rx.exactMatch(command)) {
-    emit error(tr("Invalid command string for /exec: %1").arg(command));
-  } else {
-    _scriptName = rx.cap(1);
-    params = rx.cap(3);
-  }
-
-  // Make sure we don't execute something outside a script dir
-  if(_scriptName.contains("../") || _scriptName.contains("..\\"))
-    emit error(tr("Name \"%1\" is invalid: ../ or ..\\ are not allowed!").arg(_scriptName));
-
-  else {
-    foreach(QString scriptDir, Quassel::scriptDirPaths()) {
-      QString fileName = scriptDir + _scriptName;
-      if(!QFile::exists(fileName))
-        continue;
-      _process.setWorkingDirectory(scriptDir);
-      _process.start('"' + fileName + "\" " + params);
-      return;
+
+void ExecWrapper::start(const BufferInfo &info, const QString &command)
+{
+    _bufferInfo = info;
+    QString params;
+
+    QRegExp rx("^\\s*(\\S+)(\\s+(.*))?$");
+    if (!rx.exactMatch(command)) {
+        emit error(tr("Invalid command string for /exec: %1").arg(command));
+    }
+    else {
+        _scriptName = rx.cap(1);
+        params = rx.cap(3);
+    }
+
+    // Make sure we don't execute something outside a script dir
+    if (_scriptName.contains("../") || _scriptName.contains("..\\"))
+        emit error(tr("Name \"%1\" is invalid: ../ or ..\\ are not allowed!").arg(_scriptName));
+
+    else {
+        foreach(QString scriptDir, Quassel::scriptDirPaths()) {
+            QString fileName = scriptDir + _scriptName;
+            if (!QFile::exists(fileName))
+                continue;
+            _process.setWorkingDirectory(scriptDir);
+            _process.start('"' + fileName + "\" " + params);
+            return;
+        }
+        emit error(tr("Could not find script \"%1\"").arg(_scriptName));
     }
-    emit error(tr("Could not find script \"%1\"").arg(_scriptName));
-  }
 
-  deleteLater(); // self-destruct
+    deleteLater(); // self-destruct
 }
 
-void ExecWrapper::postStdout(const QString &msg) {
-  if(_bufferInfo.isValid())
-    Client::userInput(_bufferInfo, msg);
+
+void ExecWrapper::postStdout(const QString &msg)
+{
+    if (_bufferInfo.isValid())
+        Client::userInput(_bufferInfo, msg);
 }
 
-void ExecWrapper::postStderr(const QString &msg) {
-  if(_bufferInfo.isValid())
-    Client::messageModel()->insertErrorMessage(_bufferInfo, msg);
+
+void ExecWrapper::postStderr(const QString &msg)
+{
+    if (_bufferInfo.isValid())
+        Client::messageModel()->insertErrorMessage(_bufferInfo, msg);
 }
 
-void ExecWrapper::processFinished(int exitCode, QProcess::ExitStatus status) {
-  if(status == QProcess::CrashExit) {
-    emit error(tr("Script \"%1\" crashed with exit code %2.").arg(_scriptName).arg(exitCode));
-  }
 
-  // empty buffers
-  if(!_stdoutBuffer.isEmpty())
-    foreach(QString msg, _stdoutBuffer.split('\n'))
-      emit output(msg);
-  if(!_stderrBuffer.isEmpty())
-    foreach(QString msg, _stderrBuffer.split('\n'))
-    emit error(msg);
+void ExecWrapper::processFinished(int exitCode, QProcess::ExitStatus status)
+{
+    if (status == QProcess::CrashExit) {
+        emit error(tr("Script \"%1\" crashed with exit code %2.").arg(_scriptName).arg(exitCode));
+    }
+
+    // empty buffers
+    if (!_stdoutBuffer.isEmpty())
+        foreach(QString msg, _stdoutBuffer.split('\n'))
+        emit output(msg);
+    if (!_stderrBuffer.isEmpty())
+        foreach(QString msg, _stderrBuffer.split('\n'))
+        emit error(msg);
 
-  deleteLater();
+    deleteLater();
 }
 
-void ExecWrapper::processError(QProcess::ProcessError err) {
-  if(err == QProcess::FailedToStart)
-    emit error(tr("Script \"%1\" could not start.").arg(_scriptName));
-  else
-    emit error(tr("Script \"%1\" caused error %2.").arg(_scriptName).arg(err));
 
-  if(_process.state() != QProcess::Running)
-    deleteLater();
+void ExecWrapper::processError(QProcess::ProcessError err)
+{
+    if (err == QProcess::FailedToStart)
+        emit error(tr("Script \"%1\" could not start.").arg(_scriptName));
+    else
+        emit error(tr("Script \"%1\" caused error %2.").arg(_scriptName).arg(err));
+
+    if (_process.state() != QProcess::Running)
+        deleteLater();
 }
 
-void ExecWrapper::processReadStdout() {
-  QString str = QTextCodec::codecForLocale()->toUnicode(_process.readAllStandardOutput());
-  str.replace(QRegExp("\r\n?"), "\n");
-  _stdoutBuffer.append(str);
-  int idx;
-  while((idx = _stdoutBuffer.indexOf('\n')) >= 0) {
-    emit output(_stdoutBuffer.left(idx));
-    _stdoutBuffer = _stdoutBuffer.mid(idx + 1);
-  }
+
+void ExecWrapper::processReadStdout()
+{
+    QString str = QTextCodec::codecForLocale()->toUnicode(_process.readAllStandardOutput());
+    str.replace(QRegExp("\r\n?"), "\n");
+    _stdoutBuffer.append(str);
+    int idx;
+    while ((idx = _stdoutBuffer.indexOf('\n')) >= 0) {
+        emit output(_stdoutBuffer.left(idx));
+        _stdoutBuffer = _stdoutBuffer.mid(idx + 1);
+    }
 }
 
-void ExecWrapper::processReadStderr() {
-  QString str = QTextCodec::codecForLocale()->toUnicode(_process.readAllStandardError());
-  str.replace(QRegExp("\r\n?"), "\n");
-  _stderrBuffer.append(str);
-  int idx;
-  while((idx = _stderrBuffer.indexOf('\n')) >= 0) {
-    emit error(_stderrBuffer.left(idx));
-    _stderrBuffer = _stderrBuffer.mid(idx + 1);
-  }
+
+void ExecWrapper::processReadStderr()
+{
+    QString str = QTextCodec::codecForLocale()->toUnicode(_process.readAllStandardError());
+    str.replace(QRegExp("\r\n?"), "\n");
+    _stderrBuffer.append(str);
+    int idx;
+    while ((idx = _stderrBuffer.indexOf('\n')) >= 0) {
+        emit error(_stderrBuffer.left(idx));
+        _stderrBuffer = _stderrBuffer.mid(idx + 1);
+    }
 }
index e6d6dce..b6106fd 100644 (file)
 
 #include "bufferinfo.h"
 
-class ExecWrapper : public QObject {
-  Q_OBJECT
+class ExecWrapper : public QObject
+{
+    Q_OBJECT
 
 public:
-  ExecWrapper(QObject *parent = 0);
+    ExecWrapper(QObject *parent = 0);
 
 public slots:
-  void start(const BufferInfo &info, const QString &command);
+    void start(const BufferInfo &info, const QString &command);
 
 signals:
-  void error(const QString &errorMsg);
-  void output(const QString &out);
+    void error(const QString &errorMsg);
+    void output(const QString &out);
 
 private slots:
-  void processReadStdout();
-  void processReadStderr();
-  void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
-  void processError(QProcess::ProcessError);
+    void processReadStdout();
+    void processReadStderr();
+    void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
+    void processError(QProcess::ProcessError);
 
-  void postStdout(const QString &);
-  void postStderr(const QString &);
+    void postStdout(const QString &);
+    void postStderr(const QString &);
 
 private:
-  QProcess _process;
-  BufferInfo _bufferInfo;
-  QString _scriptName;
-  QString _stdoutBuffer;
-  QString _stderrBuffer;
+    QProcess _process;
+    BufferInfo _bufferInfo;
+    QString _scriptName;
+    QString _stdoutBuffer;
+    QString _stderrBuffer;
 };
 
+
 #endif
index 83dd7c1..baf9d42 100644 (file)
 #include <QStringList>
 
 IrcListModel::IrcListModel(QObject *parent)
-  : QAbstractItemModel(parent)
+    : QAbstractItemModel(parent)
 {
 }
 
-QVariant IrcListModel::data(const QModelIndex &index, int role) const {
-  if(!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount() || role != Qt::DisplayRole)
-    return QVariant();
 
-  IrcListHelper::ChannelDescription channel = _channelList[index.row()];
+QVariant IrcListModel::data(const QModelIndex &index, int role) const
+{
+    if (!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount() || role != Qt::DisplayRole)
+        return QVariant();
+
+    IrcListHelper::ChannelDescription channel = _channelList[index.row()];
 
-  switch(index.column()) {
-  case 0:
-    return channel.channelName;
-  case 1:
-    return channel.userCount;
-  case 2:
-    return channel.topic;
-  default:
-    return QVariant();
-  }
+    switch (index.column()) {
+    case 0:
+        return channel.channelName;
+    case 1:
+        return channel.userCount;
+    case 2:
+        return channel.topic;
+    default:
+        return QVariant();
+    }
 }
 
-Qt::ItemFlags IrcListModel::flags(const QModelIndex &index) const {
-  if(!index.isValid()) {
-    return Qt::ItemIsDropEnabled;
-  } else {
-    return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
-  }
+
+Qt::ItemFlags IrcListModel::flags(const QModelIndex &index) const
+{
+    if (!index.isValid()) {
+        return Qt::ItemIsDropEnabled;
+    }
+    else {
+        return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
+    }
 }