walletview: make backupWallet() use GUIUtil::getSaveFileName()

- this allows removal of several Qt headers and makes use of a
  standardized function in GUIUtil
- adds selected path to the UI output
walletview: clarify 2 comments
Merge pull request #3163 from sipa/allunspendable

Generalize the remove-outputs check for fully-prunable transactions.
fix wrong memcmp() usage in CKey::operator==

- add a check for CKey::size() of a and b (size can be 0 or 32)
- change the fixed value in memcmp() to use a.size() instead
- fixes #3090
Bug fix: CDataStream::GetAndClear() when nReadPos > 0

Changed CDataStream::GetAndClear() to use the most obvious
get get and clear instead of a tricky swap().

Added a unit test for CDataStream insert/erase/GetAndClear.

Note: GetAndClear() is not performance critical, it is used only
by the send-a-message-to-the-network code. Bug was not noticed
before now because the send-a-message code never erased from the
stream.
-fuzzmessagestest=N : randomly corrupt 1-of-N sent messages

I needed this to test the new "reject" p2p message, but it should be generally
useful for fuzz-testing network message handling code.
Merge pull request #3162 from sipa/saninsert

Remove redundant insert method in serialize
Merge pull request #3115 from sipa/walletmain

Interaction cleanups between main and wallet
Merge pull request #3173 from gavinandresen/fuzzmessages

-fuzzmessagestest=N : randomly corrupt 1-of-N sent messages
Merge pull request #3176 from Diapolo/key

fix wrong memcmp() usage in CKey::operator==
re-work -debug switch handling

- re-work -debug help message text
- make -debug log every debugging information again (even all categories)
- remove unneeded fDebug checks in front of LogPrint()/qDebug(), as that
  check is done in LogPrintf() when category is != NULL (true for all
  LogPrint() calls
- remove fDebug ONLY in code which is NOT performance-critical
- harmonize addrman category name
- deprecate -debugnet usage, should be used via -debug=net and remove the
  corresponding global
Merge pull request #3160 from Diapolo/walletview

[Qt] walletview: make backupWallet() use GUIUtil::getSaveFileName()
transactionview: add message() signal

- allow to use message() in transactionview by connecting to the
  message() signal in WalletView
transactionview: make exportClicked() use message()

- use message() for displaying success or failure of export
- rework the strings to be more detailed / informative
- additional small cleanups
[Qt] sendcoinsdialog: convert QMessageBox usage to message()

- add new processSendCoinsReturn() function, which parses the
  status of WalletModel::SendCoinsReturn and generates a pair consisting
  of a message and message flags
- result is we only need one emit message() call
- this change ensures that the GUI is shown for warnings/errors in
  sendcoinsdialog, because of message() taking care of that for modal
  messages
- changes 2 warning message into error messages and removed "Error:"
  in front of the actual error message string
Merge pull request #3067 from Diapolo/debug-switch

re-work -debug switch handling
Merge pull request #3189

71ba467 [Qt] sendcoinsdialog: convert QMessageBox usage to message() (Philip Kaufmann)
Merge pull request #3159

9eb4ab6 transactionview: make exportClicked() use message() (Philip Kaufmann)
868d3ee transactionview: add message() signal (Philip Kaufmann)
Do not use the redundant BestInvalidWork record in the block database.

As block index entries have a flag for marking invalid blocks, the
'best invalid work' information can be derived from there. In addition,
remove the global from main.h
Make some globals in main non-public.

This means they are declared static, and their extern definition in
main.h is removed. Also moved CBlockIndexWorkComparator to the .cpp
file.