[cmyth] Fix checking for valid connection in connection.c

This fixes a couple of 'Dereference before null check' issues in
connection.c.
[cmyth] Return consistent errors in connection.c
[cmyth] Return consistent errors in storagegroup.c

- Return consistent ERROR values
- Use NULL instead 0 for null pointers
[cmyth] Use cmyth_mysql_query for DML statement

Use cmyth_mysql_query instead cmyth_mysql_query_result to avoid error messages.
[cmyth] Add cmyth_mysql_keep_livetv_recording

The function disables/enables auto expiration and sets the storage group to
'Default'/'LiveTV' to keep/release a recording.
[cmyth] Add cmyth_proginfo_storagegroup

Returns the storage group for a recording.
[cmyth] Add cmyth_proginfo_generate_pixmap

Use QUERY_GENPIXMAP2 to generate missing pixmaps. (protocol version >=61)
[cmyth] Change log level in cmyth_proginfo_get_from_timeslot

Change log level for error message "...didn't recieve OK as response"
from ERROR to NOTICE since it is not an error, just indicates that a
recording couldn't be found.
[cmyth] Cosmetics in event.c
[cmyth] Cosmetics in socket.c
[cmyth] Refactor cmyth_rcv_data

This function receives raw data from the socket and thus can be used to
get all data being leftover in the socket.

Note that this private function was not used anymore, but will be used
later for the above purpose.
[cmyth] Use cmyth_rcv_data in cmyth_rcv_okay

Improve receiving leftover data in cmyth_rcv_okay by using
cmyth_rcv_data instead of cmyth_rcv_string.
[cmyth] Clean leftover data in cmyth_event_get_message

Some events received in cmyth_event_get_message were able to break the
event connection completely by leaving back leftover data on the socket.
(Example: GENERATED_PIXMAP)

This is fixed by using cmyth_rcv_data at the function end.
In addition, events that are not interested in further data, can now
simply ignore it and don't have to read everything.
[cmyth] Fix memory leak in cmyth_mysql_delete_recordingrule

The query has to be freed in success case.
[cmyth] Fix memory leak in cmyth_mysql_tuner_type_check
[cmyth] Add missing unlock in cmyth_conn_get_backend_hostname

Fix deadlock in case of conn_version < 17 due to a missing unlock.
[cmyth] Check return value of setsockopt in cmyth_reconnect_addr
[cmyth] Fix memory leak in cmyth_mysql_testdb_connection
[mythtv-cmyth] Use PVR_STRCPY in SignalStatus

Replace strcpy with PVR_STRCPY since this checks the length.
[cmyth] Resolve deadlock in cmyth_livetv_chain_switch

Normally "865: ref_release(rec->rec_livetv_file)" never destroys the file.
It decrements only 'ref_count' because the file is hold by the chain itself.
This assumption must be known. If the chain is destroyed from another place,
the file gets destroyed here causing a deadlock (by trying to lock the
control connection for sending DONE to the backend).
It is better to avoid any confusion and destroy the file outside the mutex.

For sample, usage of SET_CHANNEL frees the chain and then on the next file
switch we have a deadlock.