Added reopenUSB method to reopen USB connection when HUP is received

Whenever a HUP or ERR signal is received, it is better to re-create the
USB connection and set the fd listeners again. This will enable seamless
connectivity between the PC app and the device sync

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
Added reopenUSB to the idle event source listener

Whenever the incoming USB event is HUP or ERR, then add the reopenUSB
listener so that the USB connection can be reopened.

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
Added handleSyncFinished method in USBConnection

Whenever sync is finished, the USB listener has to be re-added.
Listening is stopped at the beginning of the sync

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
Added handleSyncFinished method in USBConnection

This method should handle the USB state transitions between sync start
and sync end. This mainly involves adding/removing fd listeners

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
Added mutex locks to ensure synchronization of USBConnection by threads

Suspect that the USB connection open/close and add/remove of fd
listeners is going out of order. So added mutex locks to ensure
synchronization of method calls between the server threads

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
Patch to enable multiple sync sessions without restarting msyncd

During SyncMLServer::uninit(), the signal between USBConnection and
SyncMLServer is being disconnected. As a server plugin, the transport
should never be closed unless the plugin is being unloaded. Also in
reopenUSB, wrong check is being done for mDisconnected flag. Fixed these
issues and now multiple sync sessions without restarting msyncd is
possible

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
Incase of errors, reopen USB connection so server plugin is in sane state

Once pushing contacts to the device is over, syncml-ds-tool sends a
OBEX_EV_LINKERR instead of DISCONNECT command. This causes the buteo
syncml stack to think that an error has occured and so reports the sync
status as failure and then closes the USB connection. The fix is to
reopen the USB connection incase of failures so that the next
successive sync session happen. Maybe a different PC tool will send the
proper OBEX Disconnect command incase of SYNC_DONE

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
Patch to sync all contacts instead of just contacts from "buteo" target

Modified the hcontacts storage plugin to return contacts belonging to
all sync targets instead of contacts only from "buteo" sync target.
WARNING: This will sync all contacts from whichever services, like
facebook, google, phonebook etc.

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
Added Qt way of listening for the fd

The Qt way of listening for fd is to use QSocketNotifier. But it does
not look as fine-grained as glib way. With this patch, sync works, but
there are warnings related to using QObject::connect and
QObject::disconnect methods from different threads. Need to handle these
Enable glib fd watching for now

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
Fixed issue with connecting signals of QSocketNotifiers from different threads

QSocketNotifier belongs to thread ServerRunner while USBConnection
belongs to the transport thread in buteo syncml stack. So it is not
directly possible to connect signal/slots of these objects. The valid
way is to use the 5'th argument of the QObject::connect to specify
Qt::BlockingQueuedConnection instead of the default

Signed-off-by: Sateesh Kavuri <sateesh.kavuri@gmail.com>
[packaging] Drop QtGui dependency