]> git.0d.be Git - empathy.git/blobdiff - src/empathy-mic-monitor.c
Updated Kannada translation
[empathy.git] / src / empathy-mic-monitor.c
index 5a90e17184eb803acf0e29b07e559bfab09a6893..a97f70e0d5d6c181156bba027838f3c1d3eaa0b2 100644 (file)
  *
  */
 
-#include <config.h>
-
-#include <gtk/gtk.h>
-
-#include <pulse/pulseaudio.h>
-#include <pulse/glib-mainloop.h>
-
+#include "config.h"
 #include "empathy-mic-monitor.h"
 
-#include "src-marshal.h"
+#include <pulse/glib-mainloop.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
-#include <libempathy/empathy-utils.h>
+#include "empathy-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
 
 enum
 {
@@ -268,7 +263,7 @@ empathy_mic_monitor_class_init (EmpathyMicMonitorClass *klass)
     G_SIGNAL_RUN_LAST,
     0,
     NULL, NULL,
-    _src_marshal_VOID__UINT_STRING_STRING_BOOLEAN,
+    g_cclosure_marshal_generic,
     G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
 
   signals[MICROPHONE_REMOVED] = g_signal_new ("microphone-removed",
@@ -276,7 +271,7 @@ empathy_mic_monitor_class_init (EmpathyMicMonitorClass *klass)
     G_SIGNAL_RUN_LAST,
     0,
     NULL, NULL,
-    g_cclosure_marshal_VOID__UINT,
+    g_cclosure_marshal_generic,
     G_TYPE_NONE, 1, G_TYPE_UINT);
 
   signals[MICROPHONE_CHANGED] = g_signal_new ("microphone-changed",
@@ -284,7 +279,7 @@ empathy_mic_monitor_class_init (EmpathyMicMonitorClass *klass)
     G_SIGNAL_RUN_LAST,
     0,
     NULL, NULL,
-    _src_marshal_VOID__UINT_UINT,
+    g_cclosure_marshal_generic,
     G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
 
   g_type_class_add_private (object_class, sizeof (EmpathyMicMonitorPrivate));
@@ -481,7 +476,7 @@ empathy_mic_monitor_change_microphone_finish (EmpathyMicMonitor *self,
     GAsyncResult *result,
     GError **error)
 {
-  empathy_implement_finish_void (self,
+  tpaw_implement_finish_void (self,
       empathy_mic_monitor_change_microphone_async);
 }
 
@@ -564,3 +559,125 @@ empathy_mic_monitor_get_current_mic_finish (EmpathyMicMonitor *self,
   return GPOINTER_TO_UINT (
       g_simple_async_result_get_op_res_gpointer (simple));
 }
+
+/* operation: get default */
+static void
+empathy_mic_monitor_get_default_cb (pa_context *context,
+    const pa_server_info *info,
+    void *userdata)
+{
+  GSimpleAsyncResult *result = userdata;
+
+  /* TODO: it would be nice in future, for consistency, if this gave
+   * the source idx instead of the name. */
+  g_simple_async_result_set_op_res_gpointer (result,
+      g_strdup (info->default_source_name), g_free);
+  g_simple_async_result_complete (result);
+  g_object_unref (result);
+}
+
+static void
+operation_get_default (EmpathyMicMonitor *self,
+    GSimpleAsyncResult *result)
+{
+  EmpathyMicMonitorPrivate *priv = self->priv;
+
+  g_assert_cmpuint (pa_context_get_state (priv->context), ==, PA_CONTEXT_READY);
+
+  /* unset this so we can use it in the cb */
+  g_simple_async_result_set_op_res_gpointer (result, NULL, NULL);
+
+  pa_context_get_server_info (priv->context, empathy_mic_monitor_get_default_cb,
+      result);
+}
+
+void
+empathy_mic_monitor_get_default_async (EmpathyMicMonitor *self,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  EmpathyMicMonitorPrivate *priv = self->priv;
+  Operation *operation;
+  GSimpleAsyncResult *simple;
+
+  simple = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
+      empathy_mic_monitor_get_default_async);
+
+  operation = operation_new (operation_get_default, simple);
+  g_queue_push_tail (priv->operations, operation);
+
+  operations_run (self);
+}
+
+const gchar *
+empathy_mic_monitor_get_default_finish (EmpathyMicMonitor *self,
+    GAsyncResult *result,
+    GError **error)
+{
+  tpaw_implement_finish_return_pointer (self,
+      empathy_mic_monitor_get_default_async);
+}
+
+/* operation: set default */
+static void
+empathy_mic_monitor_set_default_cb (pa_context *c,
+    int success,
+    void *userdata)
+{
+  GSimpleAsyncResult *result = userdata;
+
+  if (!success)
+    {
+      g_simple_async_result_set_error (result,
+          G_IO_ERROR, G_IO_ERROR_FAILED,
+          "The operation failed for an unknown reason");
+    }
+
+  g_simple_async_result_complete (result);
+  g_object_unref (result);
+}
+
+static void
+operation_set_default (EmpathyMicMonitor *self,
+    GSimpleAsyncResult *result)
+{
+  EmpathyMicMonitorPrivate *priv = self->priv;
+  gchar *name;
+
+  g_assert_cmpuint (pa_context_get_state (priv->context), ==, PA_CONTEXT_READY);
+
+  name = g_simple_async_result_get_op_res_gpointer (result);
+
+  pa_context_set_default_source (priv->context, name,
+      empathy_mic_monitor_set_default_cb, result);
+}
+
+void
+empathy_mic_monitor_set_default_async (EmpathyMicMonitor *self,
+    const gchar *name,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  EmpathyMicMonitorPrivate *priv = self->priv;
+  Operation *operation;
+  GSimpleAsyncResult *simple;
+
+  simple = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
+      empathy_mic_monitor_set_default_async);
+
+  g_simple_async_result_set_op_res_gpointer (simple, g_strdup (name), g_free);
+
+  operation = operation_new (operation_set_default, simple);
+  g_queue_push_tail (priv->operations, operation);
+
+  operations_run (self);
+}
+
+gboolean
+empathy_mic_monitor_set_default_finish (EmpathyMicMonitor *self,
+    GAsyncResult *result,
+    GError **error)
+{
+  tpaw_implement_finish_void (self,
+      empathy_mic_monitor_set_default_async);
+}