File:  [Coherent Logic Development] / ChivanetAimPidgin / oscarprpl / src / c / family_popup.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Mon Jan 27 19:48:25 2025 UTC (6 months ago) by snw
Branches: MAIN, CoherentLogicDevelopment
CVS tags: test-tag, start, HEAD
Pidgin AIM Plugin for ChivaNet

    1: /*
    2:  * Purple's oscar protocol plugin
    3:  * This file is the legal property of its developers.
    4:  * Please see the AUTHORS file distributed alongside this file.
    5:  *
    6:  * This library is free software; you can redistribute it and/or
    7:  * modify it under the terms of the GNU Lesser General Public
    8:  * License as published by the Free Software Foundation; either
    9:  * version 2 of the License, or (at your option) any later version.
   10:  *
   11:  * This library is distributed in the hope that it will be useful,
   12:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14:  * Lesser General Public License for more details.
   15:  *
   16:  * You should have received a copy of the GNU Lesser General Public
   17:  * License along with this library; if not, write to the Free Software
   18:  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
   19: */
   20: 
   21: /*
   22:  * Family 0x0008 - Popups.
   23:  *
   24:  * Popups are just what it sounds like.  They're a way for the server to
   25:  * open up an informative box on the client's screen.
   26:  */
   27: 
   28: #include "oscar.h"
   29: 
   30: /*
   31:  * This is all there is to it.
   32:  *
   33:  * The message is probably HTML.
   34:  *
   35:  */
   36: static int
   37: parsepopup(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
   38: {
   39: 	aim_rxcallback_t userfunc;
   40: 	GSList *tlvlist;
   41: 	int ret = 0;
   42: 	char *msg, *url;
   43: 	guint16 width, height, delay;
   44: 
   45: 	tlvlist = aim_tlvlist_read(bs);
   46: 
   47: 	msg = aim_tlv_getstr(tlvlist, 0x0001, 1);
   48: 	url = aim_tlv_getstr(tlvlist, 0x0002, 1);
   49: 	width = aim_tlv_get16(tlvlist, 0x0003, 1);
   50: 	height = aim_tlv_get16(tlvlist, 0x0004, 1);
   51: 	delay = aim_tlv_get16(tlvlist, 0x0005, 1);
   52: 
   53: 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
   54: 		ret = userfunc(od, conn, frame, msg, url, width, height, delay);
   55: 
   56: 	aim_tlvlist_free(tlvlist);
   57: 	g_free(msg);
   58: 	g_free(url);
   59: 
   60: 	return ret;
   61: }
   62: 
   63: static int
   64: snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
   65: {
   66: 	if (snac->subtype == 0x0002)
   67: 		return parsepopup(od, conn, mod, frame, snac, bs);
   68: 
   69: 	return 0;
   70: }
   71: 
   72: int
   73: popups_modfirst(OscarData *od, aim_module_t *mod)
   74: {
   75: 	mod->family = SNAC_FAMILY_POPUP;
   76: 	mod->version = 0x0001;
   77: 	mod->toolid = 0x0104;
   78: 	mod->toolversion = 0x0001;
   79: 	mod->flags = 0;
   80: 	strncpy(mod->name, "popup", sizeof(mod->name));
   81: 	mod->snachandler = snachandler;
   82: 
   83: 	return 0;
   84: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>