Mercurial > pidgin
comparison libpurple/protocols/oscar/family_oservice.c @ 15624:3548e64b0245
Combine two functions that did similar things. This is a little
cleaner, but more importantly it's more extensible.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 12 Feb 2007 08:43:04 +0000 |
parents | 5fe8042783c1 |
children | 2261750cf4e9 |
comparison
equal
deleted
inserted
replaced
15623:71af5b6209d5 | 15624:3548e64b0245 |
---|---|
777 aim_srv_reqrates(od, conn); | 777 aim_srv_reqrates(od, conn); |
778 | 778 |
779 return 1; | 779 return 1; |
780 } | 780 } |
781 | 781 |
782 /* | 782 /** |
783 * Subtype 0x001e - Set various account settings (mostly ICQ related). | 783 * Subtype 0x001e - Extended Status/Extra Info. |
784 * | 784 * |
785 * These settings are transient, not server-stored (i.e. they only | 785 * These settings are transient, not server-stored (i.e. they only |
786 * apply to this session, and must be re-set the next time you sign | 786 * apply to this session, and must be re-set the next time you sign |
787 * on). | 787 * on). |
788 * | 788 * |
789 * You can set your ICQ status (available, away, do not disturb, | 789 * You can set your ICQ status (available, away, do not disturb, |
790 * etc.), or whether your IP address should be hidden or not, or | 790 * etc.), or whether your IP address should be hidden or not, or |
791 * if your status is visible on ICQ web sites, and you can set | 791 * if your status is visible on ICQ web sites, and you can set |
792 * your IP address info and what not. | 792 * your IP address info and what not. |
793 * | 793 * |
794 * You can also set your "available" message. This is currently | |
795 * only supported by iChat, Gaim and other 3rd party clients. | |
796 * | |
794 * These are the same TLVs seen in user info. You can | 797 * These are the same TLVs seen in user info. You can |
795 * also set 0x0008 and 0x000c. | 798 * also set 0x0008 and 0x000c. |
796 * | |
797 * TODO: Combine this with the function below. | |
798 */ | 799 */ |
799 int | 800 int |
800 aim_srv_setextstatus(OscarData *od, guint32 status) | 801 aim_srv_setextrainfo(OscarData *od, |
802 gboolean seticqstatus, guint32 icqstatus, | |
803 gboolean setavailmsg, const char *availmsg) | |
801 { | 804 { |
802 FlapConnection *conn; | 805 FlapConnection *conn; |
803 FlapFrame *frame; | 806 FlapFrame *frame; |
804 aim_snacid_t snacid; | 807 aim_snacid_t snacid; |
805 aim_tlvlist_t *tl = NULL; | 808 aim_tlvlist_t *tl = NULL; |
806 guint32 data; | |
807 | 809 |
808 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM))) | 810 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ICBM))) |
809 return -EINVAL; | 811 return -EINVAL; |
810 | 812 |
811 data = AIM_ICQ_STATE_HIDEIP | AIM_ICQ_STATE_DIRECTREQUIREAUTH | status; | 813 if (seticqstatus) |
812 | 814 { |
813 frame = flap_frame_new(od, 0x02, 10 + 8); | 815 aim_tlvlist_add_32(&tl, 0x0006, icqstatus | |
816 AIM_ICQ_STATE_HIDEIP | AIM_ICQ_STATE_DIRECTREQUIREAUTH); | |
817 } | |
818 | |
819 #if 0 | |
820 if (other_stuff_that_isnt_implemented) | |
821 { | |
822 aim_tlvlist_add_raw(&tl, 0x000c, 0x0025, | |
823 chunk_of_x25_bytes_with_ip_address_etc); | |
824 aim_tlvlist_add_raw(&tl, 0x0011, 0x0005, unknown 0x01 61 10 f6 41); | |
825 aim_tlvlist_add_16(&tl, 0x0012, unknown 0x00 00); | |
826 } | |
827 #endif | |
828 | |
829 if (setavailmsg) | |
830 { | |
831 int availmsglen; | |
832 ByteStream tmpbs; | |
833 | |
834 availmsglen = (availmsg != NULL) ? strlen(availmsg) : 0; | |
835 | |
836 byte_stream_new(&tmpbs, availmsglen + 8); | |
837 byte_stream_put16(&tmpbs, 0x0002); | |
838 byte_stream_put8(&tmpbs, 0x04); | |
839 byte_stream_put8(&tmpbs, availmsglen + 4); | |
840 byte_stream_put16(&tmpbs, availmsglen); | |
841 if (availmsglen > 0) | |
842 byte_stream_putstr(&tmpbs, availmsg); | |
843 byte_stream_put16(&tmpbs, 0x0000); | |
844 | |
845 aim_tlvlist_add_raw(&tl, 0x001d, | |
846 byte_stream_curpos(&tmpbs), tmpbs.data); | |
847 g_free(tmpbs.data); | |
848 } | |
849 | |
850 frame = flap_frame_new(od, 0x02, 10 + aim_tlvlist_size(&tl)); | |
814 | 851 |
815 snacid = aim_cachesnac(od, 0x0001, 0x001e, 0x0000, NULL, 0); | 852 snacid = aim_cachesnac(od, 0x0001, 0x001e, 0x0000, NULL, 0); |
816 aim_putsnac(&frame->data, 0x0001, 0x001e, 0x0000, snacid); | 853 aim_putsnac(&frame->data, 0x0001, 0x001e, 0x0000, snacid); |
817 | 854 |
818 aim_tlvlist_add_32(&tl, 0x0006, data); | |
819 #if 0 | |
820 aim_tlvlist_add_raw(&tl, 0x000c, 0x0025, chunk_of_x25_bytes_with_ip_address_etc); | |
821 aim_tlvlist_add_raw(&tl, 0x0011, 0x0005, unknown 0x01 61 10 f6 41); | |
822 aim_tlvlist_add_16(&tl, 0x0012, unknown 0x00 00); | |
823 #endif | |
824 aim_tlvlist_write(&frame->data, &tl); | 855 aim_tlvlist_write(&frame->data, &tl); |
825 aim_tlvlist_free(&tl); | 856 aim_tlvlist_free(&tl); |
826 | 857 |
827 flap_connection_send(conn, frame); | 858 flap_connection_send(conn, frame); |
828 | 859 |
829 return 0; | 860 return 0; |
830 } | 861 } |
831 | 862 |
832 /* | 863 /** |
833 * Subtype 0x001e - Extended Status. | |
834 * | |
835 * Sets your "available" message. This is currently only supported by iChat | |
836 * and Gaim. | |
837 * | |
838 * These are the same TLVs seen in user info. You can | |
839 * also set 0x0008 and 0x000c. | |
840 * | |
841 * TODO: Combine this with the above function. | |
842 */ | |
843 int | |
844 aim_srv_setstatusmsg(OscarData *od, const char *msg) | |
845 { | |
846 FlapConnection *conn; | |
847 FlapFrame *frame; | |
848 aim_snacid_t snacid; | |
849 int msglen; | |
850 | |
851 if (!od || !(conn = flap_connection_findbygroup(od, 0x0004))) | |
852 return -EINVAL; | |
853 | |
854 if (msg == NULL) | |
855 msglen = 0; | |
856 else | |
857 msglen = strlen(msg); | |
858 | |
859 frame = flap_frame_new(od, 0x02, 10 + 4 + msglen + 8); | |
860 | |
861 snacid = aim_cachesnac(od, 0x0001, 0x001e, 0x0000, NULL, 0); | |
862 aim_putsnac(&frame->data, 0x0001, 0x001e, 0x0000, snacid); | |
863 | |
864 byte_stream_put16(&frame->data, 0x001d); /* userinfo TLV type */ | |
865 byte_stream_put16(&frame->data, msglen + 8); /* total length of userinfo TLV data */ | |
866 byte_stream_put16(&frame->data, 0x0002); | |
867 byte_stream_put8(&frame->data, 0x04); | |
868 byte_stream_put8(&frame->data, msglen+4); | |
869 byte_stream_put16(&frame->data, msglen); | |
870 if (msglen > 0) | |
871 byte_stream_putstr(&frame->data, msg); | |
872 byte_stream_put16(&frame->data, 0x0000); | |
873 | |
874 flap_connection_send(conn, frame); | |
875 | |
876 return 0; | |
877 } | |
878 | |
879 /* | |
880 * Starting this past week (26 Mar 2001, say), AOL has started sending | 864 * Starting this past week (26 Mar 2001, say), AOL has started sending |
881 * this nice little extra SNAC. AFAIK, it has never been used until now. | 865 * this nice little extra SNAC. AFAIK, it has never been used until now. |
882 * | 866 * |
883 * The request contains eight bytes. The first four are an offset, the | 867 * The request contains eight bytes. The first four are an offset, the |
884 * second four are a length. | 868 * second four are a length. |