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