Fix TC-2051 - Prevents further PBAP transfers 94/31894/1 accepted/tizen/ivi/20141212.011413 submit/tizen_ivi/20141211.200836
authorJimmy Huang <jimmy.huang@intel.com>
Thu, 11 Dec 2014 19:52:22 +0000 (11:52 -0800)
committerJimmy Huang <jimmy.huang@intel.com>
Thu, 11 Dec 2014 19:54:22 +0000 (11:54 -0800)
The current phoned never close the obex session for pbap sync
for call history and contacts, this prevents other clients like
syncevolution to start another obex session.  This patch will end
each session after sync is completed, and will re-create another
session when sync is needed, trade off is a little impact on
performance.

Change-Id: Ie9076dd2ca6f01d0502057217ce129b8e0f38433
Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
packaging/phoned.changes
src/obex.cpp
src/phone.cpp

index d509129..be6a7cc 100644 (file)
@@ -1,3 +1,6 @@
+* Thu Dec 11 2014 Jimmy Huang <jimmy.huang@intel.com> accepted/tizen/ivi/20141024.005038-6-g4096c04
+- Fix TC-2051 - Prevents further PBAP transfers
+
 * Wed Oct 29 2014 Jimmy Huang <jimmy.huang@intel.com> accepted/tizen/ivi/20141024.005038-5-g1cd9a0c
 - Fixed bug where ModemRemoved signal never handled
 
index b1755b1..3b1dbac 100644 (file)
@@ -167,27 +167,32 @@ void Obex::removeSession(bool notify) {
 
     LoggerD("Removing session:" << mSession);
 
-    // delete/unref individual contacts
-    for(auto it=mContacts.begin(); it!=mContacts.end(); ++it) {
-        EContact *contact = (*it).second;
-        if(contact) {
-            // TODO: delete also all its attribs?
-            g_object_unref(contact);
+    // Changing the behavior of removeSession so that when notify is set to false,
+    // we will only close the obex session without destroying cached data, this
+    // unblocks other clients when accessing obex.
+    if (notify) {
+        // delete/unref individual contacts
+        for(auto it=mContacts.begin(); it!=mContacts.end(); ++it) {
+            EContact *contact = (*it).second;
+            if(contact) {
+                // TODO: delete also all its attribs?
+                g_object_unref(contact);
+            }
         }
-    }
-    mContacts.clear();
-    mContactsOrder.clear();
-
-    // delete/unref individual cll history entries
-    for(auto it=mCallHistory.begin(); it!=mCallHistory.end(); ++it) {
-        EContact *item = (*it).second;
-        if(item) {
-            // TODO: delete also all its attribs?
-            g_object_unref(item);
+        mContacts.clear();
+        mContactsOrder.clear();
+
+        // delete/unref individual call history entries
+        for(auto it=mCallHistory.begin(); it!=mCallHistory.end(); ++it) {
+            EContact *item = (*it).second;
+            if(item) {
+                // TODO: delete also all its attribs?
+                g_object_unref(item);
+            }
         }
+        mCallHistory.clear();
+        mCallHistoryOrder.clear();
     }
-    mCallHistory.clear();
-    mCallHistoryOrder.clear();
 
     GError *err = NULL;
     g_dbus_connection_call_sync( g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL),
@@ -828,7 +833,7 @@ void Obex::handleSignal(GDBusConnection       *connection,
                                {
                                        char *status_str=0;
                                        g_variant_get(var, "s", &status_str);
-                                       //LoggerD("Status is: " << status_str);
+                                       LoggerD("Status is: " << status_str);
 
                                        if(!strcmp(status_str, "complete"))
                                        {
index b4003a0..6850c26 100644 (file)
@@ -474,6 +474,9 @@ void Phone::callHistoryChanged() {
 void Phone::pbSynchronizationDone() {
     LoggerD("PB synchronization DONE");
     mPBSynchronized = true;
+    // remove session after sync is done to prevent blocking other clients
+    // each sync will now require calling createSession() instead
+    removeSession(false);
 }
 
 void Phone::handleMethodCall( GDBusConnection       *connection,
@@ -527,8 +530,7 @@ void Phone::handleMethodCall( GDBusConnection       *connection,
                 }
                 else {
                     // the synchronization may be already on-going, but request it anyway
-                    /*Obex::Error err = */phone->syncContacts();
-                    /*Obex::Error err = */phone->syncCallHistory();
+                    phone->createSession(phone->mWantedRemoteDevice.c_str());
                 }
             }
             else {
@@ -653,8 +655,7 @@ void Phone::handleMethodCall( GDBusConnection       *connection,
     }
     else if(!strcmp(method_name, "Synchronize")) {
         LoggerD("Synchronizing data with the phone");
-        /*Obex::Error err = */phone->syncContacts();
-        /*Obex::Error err = */phone->syncCallHistory();
+        phone->createSession(phone->mWantedRemoteDevice.c_str());
         g_dbus_method_invocation_return_value(invocation, NULL);
     }
     else if(!strcmp(method_name, "GetContacts")) {