voicecall: Implement ofono_voicecall_mpty_hint
authorDenis Kenzior <denkenz@gmail.com>
Tue, 10 Sep 2013 15:56:44 +0000 (10:56 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Thu, 12 Sep 2013 18:17:39 +0000 (13:17 -0500)
src/voicecall.c

index ae76b91..d11a4cd 100644 (file)
@@ -2355,6 +2355,46 @@ error:
                g_free(v);
 }
 
+void ofono_voicecall_mpty_hint(struct ofono_voicecall *vc, unsigned int ids)
+{
+       GSList *old;
+       GSList *l;
+
+       DBG("ids: %u", ids);
+
+       /* id of 0 is never valid for a call */
+       if (ids & 0x1)
+               return;
+
+       /* Ignore the hint if there's nothing to do */
+       if (__builtin_popcount(ids) < 2 && vc->multiparty_list == NULL)
+               return;
+
+       old = vc->multiparty_list;
+       vc->multiparty_list = NULL;
+
+       for (l = vc->call_list; l; l = l->next) {
+               struct voicecall *v = l->data;
+
+               if (ids & (1 << v->call->id))
+                       vc->multiparty_list =
+                               g_slist_prepend(vc->multiparty_list, v);
+       }
+
+       if (vc->multiparty_list)
+               vc->multiparty_list = g_slist_reverse(vc->multiparty_list);
+
+       if (g_slist_length(vc->multiparty_list) == 1) {
+               ofono_error("Created multiparty list length is 1"
+                               ", which would indicate a bug in the driver"
+                               " or the remote device");
+               vc->multiparty_list = NULL;
+       }
+
+       voicecalls_multiparty_changed(old, vc->multiparty_list);
+       g_slist_free(old);
+}
+
 static void send_ciev_after_swap_callback(const struct ofono_error *error,
                                                                void *data)
 {