diff pidgin/plugins/musicmessaging/musicmessaging.c @ 31534:a8cc50c2279f

Remove trailing whitespace
author Richard Laager <rlaager@wiktel.com>
date Tue, 04 Jan 2011 06:55:30 +0000
parents 73c8e1964eef
children 78fae2fc38d5
line wrap: on
line diff
--- a/pidgin/plugins/musicmessaging/musicmessaging.c	Tue Jan 04 06:42:45 2011 +0000
+++ b/pidgin/plugins/musicmessaging/musicmessaging.c	Tue Jan 04 06:55:30 2011 +0000
@@ -49,11 +49,11 @@
 	GtkWidget *seperator; /* seperator in the conversation */
 	GtkWidget *button; /* button in the conversation */
 	GPid pid; /* the pid of the score editor */
-	
+
 	gboolean started; /* session has started and editor run */
 	gboolean originator; /* started the mm session */
 	gboolean requested; /* received a request to start a session */
-	
+
 } MMConversation;
 
 static gboolean start_session(MMConversation *mmconv);
@@ -97,9 +97,9 @@
 /* Exported functions */
 void music_messaging_change_request(const int session, const char *command, const char *parameters)
 {
-	
+
 	MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
-	
+
 	if (mmconv->started)
 	{
 		if (mmconv->originator)
@@ -110,50 +110,50 @@
 		{
 			GString *to_send = g_string_new("");
 			g_string_append_printf(to_send, "##MM## request %s %s##MM##", command, parameters);
-			
+
 			purple_conv_im_send(PURPLE_CONV_IM(mmconv->conv), to_send->str);
-			
+
 			purple_debug_misc("musicmessaging", "Sent request: %s\n", to_send->str);
 		}
 	}
-			
+
 }
 
 void music_messaging_change_confirmed(const int session, const char *command, const char *parameters)
 {
-	
+
 	MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
-	
+
 	if (mmconv->started)
 	{
 		if (mmconv->originator)
 		{
 			GString *to_send = g_string_new("");
 			g_string_append_printf(to_send, "##MM## confirm %s %s##MM##", command, parameters);
-			
+
 			purple_conv_im_send(PURPLE_CONV_IM(mmconv->conv), to_send->str);
 		} else
 		{
 			/* Do nothing. If they aren't the originator, then they can't confirm. */
 		}
 	}
-	
+
 }
 
 void music_messaging_change_failed(const int session, const char *id, const char *command, const char *parameters)
 {
 	MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
-	
+
 	purple_notify_message(plugin_pointer, PURPLE_NOTIFY_MSG_INFO, command,
                         parameters, NULL, NULL, NULL);
-	
+
 	if (mmconv->started)
 	{
 		if (mmconv->originator)
 		{
 			GString *to_send = g_string_new("");
 			g_string_append_printf(to_send, "##MM## failed %s %s %s##MM##", id, command, parameters);
-			
+
 			purple_conv_im_send(PURPLE_CONV_IM(mmconv->conv), to_send->str);
 		} else
 		{
@@ -165,10 +165,10 @@
 void music_messaging_done_session(const int session)
 {
 	MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
-	
+
 	purple_notify_message(plugin_pointer, PURPLE_NOTIFY_MSG_INFO, "Session",
 						"Session Complete", NULL, NULL, NULL);
-	
+
 	session_end(mmconv);
 }
 
@@ -181,10 +181,10 @@
 static gboolean send_change_request (const int session, const char *id, const char *command, const char *parameters)
 {
 	DBusMessage *message;
-	
+
 	/* Create the signal we need */
 	message = dbus_message_new_signal (DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, "GscoreChangeRequest");
-	
+
 	/* Append the string "Ping!" to the signal */
 	dbus_message_append_args (message,
 							DBUS_TYPE_INT32, &session,
@@ -192,42 +192,42 @@
 							DBUS_TYPE_STRING, &command,
 							DBUS_TYPE_STRING, &parameters,
 							DBUS_TYPE_INVALID);
-	
+
 	/* Send the signal */
 	dbus_connection_send (purple_dbus_get_connection(), message, NULL);
-	
+
 	/* Free the signal now we have finished with it */
 	dbus_message_unref (message);
-	
+
 	/* Tell the user we sent a signal */
 	g_printerr("Sent change request signal: %d %s %s %s\n", session, id, command, parameters);
-	
+
 	return TRUE;
 }
 
 static gboolean send_change_confirmed (const int session, const char *command, const char *parameters)
 {
 	DBusMessage *message;
-	
+
 	/* Create the signal we need */
 	message = dbus_message_new_signal (DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, "GscoreChangeConfirmed");
-	
+
 	/* Append the string "Ping!" to the signal */
 	dbus_message_append_args (message,
 							DBUS_TYPE_INT32, &session,
 							DBUS_TYPE_STRING, &command,
 							DBUS_TYPE_STRING, &parameters,
 							DBUS_TYPE_INVALID);
-	
+
 	/* Send the signal */
 	dbus_connection_send (purple_dbus_get_connection(), message, NULL);
-	
+
 	/* Free the signal now we have finished with it */
 	dbus_message_unref (message);
-	
+
 	/* Tell the user we sent a signal */
 	g_printerr("Sent change confirmed signal.\n");
-	
+
 	return TRUE;
 }
 
@@ -238,7 +238,7 @@
 	GList *l;
 	MMConversation *mmconv_current = NULL;
 	guint i;
-	
+
 	i = 0;
 	for (l = conversations; l != NULL; l = l->next)
 	{
@@ -268,36 +268,36 @@
        main purple dbus loop.  Without this statement, the purple dbus
        code wouldn't know about our functions. */
     PURPLE_DBUS_REGISTER_BINDINGS(plugin);
-	
+
 	/* Keep the plugin for reference (needed for notify's) */
 	plugin_pointer = plugin;
-	
+
 	/* Add the button to all the current conversations */
 	purple_conversation_foreach (init_conversation);
-	
+
 	/* Listen for any new conversations */
 	conv_list_handle = purple_conversations_get_handle();
-	
-	purple_signal_connect(conv_list_handle, "conversation-created", 
+
+	purple_signal_connect(conv_list_handle, "conversation-created",
 					plugin, PURPLE_CALLBACK(init_conversation), NULL);
-	
+
 	/* Listen for conversations that are ending */
 	purple_signal_connect(conv_list_handle, "deleting-conversation",
 					plugin, PURPLE_CALLBACK(conv_destroyed), NULL);
-					
+
 	/* Listen for sending/receiving messages to replace tags */
 	purple_signal_connect(conv_list_handle, "sending-im-msg",
 					plugin, PURPLE_CALLBACK(intercept_sent), NULL);
 	purple_signal_connect(conv_list_handle, "receiving-im-msg",
 					plugin, PURPLE_CALLBACK(intercept_received), NULL);
-	
+
 	return TRUE;
 }
 
 static gboolean
 plugin_unload(PurplePlugin *plugin) {
 	MMConversation *mmconv = NULL;
-	
+
 	while (conversations != NULL)
 	{
 		mmconv = conversations->data;
@@ -353,7 +353,7 @@
 intercept_received(PurpleAccount *account, char **sender, char **message, PurpleConversation *conv, int *flags)
 {
 	MMConversation *mmconv;
-	
+
 	if (conv == NULL) {
 		/* XXX: This is just to avoid a crash (#2726).
 		 *      We may want to create the conversation instead of returning from here
@@ -362,13 +362,13 @@
 	}
 
 	mmconv = mmconv_from_conv(conv);
-	
+
 	purple_debug_misc("purple-musicmessaging", "Intercepted: %s\n", *message);
 	if (strstr(*message, MUSICMESSAGING_PREFIX))
 	{
 		char *parsed_message = strtok(strstr(*message, MUSICMESSAGING_PREFIX), "<");
 		purple_debug_misc("purple-musicmessaging", "Received an MM Message: %s\n", parsed_message);
-				
+
 		if (mmconv->started)
 		{
 			if (strstr(parsed_message, "request"))
@@ -379,18 +379,18 @@
 					char *id = (mmconv->conv)->name;
 					char *command;
 					char *parameters;
-					
+
 					purple_debug_misc("purple-musicmessaging", "Sending request to gscore.\n");
-					
+
 					/* Get past the first two terms - '##MM##' and 'request' */
 					strtok(parsed_message, " "); /* '##MM##' */
 					strtok(NULL, " "); /* 'request' */
-					
+
 					command = strtok(NULL, " ");
 					parameters = strtok(NULL, "#");
-					
+
 					send_change_request (session, id, command, parameters);
-					
+
 				}
 			} else if (strstr(parsed_message, "confirm"))
 			{
@@ -399,40 +399,40 @@
 					int session = mmconv_from_conv_loc(conv);
 					char *command;
 					char *parameters;
-					
+
 					purple_debug_misc("purple-musicmessaging", "Sending confirmation to gscore.\n");
-					
+
 					/* Get past the first two terms - '##MM##' and 'confirm' */
 					strtok(parsed_message, " "); /* '##MM##' */
 					strtok(NULL, " "); /* 'confirm' */
-					
+
 					command = strtok(NULL, " ");
 					parameters = strtok(NULL, "#");
-					
+
 					send_change_confirmed (session, command, parameters);
 				}
 			} else if (strstr(parsed_message, "failed"))
 			{
 				char *id;
 				char *command;
-				
+
 				/* Get past the first two terms - '##MM##' and 'confirm' */
 				strtok(parsed_message, " "); /* '##MM##' */
 				strtok(NULL, " "); /* 'failed' */
-				
+
 				id = strtok(NULL, " ");
 				command = strtok(NULL, " ");
 				/* char *parameters = strtok(NULL, "#"); DONT NEED PARAMETERS */
-				
+
 				if ((mmconv->conv)->name == id)
 				{
-					purple_notify_message(plugin_pointer, PURPLE_NOTIFY_MSG_ERROR, 
+					purple_notify_message(plugin_pointer, PURPLE_NOTIFY_MSG_ERROR,
 							    _("Music Messaging"),
 							    _("There was a conflict in running the command:"), command, NULL, NULL);
 				}
 			}
 		}
-		
+
 		message = 0;
 	}
 	else if (strstr(*message, MUSICMESSAGING_START_MSG))
@@ -443,12 +443,12 @@
 			mmconv->requested = TRUE;
 			return FALSE;
 		}
-		
+
 	}
 	else if (strstr(*message, MUSICMESSAGING_CONFIRM_MSG))
 	{
 		purple_debug_misc("purple-musicmessagin", "Received MM confirm.\n");
-		
+
 		if (mmconv->originator)
 		{
 			start_session(mmconv);
@@ -476,11 +476,11 @@
 	const char *convName = purple_conversation_get_name(mmconv->conv);
 	serv_send_im(connection, convName, MUSICMESSAGING_CONFIRM_MSG, PURPLE_MESSAGE_SEND);
 }
-	
+
 
 static gboolean
 start_session(MMConversation *mmconv)
-{	
+{
 	run_editor(mmconv);
 	return TRUE;
 }
@@ -496,7 +496,7 @@
 static void music_button_toggled (GtkWidget *widget, gpointer data)
 {
 	MMConversation *mmconv = mmconv_from_conv(((MMConversation *) data)->conv);
-	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) 
+	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
     {
 		if (((MMConversation *) data)->requested)
 		{
@@ -517,7 +517,7 @@
 {
 	const char * path = gtk_entry_get_text((GtkEntry*)text_field);
 	purple_prefs_set_string("/plugins/gtk/musicmessaging/editor_path", path);
-	
+
 }
 
 static void run_editor (MMConversation *mmconv)
@@ -526,14 +526,14 @@
 	GString *session_id;
 	gchar * args[4];
 	args[0] = (gchar *)purple_prefs_get_string("/plugins/gtk/musicmessaging/editor_path");
-	
+
 	args[1] = "-session_id";
 	session_id = g_string_new("");
 	g_string_append_printf(session_id, "%d", mmconv_from_conv_loc(mmconv->conv));
 	args[2] = session_id->str;
-	
+
 	args[3] = NULL;
-	
+
 	if (!(g_spawn_async (".", args, NULL, 4, NULL, NULL, &(mmconv->pid), &spawn_error)))
 	{
 		purple_notify_error(plugin_pointer, _("Error Running Editor"),
@@ -559,21 +559,21 @@
 {
 	MMConversation *mmconv;
 	mmconv = g_malloc(sizeof(MMConversation));
-	
+
 	mmconv->conv = conv;
 	mmconv->started = FALSE;
 	mmconv->originator = FALSE;
 	mmconv->requested = FALSE;
-	
+
 	add_button(mmconv);
-	
+
 	conversations = g_list_append(conversations, mmconv);
 }
 
 static void conv_destroyed (PurpleConversation *conv)
 {
 	MMConversation *mmconv = mmconv_from_conv(conv);
-	
+
 	remove_widget(mmconv->button);
 	remove_widget(mmconv->seperator);
 	if (mmconv->started)
@@ -586,7 +586,7 @@
 static void add_button (MMConversation *mmconv)
 {
 	PurpleConversation *conv = mmconv->conv;
-	
+
 	GtkWidget *button, *image, *sep;
 	gchar *file_path;
 
@@ -601,16 +601,16 @@
 	g_free(file_path);
 
 	gtk_container_add((GtkContainer *)button, image);
-	
+
 	sep = gtk_vseparator_new();
-	
+
 	mmconv->seperator = sep;
 	mmconv->button = button;
-	
+
 	gtk_widget_show(sep);
 	gtk_widget_show(image);
 	gtk_widget_show(button);
-	
+
 	gtk_box_pack_start(GTK_BOX(PIDGIN_CONVERSATION(conv)->toolbar), sep, FALSE, FALSE, 0);
 	gtk_box_pack_start(GTK_BOX(PIDGIN_CONVERSATION(conv)->toolbar), button, FALSE, FALSE, 0);
 }
@@ -618,7 +618,7 @@
 static void remove_widget (GtkWidget *button)
 {
 	gtk_widget_hide(button);
-	gtk_widget_destroy(button);		
+	gtk_widget_destroy(button);
 }
 
 static GtkWidget *
@@ -626,32 +626,32 @@
 {
 	GtkWidget *ret;
 	GtkWidget *vbox;
-	
+
 	GtkWidget *editor_path;
 	GtkWidget *editor_path_label;
 	GtkWidget *editor_path_button;
-	
+
 	/* Outside container */
 	ret = gtk_vbox_new(FALSE, 18);
 	gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
 
 	/* Configuration frame */
 	vbox = pidgin_make_frame(ret, _("Music Messaging Configuration"));
-	
+
 	/* Path to the score editor */
 	editor_path = gtk_entry_new();
 	editor_path_label = gtk_label_new(_("Score Editor Path"));
 	editor_path_button = gtk_button_new_with_mnemonic(_("_Apply"));
-	
+
 	gtk_entry_set_text((GtkEntry*)editor_path, "/usr/local/bin/gscore");
-	
+
 	g_signal_connect(G_OBJECT(editor_path_button), "clicked",
 					 G_CALLBACK(set_editor_path), editor_path);
-					 
+
 	gtk_box_pack_start(GTK_BOX(vbox), editor_path_label, FALSE, FALSE, 0);
 	gtk_box_pack_start(GTK_BOX(vbox), editor_path, FALSE, FALSE, 0);
 	gtk_box_pack_start(GTK_BOX(vbox), editor_path_button, FALSE, FALSE, 0);
-	
+
 	gtk_widget_show_all(ret);
 
 	return ret;