[mafw-lastfm-devel] [PATCH mafw-lastfm 05/12] More code-style cleanups

Felipe Contreras felipe.contreras at gmail.com
Thu Jan 14 18:33:51 EET 2010


Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
---
 mafw-lastfm/mafw-lastfm-scrobbler.c |   19 ++++++++-----------
 mafw-lastfm/mafw-lastfm-scrobbler.h |   29 ++++++++++++++++++-----------
 mafw-lastfm/mafw-lastfm.c           |   34 +++++++++++++++-------------------
 3 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/mafw-lastfm/mafw-lastfm-scrobbler.c b/mafw-lastfm/mafw-lastfm-scrobbler.c
index af84ff8..7b89f4e 100644
--- a/mafw-lastfm/mafw-lastfm-scrobbler.c
+++ b/mafw-lastfm/mafw-lastfm-scrobbler.c
@@ -326,15 +326,14 @@ set_playing_now_cb (SoupSession *session,
 
   if (SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) {
     g_print ("Playing-now: %s", message->response_body->data);
-    if (strcmp (message->response_body->data, "BADSESSION\n") == 0) {
+    if (strcmp (message->response_body->data, "BADSESSION\n") == 0)
       mafw_lastfm_scrobbler_defer_handshake (scrobbler);
-    }
   }
 }
 
 void
 mafw_lastfm_scrobbler_set_playing_now (MafwLastfmScrobbler *scrobbler,
-                                       MafwLastfmTrack     *encoded)
+                                       MafwLastfmTrack *encoded)
 {
   gchar *post_data;
   SoupMessage *message;
@@ -371,14 +370,13 @@ scrobble_real (MafwLastfmScrobbler *scrobbler)
   GList *list = NULL;
   gint tracks = 0;
 
-  if (scrobbler->priv->status != MAFW_LASTFM_SCROBBLER_READY) {
+  if (scrobbler->priv->status != MAFW_LASTFM_SCROBBLER_READY)
     return;
-  }
 
   while (!g_queue_is_empty (scrobbler->priv->scrobbling_queue) && tracks < 50) {
     track = g_queue_pop_head (scrobbler->priv->scrobbling_queue);
     list = g_list_append (list, track);
-    tracks ++;
+    tracks++;
   }
 
   if (list) {
@@ -519,24 +517,23 @@ parse_handshake_response (MafwLastfmScrobbler *scrobbler,
   response = g_strsplit (response_data, "\n", 5);
 
   if (g_str_has_prefix (response [0], "OK")) {
-
     g_free (scrobbler->priv->session_id);
     g_free (scrobbler->priv->np_url);
     g_free (scrobbler->priv->sub_url);
 
-    scrobbler->priv->session_id = response [1];
+    scrobbler->priv->session_id = response[1];
     scrobbler->priv->np_url = response[2];
     scrobbler->priv->sub_url = response[3];
 
     /* We take ownership on the relevant parsed data, free the
        array and response code. */
-    g_free (response [0]);
-    g_free (response [4]);
+    g_free (response[0]);
+    g_free (response[4]);
     g_free (response);
 
     return TRUE;
   } else {
-    g_warning ("Couldn't handshake: %s", response [0]);
+    g_warning ("Couldn't handshake: %s", response[0]);
     g_strfreev (response);
 
     return FALSE;
diff --git a/mafw-lastfm/mafw-lastfm-scrobbler.h b/mafw-lastfm/mafw-lastfm-scrobbler.h
index 1780b9e..dc1fe0f 100644
--- a/mafw-lastfm/mafw-lastfm-scrobbler.h
+++ b/mafw-lastfm/mafw-lastfm-scrobbler.h
@@ -25,7 +25,7 @@
 
 G_BEGIN_DECLS
 
-#define MAFW_LASTFM_TYPE_SCROBBLER mafw_lastfm_scrobbler_get_type()
+#define MAFW_LASTFM_TYPE_SCROBBLER mafw_lastfm_scrobbler_get_type ()
 
 #define MAFW_LASTFM_SCROBBLER(obj) \
   (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAFW_LASTFM_TYPE_SCROBBLER, MafwLastfmScrobbler))
@@ -63,19 +63,24 @@ typedef struct {
   gint number;
 } MafwLastfmTrack;
 
-GType mafw_lastfm_scrobbler_get_type (void);
+GType
+mafw_lastfm_scrobbler_get_type (void);
 
-MafwLastfmScrobbler* mafw_lastfm_scrobbler_new (void);
+MafwLastfmScrobbler *
+mafw_lastfm_scrobbler_new (void);
 
-void                 mafw_lastfm_scrobbler_set_credentials (MafwLastfmScrobbler *scrobbler,
-							    const gchar *username,
-							    const gchar *passwd);
+void
+mafw_lastfm_scrobbler_set_credentials (MafwLastfmScrobbler *scrobbler,
+                                       const gchar *username,
+                                       const gchar *passwd);
 
-void                 mafw_lastfm_scrobbler_handshake (MafwLastfmScrobbler *scrobbler);
+void
+mafw_lastfm_scrobbler_handshake (MafwLastfmScrobbler *scrobbler);
 
 void
 mafw_lastfm_scrobbler_set_playing_now (MafwLastfmScrobbler *scrobbler,
-				       MafwLastfmTrack     *track);
+				       MafwLastfmTrack *track);
+
 void
 mafw_lastfm_scrobbler_enqueue_scrobble (MafwLastfmScrobbler *scrobbler,
 					MafwLastfmTrack *track);
@@ -86,10 +91,12 @@ mafw_lastfm_scrobbler_flush_queue (MafwLastfmScrobbler *scrobbler);
 void
 mafw_lastfm_scrobbler_suspend (MafwLastfmScrobbler *scrobbler);
 
-MafwLastfmTrack * mafw_lastfm_track_new (void);
-void mafw_lastfm_track_free (MafwLastfmTrack *track);
+MafwLastfmTrack *
+mafw_lastfm_track_new (void);
+
+void
+mafw_lastfm_track_free (MafwLastfmTrack *track);
 
 G_END_DECLS
 
 #endif /* _MAFW_LASTFM_SCROBBLER */
-
diff --git a/mafw-lastfm/mafw-lastfm.c b/mafw-lastfm/mafw-lastfm.c
index f7752f0..2c1e162 100644
--- a/mafw-lastfm/mafw-lastfm.c
+++ b/mafw-lastfm/mafw-lastfm.c
@@ -26,7 +26,7 @@
 
 #include "mafw-lastfm-scrobbler.h"
 
-#define WANTED_RENDERER     "Mafw-Gst-Renderer"
+#define WANTED_RENDERER "Mafw-Gst-Renderer"
 
 gint64 length;
 
@@ -35,9 +35,7 @@ mafw_metadata_lookup_string (GHashTable *table,
                              const gchar *key)
 {
   GValue *value;
-
   value = mafw_metadata_first (table, key);
-
   return value ?  g_value_dup_string (value) : NULL;
 }
 
@@ -46,9 +44,7 @@ mafw_metadata_lookup_int (GHashTable *table,
                           const gchar *key)
 {
   GValue *value;
-
   value = mafw_metadata_first (table, key);
-
   return value ? g_value_get_int (value) : 0;
 }
 
@@ -88,8 +84,9 @@ metadata_callback (MafwRenderer *self,
 }
 
 static void
-state_changed_cb(MafwRenderer *renderer, MafwPlayState state,
-                 gpointer user_data)
+state_changed_cb (MafwRenderer *renderer,
+                  MafwPlayState state,
+                  gpointer user_data)
 {
   switch (state) {
   case Playing:
@@ -114,9 +111,8 @@ metadata_changed_cb (MafwRenderer *renderer,
                      GValueArray *varray,
                      gpointer user_data)
 {
-  if (strcmp(name, "duration") == 0) {
+  if (strcmp (name, "duration") == 0)
     length = g_value_get_int64 (g_value_array_get_nth (varray, 0));
-  }
 }
 
 static void
@@ -124,9 +120,9 @@ renderer_added_cb (MafwRegistry *registry,
                    GObject *renderer,
                    gpointer user_data)
 {
-  if (MAFW_IS_RENDERER(renderer)) {
+  if (MAFW_IS_RENDERER (renderer)) {
     const gchar *name =
-      mafw_extension_get_name (MAFW_EXTENSION(renderer));
+      mafw_extension_get_name (MAFW_EXTENSION (renderer));
 
     if (strcmp (name, WANTED_RENDERER) == 0) {
       g_signal_connect (renderer,
@@ -214,7 +210,8 @@ on_credentials_file_changed (GFileMonitor *monitor,
 }
 
 static void
-monitor_credentials_file (const gchar *path, MafwLastfmScrobbler *scrobbler)
+monitor_credentials_file (const gchar *path,
+                          MafwLastfmScrobbler *scrobbler)
 {
   GFile * file;
   GFileMonitor *monitor;
@@ -243,13 +240,13 @@ int main ()
 
   scrobbler = mafw_lastfm_scrobbler_new ();
 
-  registry = MAFW_REGISTRY(mafw_registry_get_instance());
+  registry = MAFW_REGISTRY (mafw_registry_get_instance ());
   if (registry == NULL) {
     g_warning ("Failed to get register.\n");
     return 1;
   }
 
-  mafw_shared_init(registry, &error);
+  mafw_shared_init (registry, &error);
   if (error != NULL) {
     g_warning ("Failed to initialize the shared library.\n");
     return 1;
@@ -257,13 +254,13 @@ int main ()
 
   g_signal_connect (registry,
                     "renderer-added",
-                    G_CALLBACK(renderer_added_cb), scrobbler);
+                    G_CALLBACK (renderer_added_cb), scrobbler);
   /* Also, check for already started extensions */
-  renderers = mafw_registry_get_renderers(registry);
+  renderers = mafw_registry_get_renderers (registry);
   while (renderers) {
     renderer_added_cb (registry,
-                       G_OBJECT(renderers->data), scrobbler);
-    renderers = g_list_next(renderers);
+                       G_OBJECT (renderers->data), scrobbler);
+    renderers = g_list_next (renderers);
   }
 
   file = g_build_filename (g_get_home_dir (),
@@ -277,4 +274,3 @@ int main ()
 
   return 0;
 }
-
-- 
1.6.6


More information about the mafw-lastfm-devel mailing list