libpurple/purpleprotocolconversation.c

changeset 43136
36eba703e2b9
parent 43104
f87ae4effec7
child 43235
42e7b89033fe
equal deleted inserted replaced
43135:d00a312b1d42 43136:36eba703e2b9
283 283
284 284
285 return FALSE; 285 return FALSE;
286 } 286 }
287 287
288 gboolean
289 purple_protocol_conversation_implements_set_topic(PurpleProtocolConversation *protocol)
290 {
291 PurpleProtocolConversationInterface *iface = NULL;
292
293 g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
294
295 iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
296
297 if(iface->set_topic_async == NULL) {
298 return FALSE;
299 }
300
301 if(iface->set_topic_finish == NULL) {
302 return FALSE;
303 }
304
305 return TRUE;
306 }
307
288 void 308 void
289 purple_protocol_conversation_set_topic_async(PurpleProtocolConversation *protocol, 309 purple_protocol_conversation_set_topic_async(PurpleProtocolConversation *protocol,
290 PurpleConversation *conversation, 310 PurpleConversation *conversation,
291 const char *topic, 311 const char *topic,
292 GCancellable *cancellable, 312 GCancellable *cancellable,
411 "purple_protocol_conversation_join_channel_async"); 431 "purple_protocol_conversation_join_channel_async");
412 432
413 return FALSE; 433 return FALSE;
414 } 434 }
415 435
436 gboolean
437 purple_protocol_conversation_implements_set_avatar(PurpleProtocolConversation *protocol)
438 {
439 PurpleProtocolConversationInterface *iface = NULL;
440
441 g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
442
443 iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
444
445 if(iface->set_avatar_async == NULL) {
446 return FALSE;
447 }
448
449 if(iface->set_avatar_finish == NULL) {
450 return FALSE;
451 }
452
453 return TRUE;
454 }
455
416 void 456 void
417 purple_protocol_conversation_set_avatar_async(PurpleProtocolConversation *protocol, 457 purple_protocol_conversation_set_avatar_async(PurpleProtocolConversation *protocol,
418 PurpleConversation *conversation, 458 PurpleConversation *conversation,
419 PurpleAvatar *avatar, 459 PurpleAvatar *avatar,
420 GCancellable *cancellable, 460 GCancellable *cancellable,
530 } else { 570 } else {
531 g_warning("%s does not implement refresh", 571 g_warning("%s does not implement refresh",
532 G_OBJECT_TYPE_NAME(protocol)); 572 G_OBJECT_TYPE_NAME(protocol));
533 } 573 }
534 } 574 }
575
576 gboolean
577 purple_protocol_conversation_implements_set_title(PurpleProtocolConversation *protocol)
578 {
579 PurpleProtocolConversationInterface *iface = NULL;
580
581 g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
582
583 iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
584 if(iface->set_title_async == NULL) {
585 return FALSE;
586 }
587
588 if(iface->set_title_finish == NULL) {
589 return FALSE;
590 }
591
592 return TRUE;
593 }
594
595 void
596 purple_protocol_conversation_set_title_async(PurpleProtocolConversation *protocol,
597 PurpleConversation *conversation,
598 const char *title,
599 GCancellable *cancellable,
600 GAsyncReadyCallback callback,
601 gpointer data)
602 {
603 PurpleProtocolConversationInterface *iface = NULL;
604
605 g_return_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol));
606 g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
607
608 iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
609 if(iface != NULL && iface->set_title_async != NULL) {
610 iface->set_title_async(protocol, conversation, title, cancellable,
611 callback, data);
612 } else {
613 g_task_report_new_error(G_OBJECT(protocol), callback, data,
614 purple_protocol_conversation_set_title_async,
615 PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0,
616 "%s does not implement set_title_async",
617 G_OBJECT_TYPE_NAME(protocol));
618 }
619 }
620
621 gboolean
622 purple_protocol_conversation_set_title_finish(PurpleProtocolConversation *protocol,
623 GAsyncResult *result,
624 GError **error)
625 {
626 PurpleProtocolConversationInterface *iface = NULL;
627
628 g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
629 g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
630
631 if(g_async_result_is_tagged(result,
632 purple_protocol_conversation_set_title_async))
633 {
634 return g_task_propagate_boolean(G_TASK(result), error);
635 }
636
637 iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
638 if(iface != NULL && iface->set_title_finish != NULL) {
639 return iface->set_title_finish(protocol, result, error);
640 }
641
642 g_warning("purple_protocol_conversation_set_title_finish called without "
643 "calling purple_protocol_conversation_set_title_async");
644
645 return FALSE;
646 }
647
648 gboolean
649 purple_protocol_conversation_implements_set_description(PurpleProtocolConversation *protocol)
650 {
651 PurpleProtocolConversationInterface *iface = NULL;
652
653 g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
654
655 iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
656 if(iface->set_description_async == NULL) {
657 return FALSE;
658 }
659
660 if(iface->set_description_finish == NULL) {
661 return FALSE;
662 }
663
664 return TRUE;
665 }
666
667 void
668 purple_protocol_conversation_set_description_async(PurpleProtocolConversation *protocol,
669 PurpleConversation *conversation,
670 const char *description,
671 GCancellable *cancellable,
672 GAsyncReadyCallback callback,
673 gpointer data)
674 {
675 PurpleProtocolConversationInterface *iface = NULL;
676
677 g_return_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol));
678 g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
679
680 iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
681 if(iface != NULL && iface->set_description_async != NULL) {
682 iface->set_description_async(protocol, conversation, description,
683 cancellable, callback, data);
684 } else {
685 g_task_report_new_error(G_OBJECT(protocol), callback, data,
686 purple_protocol_conversation_set_description_async,
687 PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0,
688 "%s does not implement set_description_async",
689 G_OBJECT_TYPE_NAME(protocol));
690 }
691 }
692
693 gboolean
694 purple_protocol_conversation_set_description_finish(PurpleProtocolConversation *protocol,
695 GAsyncResult *result,
696 GError **error)
697 {
698 PurpleProtocolConversationInterface *iface = NULL;
699
700 g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
701 g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
702
703 if(g_async_result_is_tagged(result,
704 purple_protocol_conversation_set_description_async))
705 {
706 return g_task_propagate_boolean(G_TASK(result), error);
707 }
708
709 iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
710 if(iface != NULL && iface->set_description_finish != NULL) {
711 return iface->set_description_finish(protocol, result, error);
712 }
713
714 g_warning("purple_protocol_conversation_set_description_finish called "
715 "without calling "
716 "purple_protocol_conversation_set_description_async");
717
718 return FALSE;
719 }

mercurial