annotate plugins/musicmessaging/musicmessaging.c @ 11890:fdb78734e2ae

[gaim-migrate @ 14181] what does everyone think of these new tooltips? committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sat, 29 Oct 2005 17:13:41 +0000
parents d9a7befbc3f1
children 21719fc8ea2d
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"
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
40 #include "dbus-gaim.h"
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
41
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
42 #define MUSICMESSAGING_PLUGIN_ID "gtk-hazure-musicmessaging"
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
43 #define MUSICMESSAGING_PREFIX "##MM##"
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
44 #define MUSICMESSAGING_START_MSG "A music messaging session has been requested. Please click the MM icon to accept."
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
45 #define MUSICMESSAGING_CONFIRM_MSG "Music messaging session confirmed."
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
46
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
47 typedef struct {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
48 GaimConversation *conv; /* pointer to the conversation */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
49 GtkWidget *seperator; /* seperator in the conversation */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
50 GtkWidget *button; /* button in the conversation */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
51 GPid pid; /* the pid of the score editor */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
52
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
53 gboolean started; /* session has started and editor run */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
54 gboolean originator; /* started the mm session */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
55 gboolean requested; /* received a request to start a session */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
56
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
57 } MMConversation;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
58
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
59 static gboolean start_session(MMConversation *mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
60 static void run_editor(MMConversation *mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
61 static void kill_editor(MMConversation *mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
62 static void add_button (MMConversation *mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
63 static void remove_widget (GtkWidget *button);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
64 static void init_conversation (GaimConversation *conv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
65 static void conv_destroyed(GaimConversation *conv);
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
66 static gboolean intercept_sent(GaimAccount *account, GaimConversation *conv, char **message, void* pData);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
67 static gboolean intercept_received(GaimAccount *account, char **sender, char **message, GaimConversation *conv, int *flags);
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
68 static gboolean send_change_request (const int session, const char *id, const char *command, const char *parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
69 static gboolean send_change_confirmed (const int session, const char *command, const char *parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
70 static void session_end (MMConversation *mmconv);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
71
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
72 /* Globals */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
73 /* List of sessions */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
74 GList *conversations;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
75
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
76 /* Pointer to this plugin */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
77 GaimPlugin *plugin_pointer;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
78
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
79 /* Define types needed for DBus */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
80 DBusGConnection *connection;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
81 DBusGProxy *proxy;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
82 #define DBUS_SERVICE_GSCORE "org.gscore.GScoreService"
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
83 #define DBUS_PATH_GSCORE "/org/gscore/GScoreObject"
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
84 #define DBUS_INTERFACE_GSCORE "org.gscore.GScoreInterface"
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
85
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
86 /* Define the functions to export for use with DBus */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
87 DBUS_EXPORT void music_messaging_change_request (const int session, const char *command, const char *parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
88 DBUS_EXPORT void music_messaging_change_confirmed (const int session, const char *command, const char *parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
89 DBUS_EXPORT void music_messaging_change_failed (const int session, const char *id, const char *command, const char *parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
90 DBUS_EXPORT void music_messaging_done_session (const int session);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
91
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
92 /* This file has been generated by the #dbus-analize-functions.py
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
93 script. It contains dbus wrappers for the four functions declared
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
94 above. */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
95 #include "music-messaging-bindings.c"
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
96
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
97 /* Exported functions */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
98 void music_messaging_change_request(const int session, const char *command, const char *parameters)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
99 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
100
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
101 MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
102
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
103 if (mmconv->started)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
104 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
105 if (mmconv->originator)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
106 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
107 char *name = (mmconv->conv)->name;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
108 send_change_request (session, name, command, parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
109 } else
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
110 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
111 GString *to_send = g_string_new("");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
112 g_string_append_printf(to_send, "##MM## request %s %s##MM##", command, parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
113
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
114 gaim_conv_im_send(GAIM_CONV_IM(mmconv->conv), to_send->str);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
115
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
116 gaim_debug_misc("Sent request: %s\n", to_send->str);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
117 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
118 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
119
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
120 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
121
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
122 void music_messaging_change_confirmed(const int session, const char *command, const char *parameters)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
123 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
124
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
125 MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
126
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
127 if (mmconv->started)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
128 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
129 if (mmconv->originator)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
130 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
131 GString *to_send = g_string_new("");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
132 g_string_append_printf(to_send, "##MM## confirm %s %s##MM##", command, parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
133
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
134 gaim_conv_im_send(GAIM_CONV_IM(mmconv->conv), to_send->str);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
135 } else
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
136 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
137 /* Do nothing. If they aren't the originator, then they can't confirm. */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
138 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
139 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
140
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
141 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
142
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
143 void music_messaging_change_failed(const int session, const char *id, const char *command, const char *parameters)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
144 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
145 gaim_notify_message(plugin_pointer, GAIM_NOTIFY_MSG_INFO, command,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
146 parameters, NULL, NULL, NULL);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
147
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
148 MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
149
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
150 if (mmconv->started)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
151 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
152 if (mmconv->originator)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
153 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
154 GString *to_send = g_string_new("");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
155 g_string_append_printf(to_send, "##MM## failed %s %s %s##MM##", id, command, parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
156
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
157 gaim_conv_im_send(GAIM_CONV_IM(mmconv->conv), to_send->str);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
158 } else
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
159 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
160 /* Do nothing. If they aren't the originator, then they can't confirm. */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
161 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
162 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
163 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
164
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
165 void music_messaging_done_session(const int session)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
166 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
167 gaim_notify_message(plugin_pointer, GAIM_NOTIFY_MSG_INFO, "Session",
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
168 "Session Complete", NULL, NULL, NULL);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
169
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
170 MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
171
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
172 session_end(mmconv);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
173 }
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
174
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
175
11355
6903f2f6d61f [gaim-migrate @ 13574]
Christian Muise <christian.muise@gmail.com>
parents: 11254
diff changeset
176 /* DBus commands that can be sent to the editor */
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
177 G_BEGIN_DECLS
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
178 DBusConnection *gaim_dbus_get_connection(void);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
179 G_END_DECLS
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
180
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
181 static gboolean send_change_request (const int session, const char *id, const char *command, const char *parameters)
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
182 {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
183 DBusMessage *message;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
184
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
185 /* Create the signal we need */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
186 message = dbus_message_new_signal (DBUS_PATH_GAIM, DBUS_INTERFACE_GAIM, "GscoreChangeRequest");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
187
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
188 /* Append the string "Ping!" to the signal */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
189 dbus_message_append_args (message,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
190 DBUS_TYPE_INT32, &session,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
191 DBUS_TYPE_STRING, &id,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
192 DBUS_TYPE_STRING, &command,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
193 DBUS_TYPE_STRING, &parameters,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
194 DBUS_TYPE_INVALID);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
195
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
196 /* Send the signal */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
197 dbus_connection_send (gaim_dbus_get_connection(), message, NULL);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
198
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
199 /* Free the signal now we have finished with it */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
200 dbus_message_unref (message);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
201
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
202 /* Tell the user we sent a signal */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
203 g_printerr("Sent change request signal: %d %s %s %s\n", session, id, command, parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
204
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
205 return TRUE;
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
206 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
207
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
208 static gboolean send_change_confirmed (const int session, const char *command, const char *parameters)
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
209 {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
210 DBusMessage *message;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
211
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
212 /* Create the signal we need */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
213 message = dbus_message_new_signal (DBUS_PATH_GAIM, DBUS_INTERFACE_GAIM, "GscoreChangeConfirmed");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
214
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
215 /* Append the string "Ping!" to the signal */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
216 dbus_message_append_args (message,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
217 DBUS_TYPE_INT32, &session,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
218 DBUS_TYPE_STRING, &command,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
219 DBUS_TYPE_STRING, &parameters,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
220 DBUS_TYPE_INVALID);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
221
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
222 /* Send the signal */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
223 dbus_connection_send (gaim_dbus_get_connection(), message, NULL);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
224
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
225 /* Free the signal now we have finished with it */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
226 dbus_message_unref (message);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
227
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
228 /* Tell the user we sent a signal */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
229 g_printerr("Sent change confirmed signal.\n");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
230
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
231 return TRUE;
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
232 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
233
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
234
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
235 static int
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
236 mmconv_from_conv_loc(GaimConversation *conv)
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
237 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
238 MMConversation *mmconv_current = NULL;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
239 guint i;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
240
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
241 for (i = 0; i < g_list_length(conversations); i++)
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
242 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
243 mmconv_current = (MMConversation *)g_list_nth_data(conversations, i);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
244 if (conv == mmconv_current->conv)
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
245 {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
246 return i;
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
247 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
248 }
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
249 return -1;
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
250 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
251
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
252 static MMConversation*
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
253 mmconv_from_conv(GaimConversation *conv)
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
254 {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
255 return (MMConversation *)g_list_nth_data(conversations, mmconv_from_conv_loc(conv));
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
256 }
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
257
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
258 static gboolean
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
259 plugin_load(GaimPlugin *plugin) {
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
260 /* 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
261 main gaim dbus loop. Without this statement, the gaim dbus
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
262 code wouldn't know about our functions. */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
263 GAIM_DBUS_REGISTER_BINDINGS(plugin);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
264
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
265
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
266 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Welcome",
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
267 "Welcome to music messaging.", NULL, NULL, NULL);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
268 /* Keep the plugin for reference (needed for notify's) */
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
269 plugin_pointer = plugin;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
270
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
271 /* Add the button to all the current conversations */
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
272 gaim_conversation_foreach (init_conversation);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
273
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
274 /* Listen for any new conversations */
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
275 void *conv_list_handle = gaim_conversations_get_handle();
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
276
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
277 gaim_signal_connect(conv_list_handle, "conversation-created",
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
278 plugin, GAIM_CALLBACK(init_conversation), NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
279
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
280 /* Listen for conversations that are ending */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
281 gaim_signal_connect(conv_list_handle, "deleting-conversation",
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
282 plugin, GAIM_CALLBACK(conv_destroyed), NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
283
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
284 /* Listen for sending/receiving messages to replace tags */
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
285 gaim_signal_connect(conv_list_handle, "displaying-im-msg",
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
286 plugin, GAIM_CALLBACK(intercept_sent), NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
287 gaim_signal_connect(conv_list_handle, "receiving-im-msg",
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
288 plugin, GAIM_CALLBACK(intercept_received), NULL);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
289
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
290 return TRUE;
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
291 }
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
292
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
293 static gboolean
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
294 plugin_unload(GaimPlugin *plugin) {
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
295
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
296 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Unloaded",
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
297 DATADIR, NULL, NULL, NULL);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
298
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
299 MMConversation *mmconv = NULL;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
300 while (g_list_length(conversations) > 0)
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 mmconv = g_list_first(conversations)->data;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
303 conv_destroyed(mmconv->conv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
304 }
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
305 return TRUE;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
306 }
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
307
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
308
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
309
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
310 static gboolean
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
311 intercept_sent(GaimAccount *account, GaimConversation *conv, char **message, void* pData)
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
312 {
11200
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 if (0 == strncmp(*message, MUSICMESSAGING_PREFIX, strlen(MUSICMESSAGING_PREFIX)))
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
315 {
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
316 gaim_debug_misc("gaim-musicmessaging", "Sent MM Message: %s\n", *message);
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
317 message = 0;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
318 }
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
319 else if (0 == strncmp(*message, MUSICMESSAGING_START_MSG, strlen(MUSICMESSAGING_START_MSG)))
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
320 {
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
321 gaim_debug_misc("gaim-musicmessaging", "Sent MM request.\n");
11420
ac07cafacb05 [gaim-migrate @ 13657]
Christian Muise <christian.muise@gmail.com>
parents: 11418
diff changeset
322 return FALSE;
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
323 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
324 else if (0 == strncmp(*message, MUSICMESSAGING_CONFIRM_MSG, strlen(MUSICMESSAGING_CONFIRM_MSG)))
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
325 {
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
326 gaim_debug_misc("gaim-musicmessaging", "Sent MM confirm.\n");
11420
ac07cafacb05 [gaim-migrate @ 13657]
Christian Muise <christian.muise@gmail.com>
parents: 11418
diff changeset
327 return FALSE;
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
328 }
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
329 else if (0 == strncmp(*message, "test1", strlen("test1")))
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
330 {
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
331 gaim_debug_misc("gaim-musicmessaging", "\n\nTEST 1\n\n");
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
332 send_change_request(0, "test-id", "test-command", "test-parameters");
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
333 return FALSE;
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
334 }
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
335 else if (0 == strncmp(*message, "test2", strlen("test2")))
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
336 {
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
337 gaim_debug_misc("gaim-musicmessaging", "\n\nTEST 2\n\n");
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
338 send_change_confirmed(1, "test-command", "test-parameters");
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
339 return FALSE;
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
340 }
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
341 else
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
342 {
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
343 return FALSE;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
344 /* Do nothing...procceed as normal */
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
345 }
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
346 return TRUE;
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
347 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
348
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
349 static gboolean
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
350 intercept_received(GaimAccount *account, char **sender, char **message, GaimConversation *conv, int *flags)
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
351 {
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
352 MMConversation *mmconv = mmconv_from_conv(conv);
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
353
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
354 gaim_debug_misc("gaim-musicmessaging", "Intercepted: %s\n", *message);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
355 if (strstr(*message, MUSICMESSAGING_PREFIX))
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
356 {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
357 char *parsed_message = strtok(strstr(*message, MUSICMESSAGING_PREFIX), "<");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
358 gaim_debug_misc("gaim-musicmessaging", "Received an MM Message: %s\n", parsed_message);
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
359
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
360 if (mmconv->started)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
361 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
362 if (strstr(parsed_message, "request"))
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
363 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
364 if (mmconv->originator)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
365 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
366 gaim_debug_misc("gaim-musicmessaging", "Sending request to gscore.\n");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
367
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
368 int session = mmconv_from_conv_loc(conv);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
369 char *id = (mmconv->conv)->name;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
370
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
371 /* Get past the first two terms - '##MM##' and 'request' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
372 strtok(parsed_message, " "); /* '##MM##' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
373 strtok(NULL, " "); /* 'request' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
374
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
375 char *command = strtok(NULL, " ");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
376 char *parameters = strtok(NULL, "#");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
377
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
378 send_change_request (session, id, command, parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
379
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
380 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
381 } else if (strstr(parsed_message, "confirm"))
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
382 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
383 if (!mmconv->originator)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
384 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
385 gaim_debug_misc("gaim-musicmessaging", "Sending confirmation to gscore.\n");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
386
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
387 int session = mmconv_from_conv_loc(conv);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
388
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
389 /* Get past the first two terms - '##MM##' and 'confirm' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
390 strtok(parsed_message, " "); /* '##MM##' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
391 strtok(NULL, " "); /* 'confirm' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
392
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
393 char *command = strtok(NULL, " ");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
394 char *parameters = strtok(NULL, "#");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
395
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
396 send_change_confirmed (session, command, parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
397 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
398 } else if (strstr(parsed_message, "failed"))
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
399 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
400 /* Get past the first two terms - '##MM##' and 'confirm' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
401 strtok(parsed_message, " "); /* '##MM##' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
402 strtok(NULL, " "); /* 'failed' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
403
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
404 char *id = strtok(NULL, " ");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
405 char *command = strtok(NULL, " ");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
406 /* char *parameters = strtok(NULL, "#"); DONT NEED PARAMETERS */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
407
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
408 if ((mmconv->conv)->name == id)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
409 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
410 gaim_notify_message(plugin_pointer, GAIM_NOTIFY_MSG_ERROR, "Music Messaging",
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
411 "There was a conflict in running the command:", command, NULL, NULL);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
412 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
413 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
414 }
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
415
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
416 message = 0;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
417 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
418 else if (strstr(*message, MUSICMESSAGING_START_MSG))
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
419 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
420 gaim_debug_misc("gaim-musicmessaging", "Received MM request.\n");
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
421 if (!(mmconv->originator))
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
422 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
423 mmconv->requested = TRUE;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
424 return FALSE;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
425 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
426
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
427 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
428 else if (strstr(*message, MUSICMESSAGING_CONFIRM_MSG))
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
429 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
430 gaim_debug_misc("gaim-musicmessagin", "Received MM confirm.\n");
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
431
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
432 if (mmconv->originator)
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
433 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
434 start_session(mmconv);
11420
ac07cafacb05 [gaim-migrate @ 13657]
Christian Muise <christian.muise@gmail.com>
parents: 11418
diff changeset
435 return FALSE;
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
436 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
437 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
438 else
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
439 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
440 return FALSE;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
441 /* Do nothing. */
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
442 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
443 return TRUE;
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
444 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
445
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
446 static void send_request(MMConversation *mmconv)
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
447 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
448 GaimConnection *connection = gaim_conversation_get_gc(mmconv->conv);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
449 const char *convName = gaim_conversation_get_name(mmconv->conv);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
450 serv_send_im(connection, convName, MUSICMESSAGING_START_MSG, GAIM_MESSAGE_SEND);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
451 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
452
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
453 static void send_request_confirmed(MMConversation *mmconv)
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
454 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
455 GaimConnection *connection = gaim_conversation_get_gc(mmconv->conv);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
456 const char *convName = gaim_conversation_get_name(mmconv->conv);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
457 serv_send_im(connection, convName, MUSICMESSAGING_CONFIRM_MSG, GAIM_MESSAGE_SEND);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
458 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
459
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
460
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
461 static gboolean
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
462 start_session(MMConversation *mmconv)
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
463 {
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
464 run_editor(mmconv);
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
465 return TRUE;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
466 }
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
467
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
468 static void session_end (MMConversation *mmconv)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
469 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
470 mmconv->started = FALSE;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
471 mmconv->originator = FALSE;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
472 mmconv->requested = FALSE;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
473 kill_editor(mmconv);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
474 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
475
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
476 static void music_button_toggled (GtkWidget *widget, gpointer data)
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
477 {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
478 MMConversation *mmconv = mmconv_from_conv(((MMConversation *) data)->conv);
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
479 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
480 {
11418
29aaa7d29015 [gaim-migrate @ 13655]
Christian Muise <christian.muise@gmail.com>
parents: 11417
diff changeset
481 if (((MMConversation *) data)->requested)
29aaa7d29015 [gaim-migrate @ 13655]
Christian Muise <christian.muise@gmail.com>
parents: 11417
diff changeset
482 {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
483 start_session(mmconv);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
484 send_request_confirmed(mmconv);
11418
29aaa7d29015 [gaim-migrate @ 13655]
Christian Muise <christian.muise@gmail.com>
parents: 11417
diff changeset
485 }
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
486 else
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
487 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
488 ((MMConversation *) data)->originator = TRUE;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
489 send_request((MMConversation *) data);
11418
29aaa7d29015 [gaim-migrate @ 13655]
Christian Muise <christian.muise@gmail.com>
parents: 11417
diff changeset
490 }
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
491 } else {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
492 session_end((MMConversation *)data);
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
493 }
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
494 }
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
495
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
496 static void set_editor_path (GtkWidget *button, GtkWidget *text_field)
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
497 {
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
498 const char * path = gtk_entry_get_text((GtkEntry*)text_field);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
499 gaim_prefs_set_string("/plugins/gtk/musicmessaging/editor_path", path);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
500
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
501 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
502
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
503 static void run_editor (MMConversation *mmconv)
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
504 {
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
505 GError *spawn_error = NULL;
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
506 gchar * args[4];
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
507 args[0] = (gchar *)gaim_prefs_get_string("/plugins/gtk/musicmessaging/editor_path");
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
508
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
509 args[1] = "-session_id";
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
510 GString *session_id = g_string_new("");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
511 g_string_sprintfa(session_id, "%d", mmconv_from_conv_loc(mmconv->conv));
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
512 args[2] = session_id->str;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
513
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
514 args[3] = NULL;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
515
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
516 if (!(g_spawn_async (".", args, NULL, 4, NULL, NULL, &(mmconv->pid), &spawn_error)))
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
517 {
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
518 gaim_notify_error(plugin_pointer, "Error Running Editor",
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
519 "The following error has occured:", spawn_error->message);
11254
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
520 mmconv->started = FALSE;
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
521 }
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
522 else
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
523 {
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
524 mmconv->started = TRUE;
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
525 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
526 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
527
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
528 static void kill_editor (MMConversation *mmconv)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
529 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
530 if (mmconv->pid)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
531 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
532 kill(mmconv->pid, SIGINT);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
533 mmconv->pid = 0;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
534 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
535 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
536
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
537 static void init_conversation (GaimConversation *conv)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
538 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
539 MMConversation *mmconv;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
540 mmconv = g_malloc(sizeof(MMConversation));
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
541
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
542 mmconv->conv = conv;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
543 mmconv->started = FALSE;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
544 mmconv->originator = FALSE;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
545 mmconv->requested = FALSE;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
546
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
547 add_button(mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
548
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
549 conversations = g_list_append(conversations, mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
550 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
551
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
552 static void conv_destroyed (GaimConversation *conv)
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
553 {
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
554 MMConversation *mmconv = mmconv_from_conv(conv);
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
555
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
556 remove_widget(mmconv->button);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
557 remove_widget(mmconv->seperator);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
558 if (mmconv->started)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
559 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
560 kill_editor(mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
561 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
562 conversations = g_list_remove(conversations, mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
563 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
564
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
565 static void add_button (MMConversation *mmconv)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
566 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
567 GaimConversation *conv = mmconv->conv;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
568
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
569 GtkWidget *button, *image, *sep;
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
570
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
571 button = gtk_toggle_button_new();
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
572 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
573
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
574 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
575
11659
d9a7befbc3f1 [gaim-migrate @ 13944]
Gary Kramlich <grim@reaperworld.com>
parents: 11420
diff changeset
576 gchar *file_path = g_build_filename(DATADIR, "pixmaps", "gaim", "buttons",
d9a7befbc3f1 [gaim-migrate @ 13944]
Gary Kramlich <grim@reaperworld.com>
parents: 11420
diff changeset
577 "music.png", NULL);
11254
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
578 image = gtk_image_new_from_file(file_path);
11659
d9a7befbc3f1 [gaim-migrate @ 13944]
Gary Kramlich <grim@reaperworld.com>
parents: 11420
diff changeset
579 g_free(file_path);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
580
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
581 gtk_container_add((GtkContainer *)button, image);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
582
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
583 sep = gtk_vseparator_new();
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
584
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
585 mmconv->seperator = sep;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
586 mmconv->button = button;
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
587
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
588 gtk_widget_show(sep);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
589 gtk_widget_show(image);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
590 gtk_widget_show(button);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
591
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
592 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
593 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
594 }
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
595
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
596 static void remove_widget (GtkWidget *button)
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
597 {
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
598 gtk_widget_hide(button);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
599 gtk_widget_destroy(button);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
600 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
601
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
602 static GtkWidget *
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
603 get_config_frame(GaimPlugin *plugin)
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
604 {
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
605 GtkWidget *ret;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
606 GtkWidget *vbox;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
607
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
608 GtkWidget *editor_path;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
609 GtkWidget *editor_path_label;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
610 GtkWidget *editor_path_button;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
611
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
612 /* Outside container */
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
613 ret = gtk_vbox_new(FALSE, 18);
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
614 gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
615
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
616 /* Configuration frame */
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
617 vbox = gaim_gtk_make_frame(ret, _("Music Messaging Configuration"));
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
618
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
619 /* Path to the score editor */
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
620 editor_path = gtk_entry_new();
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
621 editor_path_label = gtk_label_new("Score Editor Path");
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
622 editor_path_button = gtk_button_new_with_mnemonic(_("_Apply"));
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
623
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
624 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
625
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
626 g_signal_connect(G_OBJECT(editor_path_button), "clicked",
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
627 G_CALLBACK(set_editor_path), editor_path);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
628
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
629 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
630 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
631 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
632
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
633 gtk_widget_show_all(ret);
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
634
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
635 return ret;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
636 }
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
637
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
638 static GaimGtkPluginUiInfo ui_info =
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
639 {
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
640 get_config_frame
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
641 };
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
642
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
643 static GaimPluginInfo info = {
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
644 GAIM_PLUGIN_MAGIC,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
645 GAIM_MAJOR_VERSION,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
646 GAIM_MINOR_VERSION,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
647 GAIM_PLUGIN_STANDARD,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
648 GAIM_GTK_PLUGIN_TYPE,
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
649 0,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
650 NULL,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
651 GAIM_PRIORITY_DEFAULT,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
652
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
653 MUSICMESSAGING_PLUGIN_ID,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
654 "Music Messaging",
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
655 VERSION,
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
656 "Music Messaging Plugin for collabrative composition.",
11216
1b32ad61e114 [gaim-migrate @ 13348]
Richard Laager <rlaager@wiktel.com>
parents: 11200
diff changeset
657 "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
658 "Christian Muise <christian.muise@gmail.com>",
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
659 GAIM_WEBSITE,
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
660 plugin_load,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
661 plugin_unload,
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
662 NULL,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
663 &ui_info,
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
664 NULL,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
665 NULL,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
666 NULL
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
667 };
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
668
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
669 static void
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
670 init_plugin(GaimPlugin *plugin) {
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
671 gaim_prefs_add_none("/plugins/gtk/musicmessaging");
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
672 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
673 }
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
674
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
675 GAIM_INIT_PLUGIN(musicmessaging, init_plugin, info);