Avoid crash when passing empty text/non valid data to write_to_file

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
Send connected signal in connection handler, not in connection setting (as this function will also be called when we set a mode through dbus.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>