annotate pidgin/plugins/crazychat/cc_pidgin_plugin.c @ 28979:c31707e63726

Fix reset-formatting for some cases. When 'wbfo' (whole buffer formatting only) is set for an imhtml: - always reset formatting of all the text in the imhtml When 'wbfo' is not set: - if some text is selected, reset formatting for the selected text - if no text is selected, reset formatting for the current location (insert) only, and leave the rest of the text alone. We were doing this last thing wrong. Fixes #4499.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 20 Nov 2009 08:02:10 +0000
parents 3cc856ca2338
children a8cc50c2279f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15904
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 #include <stdio.h>
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 #include <assert.h>
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 #include "internal.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 #include "plugin.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 #include "gtkplugin.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 #include "gtkblist.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 #include "gtkutils.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 #include "connection.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 #include "conversation.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 #include "network.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 #include <gtk/gtkgl.h>
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 #include <GL/gl.h>
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 #include <GL/glu.h>
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 #include "crazychat.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 #include "cc_network.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 #include "cc_interface.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 #include "cc_gtk_gl.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 #include "util.h"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23 /* --- begin type and global variable definitions --- */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25 static struct crazychat cc_info;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 /* --- begin function declarations --- */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 * Called by purple plugin to start CrazyChat
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31 * @param cc the crazychat struct
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33 static void cc_init(struct crazychat *cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
34
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
35 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
36 * Called by purple plugin to destroy CrazyChat
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
37 * @param cc the crazychat struct
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39 static void cc_destroy(struct crazychat *cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
42 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43 * Buddy menu drawing callback. Adds a CrazyChat menuitem.
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 * @param menu the buddy menu widget
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 * @param b the buddy whose menu this is
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
47 static gboolean cc_buddy_menu(GtkWidget *menu, PurpleBuddy *b);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
48
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
49 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
50 * Buddy menu callback. Initiates the CrazyChat session.
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
51 * @param item the gtk buddy menu item
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
52 * @param b the buddy whose menu the item was in
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 static void cc_menu_cb(GtkMenuItem *item, PurpleBuddy *b);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
55
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
56 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
57 * IM callback. Handles receiving a CrazyChat session request.
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58 * @param account the account we received the IM on
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59 * @param sender the buddy who we received the message from
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
60 * @param message the message we received
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
61 * @param flags IM flags
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
62 * @param data user data
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
63 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
64 static gboolean receive_im_cb(PurpleAccount *account, char **sender,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
65 char **message, int *flags, void *data);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
66
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
67 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
68 * Displaying IM callback. Drops CrazyChat messages from IM window.
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
69 * @param account the account we are displaying the IM on
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
70 * @param conv the conversation we are displaying the IM on
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71 * @param message the message we are displaying
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
72 * @param data user data
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
73 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
74 static gboolean display_im_cb(PurpleAccount *account, const char *who, char **message,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 PurpleConnection *conv, PurpleMessageFlags flags, void *data);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
76
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
77 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
78 * Callback for CrazyChat plugin configuration frame
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
79 * @param plugin the plugin data
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
80 * @return the configuration frame
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
81 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
82 static GtkWidget *get_config_frame(PurplePlugin *plugin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
83
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
84 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
85 * TCP port callback. Changes the port used to listen for new CC sessions
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
86 * @param spin the spinner button whose value changed
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
87 * @param data user data
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
88 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
89 static void tcp_port_cb(GtkSpinButton *spin, struct crazychat *cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
90
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
91 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
92 * UDP port callback. Changes the port used to send/recv CC session frames
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
93 * @param spin the spinner button whose value changed
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
94 * @param data user data
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
95 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
96 static void udp_port_cb(GtkSpinButton *spin, struct crazychat *cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
97
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
98 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
99 * Features enabling/disabling callback. Initializes the input processing
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
100 * or shuts it down.
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
101 * @param data user data
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
102 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
103 static void features_enable_cb(struct crazychat *cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
104
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
105 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
106 * User signed on callback. Now we have a buddy list to connect a signal
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
107 * handler to.
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
108 * @param gc the purple connection we are signed on
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
109 * @param plugin our plugin struct
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
110 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
111 static gboolean cc_signed_on(PurpleConnection *gc, void *plugin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
112
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
113 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
114 * Plugin loading callback. If a buddy list exists, connect our buddy menu
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
115 * drawing callback to the signal handler, otherwise, connect a signed on
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
116 * signal handler so we know when we get a buddy list.
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
117 * @param plugin our plugin struct
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
118 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
119 static gboolean plugin_load(PurplePlugin *plugin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
120
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
121 /**
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
122 * Plugin unloading callback. Disconnect all handlers and free data.
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
123 * @param plugin our plugin struct
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
124 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
125 static gboolean plugin_unload(PurplePlugin *plugin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
126
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
127
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
128 /* --- end function declarations --- */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
129
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
130
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
131 #define CRAZYCHAT_PLUGIN_ID "gtk-crazychat"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
132
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
133 static PidginPluginUiInfo ui_info = {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
134 get_config_frame /**< get_config_frame */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
135 };
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
136
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
137 static PurplePluginInfo info = {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
138 2, /**< api_version */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
139 PURPLE_PLUGIN_STANDARD, /**< type */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
140 PIDGIN_PLUGIN_TYPE, /**< ui_requirement */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
141 0, /**< flags */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
142 NULL, /**< dependencies */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
143 PURPLE_PRIORITY_DEFAULT, /**< priority */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
144
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
145 CRAZYCHAT_PLUGIN_ID, /**< id */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
146 N_("Crazychat"), /**< name */
21030
3cc856ca2338 Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <stu@nosnilmot.com>
parents: 15904
diff changeset
147 DISPLAY_VERSION, /**< version */
15904
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
148 /** summary */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
149 N_("Plugin to establish a Crazychat session."),
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
150 /** description */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
151 N_("Uses Purple to obtain buddy ips to connect for a Crazychat session"),
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
152 "\n"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
153 "William Chan <chanman@stanford.edu>\n"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
154 "Ian Spiro <ispiro@stanford.edu>\n"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
155 "Charlie Stockman<stockman@stanford.edu>\n"
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
156 "Steve Yelderman<scy@stanford.edu>", /**< author */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
157 PURPLE_WEBSITE, /**< homepage */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
158
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
159 plugin_load, /**< load */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
160 plugin_unload, /**< unload */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
161 NULL, /**< destroy */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
162
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
163 &ui_info, /**< ui_info */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
164 &cc_info /**< extra_info */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
165 };
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
166
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
167 /* --- end plugin struct definition --- */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
168
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
169 static void cc_init(struct crazychat *cc)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
170 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
171 /* initialize main crazychat thread */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
172
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
173 assert(cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
174 memset(cc, 0, sizeof(*cc));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
175
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
176 /* initialize network configuration */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
177 cc->tcp_port = DEFAULT_CC_PORT;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
178 cc->udp_port = DEFAULT_CC_PORT;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
179
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
180 /* disable input subsystem */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
181 //cc->features_state = 0;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
182
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
183 /* initialize input subsystem */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
184 cc->features_state = 1;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
185 cc->input_data = init_input(cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
186 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
187
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
188 static void cc_destroy(struct crazychat *cc)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
189 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
190 assert(cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
191
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
192 if (cc->features_state) {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
193 destroy_input(cc->input_data);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
194 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
195 memset(cc, 0, sizeof(*cc));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
196 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
197
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
198 static gboolean cc_buddy_menu(GtkWidget *menu, PurpleBuddy *b)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
199 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
200 GtkWidget *menuitem;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
201
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
202 menuitem = gtk_menu_item_new_with_mnemonic("CrazyChat");
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
203 g_signal_connect(G_OBJECT(menuitem), "activate",
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
204 G_CALLBACK(cc_menu_cb), b);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
205 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
206 return FALSE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
207 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
208
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
209 static void cc_menu_cb(GtkMenuItem *item, PurpleBuddy *b)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
210 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
211 assert(item);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
212 assert(b);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
213
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
214 /* send the invite */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
215 cc_net_send_invite(&cc_info, b->name, b->account);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
216 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
217
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
218 static gboolean receive_im_cb(PurpleAccount *account, char **sender,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
219 char **message, int *flags, void *data)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
220 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
221 struct crazychat *cc;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
222
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
223 cc = (struct crazychat*)data;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
224 assert(cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
225 if (!strncmp(*message, CRAZYCHAT_INVITE_CODE,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
226 strlen(CRAZYCHAT_INVITE_CODE))) {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
227 Debug(*message);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
228 char *split = strchr(*message, '!');
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
229 assert(split);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
230 *split = 0;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
231 split++;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
232 cc_net_recv_invite(account, cc, *sender,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
233 &(*message)[strlen(CRAZYCHAT_INVITE_CODE)],
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
234 split);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
235 return TRUE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
236 } else if (!strncmp(*message, CRAZYCHAT_ACCEPT_CODE,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
237 strlen(CRAZYCHAT_ACCEPT_CODE))) {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
238 cc_net_recv_accept(account, cc, *sender,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
239 &(*message)[strlen(CRAZYCHAT_ACCEPT_CODE)]);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
240 return TRUE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
241 } else if (!strncmp(*message, CRAZYCHAT_READY_CODE,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
242 strlen(CRAZYCHAT_READY_CODE))) {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
243 cc_net_recv_ready(account, cc, *sender);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
244 return TRUE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
245 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
246
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
247 return FALSE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
248 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
249
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
250 static gboolean display_im_cb(PurpleAccount *account, PurpleConversation *conv,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
251 char **message, void *data)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
252 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
253 struct crazychat *cc;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
254
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
255 cc = (struct crazychat*)data;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
256 assert(cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
257 if (!strncmp(*message, CRAZYCHAT_INVITE_CODE,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
258 strlen(CRAZYCHAT_INVITE_CODE))) {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
259 return TRUE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
260 } else if (!strncmp(*message, CRAZYCHAT_ACCEPT_CODE,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
261 strlen(CRAZYCHAT_ACCEPT_CODE))) {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
262 return TRUE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
263 } else if (!strncmp(*message, CRAZYCHAT_READY_CODE,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
264 strlen(CRAZYCHAT_READY_CODE))) {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
265 return TRUE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
266 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
267
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
268 return FALSE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
269 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
270
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
271 static GtkWidget *get_config_frame(PurplePlugin *plugin)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
272 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
273 GtkWidget *ret;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
274 GtkWidget *frame;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
275 GtkWidget *vbox, *hbox;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
276 GtkWidget *drawing_area;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
277 GtkWidget *label;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
278 GtkAdjustment *adj;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
279 GtkWidget *spinner;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
280 GtkWidget *button, *button1, *button2;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
281 GSList *group;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
282 struct draw_info *info;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
283 struct crazychat *cc;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
284
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
285 cc = (struct crazychat*)plugin->info->extra_info;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
286 assert(cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
287
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
288 /* create widgets */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
289
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
290 /* creating the config frame */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
291 ret = gtk_vbox_new(FALSE, 18);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
292 gtk_container_set_border_width(GTK_CONTAINER(ret), 12);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
293
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
294 /* make the network configuration frame */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
295 frame = pidgin_make_frame(ret, _("Network Configuration"));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
296 gtk_widget_show(frame);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
297
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
298 /* add boxes for packing purposes */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
299 vbox = gtk_vbox_new(FALSE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
300 gtk_box_pack_start(GTK_BOX(frame), vbox, TRUE, TRUE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
301 gtk_widget_show(vbox);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
302
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
303 /* add widgets to row 1 */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
304 hbox = gtk_hbox_new(FALSE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
305 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
306 gtk_widget_show(hbox);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
307 label = gtk_label_new(_("TCP port"));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
308 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
309 gtk_widget_show(label);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
310 adj = (GtkAdjustment*)gtk_adjustment_new(DEFAULT_CC_PORT, 1,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
311 G_MAXUSHORT, 1, 1000, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
312 spinner = gtk_spin_button_new(adj, 1, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
313 g_signal_connect(G_OBJECT(spinner), "value_changed",
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
314 G_CALLBACK(tcp_port_cb), cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
315 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
316 gtk_widget_show(spinner);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
317 label = gtk_label_new(_("UDP port"));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
318 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 15);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
319 gtk_widget_show(label);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
320 adj = (GtkAdjustment*)gtk_adjustment_new(DEFAULT_CC_PORT, 1,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
321 G_MAXUSHORT, 1, 1000, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
322 spinner = gtk_spin_button_new(adj, 1, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
323 g_signal_connect(G_OBJECT(spinner), "value_changed",
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
324 G_CALLBACK(udp_port_cb), cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
325 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
326 gtk_widget_show(spinner);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
327
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
328 /* make the feature configuration frame */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
329 frame = pidgin_make_frame(ret, _("Feature Calibration"));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
330 gtk_widget_show(frame);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
331
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
332 /* add hbox for packing purposes */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
333 hbox = gtk_hbox_new(TRUE, 40);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
334 gtk_box_pack_start(GTK_BOX(frame), hbox, TRUE, TRUE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
335 gtk_widget_show(hbox);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
336
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
337 /* add feature calibration options */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
338
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
339 /* add vbox for packing purposes */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
340 vbox = gtk_vbox_new(TRUE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
341 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
342 gtk_widget_show(vbox);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
343
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
344 /* add enabled / disabled */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
345 button1 = gtk_radio_button_new_with_label(NULL, _("Enabled"));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
346 gtk_box_pack_start(GTK_BOX(vbox), button1, TRUE, TRUE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
347 gtk_widget_show(button1);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
348
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
349 group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button1));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
350 button2 = gtk_radio_button_new_with_label(group, _("Disabled"));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
351 gtk_box_pack_start(GTK_BOX(vbox), button2, TRUE, TRUE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
352 gtk_widget_show(button2);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
353
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
354 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button1),
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
355 cc->features_state);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
356 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button2),
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
357 !cc->features_state);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
358 g_signal_connect_swapped(G_OBJECT(button1), "toggled",
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
359 G_CALLBACK(features_enable_cb), cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
360
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
361 /* add vbox for packing purposes */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
362 vbox = gtk_vbox_new(TRUE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
363 gtk_box_pack_end(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
364 gtk_widget_show(vbox);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
365
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
366 /* add calibrate button */
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
367 button = gtk_button_new_with_label("Calibrate");
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
368 gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, FALSE, 0);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
369 gtk_widget_show(button);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
370
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
371 gtk_widget_show(ret);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
372
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
373 return ret;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
374 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
375
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
376 static void tcp_port_cb(GtkSpinButton *spin, struct crazychat *cc)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
377 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
378 assert(spin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
379 assert(cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
380 cc->tcp_port = gtk_spin_button_get_value_as_int(spin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
381 Debug("New tcp port: %d\n", cc->tcp_port);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
382 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
383
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
384 static void udp_port_cb(GtkSpinButton *spin, struct crazychat *cc)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
385 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
386 assert(spin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
387 assert(cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
388 cc->udp_port = gtk_spin_button_get_value_as_int(spin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
389 Debug("New udp port: %d\n", cc->udp_port);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
390 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
391
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
392 static void features_enable_cb(struct crazychat *cc)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
393 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
394 Debug("Changing features state\n");
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
395 cc->features_state = !cc->features_state;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
396 if (cc->features_state) {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
397 cc->input_data = init_input(cc);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
398 } else {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
399 if (cc->input_data) {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
400 gtk_widget_destroy(cc->input_data->widget);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
401 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
402 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
403 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
404
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
405 static gboolean cc_signed_on(PurpleConnection *gc, void *plugin)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
406 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
407 struct crazychat *extra;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
408 void *conv_handle;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
409
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
410 assert(plugin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
411 extra = (struct crazychat*)((PurplePlugin*)plugin)->info->extra_info;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
412 purple_signal_disconnect
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
413 (purple_connections_get_handle(), "signed-on",
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
414 plugin, PURPLE_CALLBACK(cc_signed_on));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
415 purple_signal_connect(PIDGIN_BLIST
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
416 (purple_get_blist()),
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
417 "drawing-menu", plugin,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
418 PURPLE_CALLBACK(cc_buddy_menu), NULL);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
419 conv_handle = purple_conversations_get_handle();
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
420 purple_signal_connect(conv_handle, "received-im-msg", plugin,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
421 PURPLE_CALLBACK(receive_im_cb), extra);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
422 purple_signal_connect(conv_handle, "displaying-im-msg", plugin,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
423 PURPLE_CALLBACK(display_im_cb), extra);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
424 return FALSE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
425 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
426
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
427 static gboolean plugin_load(PurplePlugin *plugin)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
428 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
429 PurpleBuddyList *buddy_list;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
430 void *conv_handle;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
431
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
432 if (cc_init_gtk_gl())
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
433 return FALSE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
434
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
435 cc_init(&cc_info);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
436 buddy_list = purple_get_blist();
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
437 if (buddy_list) {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
438 purple_signal_connect(PIDGIN_BLIST
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
439 (buddy_list),
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
440 "drawing-menu", plugin,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
441 PURPLE_CALLBACK(cc_buddy_menu), NULL);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
442 conv_handle = purple_conversations_get_handle();
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
443 purple_signal_connect(conv_handle, "received-im-msg", plugin,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
444 PURPLE_CALLBACK(receive_im_cb), &cc_info);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
445 purple_signal_connect(conv_handle, "displaying-im-msg", plugin,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
446 PURPLE_CALLBACK(display_im_cb), &cc_info);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
447 } else {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
448 purple_signal_connect
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
449 (purple_connections_get_handle(), "signed-on",
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
450 plugin, PURPLE_CALLBACK(cc_signed_on), plugin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
451 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
452
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
453 Debug("CrazyChat plugin loaded.\n");
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
454
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
455 return TRUE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
456 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
457
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
458 static gboolean plugin_unload(PurplePlugin *plugin)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
459 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
460 void *conv_handle;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
461 struct crazychat *extra;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
462 assert(plugin);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
463 extra = (struct crazychat*) plugin->info->extra_info;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
464 cc_destroy(extra);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
465 conv_handle = purple_conversations_get_handle();
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
466 purple_signal_disconnect(PIDGIN_BLIST
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
467 (purple_get_blist()),
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
468 "drawing-menu", plugin,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
469 PURPLE_CALLBACK(cc_buddy_menu));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
470 purple_signal_disconnect(conv_handle, "received-im", plugin,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
471 PURPLE_CALLBACK(receive_im_cb));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
472 purple_signal_disconnect(conv_handle, "displaying-im-msg", plugin,
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
473 PURPLE_CALLBACK(display_im_cb));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
474 Debug("CrazyChat plugin unloaded.\n");
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
475 return TRUE;
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
476 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
477
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
478 static void init_plugin(PurplePlugin *plugin)
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
479 {
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
480 gtk_gl_init(NULL, NULL);
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
481 memset(&cc_info, 0, sizeof(cc_info));
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
482 Debug("CrazyChat plugin initialized\n");
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
483 }
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
484
15cccdd32321 Changes that give crazychat a better chance of compiling with purple and pidgin
Mark Doliner <mark@kingant.net>
parents:
diff changeset
485 PURPLE_INIT_PLUGIN(crazychat, init_plugin, info)