annotate plugins/musicmessaging/musicmessaging.c @ 11216:1b32ad61e114

[gaim-migrate @ 13348] Spelling fix. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 09 Aug 2005 04:28:59 +0000
parents 4295083cf489
children ce3b9969b399
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
1 /*
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
2 * Music messaging plugin for Gaim
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
3 *
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
4 * Copyright (C) 2005 Christian Muise.
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
5 *
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
6 * This program is free software; you can redistribute it and/or
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
7 * modify it under the terms of the GNU General Public License as
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
9 * License, or (at your option) any later version.
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
10 *
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
11 * This program is distributed in the hope that it will be useful, but
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
14 * General Public License for more details.
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
15 *
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
16 * You should have received a copy of the GNU General Public License
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
17 * along with this program; if not, write to the Free Software
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
19 * 02111-1307, USA.
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
20 */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
21
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
22 #include "internal.h"
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
23 #include "gtkgaim.h"
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
24
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
25 #include "conversation.h"
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
26
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
27 #include "gtkconv.h"
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
28 #include "gtkplugin.h"
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
29 #include "gtkutils.h"
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
30
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
31 #include "notify.h"
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
32 #include "version.h"
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
33 #include "debug.h"
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
34
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
35 #define DBUS_API_SUBJECT_TO_CHANGE
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
36 #include <dbus/dbus.h>
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
37 #include "dbus-maybe.h"
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
38 #include "dbus-bindings.h"
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
39 #include "dbus-server.h"
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
40
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
41 #define MUSICMESSAGING_PLUGIN_ID "gtk-hazure-musicmessaging"
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
42 #define MUSICMESSAGING_PREFIX "##MM##"
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
43 #define MUSICMESSAGING_START_TAG "<a href=mm-plugin>"
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
44
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
45 /* Globals */
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
46 /* List of sessions */
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
47 GList *conversations;
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
48
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
49 /* Pointer to this plugin */
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
50 GaimPlugin *plugin_pointer;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
51
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
52 /* Define types needed for DBus */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
53
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
54 /* Define the functions to export for use with DBus */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
55 DBUS_EXPORT void music_messaging_change_request (const char *command, const char *parameters);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
56 DBUS_EXPORT void music_messaging_change_confirmed (const char *command, const char *parameters);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
57 DBUS_EXPORT void music_messaging_change_failed (const char *id, const char *command, const char *parameters);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
58 DBUS_EXPORT void music_messaging_done_session (void);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
59
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
60 /* This file has been generated by the #dbus-analize-functions.py
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
61 script. It contains dbus wrappers for the four functions declared
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
62 above. */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
63 #include "music-messaging-bindings.c"
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
64
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
65 /* Exported functions */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
66 void music_messaging_change_request(const char *command, const char *parameters)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
67 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
68 gaim_notify_message(plugin_pointer, GAIM_NOTIFY_MSG_INFO, command,
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
69 parameters, NULL, NULL, NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
70 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
71
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
72 void music_messaging_change_confirmed(const char *command, const char *parameters)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
73 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
74 gaim_notify_message(plugin_pointer, GAIM_NOTIFY_MSG_INFO, command,
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
75 parameters, NULL, NULL, NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
76 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
77
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
78 void music_messaging_change_failed(const char *id, const char *command, const char *parameters)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
79 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
80 gaim_notify_message(plugin_pointer, GAIM_NOTIFY_MSG_INFO, command,
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
81 parameters, NULL, NULL, NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
82 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
83
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
84 void music_messaging_done_session(void)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
85 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
86 gaim_notify_message(plugin_pointer, GAIM_NOTIFY_MSG_INFO, "Session",
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
87 "Session Complete", NULL, NULL, NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
88 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
89
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
90 typedef struct {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
91 GaimConversation *conv; /* pointer to the conversation */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
92 GtkWidget *seperator; /* seperator in the conversation */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
93 GtkWidget *button; /* button in the conversation */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
94 GPid pid; /* the pid of the score editor */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
95
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
96 gboolean started; /* session has started and editor run */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
97 gboolean originator; /* started the mm session */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
98 gboolean requested; /* received a request to start a session */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
99
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
100 } MMConversation;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
101
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
102 static gboolean start_session(MMConversation *mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
103 static void run_editor(MMConversation *mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
104 static void kill_editor(MMConversation *mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
105 static void add_button (MMConversation *mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
106 static void remove_widget (GtkWidget *button);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
107 static void init_conversation (GaimConversation *conv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
108 static void conv_destroyed(GaimConversation *conv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
109 static void intercept_sent(GaimAccount *account, GaimConversation *conv, char **message, void* pData);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
110 static void intercept_received(GaimAccount *account, char **sender, char **message, GaimConversation *conv, int *flags);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
111
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
112
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
113 G_BEGIN_DECLS
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
114 DBusConnection *gaim_dbus_get_connection(void);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
115 G_END_DECLS
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
116
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
117 void send_change_request (const char *id, const char *command, const char *parameters)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
118 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
119 DBusMessage *signal;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
120 signal = dbus_message_new_signal("/org/gscore/GScoreObject", "org.gscore.GScoreInterface", "gscore_change_request");
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
121
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
122 dbus_message_append_args(signal,
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
123 DBUS_TYPE_STRING, &id,
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
124 DBUS_TYPE_STRING, &command,
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
125 DBUS_TYPE_STRING, &parameters,
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
126 DBUS_TYPE_INVALID);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
127
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
128 dbus_connection_send(gaim_dbus_get_connection(), signal, NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
129 dbus_message_unref(signal);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
130 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
131
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
132 void send_change_confirmed (const char *command, const char *parameters)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
133 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
134 DBusMessage *signal;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
135 signal = dbus_message_new_signal("/org/gscore/GScoreObject", "org.gscore.GScoreInterface", "gscore_change_confirmed");
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
136
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
137 dbus_message_append_args(signal,
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
138 DBUS_TYPE_STRING, &command,
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
139 DBUS_TYPE_STRING, &parameters,
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
140 DBUS_TYPE_INVALID);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
141
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
142 dbus_connection_send(gaim_dbus_get_connection(), signal, NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
143 dbus_message_unref(signal);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
144 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
145
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
146
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
147 static gboolean
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
148 plugin_load(GaimPlugin *plugin) {
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
149 /* First, we have to register our four exported functions with the
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
150 main gaim dbus loop. Without this statement, the gaim dbus
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
151 code wouldn't know about our functions. */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
152 GAIM_DBUS_REGISTER_BINDINGS(plugin);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
153
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
154 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Welcome",
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
155 "Welcome to music messaging.", NULL, NULL, NULL);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
156 /* Keep the plugin for reference (needed for notify's) */
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
157 plugin_pointer = plugin;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
158
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
159 /* Add the button to all the current conversations */
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
160 gaim_conversation_foreach (init_conversation);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
161
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
162 /* Listen for any new conversations */
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
163 void *conv_list_handle = gaim_conversations_get_handle();
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
164
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
165 gaim_signal_connect(conv_list_handle, "conversation-created",
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
166 plugin, GAIM_CALLBACK(init_conversation), NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
167
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
168 /* Listen for conversations that are ending */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
169 gaim_signal_connect(conv_list_handle, "deleting-conversation",
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
170 plugin, GAIM_CALLBACK(conv_destroyed), NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
171
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
172 /* Listen for sending/receiving messages to replace tags */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
173 gaim_signal_connect(conv_list_handle, "writing-im-msg",
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
174 plugin, GAIM_CALLBACK(intercept_sent), NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
175 gaim_signal_connect(conv_list_handle, "receiving-im-msg",
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
176 plugin, GAIM_CALLBACK(intercept_received), NULL);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
177
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
178 return TRUE;
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
179 }
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
180
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
181 static gboolean
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
182 plugin_unload(GaimPlugin *plugin) {
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
183
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
184 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Unloaded",
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
185 DATADIR, NULL, NULL, NULL);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
186
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
187 MMConversation *mmconv = NULL;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
188 while (g_list_length(conversations) > 0)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
189 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
190 mmconv = g_list_first(conversations)->data;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
191 conv_destroyed(mmconv->conv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
192 }
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
193 return TRUE;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
194 }
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
195
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
196 static void intercept_sent(GaimAccount *account, GaimConversation *conv, char **message, void* pData)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
197 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
198 GaimConvIm *imData = gaim_conversation_get_im_data(conv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
199 GaimConnection *connection = gaim_conversation_get_gc(conv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
200 const char *convName = gaim_conversation_get_name(conv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
201 const char *who = gaim_account_get_username(account);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
202
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
203 if (0 == strncmp(*message, MUSICMESSAGING_PREFIX, strlen(MUSICMESSAGING_PREFIX)))
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
204 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
205 message = 0;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
206 gaim_debug(GAIM_DEBUG_MISC, "gaim-musicmessaging", "Received MM Message\n");
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
207 send_change_confirmed("the command", "the params");
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
208 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
209 else if (0 == strncmp(*message, MUSICMESSAGING_START_TAG, strlen(MUSICMESSAGING_START_TAG)))
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
210 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
211
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
212 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
213 else
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
214 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
215 serv_send_im(connection, convName, *message, GAIM_MESSAGE_SEND);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
216 gaim_conv_im_write (imData, NULL, *message, GAIM_MESSAGE_SYSTEM, time(NULL));
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
217 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
218 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
219
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
220 static void intercept_received(GaimAccount *account, char **sender, char **message, GaimConversation *conv, int *flags)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
221 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
222
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
223 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
224
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
225
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
226 static gboolean
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
227 start_session(MMConversation *mmconv)
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
228 {
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
229 mmconv->started = TRUE;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
230 run_editor(mmconv);
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
231 return TRUE;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
232 }
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
233
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
234 static void music_button_toggled (GtkWidget *widget, gpointer data)
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
235 {
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
236 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
237 {
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
238 start_session((MMConversation *) data);
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
239 } else {
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
240 kill_editor((MMConversation *) data);
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
241 }
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
242 }
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
243
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
244 static void set_editor_path (GtkWidget *button, GtkWidget *text_field)
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
245 {
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
246 const char * path = gtk_entry_get_text((GtkEntry*)text_field);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
247 gaim_prefs_set_string("/plugins/gtk/musicmessaging/editor_path", path);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
248
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
249 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
250
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
251 static void run_editor (MMConversation *mmconv)
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
252 {
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
253 GError *spawn_error = NULL;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
254 gchar * args[2];
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
255 args[0] = (gchar *)gaim_prefs_get_string("/plugins/gtk/musicmessaging/editor_path");
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
256 args[1] = NULL;
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
257 if (!(g_spawn_async (".", args, NULL, 12, NULL, NULL, &(mmconv->pid), &spawn_error)))
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
258 {
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
259 gaim_notify_error(plugin_pointer, "Error Running Editor",
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
260 "The following error has occured:", spawn_error->message);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
261 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
262 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
263
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
264 static void kill_editor (MMConversation *mmconv)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
265 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
266 if (mmconv->pid)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
267 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
268 kill(mmconv->pid, SIGINT);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
269 mmconv->pid = 0;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
270 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
271 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
272
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
273 static void init_conversation (GaimConversation *conv)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
274 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
275 MMConversation *mmconv;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
276 mmconv = g_malloc(sizeof(MMConversation));
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
277
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
278 mmconv->conv = conv;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
279 mmconv->started = FALSE;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
280 mmconv->originator = FALSE;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
281 mmconv->requested = FALSE;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
282
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
283 add_button(mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
284
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
285 conversations = g_list_append(conversations, mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
286 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
287
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
288 static void conv_destroyed (GaimConversation *conv)
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
289 {
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
290 MMConversation *mmconv_current = NULL;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
291 MMConversation *mmconv = NULL;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
292 guint i;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
293
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
294 for (i = 0; i < g_list_length(conversations); i++)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
295 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
296 mmconv_current = (MMConversation *)g_list_nth_data(conversations, i);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
297 if (conv == mmconv_current->conv)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
298 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
299 mmconv = mmconv_current;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
300 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
301 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
302
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
303 remove_widget(mmconv->button);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
304 remove_widget(mmconv->seperator);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
305 if (mmconv->started)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
306 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
307 kill_editor(mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
308 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
309 conversations = g_list_remove(conversations, mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
310 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
311
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
312 static void add_button (MMConversation *mmconv)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
313 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
314 GaimConversation *conv = mmconv->conv;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
315
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
316 GtkWidget *button, *image, *sep;
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
317
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
318 button = gtk_toggle_button_new();
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
319 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
320
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
321 g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(music_button_toggled), mmconv);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
322
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
323 gchar *file_path = g_build_filename (DATADIR, "pixmaps", "gaim", "buttons", "music.png", NULL);
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
324 image = gtk_image_new_from_file("/usr/local/share/pixmaps/gaim/buttons/music.png");
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
325
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
326 gtk_container_add((GtkContainer *)button, image);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
327
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
328 sep = gtk_vseparator_new();
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
329
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
330 mmconv->seperator = sep;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
331 mmconv->button = button;
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
332
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
333 gtk_widget_show(sep);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
334 gtk_widget_show(image);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
335 gtk_widget_show(button);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
336
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
337 gtk_box_pack_start(GTK_BOX(GAIM_GTK_CONVERSATION(conv)->toolbar), sep, FALSE, FALSE, 0);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
338 gtk_box_pack_start(GTK_BOX(GAIM_GTK_CONVERSATION(conv)->toolbar), button, FALSE, FALSE, 0);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
339 }
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
340
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
341 static void remove_widget (GtkWidget *button)
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
342 {
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
343 gtk_widget_hide(button);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
344 gtk_widget_destroy(button);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
345 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
346
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
347 static GtkWidget *
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
348 get_config_frame(GaimPlugin *plugin)
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
349 {
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
350 GtkWidget *ret;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
351 GtkWidget *vbox;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
352
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
353 GtkWidget *editor_path;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
354 GtkWidget *editor_path_label;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
355 GtkWidget *editor_path_button;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
356
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
357 /* Outside container */
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
358 ret = gtk_vbox_new(FALSE, 18);
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
359 gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
360
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
361 /* Configuration frame */
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
362 vbox = gaim_gtk_make_frame(ret, _("Music Messaging Configuration"));
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
363
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
364 /* Path to the score editor */
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
365 editor_path = gtk_entry_new();
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
366 editor_path_label = gtk_label_new("Score Editor Path");
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
367 editor_path_button = gtk_button_new_with_mnemonic(_("_Apply"));
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
368
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
369 gtk_entry_set_text((GtkEntry*)editor_path, "/usr/local/bin/gscore");
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
370
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
371 g_signal_connect(G_OBJECT(editor_path_button), "clicked",
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
372 G_CALLBACK(set_editor_path), editor_path);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
373
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
374 gtk_box_pack_start(GTK_BOX(vbox), editor_path_label, FALSE, FALSE, 0);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
375 gtk_box_pack_start(GTK_BOX(vbox), editor_path, FALSE, FALSE, 0);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
376 gtk_box_pack_start(GTK_BOX(vbox), editor_path_button, FALSE, FALSE, 0);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
377
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
378 gtk_widget_show_all(ret);
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
379
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
380 return ret;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
381 }
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
382
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
383 static GaimGtkPluginUiInfo ui_info =
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
384 {
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
385 get_config_frame
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
386 };
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
387
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
388 static GaimPluginInfo info = {
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
389 GAIM_PLUGIN_MAGIC,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
390 GAIM_MAJOR_VERSION,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
391 GAIM_MINOR_VERSION,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
392 GAIM_PLUGIN_STANDARD,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
393 GAIM_GTK_PLUGIN_TYPE,
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
394 0,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
395 NULL,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
396 GAIM_PRIORITY_DEFAULT,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
397
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
398 MUSICMESSAGING_PLUGIN_ID,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
399 "Music Messaging",
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
400 VERSION,
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
401 "Music Messaging Plugin for collabrative composition.",
11216
1b32ad61e114 [gaim-migrate @ 13348]
Richard Laager <rlaager@wiktel.com>
parents: 11200
diff changeset
402 "The Music Messaging Plugin allows a number of users to simultaneously work on a piece of music by editting a common score in real-time.",
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
403 "Christian Muise <christian.muise@gmail.com>",
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
404 GAIM_WEBSITE,
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
405 plugin_load,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
406 plugin_unload,
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
407 NULL,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
408 &ui_info,
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
409 NULL,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
410 NULL,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
411 NULL
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
412 };
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
413
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
414 static void
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
415 init_plugin(GaimPlugin *plugin) {
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
416 gaim_prefs_add_none("/plugins/gtk/musicmessaging");
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
417 gaim_prefs_add_string("/plugins/gtk/musicmessaging/editor_path", "/usr/local/bin/gscore");
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
418 }
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
419
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
420 GAIM_INIT_PLUGIN(musicmessaging, init_plugin, info);