comparison libpurple/prpl.c @ 23868:1aa383ee5fc8

Fixed up media functions in prpl.c and prpl.h, adding more documentation and using PURPLE_PROTOCOL_PLUGIN_HAS_FUNC.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sat, 09 Aug 2008 03:11:46 +0000
parents 4bc74deeb503
children 551a462b346a
comparison
equal deleted inserted replaced
23867:4bc74deeb503 23868:1aa383ee5fc8
492 purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code) 492 purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code)
493 { 493 {
494 got_attention(gc, id, who, type_code); 494 got_attention(gc, id, who, type_code);
495 } 495 }
496 496
497 /**************************************************************************
498 * Protocol Plugin Subsystem API
499 **************************************************************************/
500
501 PurplePlugin *
502 purple_find_prpl(const char *id)
503 {
504 GList *l;
505 PurplePlugin *plugin;
506
507 g_return_val_if_fail(id != NULL, NULL);
508
509 for (l = purple_plugins_get_protocols(); l != NULL; l = l->next) {
510 plugin = (PurplePlugin *)l->data;
511
512 if (!strcmp(plugin->info->id, id))
513 return plugin;
514 }
515
516 return NULL;
517 }
518
519
520
521 PurpleMedia * 497 PurpleMedia *
522 purple_prpl_initiate_media(PurpleAccount *account, 498 purple_prpl_initiate_media(PurpleAccount *account,
523 const char *who, 499 const char *who,
524 PurpleMediaStreamType type) 500 PurpleMediaStreamType type)
525 { 501 {
533 if (gc) 509 if (gc)
534 prpl = purple_connection_get_prpl(gc); 510 prpl = purple_connection_get_prpl(gc);
535 if (prpl) 511 if (prpl)
536 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); 512 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
537 513
538 if (prpl_info && prpl_info->initiate_media) { 514 if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, initiate_media)) {
539 /* should check that the protocol supports this media type here? */ 515 /* should check that the protocol supports this media type here? */
540 return prpl_info->initiate_media(gc, who, type); 516 return prpl_info->initiate_media(gc, who, type);
541 } else { 517 } else {
542 return NULL; 518 return NULL;
543 } 519 }
561 if (gc) 537 if (gc)
562 prpl = purple_connection_get_prpl(gc); 538 prpl = purple_connection_get_prpl(gc);
563 if (prpl) 539 if (prpl)
564 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); 540 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
565 541
566 if (prpl_info && prpl_info->can_do_media) { 542 if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, can_do_media)) {
567 return prpl_info->can_do_media(gc, who, type); 543 return prpl_info->can_do_media(gc, who, type);
568 } else { 544 } else {
569 return FALSE; 545 return FALSE;
570 } 546 }
571 #else 547 #else
572 return FALSE; 548 return FALSE;
573 #endif 549 #endif
574 } 550 }
575 551
552 /**************************************************************************
553 * Protocol Plugin Subsystem API
554 **************************************************************************/
555
556 PurplePlugin *
557 purple_find_prpl(const char *id)
558 {
559 GList *l;
560 PurplePlugin *plugin;
561
562 g_return_val_if_fail(id != NULL, NULL);
563
564 for (l = purple_plugins_get_protocols(); l != NULL; l = l->next) {
565 plugin = (PurplePlugin *)l->data;
566
567 if (!strcmp(plugin->info->id, id))
568 return plugin;
569 }
570
571 return NULL;
572 }
573