Changeset 5aa96fc8
- Timestamp:
- 2012-11-20T00:20:10Z (12 years ago)
- Branches:
- master
- Children:
- c751e51
- Parents:
- b006464
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter_lib.c
rb006464 r5aa96fc8 825 825 } 826 826 827 static gboolean twitter_stream_handle_event(struct im_connection *ic, json_value *o); 828 827 829 static gboolean twitter_stream_handle_object(struct im_connection *ic, json_value *o) 828 830 { 831 struct twitter_data *td = ic->proto_data; 829 832 struct twitter_xml_status *txs = g_new0(struct twitter_xml_status, 1); 830 833 json_value *c; … … 843 846 g_slist_free(output); 844 847 return TRUE; 848 } else if ((c = json_o_get(o, "event")) && c->type == json_string) { 849 twitter_stream_handle_event(ic, o); 850 return TRUE; 851 } else if ((c = json_o_get(o, "disconnect")) && c->type == json_object) { 852 /* HACK: Because we're inside an event handler, we can't just 853 disconnect here. Instead, just change the HTTP status string 854 into a Twitter status string. */ 855 char *reason = json_o_strdup(c, "reason"); 856 if (reason) { 857 g_free(td->stream->status_string); 858 td->stream->status_string = reason; 859 } 860 return TRUE; 845 861 } 846 862 txs_free(txs); 847 863 return FALSE; 864 } 865 866 static gboolean twitter_stream_handle_event(struct im_connection *ic, json_value *o) 867 { 868 struct twitter_data *td = ic->proto_data; 869 json_value *source = json_o_get(o, "source"); 870 json_value *target = json_o_get(o, "target"); 871 const char *type = json_o_str(o, "event"); 872 873 if (!type || !source || source->type != json_object 874 || !target || target->type != json_object) { 875 return FALSE; 876 } 877 878 if (strcmp(type, "follow") == 0) { 879 struct twitter_xml_user *us = twitter_xt_get_user(source); 880 struct twitter_xml_user *ut = twitter_xt_get_user(target); 881 if (strcmp(us->screen_name, td->user) == 0) { 882 twitter_add_buddy(ic, ut->screen_name, ut->name); 883 } 884 txu_free(us); 885 txu_free(ut); 886 } 887 888 return TRUE; 848 889 } 849 890
Note: See TracChangeset
for help on using the changeset viewer.