Mercurial > pidgin
annotate src/whiteboard.c @ 11652:a66ee70c614c
[gaim-migrate @ 13936]
Whoops
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 13 Oct 2005 01:48:03 +0000 |
parents | 88d504770c60 |
children | 2e3a6dcebaf3 |
rev | line source |
---|---|
11475 | 1 /* |
2 * gaim | |
3 * | |
4 * Gaim is the legal property of its developers, whose names are too numerous | |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 */ | |
23 | |
24 // INCLUDES ============================================================================================= | |
25 | |
26 #include <string.h> | |
27 | |
28 #include "whiteboard.h" | |
29 #include "prpl.h" | |
30 | |
31 // DATATYPES ============================================================================================ | |
32 | |
33 // GLOBALS ============================================================================================== | |
34 | |
35 static GaimWhiteboardUiOps *whiteboard_ui_ops = NULL; | |
36 //static GaimWhiteboardPrplOps *whiteboard_prpl_ops = NULL; | |
37 | |
38 static GList *wbList = NULL; | |
39 | |
40 //static gboolean auto_accept = TRUE; | |
41 | |
42 // FUNCTIONS ============================================================================================ | |
43 | |
44 void gaim_whiteboard_set_ui_ops( GaimWhiteboardUiOps *ops ) | |
45 { | |
46 whiteboard_ui_ops = ops; | |
47 } | |
48 | |
49 // ------------------------------------------------------------------------------------------------------ | |
50 | |
51 void gaim_whiteboard_set_prpl_ops( GaimWhiteboard *wb, GaimWhiteboardPrplOps *ops ) | |
52 { | |
53 wb->prpl_ops = ops; | |
54 } | |
55 | |
56 // ------------------------------------------------------------------------------------------------------ | |
57 | |
58 GaimWhiteboard *gaim_whiteboard_create( GaimAccount *account, char *who, int state ) | |
59 { | |
60 //g_print( "gaim_whiteboard_create()\n" ); | |
61 | |
11506
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11475
diff
changeset
|
62 GaimPluginProtocolInfo *prpl_info; |
11475 | 63 GaimWhiteboard *wb = g_new0( GaimWhiteboard, 1 ); |
11506
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11475
diff
changeset
|
64 |
11475 | 65 wb->account = account; |
66 wb->state = state; | |
67 wb->who = g_strdup( who ); | |
68 | |
11506
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11475
diff
changeset
|
69 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( account->gc->prpl ); |
11475 | 70 gaim_whiteboard_set_prpl_ops( wb, prpl_info->whiteboard_prpl_ops ); |
71 | |
72 // Start up protocol specifics | |
73 if( wb->prpl_ops && wb->prpl_ops->start ) | |
74 wb->prpl_ops->start( wb ); | |
75 | |
76 wbList = g_list_append( wbList, ( gpointer )( wb ) ); | |
77 | |
78 return( wb ); | |
79 } | |
80 | |
81 // ------------------------------------------------------------------------------------------------------ | |
82 | |
83 void gaim_whiteboard_destroy( GaimWhiteboard *wb ) | |
84 { | |
85 //g_print( "gaim_whiteboard_destroy()\n" ); | |
86 | |
87 if( wb->ui_data ) | |
88 { | |
89 //g_print( "---wb->ui_data = %p\n", wb->ui_data ); | |
90 | |
91 // Destroy frontend | |
92 if( whiteboard_ui_ops && whiteboard_ui_ops->destroy ) | |
93 whiteboard_ui_ops->destroy( wb ); | |
94 } | |
95 | |
96 // Do protocol specific session ending procedures | |
97 if( wb->prpl_ops && wb->prpl_ops->end ) | |
98 wb->prpl_ops->end( wb ); | |
99 | |
100 if( wb ) | |
101 { | |
102 //g_print( "---wb = %p\n", wb ); | |
103 | |
104 wb->account = NULL; | |
105 wb->state = 0; | |
106 | |
107 if( wb->who ) | |
108 g_free( wb->who ); | |
109 | |
110 wbList = g_list_remove( wbList, wb ); | |
111 | |
112 g_free( wb ); | |
113 wb = NULL; | |
114 } | |
115 } | |
116 | |
117 // ------------------------------------------------------------------------------------------------------ | |
118 | |
119 void gaim_whiteboard_start( GaimWhiteboard *wb ) | |
120 { | |
121 //g_print( "gaim_whiteboard_start()\n" ); | |
122 | |
123 // Create frontend for whiteboard | |
124 if( whiteboard_ui_ops && whiteboard_ui_ops->create ) | |
125 whiteboard_ui_ops->create( wb ); | |
126 } | |
127 | |
128 // ------------------------------------------------------------------------------------------------------ | |
129 | |
130 // Looks through the list of whiteboard sessions for one that is between usernames 'me' and 'who' | |
131 // Returns a pointer to a matching whiteboard session; if none match, it returns NULL | |
132 GaimWhiteboard *gaim_whiteboard_get_session( GaimAccount *account, char *who ) | |
133 { | |
134 //g_print( "gaim_whiteboard_get_session()\n" ); | |
135 | |
136 GaimWhiteboard *wb = NULL; | |
137 | |
138 GList *l = wbList; | |
139 | |
140 // Look for a whiteboard session between the local user and the remote user | |
141 while( l ) | |
142 { | |
143 wb = l->data; | |
144 | |
145 if( !strcmp( gaim_account_get_username( wb->account ), gaim_account_get_username( account ) ) && | |
146 !strcmp( wb->who, who ) ) | |
147 return( wb ); | |
148 | |
149 l = l->next; | |
150 } | |
151 | |
152 return( NULL ); | |
153 } | |
154 | |
155 // ------------------------------------------------------------------------------------------------------ | |
156 | |
157 GList *gaim_whiteboard_draw_list_destroy( GList *draw_list ) | |
158 { | |
159 //g_print( "gaim_whiteboard_draw_list_destroy()\n" ); | |
160 | |
161 if( draw_list == NULL ) | |
162 return( NULL ); | |
163 else | |
164 { | |
165 // Destroy the contents of this list | |
166 int *n = NULL; | |
167 GList *l = draw_list; | |
168 while( l ) | |
169 { | |
170 n = l->data; | |
171 | |
172 if( n ) | |
173 g_free( n ); | |
174 | |
175 l = l->next; | |
176 } | |
177 | |
178 g_list_free( draw_list ); | |
179 draw_list = NULL; | |
180 } | |
181 | |
182 return( draw_list ); | |
183 } | |
184 | |
185 // ------------------------------------------------------------------------------------------------------ | |
186 | |
187 void gaim_whiteboard_set_dimensions( GaimWhiteboard *wb, int width, int height ) | |
188 { | |
189 if( whiteboard_ui_ops && whiteboard_ui_ops->set_dimensions ) | |
190 whiteboard_ui_ops->set_dimensions( wb, width, height ); | |
191 } | |
192 | |
193 // ------------------------------------------------------------------------------------------------------ | |
194 | |
195 void gaim_whiteboard_draw_point( GaimWhiteboard *wb, int x, int y, int color, int size ) | |
196 { | |
197 if( whiteboard_ui_ops && whiteboard_ui_ops->draw_point ) | |
198 whiteboard_ui_ops->draw_point( wb, x, y, color, size ); | |
199 } | |
200 | |
201 // ------------------------------------------------------------------------------------------------------ | |
202 | |
203 void gaim_whiteboard_draw_line( GaimWhiteboard *wb, int x1, int y1, int x2, int y2, int color, int size ) | |
204 { | |
205 if( whiteboard_ui_ops && whiteboard_ui_ops->draw_line ) | |
206 whiteboard_ui_ops->draw_line( wb, x1, y1, x2, y2, color, size ); | |
207 } | |
208 | |
209 // ------------------------------------------------------------------------------------------------------ | |
210 | |
211 void gaim_whiteboard_clear( GaimWhiteboard *wb ) | |
212 { | |
213 if( whiteboard_ui_ops && whiteboard_ui_ops->clear ) | |
214 whiteboard_ui_ops->clear( wb ); | |
215 } | |
216 | |
217 // ------------------------------------------------------------------------------------------------------ |