Mercurial > pidgin
comparison src/whiteboard.c @ 11914:2219f4bf4a57
[gaim-migrate @ 14205]
SF Patch #1342017 from sadrul
"This patch allows a user to change brush color during
the doodle-session.
This patch is mostly a rough one to get an idea whether
the approach is correct. To make things simple, I have
kept brush_size and brush_color in GaimGtkWhiteboard,
although it's there in doodle_session. It could be in
either place, although I would think it's best to be in
GaimGtkWhiteboard because any/most implementations of
doodle-ing would have these attributes. So keeping them
within the prpl may not be the best option?
Anyway, considering the brush-size and color stay at
the prpl for now, I have introduced two functions in
GaimWhiteboardPrplOps to get/set the size and color of
the brush from the prpl.
rekkanoryo (using Y! 7) and I (using gaim) have tested
this, and it seemed to work OK."
Plus, I cleaned up a whole bunch of code.
My apologies for this all being committed together, but it was a case of "Oh, this will be quick." that lead into hours of making intertwined changes.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 31 Oct 2005 02:19:51 +0000 |
parents | 2e3a6dcebaf3 |
children | 9d562dde0a3a |
comparison
equal
deleted
inserted
replaced
11913:b3105d119a17 | 11914:2219f4bf4a57 |
---|---|
27 #include "prpl.h" | 27 #include "prpl.h" |
28 | 28 |
29 /****************************************************************************** | 29 /****************************************************************************** |
30 * Globals | 30 * Globals |
31 *****************************************************************************/ | 31 *****************************************************************************/ |
32 static GaimWhiteboardUiOps *whiteboard_ui_ops = NULL; | 32 static GaimWhiteboardUiOps *whiteboard_ui_ops = NULL; |
33 /* static GaimWhiteboardPrplOps *whiteboard_prpl_ops = NULL; */ | 33 /* static GaimWhiteboardPrplOps *whiteboard_prpl_ops = NULL; */ |
34 | 34 |
35 static GList *wbList = NULL; | 35 static GList *wbList = NULL; |
36 | 36 |
37 /*static gboolean auto_accept = TRUE; */ | 37 /*static gboolean auto_accept = TRUE; */ |
38 | 38 |
39 /****************************************************************************** | 39 /****************************************************************************** |
40 * API | 40 * API |
41 *****************************************************************************/ | 41 *****************************************************************************/ |
42 void gaim_whiteboard_set_ui_ops( GaimWhiteboardUiOps *ops ) | 42 void gaim_whiteboard_set_ui_ops(GaimWhiteboardUiOps *ops) |
43 { | 43 { |
44 whiteboard_ui_ops = ops; | 44 whiteboard_ui_ops = ops; |
45 } | 45 } |
46 | 46 |
47 void gaim_whiteboard_set_prpl_ops( GaimWhiteboard *wb, GaimWhiteboardPrplOps *ops ) | 47 void gaim_whiteboard_set_prpl_ops(GaimWhiteboard *wb, GaimWhiteboardPrplOps *ops) |
48 { | 48 { |
49 wb->prpl_ops = ops; | 49 wb->prpl_ops = ops; |
50 } | 50 } |
51 | 51 |
52 GaimWhiteboard *gaim_whiteboard_create( GaimAccount *account, char *who, int state ) | 52 GaimWhiteboard *gaim_whiteboard_create(GaimAccount *account, const char *who, int state) |
53 { | 53 { |
54 GaimPluginProtocolInfo *prpl_info; | 54 GaimPluginProtocolInfo *prpl_info; |
55 GaimWhiteboard *wb = g_new0( GaimWhiteboard, 1 ); | 55 GaimWhiteboard *wb = g_new0(GaimWhiteboard, 1); |
56 | 56 |
57 wb->account = account; | 57 wb->account = account; |
58 wb->state = state; | 58 wb->state = state; |
59 wb->who = g_strdup( who ); | 59 wb->who = g_strdup(who); |
60 | 60 |
61 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( account->gc->prpl ); | 61 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); |
62 gaim_whiteboard_set_prpl_ops( wb, prpl_info->whiteboard_prpl_ops ); | 62 gaim_whiteboard_set_prpl_ops(wb, prpl_info->whiteboard_prpl_ops); |
63 | 63 |
64 /* Start up protocol specifics */ | 64 /* Start up protocol specifics */ |
65 if( wb->prpl_ops && wb->prpl_ops->start ) | 65 if(wb->prpl_ops && wb->prpl_ops->start) |
66 wb->prpl_ops->start( wb ); | 66 wb->prpl_ops->start(wb); |
67 | 67 |
68 wbList = g_list_append( wbList, ( gpointer )( wb ) ); | 68 wbList = g_list_append(wbList, wb); |
69 | 69 |
70 return( wb ); | 70 return wb; |
71 } | 71 } |
72 | 72 |
73 void gaim_whiteboard_destroy( GaimWhiteboard *wb ) | 73 void gaim_whiteboard_destroy(GaimWhiteboard *wb) |
74 { | 74 { |
75 if( wb->ui_data ) | 75 if(wb->ui_data) |
76 { | 76 { |
77 /* Destroy frontend */ | 77 /* Destroy frontend */ |
78 if( whiteboard_ui_ops && whiteboard_ui_ops->destroy ) | 78 if(whiteboard_ui_ops && whiteboard_ui_ops->destroy) |
79 whiteboard_ui_ops->destroy( wb ); | 79 whiteboard_ui_ops->destroy(wb); |
80 } | 80 } |
81 | 81 |
82 /* Do protocol specific session ending procedures */ | 82 /* Do protocol specific session ending procedures */ |
83 if( wb->prpl_ops && wb->prpl_ops->end ) | 83 if(wb->prpl_ops && wb->prpl_ops->end) |
84 wb->prpl_ops->end( wb ); | 84 wb->prpl_ops->end(wb); |
85 | 85 |
86 if( wb ) | 86 if(wb) |
87 { | 87 { |
88 wb->account = NULL; | 88 if(wb->who) |
89 wb->state = 0; | 89 g_free(wb->who); |
90 | 90 |
91 if( wb->who ) | 91 wbList = g_list_remove(wbList, wb); |
92 g_free( wb->who ); | |
93 | 92 |
94 wbList = g_list_remove( wbList, wb ); | 93 g_free(wb); |
95 | |
96 g_free( wb ); | |
97 wb = NULL; | |
98 } | 94 } |
99 } | 95 } |
100 | 96 |
101 void gaim_whiteboard_start( GaimWhiteboard *wb ) | 97 void gaim_whiteboard_start(GaimWhiteboard *wb) |
102 { | 98 { |
103 /* Create frontend for whiteboard */ | 99 /* Create frontend for whiteboard */ |
104 if( whiteboard_ui_ops && whiteboard_ui_ops->create ) | 100 if(whiteboard_ui_ops && whiteboard_ui_ops->create) |
105 whiteboard_ui_ops->create( wb ); | 101 whiteboard_ui_ops->create(wb); |
106 } | 102 } |
107 | 103 |
108 /* Looks through the list of whiteboard sessions for one that is between | 104 /* Looks through the list of whiteboard sessions for one that is between |
109 * usernames 'me' and 'who'. Returns a pointer to a matching whiteboard | 105 * usernames 'me' and 'who'. Returns a pointer to a matching whiteboard |
110 * session; if none match, it returns NULL. | 106 * session; if none match, it returns NULL. |
111 */ | 107 */ |
112 GaimWhiteboard *gaim_whiteboard_get_session( GaimAccount *account, char *who ) | 108 GaimWhiteboard *gaim_whiteboard_get_session(GaimAccount *account, const char *who) |
113 { | 109 { |
114 GaimWhiteboard *wb = NULL; | 110 GaimWhiteboard *wb = NULL; |
115 | 111 |
116 GList *l = wbList; | 112 GList *l = wbList; |
117 | 113 |
118 /* Look for a whiteboard session between the local user and the remote | 114 /* Look for a whiteboard session between the local user and the remote user |
119 * user | |
120 */ | 115 */ |
121 while( l ) | 116 while(l != NULL) |
122 { | 117 { |
123 wb = l->data; | 118 wb = l->data; |
124 | 119 |
125 if( !strcmp( gaim_account_get_username( wb->account ), | 120 if(wb->account == account && !strcmp(wb->who, who)) |
126 gaim_account_get_username( account ) ) && | 121 return wb; |
127 !strcmp( wb->who, who ) ) | |
128 return( wb ); | |
129 | 122 |
130 l = l->next; | 123 l = l->next; |
131 } | 124 } |
132 | 125 |
133 return( NULL ); | 126 return NULL; |
134 } | 127 } |
135 | 128 |
136 GList *gaim_whiteboard_draw_list_destroy( GList *draw_list ) | 129 void gaim_whiteboard_draw_list_destroy(GList *draw_list) |
137 { | |
138 if( draw_list == NULL ) | |
139 return( NULL ); | |
140 else | |
141 { | |
142 /* Destroy the contents of this list */ | |
143 int *n = NULL; | |
144 GList *l = draw_list; | |
145 while( l ) | |
146 { | 130 { |
147 n = l->data; | 131 if (draw_list) |
148 | 132 g_list_free(draw_list); |
149 if( n ) | |
150 g_free( n ); | |
151 | |
152 l = l->next; | |
153 } | |
154 | |
155 g_list_free( draw_list ); | |
156 draw_list = NULL; | |
157 } | |
158 | |
159 return( draw_list ); | |
160 } | 133 } |
161 | 134 |
162 void gaim_whiteboard_set_dimensions( GaimWhiteboard *wb, int width, int height ) | 135 void gaim_whiteboard_set_dimensions(GaimWhiteboard *wb, int width, int height) |
163 { | 136 { |
164 if( whiteboard_ui_ops && whiteboard_ui_ops->set_dimensions ) | 137 if(whiteboard_ui_ops && whiteboard_ui_ops->set_dimensions) |
165 whiteboard_ui_ops->set_dimensions( wb, width, height ); | 138 whiteboard_ui_ops->set_dimensions(wb, width, height); |
166 } | 139 } |
167 | 140 |
168 void gaim_whiteboard_draw_point( GaimWhiteboard *wb, int x, int y, int color, int size ) | 141 void gaim_whiteboard_draw_point(GaimWhiteboard *wb, int x, int y, int color, int size) |
169 { | 142 { |
170 if( whiteboard_ui_ops && whiteboard_ui_ops->draw_point ) | 143 if(whiteboard_ui_ops && whiteboard_ui_ops->draw_point) |
171 whiteboard_ui_ops->draw_point( wb, x, y, color, size ); | 144 whiteboard_ui_ops->draw_point(wb, x, y, color, size); |
172 } | 145 } |
173 | 146 |
174 void gaim_whiteboard_draw_line( GaimWhiteboard *wb, int x1, int y1, int x2, int y2, int color, int size ) | 147 void gaim_whiteboard_draw_line(GaimWhiteboard *wb, int x1, int y1, int x2, int y2, int color, int size) |
175 { | 148 { |
176 if( whiteboard_ui_ops && whiteboard_ui_ops->draw_line ) | 149 if(whiteboard_ui_ops && whiteboard_ui_ops->draw_line) |
177 whiteboard_ui_ops->draw_line( wb, x1, y1, x2, y2, color, size ); | 150 whiteboard_ui_ops->draw_line(wb, x1, y1, x2, y2, color, size); |
178 } | 151 } |
179 | 152 |
180 void gaim_whiteboard_clear( GaimWhiteboard *wb ) | 153 void gaim_whiteboard_clear(GaimWhiteboard *wb) |
181 { | 154 { |
182 if( whiteboard_ui_ops && whiteboard_ui_ops->clear ) | 155 if(whiteboard_ui_ops && whiteboard_ui_ops->clear) |
183 whiteboard_ui_ops->clear( wb ); | 156 whiteboard_ui_ops->clear(wb); |
184 } | 157 } |
185 | 158 |