annotate plugins/musicmessaging/musicmessaging.c @ 12164:281ab2ecc08c

[gaim-migrate @ 14465] SF Patch #1361253 from Sadrul Summary: "Contact Priority Fix" "This was not updated when GAIM_STATUS_ONLINE was removed." Comment by sadrul: "I have also included a fix for the contact-priority plugin." I made a lot more changes to the contact priority. It seems to work for me now. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sat, 19 Nov 2005 16:35:34 +0000
parents 21719fc8ea2d
children 829203b89200
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 {
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
145 MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
146
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
147 gaim_notify_message(plugin_pointer, GAIM_NOTIFY_MSG_INFO, command,
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
148 parameters, NULL, NULL, NULL);
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 {
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
167 MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
168
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
169 gaim_notify_message(plugin_pointer, GAIM_NOTIFY_MSG_INFO, "Session",
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
170 "Session Complete", NULL, NULL, NULL);
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) {
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
260 void *conv_list_handle;
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
261
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
262 /* 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
263 main gaim dbus loop. Without this statement, the gaim dbus
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
264 code wouldn't know about our functions. */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
265 GAIM_DBUS_REGISTER_BINDINGS(plugin);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
266
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
267
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
268 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Welcome",
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
269 "Welcome to music messaging.", NULL, NULL, NULL);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
270 /* Keep the plugin for reference (needed for notify's) */
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
271 plugin_pointer = plugin;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
272
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
273 /* Add the button to all the current conversations */
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
274 gaim_conversation_foreach (init_conversation);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
275
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
276 /* Listen for any new conversations */
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
277 conv_list_handle = gaim_conversations_get_handle();
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
278
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
279 gaim_signal_connect(conv_list_handle, "conversation-created",
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
280 plugin, GAIM_CALLBACK(init_conversation), NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
281
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
282 /* Listen for conversations that are ending */
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
283 gaim_signal_connect(conv_list_handle, "deleting-conversation",
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
284 plugin, GAIM_CALLBACK(conv_destroyed), NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
285
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
286 /* Listen for sending/receiving messages to replace tags */
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
287 gaim_signal_connect(conv_list_handle, "displaying-im-msg",
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
288 plugin, GAIM_CALLBACK(intercept_sent), NULL);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
289 gaim_signal_connect(conv_list_handle, "receiving-im-msg",
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
290 plugin, GAIM_CALLBACK(intercept_received), NULL);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
291
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
292 return TRUE;
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
293 }
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
294
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
295 static gboolean
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
296 plugin_unload(GaimPlugin *plugin) {
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
297 MMConversation *mmconv = NULL;
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
298
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
299 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Unloaded",
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
300 DATADIR, NULL, NULL, NULL);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
301
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
302 while (g_list_length(conversations) > 0)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
303 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
304 mmconv = g_list_first(conversations)->data;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
305 conv_destroyed(mmconv->conv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
306 }
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
307 return TRUE;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
308 }
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
309
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
310
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
311
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
312 static gboolean
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
313 intercept_sent(GaimAccount *account, GaimConversation *conv, char **message, void* pData)
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
314 {
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
315
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
316 if (0 == strncmp(*message, MUSICMESSAGING_PREFIX, strlen(MUSICMESSAGING_PREFIX)))
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
317 {
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
318 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
319 message = 0;
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 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
322 {
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
323 gaim_debug_misc("gaim-musicmessaging", "Sent MM request.\n");
11420
ac07cafacb05 [gaim-migrate @ 13657]
Christian Muise <christian.muise@gmail.com>
parents: 11418
diff changeset
324 return FALSE;
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
325 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
326 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
327 {
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
328 gaim_debug_misc("gaim-musicmessaging", "Sent MM confirm.\n");
11420
ac07cafacb05 [gaim-migrate @ 13657]
Christian Muise <christian.muise@gmail.com>
parents: 11418
diff changeset
329 return FALSE;
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
330 }
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
331 else if (0 == strncmp(*message, "test1", strlen("test1")))
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
332 {
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
333 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
334 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
335 return FALSE;
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 else if (0 == strncmp(*message, "test2", strlen("test2")))
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
338 {
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
339 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
340 send_change_confirmed(1, "test-command", "test-parameters");
11365
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
341 return FALSE;
817e52833803 [gaim-migrate @ 13589]
Christian Muise <christian.muise@gmail.com>
parents: 11362
diff changeset
342 }
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
343 else
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
344 {
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
345 return FALSE;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
346 /* Do nothing...procceed as normal */
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
347 }
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
348 return TRUE;
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
349 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
350
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
351 static gboolean
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
352 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
353 {
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
354 MMConversation *mmconv = mmconv_from_conv(conv);
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
355
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
356 gaim_debug_misc("gaim-musicmessaging", "Intercepted: %s\n", *message);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
357 if (strstr(*message, MUSICMESSAGING_PREFIX))
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
358 {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
359 char *parsed_message = strtok(strstr(*message, MUSICMESSAGING_PREFIX), "<");
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
360 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
361
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
362 if (mmconv->started)
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 (strstr(parsed_message, "request"))
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 if (mmconv->originator)
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;
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
370 char *command;
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
371 char *parameters;
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
372
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
373 gaim_debug_misc("gaim-musicmessaging", "Sending request to gscore.\n");
11417
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 /* Get past the first two terms - '##MM##' and 'request' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
376 strtok(parsed_message, " "); /* '##MM##' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
377 strtok(NULL, " "); /* 'request' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
378
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
379 command = strtok(NULL, " ");
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
380 parameters = strtok(NULL, "#");
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
381
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
382 send_change_request (session, id, command, parameters);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
383
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 } else if (strstr(parsed_message, "confirm"))
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 if (!mmconv->originator)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
388 {
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
389 int session = mmconv_from_conv_loc(conv);
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
390 char *command;
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
391 char *parameters;
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
392
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
393 gaim_debug_misc("gaim-musicmessaging", "Sending confirmation to gscore.\n");
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
394
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
395 /* Get past the first two terms - '##MM##' and 'confirm' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
396 strtok(parsed_message, " "); /* '##MM##' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
397 strtok(NULL, " "); /* 'confirm' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
398
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
399 command = strtok(NULL, " ");
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
400 parameters = strtok(NULL, "#");
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
401
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
402 send_change_confirmed (session, command, parameters);
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 } else if (strstr(parsed_message, "failed"))
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
405 {
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
406 char *id;
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
407 char *command;
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
408
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
409 /* Get past the first two terms - '##MM##' and 'confirm' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
410 strtok(parsed_message, " "); /* '##MM##' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
411 strtok(NULL, " "); /* 'failed' */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
412
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
413 id = strtok(NULL, " ");
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
414 command = strtok(NULL, " ");
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
415 /* char *parameters = strtok(NULL, "#"); DONT NEED PARAMETERS */
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
416
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
417 if ((mmconv->conv)->name == id)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
418 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
419 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
420 "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
421 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
422 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
423 }
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
424
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
425 message = 0;
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 else if (strstr(*message, MUSICMESSAGING_START_MSG))
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
428 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
429 gaim_debug_misc("gaim-musicmessaging", "Received MM request.\n");
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
430 if (!(mmconv->originator))
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 mmconv->requested = TRUE;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
433 return FALSE;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
434 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
435
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 else if (strstr(*message, MUSICMESSAGING_CONFIRM_MSG))
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
438 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
439 gaim_debug_misc("gaim-musicmessagin", "Received MM confirm.\n");
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
440
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
441 if (mmconv->originator)
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 start_session(mmconv);
11420
ac07cafacb05 [gaim-migrate @ 13657]
Christian Muise <christian.muise@gmail.com>
parents: 11418
diff changeset
444 return FALSE;
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
445 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
446 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
447 else
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
448 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
449 return FALSE;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
450 /* Do nothing. */
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 return TRUE;
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
453 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
454
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
455 static void send_request(MMConversation *mmconv)
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
456 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
457 GaimConnection *connection = gaim_conversation_get_gc(mmconv->conv);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
458 const char *convName = gaim_conversation_get_name(mmconv->conv);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
459 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
460 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
461
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
462 static void send_request_confirmed(MMConversation *mmconv)
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
463 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
464 GaimConnection *connection = gaim_conversation_get_gc(mmconv->conv);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
465 const char *convName = gaim_conversation_get_name(mmconv->conv);
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
466 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
467 }
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
468
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
469
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
470 static gboolean
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
471 start_session(MMConversation *mmconv)
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
472 {
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
473 run_editor(mmconv);
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
474 return TRUE;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
475 }
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
476
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
477 static void session_end (MMConversation *mmconv)
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
478 {
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
479 mmconv->started = FALSE;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
480 mmconv->originator = FALSE;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
481 mmconv->requested = FALSE;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
482 kill_editor(mmconv);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
483 }
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
484
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
485 static void music_button_toggled (GtkWidget *widget, gpointer data)
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
486 {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
487 MMConversation *mmconv = mmconv_from_conv(((MMConversation *) data)->conv);
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
488 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
489 {
11418
29aaa7d29015 [gaim-migrate @ 13655]
Christian Muise <christian.muise@gmail.com>
parents: 11417
diff changeset
490 if (((MMConversation *) data)->requested)
29aaa7d29015 [gaim-migrate @ 13655]
Christian Muise <christian.muise@gmail.com>
parents: 11417
diff changeset
491 {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
492 start_session(mmconv);
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
493 send_request_confirmed(mmconv);
11418
29aaa7d29015 [gaim-migrate @ 13655]
Christian Muise <christian.muise@gmail.com>
parents: 11417
diff changeset
494 }
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
495 else
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
496 {
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
497 ((MMConversation *) data)->originator = TRUE;
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
498 send_request((MMConversation *) data);
11418
29aaa7d29015 [gaim-migrate @ 13655]
Christian Muise <christian.muise@gmail.com>
parents: 11417
diff changeset
499 }
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
500 } else {
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
501 session_end((MMConversation *)data);
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
502 }
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
503 }
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
504
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
505 static void set_editor_path (GtkWidget *button, GtkWidget *text_field)
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
506 {
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
507 const char * path = gtk_entry_get_text((GtkEntry*)text_field);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
508 gaim_prefs_set_string("/plugins/gtk/musicmessaging/editor_path", path);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
509
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
510 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
511
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
512 static void run_editor (MMConversation *mmconv)
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
513 {
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
514 GError *spawn_error = NULL;
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
515 GString *session_id;
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
516 gchar * args[4];
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
517 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
518
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
519 args[1] = "-session_id";
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
520 session_id = g_string_new("");
11417
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
521 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
522 args[2] = session_id->str;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
523
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
524 args[3] = NULL;
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
525
a9ec436535bc [gaim-migrate @ 13654]
Christian Muise <christian.muise@gmail.com>
parents: 11365
diff changeset
526 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
527 {
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
528 gaim_notify_error(plugin_pointer, "Error Running Editor",
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
529 "The following error has occured:", spawn_error->message);
11254
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
530 mmconv->started = FALSE;
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
531 }
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
532 else
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
533 {
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
534 mmconv->started = TRUE;
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
535 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
536 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
537
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
538 static void kill_editor (MMConversation *mmconv)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
539 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
540 if (mmconv->pid)
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 kill(mmconv->pid, SIGINT);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
543 mmconv->pid = 0;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
544 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
545 }
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 static void init_conversation (GaimConversation *conv)
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 MMConversation *mmconv;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
550 mmconv = g_malloc(sizeof(MMConversation));
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 mmconv->conv = conv;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
553 mmconv->started = FALSE;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
554 mmconv->originator = FALSE;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
555 mmconv->requested = FALSE;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
556
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
557 add_button(mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
558
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
559 conversations = g_list_append(conversations, mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
560 }
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 static void conv_destroyed (GaimConversation *conv)
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
563 {
11362
6ef19bbfb7cb [gaim-migrate @ 13586]
Christian Muise <christian.muise@gmail.com>
parents: 11355
diff changeset
564 MMConversation *mmconv = mmconv_from_conv(conv);
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
565
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
566 remove_widget(mmconv->button);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
567 remove_widget(mmconv->seperator);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
568 if (mmconv->started)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
569 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
570 kill_editor(mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
571 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
572 conversations = g_list_remove(conversations, mmconv);
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
573 }
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
574
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
575 static void add_button (MMConversation *mmconv)
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
576 {
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
577 GaimConversation *conv = mmconv->conv;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
578
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
579 GtkWidget *button, *image, *sep;
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
580 gchar *file_path;
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
581
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
582 button = gtk_toggle_button_new();
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
583 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
584
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
585 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
586
11900
21719fc8ea2d [gaim-migrate @ 14191]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11659
diff changeset
587 file_path = g_build_filename(DATADIR, "pixmaps", "gaim", "buttons",
11659
d9a7befbc3f1 [gaim-migrate @ 13944]
Gary Kramlich <grim@reaperworld.com>
parents: 11420
diff changeset
588 "music.png", NULL);
11254
ce3b9969b399 [gaim-migrate @ 13426]
Christian Muise <christian.muise@gmail.com>
parents: 11216
diff changeset
589 image = gtk_image_new_from_file(file_path);
11659
d9a7befbc3f1 [gaim-migrate @ 13944]
Gary Kramlich <grim@reaperworld.com>
parents: 11420
diff changeset
590 g_free(file_path);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
591
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
592 gtk_container_add((GtkContainer *)button, image);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
593
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
594 sep = gtk_vseparator_new();
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
595
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
596 mmconv->seperator = sep;
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
597 mmconv->button = button;
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
598
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
599 gtk_widget_show(sep);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
600 gtk_widget_show(image);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
601 gtk_widget_show(button);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
602
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
603 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
604 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
605 }
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
606
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
607 static void remove_widget (GtkWidget *button)
11169
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
608 {
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
609 gtk_widget_hide(button);
778d5464a9b8 [gaim-migrate @ 13270]
Christian Muise <christian.muise@gmail.com>
parents: 11166
diff changeset
610 gtk_widget_destroy(button);
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
611 }
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
612
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
613 static GtkWidget *
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
614 get_config_frame(GaimPlugin *plugin)
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 GtkWidget *ret;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
617 GtkWidget *vbox;
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 GtkWidget *editor_path;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
620 GtkWidget *editor_path_label;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
621 GtkWidget *editor_path_button;
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
622
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
623 /* Outside container */
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
624 ret = gtk_vbox_new(FALSE, 18);
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
625 gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
626
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
627 /* Configuration frame */
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
628 vbox = gaim_gtk_make_frame(ret, _("Music Messaging Configuration"));
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
629
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
630 /* Path to the score editor */
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
631 editor_path = gtk_entry_new();
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
632 editor_path_label = gtk_label_new("Score Editor Path");
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
633 editor_path_button = gtk_button_new_with_mnemonic(_("_Apply"));
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
634
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
635 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
636
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
637 g_signal_connect(G_OBJECT(editor_path_button), "clicked",
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
638 G_CALLBACK(set_editor_path), editor_path);
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
639
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
640 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
641 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
642 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
643
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
644 gtk_widget_show_all(ret);
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
645
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
646 return ret;
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
647 }
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
648
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
649 static GaimGtkPluginUiInfo ui_info =
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
650 {
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
651 get_config_frame
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
652 };
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
653
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
654 static GaimPluginInfo info = {
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
655 GAIM_PLUGIN_MAGIC,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
656 GAIM_MAJOR_VERSION,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
657 GAIM_MINOR_VERSION,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
658 GAIM_PLUGIN_STANDARD,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
659 GAIM_GTK_PLUGIN_TYPE,
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
660 0,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
661 NULL,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
662 GAIM_PRIORITY_DEFAULT,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
663
11200
4295083cf489 [gaim-migrate @ 13328]
Christian Muise <christian.muise@gmail.com>
parents: 11169
diff changeset
664 MUSICMESSAGING_PLUGIN_ID,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
665 "Music Messaging",
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
666 VERSION,
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
667 "Music Messaging Plugin for collabrative composition.",
11216
1b32ad61e114 [gaim-migrate @ 13348]
Richard Laager <rlaager@wiktel.com>
parents: 11200
diff changeset
668 "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
669 "Christian Muise <christian.muise@gmail.com>",
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
670 GAIM_WEBSITE,
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
671 plugin_load,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
672 plugin_unload,
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
673 NULL,
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
674 &ui_info,
11088
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
675 NULL,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
676 NULL,
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
677 NULL
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
678 };
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
679
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
680 static void
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
681 init_plugin(GaimPlugin *plugin) {
11166
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
682 gaim_prefs_add_none("/plugins/gtk/musicmessaging");
268d5c498b64 [gaim-migrate @ 13267]
Christian Muise <christian.muise@gmail.com>
parents: 11108
diff changeset
683 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
684 }
b8bfa71e5595 [gaim-migrate @ 13108]
Christian Muise <christian.muise@gmail.com>
parents:
diff changeset
685
11108
641915a13cec [gaim-migrate @ 13157]
Christian Muise <christian.muise@gmail.com>
parents: 11088
diff changeset
686 GAIM_INIT_PLUGIN(musicmessaging, init_plugin, info);