comparison src/whiteboard.c @ 11802:2e3a6dcebaf3

[gaim-migrate @ 14093] This should be it for the // -> /* */ for the doodle/whiteboard stuff. This could use a bit of cleaning yet.... committer: Tailor Script <tailor@pidgin.im>
author Gary Kramlich <grim@reaperworld.com>
date Mon, 24 Oct 2005 22:45:24 +0000
parents 88d504770c60
children 2219f4bf4a57
comparison
equal deleted inserted replaced
11801:81806e9241be 11802:2e3a6dcebaf3
19 * along with this program; if not, write to the Free Software 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 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * 21 *
22 */ 22 */
23 23
24 // INCLUDES =============================================================================================
25
26 #include <string.h> 24 #include <string.h>
27 25
28 #include "whiteboard.h" 26 #include "whiteboard.h"
29 #include "prpl.h" 27 #include "prpl.h"
30 28
31 // DATATYPES ============================================================================================ 29 /******************************************************************************
32 30 * Globals
33 // GLOBALS ============================================================================================== 31 *****************************************************************************/
34
35 static GaimWhiteboardUiOps *whiteboard_ui_ops = NULL; 32 static GaimWhiteboardUiOps *whiteboard_ui_ops = NULL;
36 //static GaimWhiteboardPrplOps *whiteboard_prpl_ops = NULL; 33 /* static GaimWhiteboardPrplOps *whiteboard_prpl_ops = NULL; */
37 34
38 static GList *wbList = NULL; 35 static GList *wbList = NULL;
39 36
40 //static gboolean auto_accept = TRUE; 37 /*static gboolean auto_accept = TRUE; */
41 38
42 // FUNCTIONS ============================================================================================ 39 /******************************************************************************
43 40 * API
41 *****************************************************************************/
44 void gaim_whiteboard_set_ui_ops( GaimWhiteboardUiOps *ops ) 42 void gaim_whiteboard_set_ui_ops( GaimWhiteboardUiOps *ops )
45 { 43 {
46 whiteboard_ui_ops = ops; 44 whiteboard_ui_ops = ops;
47 } 45 }
48
49 // ------------------------------------------------------------------------------------------------------
50 46
51 void gaim_whiteboard_set_prpl_ops( GaimWhiteboard *wb, GaimWhiteboardPrplOps *ops ) 47 void gaim_whiteboard_set_prpl_ops( GaimWhiteboard *wb, GaimWhiteboardPrplOps *ops )
52 { 48 {
53 wb->prpl_ops = ops; 49 wb->prpl_ops = ops;
54 } 50 }
55 51
56 // ------------------------------------------------------------------------------------------------------
57
58 GaimWhiteboard *gaim_whiteboard_create( GaimAccount *account, char *who, int state ) 52 GaimWhiteboard *gaim_whiteboard_create( GaimAccount *account, char *who, int state )
59 { 53 {
60 //g_print( "gaim_whiteboard_create()\n" );
61
62 GaimPluginProtocolInfo *prpl_info; 54 GaimPluginProtocolInfo *prpl_info;
63 GaimWhiteboard *wb = g_new0( GaimWhiteboard, 1 ); 55 GaimWhiteboard *wb = g_new0( GaimWhiteboard, 1 );
64 56
65 wb->account = account; 57 wb->account = account;
66 wb->state = state; 58 wb->state = state;
67 wb->who = g_strdup( who ); 59 wb->who = g_strdup( who );
68 60
69 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( account->gc->prpl ); 61 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( account->gc->prpl );
70 gaim_whiteboard_set_prpl_ops( wb, prpl_info->whiteboard_prpl_ops ); 62 gaim_whiteboard_set_prpl_ops( wb, prpl_info->whiteboard_prpl_ops );
71 63
72 // Start up protocol specifics 64 /* Start up protocol specifics */
73 if( wb->prpl_ops && wb->prpl_ops->start ) 65 if( wb->prpl_ops && wb->prpl_ops->start )
74 wb->prpl_ops->start( wb ); 66 wb->prpl_ops->start( wb );
75 67
76 wbList = g_list_append( wbList, ( gpointer )( wb ) ); 68 wbList = g_list_append( wbList, ( gpointer )( wb ) );
77 69
78 return( wb ); 70 return( wb );
79 } 71 }
80 72
81 // ------------------------------------------------------------------------------------------------------
82
83 void gaim_whiteboard_destroy( GaimWhiteboard *wb ) 73 void gaim_whiteboard_destroy( GaimWhiteboard *wb )
84 { 74 {
85 //g_print( "gaim_whiteboard_destroy()\n" );
86
87 if( wb->ui_data ) 75 if( wb->ui_data )
88 { 76 {
89 //g_print( "---wb->ui_data = %p\n", wb->ui_data ); 77 /* Destroy frontend */
90
91 // Destroy frontend
92 if( whiteboard_ui_ops && whiteboard_ui_ops->destroy ) 78 if( whiteboard_ui_ops && whiteboard_ui_ops->destroy )
93 whiteboard_ui_ops->destroy( wb ); 79 whiteboard_ui_ops->destroy( wb );
94 } 80 }
95 81
96 // Do protocol specific session ending procedures 82 /* Do protocol specific session ending procedures */
97 if( wb->prpl_ops && wb->prpl_ops->end ) 83 if( wb->prpl_ops && wb->prpl_ops->end )
98 wb->prpl_ops->end( wb ); 84 wb->prpl_ops->end( wb );
99 85
100 if( wb ) 86 if( wb )
101 { 87 {
102 //g_print( "---wb = %p\n", wb );
103
104 wb->account = NULL; 88 wb->account = NULL;
105 wb->state = 0; 89 wb->state = 0;
106 90
107 if( wb->who ) 91 if( wb->who )
108 g_free( wb->who ); 92 g_free( wb->who );
109 93
110 wbList = g_list_remove( wbList, wb ); 94 wbList = g_list_remove( wbList, wb );
111 95
112 g_free( wb ); 96 g_free( wb );
113 wb = NULL; 97 wb = NULL;
114 } 98 }
115 } 99 }
116 100
117 // ------------------------------------------------------------------------------------------------------
118
119 void gaim_whiteboard_start( GaimWhiteboard *wb ) 101 void gaim_whiteboard_start( GaimWhiteboard *wb )
120 { 102 {
121 //g_print( "gaim_whiteboard_start()\n" ); 103 /* Create frontend for whiteboard */
122
123 // Create frontend for whiteboard
124 if( whiteboard_ui_ops && whiteboard_ui_ops->create ) 104 if( whiteboard_ui_ops && whiteboard_ui_ops->create )
125 whiteboard_ui_ops->create( wb ); 105 whiteboard_ui_ops->create( wb );
126 } 106 }
127 107
128 // ------------------------------------------------------------------------------------------------------ 108 /* Looks through the list of whiteboard sessions for one that is between
129 109 * usernames 'me' and 'who'. Returns a pointer to a matching whiteboard
130 // Looks through the list of whiteboard sessions for one that is between usernames 'me' and 'who' 110 * session; if none match, it returns NULL.
131 // Returns a pointer to a matching whiteboard session; if none match, it returns NULL 111 */
132 GaimWhiteboard *gaim_whiteboard_get_session( GaimAccount *account, char *who ) 112 GaimWhiteboard *gaim_whiteboard_get_session( GaimAccount *account, char *who )
133 { 113 {
134 //g_print( "gaim_whiteboard_get_session()\n" );
135
136 GaimWhiteboard *wb = NULL; 114 GaimWhiteboard *wb = NULL;
137 115
138 GList *l = wbList; 116 GList *l = wbList;
139 117
140 // Look for a whiteboard session between the local user and the remote user 118 /* Look for a whiteboard session between the local user and the remote
119 * user
120 */
141 while( l ) 121 while( l )
142 { 122 {
143 wb = l->data; 123 wb = l->data;
144 124
145 if( !strcmp( gaim_account_get_username( wb->account ), gaim_account_get_username( account ) ) && 125 if( !strcmp( gaim_account_get_username( wb->account ),
126 gaim_account_get_username( account ) ) &&
146 !strcmp( wb->who, who ) ) 127 !strcmp( wb->who, who ) )
147 return( wb ); 128 return( wb );
148 129
149 l = l->next; 130 l = l->next;
150 } 131 }
151 132
152 return( NULL ); 133 return( NULL );
153 } 134 }
154 135
155 // ------------------------------------------------------------------------------------------------------
156
157 GList *gaim_whiteboard_draw_list_destroy( GList *draw_list ) 136 GList *gaim_whiteboard_draw_list_destroy( GList *draw_list )
158 { 137 {
159 //g_print( "gaim_whiteboard_draw_list_destroy()\n" );
160
161 if( draw_list == NULL ) 138 if( draw_list == NULL )
162 return( NULL ); 139 return( NULL );
163 else 140 else
164 { 141 {
165 // Destroy the contents of this list 142 /* Destroy the contents of this list */
166 int *n = NULL; 143 int *n = NULL;
167 GList *l = draw_list; 144 GList *l = draw_list;
168 while( l ) 145 while( l )
169 { 146 {
170 n = l->data; 147 n = l->data;
171 148
172 if( n ) 149 if( n )
173 g_free( n ); 150 g_free( n );
174 151
175 l = l->next; 152 l = l->next;
176 } 153 }
177 154
178 g_list_free( draw_list ); 155 g_list_free( draw_list );
179 draw_list = NULL; 156 draw_list = NULL;
180 } 157 }
181 158
182 return( draw_list ); 159 return( draw_list );
183 } 160 }
184
185 // ------------------------------------------------------------------------------------------------------
186 161
187 void gaim_whiteboard_set_dimensions( GaimWhiteboard *wb, int width, int height ) 162 void gaim_whiteboard_set_dimensions( GaimWhiteboard *wb, int width, int height )
188 { 163 {
189 if( whiteboard_ui_ops && whiteboard_ui_ops->set_dimensions ) 164 if( whiteboard_ui_ops && whiteboard_ui_ops->set_dimensions )
190 whiteboard_ui_ops->set_dimensions( wb, width, height ); 165 whiteboard_ui_ops->set_dimensions( wb, width, height );
191 } 166 }
192 167
193 // ------------------------------------------------------------------------------------------------------
194
195 void gaim_whiteboard_draw_point( GaimWhiteboard *wb, int x, int y, int color, int size ) 168 void gaim_whiteboard_draw_point( GaimWhiteboard *wb, int x, int y, int color, int size )
196 { 169 {
197 if( whiteboard_ui_ops && whiteboard_ui_ops->draw_point ) 170 if( whiteboard_ui_ops && whiteboard_ui_ops->draw_point )
198 whiteboard_ui_ops->draw_point( wb, x, y, color, size ); 171 whiteboard_ui_ops->draw_point( wb, x, y, color, size );
199 } 172 }
200
201 // ------------------------------------------------------------------------------------------------------
202 173
203 void gaim_whiteboard_draw_line( GaimWhiteboard *wb, int x1, int y1, int x2, int y2, int color, int size ) 174 void gaim_whiteboard_draw_line( GaimWhiteboard *wb, int x1, int y1, int x2, int y2, int color, int size )
204 { 175 {
205 if( whiteboard_ui_ops && whiteboard_ui_ops->draw_line ) 176 if( whiteboard_ui_ops && whiteboard_ui_ops->draw_line )
206 whiteboard_ui_ops->draw_line( wb, x1, y1, x2, y2, color, size ); 177 whiteboard_ui_ops->draw_line( wb, x1, y1, x2, y2, color, size );
207 } 178 }
208 179
209 // ------------------------------------------------------------------------------------------------------
210
211 void gaim_whiteboard_clear( GaimWhiteboard *wb ) 180 void gaim_whiteboard_clear( GaimWhiteboard *wb )
212 { 181 {
213 if( whiteboard_ui_ops && whiteboard_ui_ops->clear ) 182 if( whiteboard_ui_ops && whiteboard_ui_ops->clear )
214 whiteboard_ui_ops->clear( wb ); 183 whiteboard_ui_ops->clear( wb );
215 } 184 }
216 185
217 // ------------------------------------------------------------------------------------------------------