| 207 NULL, |
205 NULL, |
| 208 NULL, |
206 NULL, |
| 209 G_TYPE_NONE, |
207 G_TYPE_NONE, |
| 210 1, |
208 1, |
| 211 PURPLE_TYPE_PROTOCOL); |
209 PURPLE_TYPE_PROTOCOL); |
| 212 |
|
| 213 /** |
|
| 214 * PurpleProtocolManager::registered: |
|
| 215 * @manager: The #PurpleProtocolManager instance. |
|
| 216 * @protocol: The #PurpleProtocol that was registered. |
|
| 217 * |
|
| 218 * Emitted after @protocol has been registered in @manager. |
|
| 219 * |
|
| 220 * Since: 3.0 |
|
| 221 * |
|
| 222 * Deprecated: 3.0 |
|
| 223 */ |
|
| 224 signals[SIG_REGISTERED] = g_signal_new_class_handler( |
|
| 225 "registered", |
|
| 226 G_OBJECT_CLASS_TYPE(klass), |
|
| 227 G_SIGNAL_RUN_LAST, |
|
| 228 NULL, |
|
| 229 NULL, |
|
| 230 NULL, |
|
| 231 NULL, |
|
| 232 G_TYPE_NONE, |
|
| 233 1, |
|
| 234 PURPLE_TYPE_PROTOCOL); |
|
| 235 |
|
| 236 /** |
|
| 237 * PurpleProtocolManager::unregistered: |
|
| 238 * @manager: The #PurpleProtocolManager instance. |
|
| 239 * @protocol: The #PurpleProtocol that was unregistered. |
|
| 240 * |
|
| 241 * Emitted after @protocol has been unregistered from @manager. |
|
| 242 * |
|
| 243 * Since: 3.0 |
|
| 244 * |
|
| 245 * Deprecated: 3.0 |
|
| 246 */ |
|
| 247 signals[SIG_UNREGISTERED] = g_signal_new_class_handler( |
|
| 248 "unregistered", |
|
| 249 G_OBJECT_CLASS_TYPE(klass), |
|
| 250 G_SIGNAL_RUN_LAST, |
|
| 251 NULL, |
|
| 252 NULL, |
|
| 253 NULL, |
|
| 254 NULL, |
|
| 255 G_TYPE_NONE, |
|
| 256 1, |
|
| 257 PURPLE_TYPE_PROTOCOL); |
|
| 258 } |
210 } |
| 259 |
211 |
| 260 /****************************************************************************** |
212 /****************************************************************************** |
| 261 * Private API |
213 * Private API |
| 262 *****************************************************************************/ |
214 *****************************************************************************/ |
| 296 g_object_ref(protocol)); |
248 g_object_ref(protocol)); |
| 297 g_ptr_array_add(manager->list, protocol); |
249 g_ptr_array_add(manager->list, protocol); |
| 298 g_list_model_items_changed(G_LIST_MODEL(manager), manager->list->len - 1, 0, 1); |
250 g_list_model_items_changed(G_LIST_MODEL(manager), manager->list->len - 1, 0, 1); |
| 299 |
251 |
| 300 g_signal_emit(G_OBJECT(manager), signals[SIG_ADDED], 0, protocol); |
252 g_signal_emit(G_OBJECT(manager), signals[SIG_ADDED], 0, protocol); |
| 301 g_signal_emit(G_OBJECT(manager), signals[SIG_REGISTERED], 0, protocol); |
|
| 302 |
253 |
| 303 return TRUE; |
254 return TRUE; |
| 304 } |
255 } |
| 305 |
256 |
| 306 PurpleProtocolManager * |
257 PurpleProtocolManager * |
| 307 purple_protocol_manager_get_default(void) { |
258 purple_protocol_manager_get_default(void) { |
| 308 return default_manager; |
259 return default_manager; |
| 309 } |
260 } |
| 310 |
261 |
| 311 gboolean |
|
| 312 purple_protocol_manager_register(PurpleProtocolManager *manager, |
|
| 313 PurpleProtocol *protocol, GError **error) |
|
| 314 { |
|
| 315 g_return_val_if_fail(PURPLE_IS_PROTOCOL_MANAGER(manager), FALSE); |
|
| 316 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), FALSE); |
|
| 317 |
|
| 318 return purple_protocol_manager_add(manager, protocol, error); |
|
| 319 } |
|
| 320 |
|
| 321 gboolean |
|
| 322 purple_protocol_manager_unregister(PurpleProtocolManager *manager, |
|
| 323 PurpleProtocol *protocol, GError **error) |
|
| 324 { |
|
| 325 g_return_val_if_fail(PURPLE_IS_PROTOCOL_MANAGER(manager), FALSE); |
|
| 326 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), FALSE); |
|
| 327 |
|
| 328 return purple_protocol_manager_remove(manager, protocol, error); |
|
| 329 } |
|
| 330 |
|
| 331 PurpleProtocol * |
262 PurpleProtocol * |
| 332 purple_protocol_manager_find(PurpleProtocolManager *manager, const gchar *id) { |
263 purple_protocol_manager_find(PurpleProtocolManager *manager, const gchar *id) { |
| 333 gpointer value = NULL; |
264 gpointer value = NULL; |
| 334 |
265 |
| 335 g_return_val_if_fail(PURPLE_IS_PROTOCOL_MANAGER(manager), NULL); |
266 g_return_val_if_fail(PURPLE_IS_PROTOCOL_MANAGER(manager), NULL); |
| 339 if(value == NULL) { |
270 if(value == NULL) { |
| 340 return NULL; |
271 return NULL; |
| 341 } |
272 } |
| 342 |
273 |
| 343 return PURPLE_PROTOCOL(value); |
274 return PURPLE_PROTOCOL(value); |
| 344 } |
|
| 345 |
|
| 346 void |
|
| 347 purple_protocol_manager_foreach(PurpleProtocolManager *manager, |
|
| 348 PurpleProtocolManagerForeachFunc func, |
|
| 349 gpointer data) |
|
| 350 { |
|
| 351 GHashTableIter iter; |
|
| 352 gpointer value; |
|
| 353 |
|
| 354 g_return_if_fail(PURPLE_IS_PROTOCOL_MANAGER(manager)); |
|
| 355 g_return_if_fail(func != NULL); |
|
| 356 |
|
| 357 g_hash_table_iter_init(&iter, manager->protocols); |
|
| 358 while(g_hash_table_iter_next(&iter, NULL, &value)) { |
|
| 359 func(PURPLE_PROTOCOL(value), data); |
|
| 360 } |
|
| 361 } |
|
| 362 |
|
| 363 GList * |
|
| 364 purple_protocol_manager_get_all(PurpleProtocolManager *manager) { |
|
| 365 g_return_val_if_fail(PURPLE_IS_PROTOCOL_MANAGER(manager), NULL); |
|
| 366 |
|
| 367 return g_hash_table_get_values(manager->protocols); |
|
| 368 } |
275 } |
| 369 |
276 |
| 370 gboolean |
277 gboolean |
| 371 purple_protocol_manager_remove(PurpleProtocolManager *manager, |
278 purple_protocol_manager_remove(PurpleProtocolManager *manager, |
| 372 PurpleProtocol *protocol, GError **error) |
279 PurpleProtocol *protocol, GError **error) |
| 393 g_ptr_array_remove_index(manager->list, position); |
300 g_ptr_array_remove_index(manager->list, position); |
| 394 g_list_model_items_changed(G_LIST_MODEL(manager), position, 1, 0); |
301 g_list_model_items_changed(G_LIST_MODEL(manager), position, 1, 0); |
| 395 } |
302 } |
| 396 |
303 |
| 397 g_signal_emit(G_OBJECT(manager), signals[SIG_REMOVED], 0, protocol); |
304 g_signal_emit(G_OBJECT(manager), signals[SIG_REMOVED], 0, protocol); |
| 398 g_signal_emit(G_OBJECT(manager), signals[SIG_UNREGISTERED], 0, |
|
| 399 protocol); |
|
| 400 |
305 |
| 401 ret = TRUE; |
306 ret = TRUE; |
| 402 } else { |
307 } else { |
| 403 g_set_error(error, PURPLE_PROTOCOL_MANAGER_DOMAIN, 0, |
308 g_set_error(error, PURPLE_PROTOCOL_MANAGER_DOMAIN, 0, |
| 404 _("protocol %s has not been added"), id); |
309 _("protocol %s has not been added"), id); |