From: <mar...@us...> - 2006-06-26 03:44:44
|
Revision: 16341 Author: markhuetsch Date: 2006-06-25 20:44:39 -0700 (Sun, 25 Jun 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16341&view=rev Log Message: ----------- Fixed a bug that prevented libqq from being loaded as a plugin. Modified Paths: -------------- trunk/src/protocols/qq/buddy_status.c trunk/src/protocols/qq/im.c trunk/src/protocols/qq/qq_proxy.c trunk/src/protocols/qq/send_core.c trunk/src/protocols/qq/send_file.c Modified: trunk/src/protocols/qq/buddy_status.c =================================================================== --- trunk/src/protocols/qq/buddy_status.c 2006-06-26 02:58:54 UTC (rev 16340) +++ trunk/src/protocols/qq/buddy_status.c 2006-06-26 03:44:39 UTC (rev 16341) @@ -62,7 +62,7 @@ /*****************************************************************************/ // parse the data into qq_buddy_status -static gint _qq_buddy_status_read(guint8 * data, guint8 ** cursor, gint len, qq_buddy_status * s) { +gint _qq_buddy_status_read(guint8 * data, guint8 ** cursor, gint len, qq_buddy_status * s) { gint bytes; g_return_val_if_fail(data != NULL && *cursor != NULL && s != NULL, -1); Modified: trunk/src/protocols/qq/im.c =================================================================== --- trunk/src/protocols/qq/im.c 2006-06-26 02:58:54 UTC (rev 16340) +++ trunk/src/protocols/qq/im.c 2006-06-26 03:44:39 UTC (rev 16341) @@ -48,7 +48,7 @@ #define DEFAULT_FONT_NAME_LEN 4 // a debug function -static void _qq_show_packet(gchar * desc, gchar * buf, gint len); +void _qq_show_packet(gchar * desc, gchar * buf, gint len); enum { @@ -230,7 +230,7 @@ /*****************************************************************************/ // generate a md5 key using uid and session_key -static gchar *_gen_session_md5(gint uid, gchar * session_key) +gchar *_gen_session_md5(gint uid, gchar * session_key) { gchar *src, md5_str[QQ_KEY_LENGTH]; guint8 *cursor; Modified: trunk/src/protocols/qq/qq_proxy.c =================================================================== --- trunk/src/protocols/qq/qq_proxy.c 2006-06-26 02:58:54 UTC (rev 16340) +++ trunk/src/protocols/qq/qq_proxy.c 2006-06-26 03:44:39 UTC (rev 16341) @@ -60,7 +60,7 @@ } */ -static void _qq_show_packet(gchar * desc, gchar * buf, gint len) +void _qq_show_packet(gchar * desc, gchar * buf, gint len) { char buf1[4096], buf2[10]; int i; @@ -108,7 +108,7 @@ /*****************************************************************************/ -static gint _qq_fill_host(struct sockaddr_in * addr, const gchar * host, guint16 port) +gint _qq_fill_host(struct sockaddr_in * addr, const gchar * host, guint16 port) { if (!inet_aton(host, &(addr->sin_addr))) { struct hostent *hp; Modified: trunk/src/protocols/qq/send_core.c =================================================================== --- trunk/src/protocols/qq/send_core.c 2006-06-26 02:58:54 UTC (rev 16340) +++ trunk/src/protocols/qq/send_core.c 2006-06-26 03:44:39 UTC (rev 16341) @@ -37,7 +37,7 @@ // create qq packet header with given sequence // return the number of bytes in header if succeeds // return -1 if there is any error -static gint _create_packet_head_seq(guint8 * buf, guint8 ** cursor, +gint _create_packet_head_seq(guint8 * buf, guint8 ** cursor, GaimConnection * gc, guint16 cmd, gboolean is_auto_seq, guint16 * seq) { qq_data *qd; @@ -77,7 +77,7 @@ // for those need ack and resend no ack feed back from server // return number of bytes written to the socket, // return -1 if there is any error -static gint _qq_send_packet(GaimConnection * gc, guint8 * buf, gint len, guint16 cmd) +gint _qq_send_packet(GaimConnection * gc, guint8 * buf, gint len, guint16 cmd) { qq_data *qd; qq_sendpacket *p; Modified: trunk/src/protocols/qq/send_file.c =================================================================== --- trunk/src/protocols/qq/send_file.c 2006-06-26 02:58:54 UTC (rev 16340) +++ trunk/src/protocols/qq/send_file.c 2006-06-26 03:44:39 UTC (rev 16341) @@ -140,7 +140,7 @@ } */ -static gssize _qq_xfer_write(const guchar *buf, size_t len, GaimXfer *xfer) //gfhuang +gssize _qq_xfer_write(const guchar *buf, size_t len, GaimXfer *xfer) //gfhuang { return _qq_xfer_udp_send(buf, len, xfer); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-06-26 04:21:06
|
Revision: 16346 Author: thekingant Date: 2006-06-25 21:21:04 -0700 (Sun, 25 Jun 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16346&view=rev Log Message: ----------- Makefile.in should not be in the repository, and Makefile and .deps should be ignored (I'm not sure I did this right... we'll see :-) ) Removed Paths: ------------- trunk/src/protocols/qq/Makefile.in Property Changed: ---------------- trunk/src/protocols/qq/ Property changes on: trunk/src/protocols/qq ___________________________________________________________________ Name: svn:ignore + .deps/ Makefile Deleted: trunk/src/protocols/qq/Makefile.in =================================================================== --- trunk/src/protocols/qq/Makefile.in 2006-06-26 03:57:19 UTC (rev 16345) +++ trunk/src/protocols/qq/Makefile.in 2006-06-26 04:21:04 UTC (rev 16346) @@ -1,576 +0,0 @@ -# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am - -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -DESTDIR = - -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ - -top_builddir = ../../.. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -transform = @program_transform_name@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_alias = @build_alias@ -build_triplet = @build@ -host_alias = @host_alias@ -host_triplet = @host@ -target_alias = @target_alias@ -target_triplet = @target@ -ALL_LINGUAS = @ALL_LINGUAS@ -AO_CFLAGS = @AO_CFLAGS@ -AO_LIBS = @AO_LIBS@ -AR = @AR@ -AS = @AS@ -AUDIOFILE_CFLAGS = @AUDIOFILE_CFLAGS@ -AUDIOFILE_CONFIG = @AUDIOFILE_CONFIG@ -AUDIOFILE_LIBS = @AUDIOFILE_LIBS@ -BINRELOC_CFLAGS = @BINRELOC_CFLAGS@ -BINRELOC_LIBS = @BINRELOC_LIBS@ -BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ -CATALOGS = @CATALOGS@ -CATOBJEXT = @CATOBJEXT@ -CC = @CC@ -CFLAGS = @CFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -DATADIRNAME = @DATADIRNAME@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@ -DEBUG_CFLAGS = @DEBUG_CFLAGS@ -DLLTOOL = @DLLTOOL@ -DOT = @DOT@ -DOXYGEN = @DOXYGEN@ -DYNALOADER_A = @DYNALOADER_A@ -DYNAMIC_PRPLS = @DYNAMIC_PRPLS@ -ECHO = @ECHO@ -EGREP = @EGREP@ -EVOLUTION_ADDRESSBOOK_CFLAGS = @EVOLUTION_ADDRESSBOOK_CFLAGS@ -EVOLUTION_ADDRESSBOOK_LIBS = @EVOLUTION_ADDRESSBOOK_LIBS@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -GADU_CFLAGS = @GADU_CFLAGS@ -GADU_LIBS = @GADU_LIBS@ -GCJ = @GCJ@ -GCJFLAGS = @GCJFLAGS@ -GENCAT = @GENCAT@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIBC2 = @GLIBC2@ -GLIBC21 = @GLIBC21@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMOFILES = @GMOFILES@ -GMSGFMT = @GMSGFMT@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GOBJECT_QUERY = @GOBJECT_QUERY@ -GSTREAMER_CFLAGS = @GSTREAMER_CFLAGS@ -GSTREAMER_LIBS = @GSTREAMER_LIBS@ -GTKSPELL_CFLAGS = @GTKSPELL_CFLAGS@ -GTKSPELL_LIBS = @GTKSPELL_LIBS@ -GTK_CFLAGS = @GTK_CFLAGS@ -GTK_LIBS = @GTK_LIBS@ -HAVE_ASPRINTF = @HAVE_ASPRINTF@ -HAVE_LIB = @HAVE_LIB@ -HAVE_POSIX_PRINTF = @HAVE_POSIX_PRINTF@ -HAVE_SNPRINTF = @HAVE_SNPRINTF@ -HAVE_WPRINTF = @HAVE_WPRINTF@ -HOWL_CFLAGS = @HOWL_CFLAGS@ -HOWL_LIBS = @HOWL_LIBS@ -INSTOBJEXT = @INSTOBJEXT@ -INTLBISON = @INTLBISON@ -INTLLIBS = @INTLLIBS@ -INTLOBJS = @INTLOBJS@ -INTLTOOL_CAVES_RULE = @INTLTOOL_CAVES_RULE@ -INTLTOOL_DESKTOP_RULE = @INTLTOOL_DESKTOP_RULE@ -INTLTOOL_DIRECTORY_RULE = @INTLTOOL_DIRECTORY_RULE@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_ICONV = @INTLTOOL_ICONV@ -INTLTOOL_KBD_RULE = @INTLTOOL_KBD_RULE@ -INTLTOOL_KEYS_RULE = @INTLTOOL_KEYS_RULE@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_MSGFMT = @INTLTOOL_MSGFMT@ -INTLTOOL_MSGMERGE = @INTLTOOL_MSGMERGE@ -INTLTOOL_OAF_RULE = @INTLTOOL_OAF_RULE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_PONG_RULE = @INTLTOOL_PONG_RULE@ -INTLTOOL_PROP_RULE = @INTLTOOL_PROP_RULE@ -INTLTOOL_SCHEMAS_RULE = @INTLTOOL_SCHEMAS_RULE@ -INTLTOOL_SERVER_RULE = @INTLTOOL_SERVER_RULE@ -INTLTOOL_SERVICE_RULE = @INTLTOOL_SERVICE_RULE@ -INTLTOOL_SHEET_RULE = @INTLTOOL_SHEET_RULE@ -INTLTOOL_SOUNDLIST_RULE = @INTLTOOL_SOUNDLIST_RULE@ -INTLTOOL_THEME_RULE = @INTLTOOL_THEME_RULE@ -INTLTOOL_UI_RULE = @INTLTOOL_UI_RULE@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_XAM_RULE = @INTLTOOL_XAM_RULE@ -INTLTOOL_XGETTEXT = @INTLTOOL_XGETTEXT@ -INTLTOOL_XML_NOMERGE_RULE = @INTLTOOL_XML_NOMERGE_RULE@ -INTLTOOL_XML_RULE = @INTLTOOL_XML_RULE@ -INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -KRB4_CFLAGS = @KRB4_CFLAGS@ -KRB4_LDFLAGS = @KRB4_LDFLAGS@ -KRB4_LIBS = @KRB4_LIBS@ -LDADD = @LDADD@ -LIB = @LIB@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBPERL_A = @LIBPERL_A@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIBXML_CFLAGS = @LIBXML_CFLAGS@ -LIBXML_LIBS = @LIBXML_LIBS@ -LN_S = @LN_S@ -LTLIB = @LTLIB@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -MAKEINFO = @MAKEINFO@ -MEANWHILE_CFLAGS = @MEANWHILE_CFLAGS@ -MEANWHILE_LIBS = @MEANWHILE_LIBS@ -MKINSTALLDIRS = @MKINSTALLDIRS@ -MONO_CFLAGS = @MONO_CFLAGS@ -MONO_LIBS = @MONO_LIBS@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PERL = @PERL@ -PERL_CFLAGS = @PERL_CFLAGS@ -PERL_LIBS = @PERL_LIBS@ -PERL_MM_PARAMS = @PERL_MM_PARAMS@ -PKG_CONFIG = @PKG_CONFIG@ -POFILES = @POFILES@ -POSUB = @POSUB@ -PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ -PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ -PYTHON = @PYTHON@ -RANLIB = @RANLIB@ -RC = @RC@ -SASL_LIBS = @SASL_LIBS@ -SILC_CFLAGS = @SILC_CFLAGS@ -SILC_LIBS = @SILC_LIBS@ -SM_LIBS = @SM_LIBS@ -STARTUP_NOTIFICATION_CFLAGS = @STARTUP_NOTIFICATION_CFLAGS@ -STARTUP_NOTIFICATION_LIBS = @STARTUP_NOTIFICATION_LIBS@ -STATIC_LINK_LIBS = @STATIC_LINK_LIBS@ -STATIC_PRPLS = @STATIC_PRPLS@ -STRIP = @STRIP@ -TCL_CFLAGS = @TCL_CFLAGS@ -TCL_LIBS = @TCL_LIBS@ -TK_LIBS = @TK_LIBS@ -USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ -USE_NLS = @USE_NLS@ -VERSION = @VERSION@ -XSS_LIBS = @XSS_LIBS@ -ZEPHYR_CFLAGS = @ZEPHYR_CFLAGS@ -ZEPHYR_LDFLAGS = @ZEPHYR_LDFLAGS@ -ZEPHYR_LIBS = @ZEPHYR_LIBS@ -enable_dbus = @enable_dbus@ -enable_dot = @enable_dot@ -enable_doxygen = @enable_doxygen@ -gaimpath = @gaimpath@ -perlpath = @perlpath@ -sedpath = @sedpath@ - -EXTRA_DIST = Makefile.mingw - - -pkgdir = $(libdir)/gaim - -QQSOURCES = utils.c utils.h packet_parse.c packet_parse.h buddy_info.c buddy_info.h buddy_list.c buddy_list.h buddy_opt.c buddy_opt.h buddy_status.c buddy_status.h qq.c char_conv.c char_conv.h crypt.c crypt.h group_admindlg.c group_admindlg.h group.c group_conv.c group_conv.h group_find.c group_find.h group_free.c group_free.h group.h group_hash.c group_hash.h group_im.c group_im.h group_info.c group_info.h group_join.c group_join.h group_misc.c group_misc.h group_network.c group_network.h group_opt.c group_opt.h group_search.c group_search.h qq.h header_info.c header_info.h im.c im.h infodlg.c infodlg.h ip_location.c ip_location.h keep_alive.c keep_alive.h login_logout.c login_logout.h qq_proxy.c qq_proxy.h recv_core.c recv_core.h send_core.c send_core.h sendqueue.c sendqueue.h show.c show.h sys_msg.c sys_msg.h udp_proxy_s5.c udp_proxy_s5.h send_file.c send_file.h file_trans.c file_trans.h - - -AM_CFLAGS = $(st) - -libqq_la_LDFLAGS = -module -avoid-version - -@STATIC_QQ_TRUE@st = -DGAIM_STATIC_PRPL -@STATIC_QQ_FALSE@st = -@STATIC_QQ_TRUE@noinst_LIBRARIES = libqq.a -@STATIC_QQ_TRUE@libqq_a_SOURCES = $(QQSOURCES) -@STATIC_QQ_TRUE@libqq_a_CFLAGS = $(AM_CFLAGS) -@STATIC_QQ_FALSE@pkg_LTLIBRARIES = libqq.la -@STATIC_QQ_FALSE@libqq_la_SOURCES = $(QQSOURCES) - -AM_CPPFLAGS = -I$(top_srcdir)/src -DDATADIR=\"${datadir}\" -DVERSION=\"$(VERSION)\" $(DEBUG_CFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(GAIM_CFLAGS) - -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = ../../../config.h -CONFIG_CLEAN_FILES = -LIBRARIES = $(noinst_LIBRARIES) - - -DEFS = @DEFS@ -I. -I$(srcdir) -I../../.. -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -X_CFLAGS = @X_CFLAGS@ -X_LIBS = @X_LIBS@ -X_EXTRA_LIBS = @X_EXTRA_LIBS@ -X_PRE_LIBS = @X_PRE_LIBS@ -libqq_a_LIBADD = -@STATIC_QQ_TRUE@libqq_a_OBJECTS = utils.$(OBJEXT) \ -@STATIC_QQ_TRUE@packet_parse.$(OBJEXT) buddy_info.$(OBJEXT) \ -@STATIC_QQ_TRUE@buddy_list.$(OBJEXT) buddy_opt.$(OBJEXT) \ -@STATIC_QQ_TRUE@buddy_status.$(OBJEXT) qq.$(OBJEXT) char_conv.$(OBJEXT) \ -@STATIC_QQ_TRUE@crypt.$(OBJEXT) group_admindlg.$(OBJEXT) \ -@STATIC_QQ_TRUE@group.$(OBJEXT) group_conv.$(OBJEXT) \ -@STATIC_QQ_TRUE@group_find.$(OBJEXT) group_free.$(OBJEXT) \ -@STATIC_QQ_TRUE@group_hash.$(OBJEXT) group_im.$(OBJEXT) \ -@STATIC_QQ_TRUE@group_info.$(OBJEXT) group_join.$(OBJEXT) \ -@STATIC_QQ_TRUE@group_misc.$(OBJEXT) group_network.$(OBJEXT) \ -@STATIC_QQ_TRUE@group_opt.$(OBJEXT) group_search.$(OBJEXT) \ -@STATIC_QQ_TRUE@header_info.$(OBJEXT) im.$(OBJEXT) infodlg.$(OBJEXT) \ -@STATIC_QQ_TRUE@ip_location.$(OBJEXT) keep_alive.$(OBJEXT) \ -@STATIC_QQ_TRUE@login_logout.$(OBJEXT) qq_proxy.$(OBJEXT) \ -@STATIC_QQ_TRUE@recv_core.$(OBJEXT) send_core.$(OBJEXT) \ -@STATIC_QQ_TRUE@sendqueue.$(OBJEXT) show.$(OBJEXT) sys_msg.$(OBJEXT) \ -@STATIC_QQ_TRUE@udp_proxy_s5.$(OBJEXT) send_file.$(OBJEXT) \ -@STATIC_QQ_TRUE@file_trans.$(OBJEXT) -LTLIBRARIES = $(pkg_LTLIBRARIES) - -libqq_la_LIBADD = -@STATIC_QQ_FALSE@libqq_la_OBJECTS = utils.lo packet_parse.lo \ -@STATIC_QQ_FALSE@buddy_info.lo buddy_list.lo buddy_opt.lo \ -@STATIC_QQ_FALSE@buddy_status.lo qq.lo char_conv.lo crypt.lo \ -@STATIC_QQ_FALSE@group_admindlg.lo group.lo group_conv.lo group_find.lo \ -@STATIC_QQ_FALSE@group_free.lo group_hash.lo group_im.lo group_info.lo \ -@STATIC_QQ_FALSE@group_join.lo group_misc.lo group_network.lo \ -@STATIC_QQ_FALSE@group_opt.lo group_search.lo header_info.lo im.lo \ -@STATIC_QQ_FALSE@infodlg.lo ip_location.lo keep_alive.lo \ -@STATIC_QQ_FALSE@login_logout.lo qq_proxy.lo recv_core.lo send_core.lo \ -@STATIC_QQ_FALSE@sendqueue.lo show.lo sys_msg.lo udp_proxy_s5.lo \ -@STATIC_QQ_FALSE@send_file.lo file_trans.lo -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -DIST_COMMON = Makefile.am Makefile.in - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = tar -GZIP_ENV = --best -DEP_FILES = .deps/buddy_info.P .deps/buddy_list.P .deps/buddy_opt.P \ -.deps/buddy_status.P .deps/char_conv.P .deps/crypt.P .deps/file_trans.P \ -.deps/group.P .deps/group_admindlg.P .deps/group_conv.P \ -.deps/group_find.P .deps/group_free.P .deps/group_hash.P \ -.deps/group_im.P .deps/group_info.P .deps/group_join.P \ -.deps/group_misc.P .deps/group_network.P .deps/group_opt.P \ -.deps/group_search.P .deps/header_info.P .deps/im.P .deps/infodlg.P \ -.deps/ip_location.P .deps/keep_alive.P .deps/login_logout.P \ -.deps/packet_parse.P .deps/qq.P .deps/qq_proxy.P .deps/recv_core.P \ -.deps/send_core.P .deps/send_file.P .deps/sendqueue.P .deps/show.P \ -.deps/sys_msg.P .deps/udp_proxy_s5.P .deps/utils.P -SOURCES = $(libqq_a_SOURCES) $(libqq_la_SOURCES) -OBJECTS = $(libqq_a_OBJECTS) $(libqq_la_OBJECTS) - -all: all-redirect -.SUFFIXES: -.SUFFIXES: .S .c .lo .o .obj .s -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu src/protocols/qq/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - - -mostlyclean-noinstLIBRARIES: - -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) - -distclean-noinstLIBRARIES: - -maintainer-clean-noinstLIBRARIES: - -# FIXME: We should only use cygpath when building on Windows, -# and only if it is available. -.c.obj: - $(COMPILE) -c `cygpath -w $<` - -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - -mostlyclean-compile: - -rm -f *.o core *.core - -rm -f *.$(OBJEXT) - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -.s.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.S.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -maintainer-clean-libtool: - -libqq.a: $(libqq_a_OBJECTS) $(libqq_a_DEPENDENCIES) - -rm -f libqq.a - $(AR) cru libqq.a $(libqq_a_OBJECTS) $(libqq_a_LIBADD) - $(RANLIB) libqq.a - -mostlyclean-pkgLTLIBRARIES: - -clean-pkgLTLIBRARIES: - -test -z "$(pkg_LTLIBRARIES)" || rm -f $(pkg_LTLIBRARIES) - -distclean-pkgLTLIBRARIES: - -maintainer-clean-pkgLTLIBRARIES: - -install-pkgLTLIBRARIES: $(pkg_LTLIBRARIES) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(pkgdir) - @list='$(pkg_LTLIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(pkgdir)/$$p"; \ - $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(pkgdir)/$$p; \ - else :; fi; \ - done - -uninstall-pkgLTLIBRARIES: - @$(NORMAL_UNINSTALL) - list='$(pkg_LTLIBRARIES)'; for p in $$list; do \ - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(pkgdir)/$$p; \ - done - -libqq.la: $(libqq_la_OBJECTS) $(libqq_la_DEPENDENCIES) - $(LINK) -rpath $(pkgdir) $(libqq_la_LDFLAGS) $(libqq_la_OBJECTS) $(libqq_la_LIBADD) $(LIBS) - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP)) - -mostlyclean-tags: - -clean-tags: - -distclean-tags: - -rm -f TAGS ID - -maintainer-clean-tags: - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) - -subdir = src/protocols/qq - -distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu src/protocols/qq/Makefile - @for file in $(DISTFILES); do \ - d=$(srcdir); \ - if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ - else \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file || :; \ - fi; \ - done - -DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) - --include $(DEP_FILES) - -mostlyclean-depend: - -clean-depend: - -distclean-depend: - -rm -rf .deps - -maintainer-clean-depend: - -%.o: %.c - @echo '$(COMPILE) -c $<'; \ - $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-cp .deps/$(*F).pp .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm .deps/$(*F).pp - -%.lo: %.c - @echo '$(LTCOMPILE) -c $<'; \ - $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ - < .deps/$(*F).pp > .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm -f .deps/$(*F).pp -info-am: -info: info-am -dvi-am: -dvi: dvi-am -check-am: all-am -check: check-am -installcheck-am: -installcheck: installcheck-am -install-exec-am: -install-exec: install-exec-am - -install-data-am: install-pkgLTLIBRARIES -install-data: install-data-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: uninstall-pkgLTLIBRARIES -uninstall: uninstall-am -all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -installdirs: - $(mkinstalldirs) $(DESTDIR)$(pkgdir) - - -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -maintainer-clean-generic: -mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ - mostlyclean-libtool mostlyclean-pkgLTLIBRARIES \ - mostlyclean-tags mostlyclean-depend mostlyclean-generic - -mostlyclean: mostlyclean-am - -clean-am: clean-noinstLIBRARIES clean-compile clean-libtool \ - clean-pkgLTLIBRARIES clean-tags clean-depend \ - clean-generic mostlyclean-am - -clean: clean-am - -distclean-am: distclean-noinstLIBRARIES distclean-compile \ - distclean-libtool distclean-pkgLTLIBRARIES \ - distclean-tags distclean-depend distclean-generic \ - clean-am - -rm -f libtool - -distclean: distclean-am - -maintainer-clean-am: maintainer-clean-noinstLIBRARIES \ - maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-pkgLTLIBRARIES maintainer-clean-tags \ - maintainer-clean-depend maintainer-clean-generic \ - distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -maintainer-clean: maintainer-clean-am - -.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ -clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ -mostlyclean-compile distclean-compile clean-compile \ -maintainer-clean-compile mostlyclean-libtool distclean-libtool \ -clean-libtool maintainer-clean-libtool mostlyclean-pkgLTLIBRARIES \ -distclean-pkgLTLIBRARIES clean-pkgLTLIBRARIES \ -maintainer-clean-pkgLTLIBRARIES uninstall-pkgLTLIBRARIES \ -install-pkgLTLIBRARIES tags mostlyclean-tags distclean-tags clean-tags \ -maintainer-clean-tags distdir mostlyclean-depend distclean-depend \ -clean-depend maintainer-clean-depend info-am info dvi-am dvi check \ -check-am installcheck-am installcheck install-exec-am install-exec \ -install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs mostlyclean-generic \ -distclean-generic clean-generic maintainer-clean-generic clean \ -mostlyclean distclean maintainer-clean - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-07-24 13:39:39
|
Revision: 16562 Author: markhuetsch Date: 2006-07-24 06:39:12 -0700 (Mon, 24 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16562&view=rev Log Message: ----------- *Eliminated all Gtk-related code from the prpl. Notably, this included the group ("Qun") administrative dialog and a dialog for setting and viewing personal information. Code for the latter now uses the gaim UI, while the former is currently disabled. *Disabled a few non-functional/non-essential menu actions. These included: IP lookup, system logging, about dialog, and qq_buddy_menu. Modified Paths: -------------- trunk/src/protocols/qq/Makefile.am trunk/src/protocols/qq/Makefile.mingw trunk/src/protocols/qq/buddy_info.c trunk/src/protocols/qq/buddy_info.h trunk/src/protocols/qq/buddy_list.c trunk/src/protocols/qq/buddy_status.c trunk/src/protocols/qq/buddy_status.h trunk/src/protocols/qq/group_opt.c trunk/src/protocols/qq/qq.c trunk/src/protocols/qq/qq_proxy.c trunk/src/protocols/qq/qq_proxy.h trunk/src/protocols/qq/utils.c trunk/src/protocols/qq/utils.h Removed Paths: ------------- trunk/src/protocols/qq/TODO trunk/src/protocols/qq/group_admindlg.c trunk/src/protocols/qq/group_admindlg.h trunk/src/protocols/qq/infodlg.c trunk/src/protocols/qq/infodlg.h trunk/src/protocols/qq/show.c trunk/src/protocols/qq/show.h Modified: trunk/src/protocols/qq/Makefile.am =================================================================== --- trunk/src/protocols/qq/Makefile.am 2006-07-24 09:25:48 UTC (rev 16561) +++ trunk/src/protocols/qq/Makefile.am 2006-07-24 13:39:12 UTC (rev 16562) @@ -21,8 +21,6 @@ char_conv.h \ crypt.c \ crypt.h \ - group_admindlg.c \ - group_admindlg.h \ group.c \ group_conv.c \ group_conv.h \ @@ -52,8 +50,6 @@ header_info.h \ im.c \ im.h \ - infodlg.c \ - infodlg.h \ ip_location.c \ ip_location.h \ keep_alive.c \ @@ -68,8 +64,6 @@ send_core.h \ sendqueue.c \ sendqueue.h \ - show.c \ - show.h \ sys_msg.c \ sys_msg.h \ udp_proxy_s5.c \ @@ -104,6 +98,5 @@ -DLOCALEDIR=\"${datadir}/locale\" \ -DVERSION=\"$(VERSION)\" \ $(DEBUG_CFLAGS) \ - $(GTK_CFLAGS) \ $(GLIB_CFLAGS) \ $(GAIM_CFLAGS) Modified: trunk/src/protocols/qq/Makefile.mingw =================================================================== --- trunk/src/protocols/qq/Makefile.mingw 2006-07-24 09:25:48 UTC (rev 16561) +++ trunk/src/protocols/qq/Makefile.mingw 2006-07-24 13:39:12 UTC (rev 16562) @@ -82,7 +82,6 @@ crypt.c \ file_trans.c \ group.c \ - group_admindlg.c \ group_conv.c \ group_find.c \ group_free.c \ @@ -96,7 +95,6 @@ group_search.c \ header_info.c \ im.c \ - infodlg.c \ ip_location.c \ keep_alive.c \ login_logout.c \ Deleted: trunk/src/protocols/qq/TODO =================================================================== --- trunk/src/protocols/qq/TODO 2006-07-24 09:25:48 UTC (rev 16561) +++ trunk/src/protocols/qq/TODO 2006-07-24 13:39:12 UTC (rev 16562) @@ -1,18 +0,0 @@ -* Decide how to handle QQ status icons, which are customizable and legion. -* Give "Online Offline" and "My Offline" statuses appropriate titles. -* Handle emoticon at beginning of message via passthrough_unknown_commands. -* Fix file transfer. -* QQ protocol currently breaks Chinese localization of Gaim. Fix this. -* Fix ability to insert images into a conversation via the menubar. -* Fix _qq_menu_block_buddy in qq.c -* Eliminate all references to QQWry.dat and the geolocation lookup feature previously present OpenQ. -* Give smileys verbal instead of numerical titles. -* Clean up signedness warnings. -* Clean up mixed declaration and code warnings. -* Better decomposition: -** some of these functions are _really_ long -** buddy_status.c has a helper function which seems to belong in buddy_status.c -** consider cleaning up qq_encrypt (nested function declarations) -** eliminate group_misc.c -** investigate whether all of these externs are appropriate -* Check for memory leaks. Modified: trunk/src/protocols/qq/buddy_info.c =================================================================== --- trunk/src/protocols/qq/buddy_info.c 2006-07-24 09:25:48 UTC (rev 16561) +++ trunk/src/protocols/qq/buddy_info.c 2006-07-24 13:39:12 UTC (rev 16562) @@ -20,11 +20,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ #include "internal.h" // strlen, _("get_text) #include "debug.h" // gaim_debug #include "notify.h" // gaim_notify +#include "request.h" // gaim_request_fields_new #include "utils.h" // uid_to_gaim_name #include "packet_parse.h" // MAX_PACKET_SIZE @@ -32,68 +31,295 @@ #include "char_conv.h" // qq_to_utf8 #include "crypt.h" // qq_crypt #include "header_info.h" // cmd alias -#include "infodlg.h" // info_window #include "keep_alive.h" // qq_update_buddy_contact #include "send_core.h" // qq_send_cmd -// amount of fiedls in user info -#define QQ_CONTACT_FIELDS 37 +// Below is all of the information necessary to reconstruct the various +// information fields that one can set in the official client. When we need +// to know about a specific field (e.g., should "city" be a choice +// or text field?), we can simply look it up from the template. Note that +// there are a number of unidentified fields. -// There is no user id stored in the reply packet for information query -// we have to manually store the query, so that we know the query source -typedef struct _qq_info_query { - guint32 uid; - gboolean show_window; - contact_info *ret_info; -} qq_info_query; +typedef struct _info_field { + gchar *title; + gchar *id; // used by gaim_request fields + gint pos; + gchar *group; + gint group_pos; // for display order in the UI + gint choice; // indicates which character array contains the choices + gboolean customizable; // whether a user can enter any text as a value, regardless of choice arrays + gchar *value; +} info_field; -/*****************************************************************************/ -// send a packet to get detailed information of uid, -// if show_window, a info window will be display upon receiving a reply +static const info_field info_template_data[] = { + { N_("User ID"), "uid", 0, QQ_MAIN_INFO, 0, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Nickname"), "nick", 1, QQ_MAIN_INFO, 1, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Country/Region"), "country", 2, QQ_MAIN_INFO, 5, QQ_COUNTRY, TRUE, NULL }, + { N_("Province/State"), "province", 3, QQ_MAIN_INFO, 6, QQ_PROVINCE, TRUE, NULL }, + { N_("Zipcode"), "zipcode", 4, QQ_EXTRA_INFO, 7, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Address"), "address", 5, QQ_EXTRA_INFO, 6, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Phone Number"), "tel", 6, QQ_EXTRA_INFO, 9, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Age"), "age", 7, QQ_MAIN_INFO, 3, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Gender"), "gender", 8, QQ_MAIN_INFO, 4, QQ_GENDER, FALSE, NULL }, + { N_("Name"), "name", 9, QQ_MAIN_INFO, 2, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Email"), "email", 10, QQ_EXTRA_INFO, 5, QQ_NO_CHOICE, TRUE, NULL }, + { "pager_sn", "pager_sn", 11, QQ_MISC, 0, QQ_NO_CHOICE, TRUE, NULL }, + { "pager_num", "pager_num", 12, QQ_MISC, 1, QQ_NO_CHOICE, TRUE, NULL }, + { "pager_sp", "pager_sp", 13, QQ_MISC, 2, QQ_NO_CHOICE, TRUE, NULL }, + { "pager_base_num", "pager_base_num", 14, QQ_MISC, 3, QQ_NO_CHOICE, TRUE, NULL }, + { "pager_type", "pager_type", 15, QQ_MISC, 4, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Occupation"), "occupation", 16, QQ_EXTRA_INFO, 1, QQ_OCCUPATION, TRUE, NULL }, + { N_("Homepage"), "homepage", 17, QQ_EXTRA_INFO, 10, QQ_NO_CHOICE, TRUE, NULL }, + { "auth_type", "auth_type", 18, QQ_MISC, 5, QQ_NO_CHOICE, TRUE, NULL }, + { "unknown1", "unknown1", 19, QQ_MISC, 6, QQ_NO_CHOICE, TRUE, NULL }, + { "unknown2", "unknown2", 20, QQ_MISC, 7, QQ_NO_CHOICE, TRUE, NULL }, + { "face", "face", 21, QQ_MISC, 8, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Cellphone Number"), "hp_num", 22, QQ_EXTRA_INFO, 8, QQ_NO_CHOICE, TRUE, NULL }, + { "hp_type", "hp_type", 23, QQ_MISC, 9, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Personal Introduction"), "intro", 24, QQ_PERSONAL_INTRO, 0, QQ_NO_CHOICE, TRUE, NULL }, + { N_("City"), "city", 25, QQ_MAIN_INFO, 7, QQ_NO_CHOICE, TRUE, NULL }, + { "unknown3", "unknown3", 26, QQ_MISC, 10, QQ_NO_CHOICE, TRUE, NULL }, + { "unknown4", "unknown4", 27, QQ_MISC, 11, QQ_NO_CHOICE, TRUE, NULL }, + { "unknown5", "unknown5", 28, QQ_MISC, 12, QQ_NO_CHOICE, TRUE, NULL }, + { "is_open_hp", "is_open_hp", 29, QQ_MISC, 13, QQ_NO_CHOICE, TRUE, NULL }, + { "is_open_contact", "is_open_contact", 30, QQ_MISC, 14, QQ_NO_CHOICE, TRUE, NULL }, + { N_("College"), "college", 31, QQ_EXTRA_INFO, 4, QQ_NO_CHOICE, TRUE, NULL }, + { N_("Horoscope Symbol"), "horoscope", 32, QQ_EXTRA_INFO, 0, QQ_HOROSCOPE, FALSE, NULL }, + { N_("Zodiac Symbol"), "zodiac", 33, QQ_EXTRA_INFO, 2, QQ_ZODIAC, FALSE, NULL }, + { N_("Blood Type"), "blood", 34, QQ_EXTRA_INFO, 3, QQ_BLOOD, FALSE, NULL }, + { "qq_show", "qq_show", 35, QQ_MISC, 15, QQ_NO_CHOICE, TRUE, NULL }, + { "unknown6", "unknown6", 36, QQ_MISC, 16, QQ_NO_CHOICE, TRUE, NULL }, + { NULL, NULL, 0, NULL, 0, 0, 0, NULL } //NULL termination +}; + +//TODO: translate these arrays to their English equivalents +// and move these characters to the zh_CN po file +static const gchar *horoscope_names[] = { + "-", "水瓶座", "双鱼座", "牡羊座", "金牛座", + "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", + "天蝎座", "射手座", "魔羯座", NULL +}; + +static const gchar *zodiac_names[] = { + "-", "鼠", "牛", "虎", "兔", + "龙", "蛇", "马", "羊", "猴", + "鸡", "狗", "猪", NULL +}; + +static const gchar *blood_types[] = { + "其它", "A型", "B型", "O型", "AB型", NULL +}; + +static const gchar *genders[] = { + N_("Male"), + N_("Female"), + NULL +}; + +static const gchar *country_names[] = { + "中国", "中国香港", "中国澳门", "中国台湾", + "新加坡", "马来西亚", "美国", NULL +}; + +static const gchar *province_names[] = { + "北京", "天津", "上海", "重庆", "香港", + "河北", "山西", "内蒙古", "辽宁", "吉林", + "黑龙江", "江西", "浙江", "江苏", "安徽", + "福建", "山东", "河南", "湖北", "湖南", + "广东", "广西", "海南", "四川", "贵州", + "云南", "西藏", "陕西", "甘肃", "宁夏", + "青海", "新疆", "台湾", "澳门", NULL +}; + +static const gchar *occupation_names[] = { + "全职", "兼职", "制造业", "商业", "失业中", + "学生", "工程师", "政府部门", "教育业", "服务行业", + "老板", "计算机业", "退休", "金融业", + "销售/广告/市场", NULL +}; + +static const gint choice_sizes[] = { 0, 13, 13, 5, 2, 7, 34, 15 }; + + +static const gchar *info_group_headers[] = { + QQ_MAIN_INFO, + QQ_EXTRA_INFO, + QQ_PERSONAL_INTRO, + QQ_MISC +}; + +static const gchar **choices[] = { + NULL, + horoscope_names, + zodiac_names, + blood_types, + genders, + country_names, + province_names, + occupation_names +}; + +/*************** info and info_field methods *****************/ + +// Given an id, return the template for that field. +// Returns NULL if the id is not found. +static const info_field *info_field_get_template(const gchar *id) +{ + const info_field *cur_field; + const gchar *cur_id; + + cur_field = info_template_data; + cur_id = cur_field->id; + while(cur_id != NULL) { + if (g_ascii_strcasecmp(cur_id, id) == 0) return cur_field; + cur_field++; + cur_id = cur_field->id; + } + gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Info field with id %s not found!", id); + return NULL; +} + +// info_fields are compared by their group positions +static gint info_field_compare(gconstpointer a, gconstpointer b, gpointer unused) +{ + return ((info_field *) a)->group_pos - ((info_field *) b)->group_pos; +} + +static void info_field_free(info_field *i) +{ + g_free(i->value); + g_free(i); +} + +// Parses the info_template_data above and returns a newly-allocated list +// containing the desired fields from segments. This list is ordered by +// group_pos. +static GList *info_get_group(const gchar **info, const gchar *group_name) +{ + const info_field *cur; + info_field *entry; + GList *group = NULL; + + cur = info_template_data; + while (cur->id != NULL) { + if (g_ascii_strcasecmp(group_name, cur->group) == 0) { + entry = g_memdup(cur, sizeof(info_field)); + entry->value = g_strdup(info[entry->pos]); + group = g_list_insert_sorted_with_data(group, entry, info_field_compare, NULL); + } + cur++; + } + + return group; +} + +// determines if the given text value and choice group require +// a lookup from the choice arrays +static gboolean is_valid_index(gchar *value, gint choice) +{ + gint len, i; + + if (choice == 0) return FALSE; + len = strlen(value); + // the server sends us an ascii index and none of arrays has more than 99 + // elements + if (len > 3 || len == 0) return FALSE; + for (i = 0; i < len; i++) + if (!g_ascii_isdigit(value[i])) return FALSE; + i = atoi(value); + if (i < 0 || i >= choice_sizes[choice]) return FALSE; + return TRUE; +} + +// formats a field for printing +static void append_field_to_str(gpointer field, gpointer str) +{ + info_field *f; + gint choice; + gboolean valid_index; + gchar *value; + + f = (info_field *) field; + choice = f->choice; + valid_index = is_valid_index(f->value, choice); + if (choice && valid_index) value = g_strdup(choices[choice][atoi(f->value)]); + else value = qq_to_utf8(f->value, QQ_CHARSET_DEFAULT); + g_string_append_printf((GString *) str, "<b>%s:</b> %s<br />", + f->title, value); + g_free(value); + info_field_free(f); +} + +// formats a group of information for printing +static void append_group_to_str(GString *str, const gchar *group_name, const gchar **info) +{ + GList *group; + + group = info_get_group(info, group_name); + g_string_append_printf(str, "<b>%s</b><br /><br />", (*(info_field *) group->data).group); + g_list_foreach(group, append_field_to_str, str); + g_list_free(group); + g_string_append_printf(str, "<br />"); +} + +// takes a contact_info struct and outputs the appropriate fields in +// a printable format for our upcoming call to gaim_notify_userinfo +static GString *info_to_str(const gchar **info) +{ + GString *info_text; + + info_text = g_string_new(""); + append_group_to_str(info_text, QQ_MAIN_INFO, info); + append_group_to_str(info_text, QQ_EXTRA_INFO, info); + append_group_to_str(info_text, QQ_PERSONAL_INTRO, info); + //if (QQ_DEBUG) append_group_to_str(info_text, QQ_MISC, info); + + return info_text; +} + +/*************** packets and UI management *****************/ + +// send a packet to get detailed information of uid void qq_send_packet_get_info(GaimConnection * gc, guint32 uid, gboolean show_window) { qq_data *qd; gchar *uid_str; - GList *list; qq_info_query *query; - gboolean is_exist; - contact_info_window *info_window; g_return_if_fail(gc != NULL && gc->proto_data != NULL && uid != 0); qd = (qq_data *) gc->proto_data; uid_str = g_strdup_printf("%d", uid); - qq_send_cmd(gc, QQ_CMD_GET_USER_INFO, TRUE, 0, TRUE, uid_str, strlen(uid_str)); + qq_send_cmd(gc, QQ_CMD_GET_USER_INFO, TRUE, 0, TRUE, (guint8 *) uid_str, strlen(uid_str)); - if (show_window) { // prepare the window - is_exist = FALSE; // see if there is already a window for this uid - list = qd->contact_info_window; - while (list != NULL) { - info_window = (contact_info_window *) list->data; - if (uid == info_window->uid) { - is_exist = TRUE; - break; - } else - list = list->next; - } // while list - if (!is_exist) { // create a new one - info_window = g_new0(contact_info_window, 1); - info_window->uid = uid; - qd->contact_info_window = g_list_append(qd->contact_info_window, info_window); - } // if !is_exist - } // if show_window - query = g_new0(qq_info_query, 1); query->uid = uid; query->show_window = show_window; + query->modify_info = FALSE; qd->info_query = g_list_append(qd->info_query, query); g_free(uid_str); -} // qq_send_packet_get_info +} -/*****************************************************************************/ +// set up the fields requesting personal information and send a get_info packet +// for myself +void qq_prepare_modify_info(GaimConnection *gc) +{ + qq_data *qd; + GList *ql; + qq_info_query *query; + + qd = (qq_data *) gc->proto_data; + qq_send_packet_get_info(gc, qd->uid, FALSE); + // traverse backwards so we get the most recent info_query + for (ql = g_list_last(qd->info_query); ql != NULL; ql = g_list_previous(ql)) { + query = ql->data; + if (query->uid == qd->uid) query->modify_info = TRUE; + } +} + // send packet to modify personal information, and/or change password -void qq_send_packet_modify_info(GaimConnection * gc, contact_info * info, gchar * new_passwd) +void qq_send_packet_modify_info(GaimConnection *gc, contact_info *info, gchar *new_passwd) { GaimAccount *a; gchar *old_passwd, *info_field[QQ_CONTACT_FIELDS]; @@ -112,27 +338,175 @@ if (new_passwd == NULL || strlen(new_passwd) == 0) create_packet_b(raw_data, &cursor, bar); - else { // we gonna change passwd - create_packet_data(raw_data, &cursor, old_passwd, strlen(old_passwd)); + else { // we're gonna change passwd + create_packet_data(raw_data, &cursor, (guint8 *) old_passwd, strlen(old_passwd)); create_packet_b(raw_data, &cursor, bar); - create_packet_data(raw_data, &cursor, new_passwd, strlen(new_passwd)); + create_packet_data(raw_data, &cursor, (guint8 *) new_passwd, strlen(new_passwd)); } // important!, skip the first uid entry for (i = 1; i < QQ_CONTACT_FIELDS; i++) { create_packet_b(raw_data, &cursor, bar); - create_packet_data(raw_data, &cursor, info_field[i], strlen(info_field[i])); + create_packet_data(raw_data, &cursor, (guint8 *) info_field[i], strlen(info_field[i])); } create_packet_b(raw_data, &cursor, bar); qq_send_cmd(gc, QQ_CMD_UPDATE_INFO, TRUE, 0, TRUE, raw_data, cursor - raw_data); -} // qq_send_packet_modify_info +} -/*****************************************************************************/ -// process the reply of modidy_info packet -void qq_process_modify_info_reply(guint8 * buf, gint buf_len, GaimConnection * gc) +static void modify_info_cancel_cb(modify_info_data *mid) { + g_list_free(mid->misc); + g_free(mid); +} + +// runs through all of the fields in the modify info UI and put +// their values into the outgoing packet +static void parse_field(gpointer field, gpointer outgoing_info) +{ + GaimRequestField *f; + gchar **segments, *value; + const info_field *ft; + const gchar *id; + + f = (GaimRequestField *) field; + segments = (gchar **) outgoing_info; + id = gaim_request_field_get_id(f); + ft = info_field_get_template(id); + if (ft->choice && !ft->customizable) + value = g_strdup_printf("%d", gaim_request_field_choice_get_value(f)); + else { + value = (gchar *) gaim_request_field_string_get_value(f); + if (value == NULL) value = g_strdup(""); + else value = utf8_to_qq(value, QQ_CHARSET_DEFAULT); + } + segments[ft->pos] = value; +} + +// dumps the uneditable information straight into the outgoing packet +static void parse_misc_field(gpointer field, gpointer outgoing_info) +{ + info_field *f; + gchar **segments; + + f = (info_field *) field; + segments = (gchar **) outgoing_info; + segments[f->pos] = g_strdup(f->value); + info_field_free(f); +} + +// runs through all of the information fields and copies them into an +// outgoing packet, then sends that packet +static void modify_info_ok_cb(modify_info_data *mid, GaimRequestFields *fields) +{ + GaimConnection *gc; + GList *list, *groups, *group_node; + gchar *info_field[QQ_CONTACT_FIELDS]; + contact_info *info; + gint i; + + gc = mid->gc; + list = mid->misc; + g_list_foreach(list, parse_misc_field, info_field); + g_list_free(list); + groups = gaim_request_fields_get_groups(fields); + while(groups) { + group_node = groups; + list = gaim_request_field_group_get_fields(group_node->data); + g_list_foreach(list, parse_field, info_field); + groups = g_list_remove_link(groups, group_node); + } + info = (contact_info *) info_field; + + qq_send_packet_modify_info(gc, info, NULL); + g_free(mid); + for (i = 0; i < QQ_CONTACT_FIELDS; i++) + g_free(info_field[i]); +} + +// Sets up the display for one group of information. This includes +// managing which fields in the UI should be textfields and +// which choices, and also mapping ints to choice values when appropriate. +static void setup_group(gpointer field, gpointer group) +{ + info_field *f; + GaimRequestFieldGroup *g; + GaimRequestField *rf; + gint choice, index, j; + gboolean customizable, valid_index, multiline; + gchar *id, *value; + + f = (info_field *) field; + g = (GaimRequestFieldGroup *) group; + choice = f->choice; + customizable = f->customizable; + id = f->id; + valid_index = TRUE; + + if (!choice || customizable) { + valid_index = is_valid_index(f->value, choice); + multiline = id == "intro"; + if (valid_index) { + index = atoi(f->value); + value = (gchar *) choices[choice][index]; + } else value = qq_to_utf8(f->value, QQ_CHARSET_DEFAULT); + rf = gaim_request_field_string_new(id, f->title, value, multiline); + } else { + index = atoi(f->value); + value = (gchar *) choices[choice][index]; + rf = gaim_request_field_choice_new(id, f->title, index); + j = 0; + while(choices[choice][j] != NULL) + gaim_request_field_choice_add(rf, choices[choice][j++]); + } + gaim_request_field_group_add_field(g, rf); + if (!valid_index) g_free(value); + info_field_free(f); +} + +// Takes the info returned by a get_info packet for the user and sets up +// a form using those values and the info_template. +static void create_modify_info_dialogue(GaimConnection *gc, const gchar **info) +{ + GaimRequestFields *fields; + GaimRequestFieldGroup *group; + GaimRequestField *field; + GList *group_list; + modify_info_data *mid; + gint i; + + fields = gaim_request_fields_new(); + + // we only care about the first 3 groups, not the miscellaneous stuff + for (i = 0; i < 3; i++) { + group = gaim_request_field_group_new(info_group_headers[i]); + gaim_request_fields_add_group(fields, group); + group_list = info_get_group(info, info_group_headers[i]); + g_list_foreach(group_list, setup_group, group); + g_list_free(group_list); + } + + //set this manually here instead of generating a new template column + field = gaim_request_fields_get_field(fields, "uid"); + gaim_request_field_string_set_editable(field, FALSE); + + //we need to pass the info that doesn't get modified as aux data + //because we'll still need it when we send the modify_info packet + mid = g_new0(modify_info_data, 1); + mid->gc = gc; + mid->misc = info_get_group(info, info_group_headers[3]); + + gaim_request_fields(gc, _("Modify my information"), + _("Modify my information"), NULL, fields, + _("Update my information"), G_CALLBACK(modify_info_ok_cb), + _("Cancel"), G_CALLBACK(modify_info_cancel_cb), + mid); +} + +// process the reply of modify_info packet +void qq_process_modify_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; gint len; guint8 *data; @@ -145,18 +519,17 @@ data = g_newa(guint8, len); if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { - if (qd->uid == atoi(data)) { // return should be my uid + if (qd->uid == atoi((gchar *) data)) { // return should be my uid gaim_debug(GAIM_DEBUG_INFO, "QQ", "Update info ACK OK\n"); - gaim_notify_info(gc, NULL, _("You information have been updated"), NULL); + gaim_notify_info(gc, NULL, _("Your information has been updated"), NULL); } } else gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt modify info reply\n"); -} // qq_process_modify_info_reply +} -/*****************************************************************************/ // after getting info or modify myself, refresh the buddy list accordingly -void qq_refresh_buddy_and_myself(contact_info * info, GaimConnection * gc) +void qq_refresh_buddy_and_myself(contact_info *info, GaimConnection *gc) { GaimBuddy *b; qq_data *qd; @@ -182,13 +555,16 @@ if (alias_utf8 != NULL) q_bud->nickname = g_strdup(alias_utf8); qq_update_buddy_contact(gc, q_bud); - } // if q_bud + } g_free(alias_utf8); -} // qq_refresh_buddy_and_myself +} -/*****************************************************************************/ +// XXX When we don't have any immediate response, we send duplicate get info packets +// to the server. If the server ends up responding to multiple packets, we get multiple +// modify info dialogues, which is annoying. Fix this. + // process reply to get_info packet -void qq_process_get_info_reply(guint8 * buf, gint buf_len, GaimConnection * gc) +void qq_process_get_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { gint len; guint8 *data; @@ -196,9 +572,8 @@ qq_info_query *query; qq_data *qd; contact_info *info; - contact_info_window *info_window; - gboolean show_window; GList *list, *query_list; + GString *info_text; g_return_if_fail(gc != NULL && gc->proto_data != NULL); g_return_if_fail(buf != NULL && buf_len != 0); @@ -217,42 +592,30 @@ qq_refresh_buddy_and_myself(info, gc); query_list = qd->info_query; - show_window = FALSE; - while (query_list != NULL) { + // ensure we're processing the right query + while (query_list) { query = (qq_info_query *) query_list->data; if (query->uid == atoi(info->uid)) { - show_window = query->show_window; + if (query->show_window) { + info_text = info_to_str((const gchar **) segments); + gaim_notify_userinfo(gc, info->uid, info_text->str, NULL, NULL); + g_string_free(info_text, TRUE); + } else if (query->modify_info) { + create_modify_info_dialogue(gc, (const gchar **) segments); + } qd->info_query = g_list_remove(qd->info_query, qd->info_query->data); g_free(query); break; } query_list = query_list->next; - } // while query_list + } - if (!show_window) { - g_strfreev(segments); - return; - } - // if not show_window, we can not find the window here either - list = qd->contact_info_window; - while (list != NULL) { - info_window = (contact_info_window *) (list->data); - if (info_window->uid == atoi(info->uid)) { - if (info_window->window) - qq_refresh_contact_info_dialog(info, gc, info_window); - else - qq_show_contact_info_dialog(info, gc, info_window); - break; - } else - list = list->next; - } // while list g_strfreev(segments); } else gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt get info reply\n"); -} // qq_process_get_info_reply +} -/*****************************************************************************/ void qq_info_query_free(qq_data * qd) { gint i; @@ -268,7 +631,4 @@ i++; } gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d info queries are freed!\n", i); -} // qq_add_buddy_request_free - -/*****************************************************************************/ -// END OF FILE +} Modified: trunk/src/protocols/qq/buddy_info.h =================================================================== --- trunk/src/protocols/qq/buddy_info.h 2006-07-24 09:25:48 UTC (rev 16561) +++ trunk/src/protocols/qq/buddy_info.h 2006-07-24 13:39:12 UTC (rev 16562) @@ -40,9 +40,7 @@ #define QQ_BUDDY_GENDER_MM 0x01 #define QQ_BUDDY_GENDER_UNKNOWN 0xff -typedef struct _contact_info contact_info; - -struct _contact_info { +typedef struct _contact_info { gchar *uid; //0 gchar *nick; //1 gchar *country; //2 @@ -80,15 +78,46 @@ gchar *blood; //34 gchar *qq_show; //35 gchar *unknown6; //36, always 0x2D -}; +} contact_info; -void qq_refresh_buddy_and_myself(contact_info * info, GaimConnection * gc); -void qq_send_packet_get_info(GaimConnection * gc, guint32 uid, gboolean show_window); -void qq_send_packet_modify_info(GaimConnection * gc, contact_info * info, gchar * new_passwd); -void qq_process_modify_info_reply(guint8 * buf, gint buf_len, GaimConnection * gc); -void qq_process_get_info_reply(guint8 * buf, gint buf_len, GaimConnection * gc); -void qq_info_query_free(qq_data * qd); +// There is no user id stored in the reply packet for information query +// we have to manually store the query, so that we know the query source +typedef struct _qq_info_query { + guint32 uid; + gboolean show_window; + gboolean modify_info; +} qq_info_query; +// We get an info packet on ourselves before we modify our information. +// Even though not all of the information is currently modifiable, it still +// all needs to be there when we send out the modify info packet +typedef struct _modify_info_data { + GaimConnection *gc; + GList *misc, *node; +} modify_info_data; + +#define QQ_CONTACT_FIELDS 37 + +#define QQ_MAIN_INFO "Primary Information" +#define QQ_EXTRA_INFO "Detailed Information" +#define QQ_PERSONAL_INTRO "Personal Introduction" +#define QQ_MISC "Miscellaneous" + +#define QQ_NO_CHOICE 0 +#define QQ_HOROSCOPE 1 +#define QQ_ZODIAC 2 +#define QQ_BLOOD 3 +#define QQ_GENDER 4 +#define QQ_COUNTRY 5 +#define QQ_PROVINCE 6 +#define QQ_OCCUPATION 7 + +void qq_refresh_buddy_and_myself(contact_info *info, GaimConnection *gc); +void qq_send_packet_get_info(GaimConnection *gc, guint32 uid, gboolean show_window); +void qq_send_packet_modify_info(GaimConnection *gc, contact_info *info, gchar *new_passwd); +void qq_prepare_modify_info(GaimConnection *gc); +void qq_process_modify_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc); +void qq_process_get_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc); +void qq_info_query_free(qq_data *qd); + #endif -/*****************************************************************************/ -// END OF FILE Modified: trunk/src/protocols/qq/buddy_list.c =================================================================== --- trunk/src/protocols/qq/buddy_list.c 2006-07-24 09:25:48 UTC (rev 16561) +++ trunk/src/protocols/qq/buddy_list.c 2006-07-24 13:39:12 UTC (rev 16562) @@ -42,6 +42,8 @@ #include "group_hash.h" //qq_group_create_by_id #include "group_info.h" //qq_send_cmd_group_get_group_info +#include "qq_proxy.h" + #define QQ_GET_ONLINE_BUDDY_02 0x02 #define QQ_GET_ONLINE_BUDDY_03 0x03 // unknown function @@ -56,13 +58,6 @@ guint8 ending; //0x00 } qq_friends_online_entry; -//TODO: defined in qq_buddy_status.c, but only used here. Check decomposition. -extern void // defined in qq_buddy_status.c - _qq_buddy_status_dump_unclear(qq_buddy_status * s); - -extern gint // defined in qq_buddy_status.c - _qq_buddy_status_read(guint8 * data, guint8 ** cursor, gint len, qq_buddy_status * s); - /*****************************************************************************/ // get a list of online_buddies void qq_send_packet_get_buddies_online(GaimConnection * gc, guint8 position) @@ -148,7 +143,7 @@ g_return_if_fail(fe != NULL); - _qq_buddy_status_dump_unclear(fe->s); + qq_buddy_status_dump_unclear(fe->s); dump = g_string_new(""); g_string_append_printf(dump, "unclear fields for [%d]:\n", fe->s->uid); @@ -180,9 +175,14 @@ data = g_newa(guint8, len); cursor = data; + gaim_debug(GAIM_DEBUG_INFO, "QQ", "processing get_buddies_online_reply\n"); + if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + _qq_show_packet("Get buddies online reply packet", data, len); + read_packet_b(data, &cursor, len, &position); + fe = g_newa(qq_friends_online_entry, 1); fe->s = g_newa(qq_buddy_status, 1); @@ -190,7 +190,7 @@ // based on one online buddy entry bytes = 0; // 000-030 qq_buddy_status - bytes += _qq_buddy_status_read(data, &cursor, len, fe->s); + bytes += qq_buddy_status_read(data, &cursor, len, fe->s); // 031-032: unknown4 bytes += read_packet_w(data, &cursor, len, &fe->unknown1); // 033-033: flag1 @@ -209,8 +209,8 @@ continue; } // check if it is a valid entry -// if (QQ_DEBUG) -// _qq_buddies_online_reply_dump_unclear(fe); + if (QQ_DEBUG) + _qq_buddies_online_reply_dump_unclear(fe); // update buddy information b = gaim_find_buddy(gaim_connection_get_account(gc), uid_to_gaim_name(fe->s->uid)); @@ -219,10 +219,10 @@ if (q_bud != NULL) { // we find one and update qq_buddy if(0 != fe->s->client_version) q_bud->client_version = fe->s->client_version; //by gfhuang - if(0 != *((guint32 *)fe->s->ip)) { // by gfhuang + // if(0 != *((guint32 *)fe->s->ip)) { // by gfhuang g_memmove(q_bud->ip, fe->s->ip, 4); q_bud->port = fe->s->port; - } + // } q_bud->status = fe->s->status; q_bud->flag1 = fe->flag1; q_bud->comm_flag = fe->comm_flag; Modified: trunk/src/protocols/qq/buddy_status.c =================================================================== --- trunk/src/protocols/qq/buddy_status.c 2006-07-24 09:25:48 UTC (rev 16561) +++ trunk/src/protocols/qq/buddy_status.c 2006-07-24 13:39:12 UTC (rev 16562) @@ -34,6 +34,8 @@ #include "keep_alive.h" // qq_update_buddy_contact #include "send_core.h" // qq_send_cmd +#include "qq_proxy.h" + #define QQ_MISC_STATUS_HAVING_VIIDEO 0x00000001 #define QQ_ICON_SUFFIX_DEFAULT QQ_ICON_SUFFIX_OFFLINE @@ -46,7 +48,7 @@ }; /*****************************************************************************/ -static void _qq_buddy_status_dump_unclear(qq_buddy_status * s) +void qq_buddy_status_dump_unclear(qq_buddy_status * s) { GString *dump; @@ -55,14 +57,23 @@ dump = g_string_new(""); g_string_append_printf(dump, "unclear fields for [%d]:\n", s->uid); g_string_append_printf(dump, "004: %02x (unknown)\n", s->unknown1); + //g_string_append_printf(dump, "005-008: %09x (ip)\n", *(s->ip)); + g_string_append_printf(dump, "009-010: %04x (port)\n", s->port); g_string_append_printf(dump, "011: %02x (unknown)\n", s->unknown2); + g_string_append_printf(dump, "012: %02x (status)\n", s->status); + g_string_append_printf(dump, "013-014: %04x (client_version)\n", s->client_version); + //g_string_append_printf(dump, "015-030: %s (unknown key)\n", s->unknown_key); gaim_debug(GAIM_DEBUG_INFO, "QQ", "Buddy status entry, %s", dump->str); + _qq_show_packet("Unknown key", s->unknown_key, QQ_KEY_LENGTH); g_string_free(dump, TRUE); -} // _qq_buddy_status_dump_unclear +} /*****************************************************************************/ +// TODO: figure out what's going on with the IP region. Sometimes I get things which +// may be valid IP addresses, but the port number's weird, other times I get 0s. +// Note: I get these simultaneously on the same buddy, using different accounts to get info. // parse the data into qq_buddy_status -gint _qq_buddy_status_read(guint8 * data, guint8 ** cursor, gint len, qq_buddy_status * s) { +gint qq_buddy_status_read(guint8 * data, guint8 ** cursor, gint len, qq_buddy_status * s) { gint bytes; g_return_val_if_fail(data != NULL && *cursor != NULL && s != NULL, -1); @@ -73,9 +84,12 @@ bytes += read_packet_dw(data, cursor, len, &s->uid); // 004-004: 0x01 bytes += read_packet_b(data, cursor, len, &s->unknown1); + // this is no longer the IP, it seems QQ (as of 2006) no longer sends + // the buddy's IP in this packet. all 0s // 005-008: ip s->ip = g_new0(guint8, 4); bytes += read_packet_data(data, cursor, len, s->ip, 4); + // port info is no longer here either // 009-010: port bytes += read_packet_w(data, cursor, len, &s->port); // 011-011: 0x00 @@ -93,7 +107,7 @@ return bytes; -} // _qq_buddy_status_read +} /*****************************************************************************/ // check if status means online or offline @@ -159,7 +173,7 @@ break; default: away_cmd = QQ_BUDDY_ONLINE_NORMAL; - } // switch + } raw_data = g_new0(guint8, 5); cursor = raw_data; @@ -175,7 +189,7 @@ qq_send_cmd(gc, QQ_CMD_CHANGE_ONLINE_STATUS, TRUE, 0, TRUE, raw_data, 5); g_free(raw_data); -} // qq_send_packet_change_status +} /*****************************************************************************/ // parse the reply packet for change_status @@ -201,7 +215,7 @@ } else gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt chg status reply\n"); -} // qq_process_change_status_reply +} /*****************************************************************************/ // it is a server message @@ -228,7 +242,7 @@ s = g_new0(qq_buddy_status, 1); bytes = 0; // 000-030: qq_buddy_status; - bytes += _qq_buddy_status_read(data, &cursor, len, s); + bytes += qq_buddy_status_read(data, &cursor, len, s); // 031-034: my uid bytes += read_packet_dw(data, &cursor, len, &my_uid); @@ -242,19 +256,19 @@ // if (QQ_DEBUG) gfhuang // _qq_buddy_status_dump_unclear(s); - name = uid_to_gaim_name(s->uid); //by gfhuang + name = uid_to_gaim_name(s->uid); b = gaim_find_buddy(gc->account, name); g_free(name); q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; if (q_bud) { gaim_debug(GAIM_DEBUG_INFO, "QQ", "s->uid = %d, q_bud->uid = %d\n", s->uid , q_bud->uid); - if(0 != *((guint32 *)s->ip)) { //by gfhuang + if(0 != *((guint32 *)s->ip)) { g_memmove(q_bud->ip, s->ip, 4); q_bud->port = s->port; } q_bud->status = s->status; if(0 != s->client_version) - q_bud->client_version = s->client_version; //gfhuang + q_bud->client_version = s->client_version; qq_update_buddy_contact(gc, q_bud); } else @@ -265,8 +279,7 @@ g_free(s); } else gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt buddy status change packet\n"); +} -} // qq_process_friend_change_status - /*****************************************************************************/ // END OF FILE Modified: trunk/src/protocols/qq/buddy_status.h =================================================================== --- trunk/src/protocols/qq/buddy_status.h 2006-07-24 09:25:48 UTC (rev 16561) +++ trunk/src/protocols/qq/buddy_status.h 2006-07-24 13:39:12 UTC (rev 16562) @@ -56,9 +56,11 @@ QQ_SELF_STATUS_CUSTOM = 0x14, QQ_SELF_STATUS_IDLE = 0x15, }; - + +void qq_buddy_status_dump_unclear(qq_buddy_status * s); gboolean is_online(guint8 status); +gint qq_buddy_status_read(guint8 * data, guint8 ** cursor, gint len, qq_buddy_status * s); gchar get_suffix_from_status(guint8 status); void qq_send_packet_change_status(GaimConnection * gc); Deleted: trunk/src/protocols/qq/group_admindlg.c =================================================================== --- trunk/src/protocols/qq/group_admindlg.c 2006-07-24 09:25:48 UTC (rev 16561) +++ trunk/src/protocols/qq/group_admindlg.c 2006-07-24 13:39:12 UTC (rev 16562) @@ -1,659 +0,0 @@ -/** -* The QQ2003C protocol plugin - * - * for gaim - * - * Copyright (C) 2004 Puzzlebird - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -// START OF FILE -/*****************************************************************************/ -#include "debug.h" // gaim_debug -#include "blist.h" // GAIM_BLIST_NODE_IS_BUDDY -#include "notify.h" // gaim_notify_warning - -#include "utils.h" // gaim_name_to_uid -#include "group_admindlg.h" -#include "group_find.h" // qq_group_find_by_internal_group_id -#include "group_join.h" // auth_type -#include "group_opt.h" // QQ_GROUP_TYPE_PERMANENT - -enum { - COLUMN_SELECTED = 0, - COLUMN_UID, - COLUMN_NICKNAME, - NUM_COLUMNS -}; - -enum { - PAGE_INFO = 0, - PAGE_MEMBER, -}; - -typedef struct _qun_info_window { - guint32 internal_group_id; - GaimConnection *gc; - GtkWidget *window; - GtkWidget *notebook; - GtkWidget *lbl_external_group_id; - GtkWidget *lbl_admin_uid; - GtkWidget *ent_group_name; - GtkWidget *cmb_group_category; - GtkWidget *txt_group_desc; - GtkWidget *txt_group_notice; - GtkWidget *rad_auth[3]; - GtkWidget *btn_mod; - GtkWidget *btn_close; - GtkWidget *tre_members; -} qun_info_window; - -const gchar *qq_group_category[] = { - "同学", "朋友", "同事", "其他", -}; // qq_group_category - -const gchar *qq_group_auth_type_desc[] = { - "无须认证", "需要认证", "不可添加", -}; // qq_group_auth_type_desc - -/*****************************************************************************/ -static void _qq_group_info_window_deleteevent(GtkWidget * widget, GdkEvent * event, gpointer data) { - gtk_widget_destroy(widget); // this will call _window_destroy -} // _window_deleteevent - -/*****************************************************************************/ -static void _qq_group_info_window_close(GtkWidget * widget, gpointer data) -{ - // this will call _info_window_destroy if it is info-window - gtk_widget_destroy(GTK_WIDGET(data)); -} // _window_close - -/*****************************************************************************/ -static void _qq_group_info_window_destroy(GtkWidget * widget, gpointer data) -{ - GaimConnection *gc; - GList *list; - qq_data *qd; - qun_info_window *info_window; - - gc = (GaimConnection *) data; - g_return_if_fail(gc != NULL && gc->proto_data != NULL); - gaim_debug(GAIM_DEBUG_INFO, "QQ", "Group info is destoryed\n"); - - qd = (qq_data *) gc->proto_data; - list = qd->qun_info_window; - - while (list) { - info_window = (qun_info_window *) (list->data); - if (info_window->window != widget) - list = list->next; - else { - qd->qun_info_window = g_list_remove(qd->qun_info_window, info_window); - g_free(info_window); - break; - } // if info_window - } // while -} // _window_destroy - -/*****************************************************************************/ -void qq_qun_info_window_free(qq_data * qd) -{ - gint i; - qun_info_window *info_window; - - i = 0; - while (qd->qun_info_window) { - info_window = (qun_info_window *) qd->qun_info_window->data; - qd->qun_info_window = g_list_remove(qd->qun_info_window, info_window); - if (info_window->window) - gtk_widget_destroy(info_window->window); - g_free(info_window); - i++; - } // while - - gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d Qun info windows are freed\n", i); -} // qq_qun_info_window_free - -/*****************************************************************************/ -static void _qq_group_info_window_modify(GtkWidget * widget, gpointer data) -{ - GaimConnection *gc; - qun_info_window *info_window; - - g_return_if_fail(data != NULL); - info_window = (qun_info_window *) data; - - gc = info_window->gc; - g_return_if_fail(gc != NULL && gc->proto_data != NULL); - - //henry: This function contains some codes only supported by gtk-2.4 or later -//#if !GTK_CHECK_VERSION(2,4,0) -// gaim_notify_info(gc, _("QQ Qun Operation"), -// _("This version of GTK-2 does not support this function"), NULL); -// return; -//#else - gint page, group_category, i = 0; - qq_group *group; - qq_data *qd; - GtkTextIter start, end; - GtkTreeModel *model; - GtkTreeIter iter; - GValue value = { 0, }; - guint32 *new_members; - guint32 uid; - gboolean selected; - - qd = (qq_data *) gc->proto_data; - - // we assume the modification can succeed - // maybe it needs some tweak here - group = qq_group_find_by_internal_group_id(gc, info_window->internal_group_id); - g_return_if_fail(group != NULL); - - new_members = g_newa(guint32, QQ_QUN_MEMBER_MAX); - - page = gtk_notebook_get_current_page(GTK_NOTEBOOK(info_window->notebook)); - switch (page) { - case PAGE_INFO: - gaim_debug(GAIM_DEBUG_INFO, "QQ", "Gonna change Qun detailed information\n"); - // get the group_category -#if GTK_CHECK_VERSION(2,4,0) - group_category = gtk_combo_box_get_active(GTK_COMBO_BOX(info_window->cmb_group_category)); -#else - group_category = gtk_option_menu_get_history(GTK_OPTION_MENU(info_window->cmb_group_category)); -#endif - - if (group_category >= 0) - group->group_category = group_category; - else { - g_free(group); - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Invalid group_category: %d\n", group_category); - return; - } // if group_category - // get auth_type - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info_window->rad_auth[0]))) - group->auth_type = QQ_GROUP_AUTH_TYPE_NO_AUTH; - else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info_window->rad_auth[1]))) - group->auth_type = QQ_GROUP_AUTH_TYPE_NEED_AUTH; - else - group->auth_type = QQ_GROUP_AUTH_TYPE_NO_ADD; - // MUST use g_strdup, otherwise core dump after info_window is closed - group->group_name_utf8 = g_strdup(gtk_entry_get_text(GTK_ENTRY(info_window->ent_group_name))); - gtk_text_buffer_get_bounds(gtk_text_view_get_buffer - (GTK_TEXT_VIEW(info_window->txt_group_desc)), &start, &end); - group->group_desc_utf8 = - g_strdup(gtk_text_buffer_get_text - (gtk_text_view_get_buffer - (GTK_TEXT_VIEW(info_window->txt_group_desc)), &start, &end, FALSE)); - gtk_text_buffer_get_bounds(gtk_text_view_get_buffer - (GTK_TEXT_VIEW(info_window->txt_group_notice)), &start, &end); - group->notice_utf8 = - g_strdup(gtk_text_buffer_get_text - (gtk_text_view_get_buffer - (GTK_TEXT_VIEW(info_window->txt_group_notice)), &start, &end, FALSE)); - // finally we can modify it with new information - qq_group_modify_info(gc, group); - break; - case PAGE_MEMBER: - if (info_window->tre_members == NULL) { - gaim_debug(GAIM_DEBUG_INFO, "QQ", "Member list is not ready, cannot modify!\n"); - } else { - gaim_debug(GAIM_DEBUG_INFO, "QQ", "Gonna change Qun member list\n"); - model = gtk_tree_view_get_model(GTK_TREE_VIEW(info_window->tre_members)); - if (gtk_tree_model_get_iter_first(model, &iter)) { - gtk_tree_model_get_value(model, &iter, COLUMN_UID, &value); - uid = g_value_get_uint(&value); - g_value_unset(&value); - gtk_tree_model_get_value(model, &iter, COLUMN_SELECTED, &value); - selected = g_value_get_boolean(&value); - g_value_unset(&value); - if (!selected) - new_members[i++] = uid; - while (gtk_tree_model_iter_next(model, &iter)) { - gtk_tree_model_get_value(model, &iter, COLUMN_UID, &value); - uid = g_value_get_uint(&value); - g_value_unset(&value); - gtk_tree_model_get_value(model, &iter, COLUMN_SELECTED, &value); - selected = g_value_get_boolean(&value); - g_value_unset(&value); - if (!selected) - new_members[i++] = uid; - } // while - new_members[i] = 0xffffffff; // this labels the end - } else - new_members[0] = 0xffffffff; - qq_group_modify_members(gc, group, new_members); - } // if info_window->tre_members - break; - default: - gaim_debug(GAIM_DEBUG_INFO, "QQ", "Invalid page number: %d\n", page); - } // switch - - _qq_group_info_window_close(NULL, info_window->window); - -//#endif /* GTK_CHECK_VERSION */ -} // _qq_group_info_window_modify - -/*****************************************************************************/ -static void _qq_group_member_list_deleted_toggled(GtkCellRendererToggle * cell, gchar * path_str, gpointer data) { - qun_info_window *info_window; - GaimConnection *gc; - qq_group *group; - - info_window = (qun_info_window *) data; - g_return_if_fail(info_window != NULL); - - gc = info_window->gc; - g_return_if_fail(gc != NULL); - - group = qq_group_find_by_internal_group_id(gc, info_window->internal_group_id); - g_return_if_fail(group != NULL); - - GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(info_window->tre_members)); - GtkTreeIter iter; - GtkTreePath *path = gtk_tree_path_new_from_string(path_str); - gboolean selected; - guint32 uid; - - gtk_tree_model_get_iter(model, &iter, path); - gtk_tree_model_get(model, &iter, COLUMN_SELECTED, &selected, -1); - gtk_tree_model_get(model, &iter, COLUMN_UID, &uid, -1); - - if (uid != group->creator_uid) { // do not allow delete admin - selected ^= 1; - gtk_list_store_set(GTK_LIST_STORE(model), &iter, COLUMN_SELECTED, selected, -1); - gtk_tree_path_free(path); - } else - gaim_notify_error(gc, NULL, _("Qun creator cannot be removed"), NULL); -} // _qq_group_member_list_deleted_toggled - -/*****************************************************************************/ -static void _qq_group_member_list_drag_data_rcv_cb - (GtkWidget * widget, GdkDragContext * dc, guint x, guint y, - GtkSelectionData * sd, guint info, guint t, gpointer data) { - - GaimConnection *gc; - GaimAccount *account; - GaimBlistNode *n = NULL; - GaimContact *c = NULL; - GaimBuddy *b = NULL; - GtkWidget *treeview; - GtkTreeModel *model; - GtkListStore *store; - GtkTreeIter iter; - GValue value = { 0, }; - guint32 uid, input_uid; - - treeview = widget; - gc = (GaimConnection *) data; - g_return_if_fail(gc != NULL); - account = gaim_connection_get_account(gc); - - if (sd->target != gdk_atom_intern("GAIM_BLIST_NODE", FALSE) || sd->data == NULL) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Invalid drag data received, discard...\n"); - return; - } // if (sd->target - - memcpy(&n, sd->data, sizeof(n)); - - // we expect GAIM_BLIST_CONTACT_NODE and GAIM_BLIST_BUDDY_NODE - if (GAIM_BLIST_NODE_IS_CONTACT(n)) { - c = (GaimContact *) n; - b = c->priority; // we get the first buddy only - } else if (GAIM_BLIST_NODE_IS_BUDDY(n)) - b = (GaimBuddy *) n; - - if (b == NULL) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "No valid GaimBuddy is passed from DnD\n"); - return; - } // if b == NULL - - gaim_debug(GAIM_DEBUG_INFO, "QQ", "We get a GaimBuddy: %s\n", b->name); - input_uid = gaim_name_to_uid(b->name); - g_return_if_fail(input_uid > 0); - - model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)); - // we need to check if the user id in the member list is unique - // possibly a tree transverse is necessary to achieve this - if (gtk_tree_model_get_iter_first(model, &iter)) { - gtk_tree_model_get_value(model, &iter, COLUMN_UID, &value); - uid = g_value_get_uint(&value); - g_value_unset(&value); - while (uid != input_uid && gtk_tree_model_iter_next(model, &iter)) { - gtk_tree_model_get_value(model, &iter, COLUMN_UID, &value); - uid = g_value_get_uint(&value); - g_value_unset(&value); - } // while - } else - uid = 0; // if gtk_tree_model_get_iter_first - - if (uid == input_uid) { - gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Qun already has this buddy %s\n", b->name); - return; - } else { // we add it to list - store = GTK_LIST_STORE(model); - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - COLUMN_SELECTED, FALSE, COLUMN_UID, input_uid, COLUMN_NICKNAME, b->alias, -1); - // re-sort the list - gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), COLUMN_UID, GTK_SORT_ASCENDING); - } // if uid - -} // _qq_group_member_list_drag_data_rcv_cb - -/*****************************************************************************/ -static GtkWidget *_create_page_info(GaimConnection * gc, qq_group * group, gboolean do_manage, qun_info_window * info_window) { - GtkWidget *vbox, *hbox; - GtkWidget *frame_info, *frame_auth; - GtkWidget *tbl_info; - GtkWidget *label, *entry, *combo, *text, *scrolled_window; - gint i; - - g_return_val_if_fail(gc != NULL && group != NULL, NULL); - - vbox = gtk_vbox_new(FALSE, 5); - - frame_info = gtk_frame_new(NULL); - gtk_box_pack_start(GTK_BOX(vbox), frame_info, TRUE, TRUE, 0); - - tbl_info = gtk_table_new(6, 4, FALSE); - gtk_table_set_row_spacings(GTK_TABLE(tbl_info), 4); - gtk_table_set_col_spacing(GTK_TABLE(tbl_info), 1, 10); - gtk_container_add(GTK_CONTAINER(frame_info), tbl_info); - - label = gtk_label_new(_("Group ID: ")); - gtk_table_attach(GTK_TABLE(tbl_info), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - label = gtk_label_new(g_strdup_printf("%d", group->external_group_id)); - gtk_table_attach(GTK_TABLE(tbl_info), label, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - info_window->lbl_external_group_id = label; - - label = gtk_label_new(_("Group Name")); - gtk_table_attach(GTK_TABLE(tbl_info), label, 2, 3, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - entry = gtk_entry_new(); - gtk_widget_set_size_request(entry, 100, -1); - if (group->group_name_utf8 != NULL) - gtk_entry_set_text(GTK_ENTRY(entry), group->group_name_utf8); - gtk_table_attach(GTK_TABLE(tbl_info), entry, 3, 4, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - info_window->ent_group_name = entry; - - label = gtk_label_new(_("Admin: ")); - gtk_table_attach(GTK_TABLE(tbl_info), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - label = gtk_label_new(g_strdup_printf("%d", group->creator_uid)); - gtk_table_attach(GTK_TABLE(tbl_info), label, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - info_window->lbl_admin_uid = label; - - label = gtk_label_new(_("Category")); - gtk_table_attach(GTK_TABLE(tbl_info), label, 2, 3, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - - //henry: these codes are supported only in GTK-2.4 or later -#if GTK_CHECK_VERSION(2, 4, 0) - combo = gtk_combo_box_new_text(); - for (i = 0; i < 4; i++) - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), qq_group_category[i]); - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), group->group_category); -#else - GtkWidget *menu; - GtkWidget *item; - - combo = gtk_option_menu_new(); - menu = gtk_menu_new(); - for (i = 0; i < 4; i++) { - item = gtk_menu_item_new_with_label(qq_group_category[i]); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show(item); - } - gtk_option_menu_set_menu(GTK_OPTION_MENU(combo), menu); - gtk_option_menu_set_history(GTK_OPTION_MENU(combo), group->group_category); -#endif /* GTK_CHECK_VERSION */ - - gtk_table_attach(GTK_TABLE(tbl_info), combo, 3, 4, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - info_window->cmb_group_category = combo; - - label = gtk_label_new(_("Description")); - gtk_table_attach(GTK_TABLE(tbl_info), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0); - text = gtk_text_view_new(); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); - gtk_widget_set_size_request(text, -1, 50); - if (group->group_desc_utf8 != NULL) - gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), group->group_desc_utf8, -1); - info_window->txt_group_desc = text; - - scrolled_window = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(scrolled_window), text); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN); - gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 2); - gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 2); - gtk_table_attach(GTK_TABLE(tbl_info), scrolled_window, 0, 4, 3, 4, GTK_FILL, GTK_FILL, 0, 0); - - label = gtk_label_new(_("Group Notice")); - gtk_table_attach(GTK_TABLE(tbl_info), label, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0); - text = gtk_text_view_new(); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); - gtk_widget_set_size_request(text, -1, 50); - if (group->notice_utf8 != NULL) - gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)), group->notice_utf8, -1); - info_window->txt_group_notice = text; - - scrolled_window = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(scrolled_window), text); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN); - gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 2); - gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 2); - gtk_table_attach(GTK_TABLE(tbl_info), scrolled_window, 0, 4, 5, 6, GTK_FILL, GTK_FILL, 0, 0); - - frame_auth = gtk_frame_new(_("Authentication")); - hbox = gtk_hbox_new(FALSE, 5); - gtk_container_add(GTK_CONTAINER(frame_auth), hbox); - info_window->rad_auth[0] = gtk_radio_button_new_with_label(NULL, qq_group_auth_type_desc[0]); - info_window->rad_auth[1] = - gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON - (info_window->rad_auth[0]), qq_group_auth_type_desc[1]); - info_window->rad_auth[2] = - gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON - (info_window->rad_auth[0]), qq_group_auth_type_desc[2]); - for (i = 0; i < 3; i++) - gtk_box_pack_start(GTK_BOX(hbox), info_window->rad_auth[i], FALSE, FALSE, 0); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(info_window->rad_auth[group->auth_type - 1]), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), frame_auth, FALSE, FALSE, 0); - - if (!do_manage) { - gtk_widget_set_sensitive(frame_info, FALSE); - gtk_widget_set_sensitive(frame_auth, FALSE); - } // if ! do_manage - - return vbox; -} // _create_info_page - -/*****************************************************************************/ -static GtkWidget *_create_page_members - (GaimConnection * gc, qq_group * group, gboolean do_manage, qun_info_window * info_window) { - GtkWidget *vbox, *sw, *treeview; - GtkTreeModel *model; - GtkListStore *store; - GtkTreeIter iter; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GList *list; - qq_buddy *q_bud; - GtkTargetEntry gte = { "GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0 }; - - g_return_val_if_fail(gc != NULL && group != NULL, NULL); - - vbox = gtk_vbox_new(FALSE, 0); - - if (group->members == NULL) { // if NULL, not ready - sw = gtk_label_new(_ - ("OpenQ is collecting member information.\nPlease close this window and open again")); - gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); - return vbox; - } // if group->members - - sw = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); - - store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_UINT, G_TYPE_STRING); - - list = group->members; - while (list != NULL) { - q_bud = (qq_buddy *) list->data; - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - COLUMN_SELECTED, FALSE, - COLUMN_UID, q_bud->uid, COLUMN_NICKNAME, q_bud->nickname, -1); - list = list->next; - } // for - - model = GTK_TREE_MODEL(store); - treeview = gtk_tree_view_new_with_model(model); - info_window->tre_members = treeview; - - gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); - gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), COLUMN_UID); - g_object_unref(model); - - // set up drag & drop ONLY for managable Qun - if (do_manage) { - gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(treeview), >e, 1, GDK_ACTION_COPY); - g_signal_connect(G_OBJECT(treeview), "drag-data-received", - G_CALLBACK(_qq_group_member_list_drag_data_rcv_cb), gc); - } // if do manage - - gtk_container_add(GTK_CONTAINER(sw), treeview); - - model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)); - renderer = gtk_cell_renderer_toggle_new(); - - // it seems this signal has to be handled - // otherwise, the checkbox in the column does not reponse to user action - if (do_manage) - g_signal_connect(renderer, "toggled", G_CALLBACK(_qq_group_member_list_deleted_toggled), info_window); - - column = gtk_tree_view_column_new_with_attributes(_("Del"), renderer, "active", COLUMN_SELECTED, NULL); - - gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column), GTK_TREE_VIEW_COLUMN_FIXED); - gtk_tree_view_column_set_fixed_width(GTK_TREE_VIEW_COLUMN(column), 30); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); - - renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes(_("UID"), renderer, "text", COLUMN_UID, NULL); - gtk_tree_view_column_set_sort_column_id(column, COLUMN_UID); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); - // default sort by UID - gtk_tree_view_column_set_sort_order(column, GTK_SORT_ASCENDING); - gtk_tree_view_column_set_sort_indicator(column, TRUE); - - renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes(_("Nickname"), renderer, "text", COLUMN_NICKNAME, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); - - return vbox; -} // _create_page_members - -/**************************************************************... [truncated message content] |
From: <mar...@us...> - 2006-07-25 04:31:43
|
Revision: 16570 Author: markhuetsch Date: 2006-07-24 21:31:36 -0700 (Mon, 24 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16570&view=rev Log Message: ----------- *Fixed an off-by-one blood_types bug. *Made it so that only one modify info dialog can be open at a time. *Fixed a bug where the user wasn't always notified when his info had been modified. *Eliminated the ability to send empty strings as info fields as these were making the official client unhappy. Modified Paths: -------------- trunk/src/protocols/qq/buddy_info.c trunk/src/protocols/qq/qq.h Modified: trunk/src/protocols/qq/buddy_info.c =================================================================== --- trunk/src/protocols/qq/buddy_info.c 2006-07-25 04:26:31 UTC (rev 16569) +++ trunk/src/protocols/qq/buddy_info.c 2006-07-25 04:31:36 UTC (rev 16570) @@ -107,7 +107,7 @@ }; static const gchar *blood_types[] = { - "其它", "A型", "B型", "O型", "AB型", NULL + "-", N_("A"), N_("B"), N_("O"), N_("AB"), N_("Other"), NULL }; static const gchar *genders[] = { @@ -138,7 +138,7 @@ "销售/广告/市场", NULL }; -static const gint choice_sizes[] = { 0, 13, 13, 5, 2, 7, 34, 15 }; +static const gint choice_sizes[] = { 0, 13, 13, 6, 2, 7, 34, 15 }; static const gchar *info_group_headers[] = { @@ -221,7 +221,7 @@ if (choice == 0) return FALSE; len = strlen(value); - // the server sends us an ascii index and none of arrays has more than 99 + // the server sends us an ascii index and none of the arrays has more than 99 // elements if (len > 3 || len == 0) return FALSE; for (i = 0; i < len; i++) @@ -357,6 +357,11 @@ static void modify_info_cancel_cb(modify_info_data *mid) { + qq_data *qd; + + qd = (qq_data *) mid->gc->proto_data; + qd->modifying_info = FALSE; + g_list_free(mid->misc); g_free(mid); } @@ -378,7 +383,7 @@ value = g_strdup_printf("%d", gaim_request_field_choice_get_value(f)); else { value = (gchar *) gaim_request_field_string_get_value(f); - if (value == NULL) value = g_strdup(""); + if (value == NULL) value = g_strdup("-"); else value = utf8_to_qq(value, QQ_CHARSET_DEFAULT); } segments[ft->pos] = value; @@ -401,12 +406,15 @@ static void modify_info_ok_cb(modify_info_data *mid, GaimRequestFields *fields) { GaimConnection *gc; + qq_data *qd; GList *list, *groups, *group_node; gchar *info_field[QQ_CONTACT_FIELDS]; contact_info *info; gint i; gc = mid->gc; + qd = (qq_data *) gc->proto_data; + qd->modifying_info = FALSE; list = mid->misc; g_list_foreach(list, parse_misc_field, info_field); g_list_free(list); @@ -469,6 +477,7 @@ // a form using those values and the info_template. static void create_modify_info_dialogue(GaimConnection *gc, const gchar **info) { + qq_data *qd; GaimRequestFields *fields; GaimRequestFieldGroup *group; GaimRequestField *field; @@ -476,32 +485,38 @@ modify_info_data *mid; gint i; - fields = gaim_request_fields_new(); + // so we only have one dialog open at a time + qd = (qq_data *) gc->proto_data; + if (!qd->modifying_info) { + qd->modifying_info = TRUE; + + fields = gaim_request_fields_new(); - // we only care about the first 3 groups, not the miscellaneous stuff - for (i = 0; i < 3; i++) { - group = gaim_request_field_group_new(info_group_headers[i]); - gaim_request_fields_add_group(fields, group); - group_list = info_get_group(info, info_group_headers[i]); - g_list_foreach(group_list, setup_group, group); - g_list_free(group_list); - } + // we only care about the first 3 groups, not the miscellaneous stuff + for (i = 0; i < 3; i++) { + group = gaim_request_field_group_new(info_group_headers[i]); + gaim_request_fields_add_group(fields, group); + group_list = info_get_group(info, info_group_headers[i]); + g_list_foreach(group_list, setup_group, group); + g_list_free(group_list); + } - //set this manually here instead of generating a new template column - field = gaim_request_fields_get_field(fields, "uid"); - gaim_request_field_string_set_editable(field, FALSE); + //set this manually here instead of generating a new template column + field = gaim_request_fields_get_field(fields, "uid"); + gaim_request_field_string_set_editable(field, FALSE); - //we need to pass the info that doesn't get modified as aux data - //because we'll still need it when we send the modify_info packet - mid = g_new0(modify_info_data, 1); - mid->gc = gc; - mid->misc = info_get_group(info, info_group_headers[3]); + //we need to pass the info that doesn't get modified as aux data + //because we'll still need it when we send the modify_info packet + mid = g_new0(modify_info_data, 1); + mid->gc = gc; + mid->misc = info_get_group(info, info_group_headers[3]); - gaim_request_fields(gc, _("Modify my information"), + gaim_request_fields(gc, _("Modify my information"), _("Modify my information"), NULL, fields, _("Update my information"), G_CALLBACK(modify_info_ok_cb), _("Cancel"), G_CALLBACK(modify_info_cancel_cb), mid); + } } // process the reply of modify_info packet @@ -519,6 +534,7 @@ data = g_newa(guint8, len); if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { + data[len] = '\0'; if (qd->uid == atoi((gchar *) data)) { // return should be my uid gaim_debug(GAIM_DEBUG_INFO, "QQ", "Update info ACK OK\n"); gaim_notify_info(gc, NULL, _("Your information has been updated"), NULL); @@ -559,10 +575,6 @@ g_free(alias_utf8); } -// XXX When we don't have any immediate response, we send duplicate get info packets -// to the server. If the server ends up responding to multiple packets, we get multiple -// modify info dialogues, which is annoying. Fix this. - // process reply to get_info packet void qq_process_get_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { Modified: trunk/src/protocols/qq/qq.h =================================================================== --- trunk/src/protocols/qq/qq.h 2006-07-25 04:26:31 UTC (rev 16569) +++ trunk/src/protocols/qq/qq.h 2006-07-25 04:31:36 UTC (rev 16570) @@ -102,6 +102,8 @@ GList *info_query; GList *add_buddy_request; GQueue *before_login_packets; + + gboolean modifying_info; }; void qq_function_not_implemented(GaimConnection * gc); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-01 13:08:40
|
Revision: 16605 Author: markhuetsch Date: 2006-08-01 06:08:03 -0700 (Tue, 01 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16605&view=rev Log Message: ----------- *Safeguarded against a possible memory violation upon receiving a malformed login token reply packet. *Eliminated a couple of compiler warnings. Modified Paths: -------------- trunk/src/protocols/qq/login_logout.c trunk/src/protocols/qq/login_logout.h Modified: trunk/src/protocols/qq/login_logout.c =================================================================== --- trunk/src/protocols/qq/login_logout.c 2006-08-01 00:05:14 UTC (rev 16604) +++ trunk/src/protocols/qq/login_logout.c 2006-08-01 13:08:03 UTC (rev 16605) @@ -20,8 +20,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ #include "debug.h" // gaim_debug #include "internal.h" // memcpy, _("get_text") #include "server.h" // serv_finish_login @@ -40,16 +38,14 @@ #include "send_core.h" // qq_send_cmd #include "qq.h" // qq_data -//#define QQ_LOGIN_DATA_LENGTH 69 //length of plain login packet -#define QQ_LOGIN_DATA_LENGTH 416 //new length from eva, by gfhuang +#define QQ_LOGIN_DATA_LENGTH 416 #define QQ_LOGIN_REPLY_OK_PACKET_LEN 139 #define QQ_LOGIN_REPLY_REDIRECT_PACKET_LEN 11 -#define QQ_REQUEST_LOGIN_TOKEN_REPLY_OK 0x00 //added by gfhuang +#define QQ_REQUEST_LOGIN_TOKEN_REPLY_OK 0x00 #define QQ_LOGIN_REPLY_OK 0x00 #define QQ_LOGIN_REPLY_REDIRECT 0x01 -//#define QQ_LOGIN_REPLY_PWD_ERROR 0x02 #define QQ_LOGIN_REPLY_PWD_ERROR 0x05 #define QQ_LOGIN_REPLY_MISC_ERROR 0xff // defined by myself @@ -71,7 +67,7 @@ }; */ -//for QQ 2005? copy from lumqq +//for QQ 2005? copy from lumaqq static const gint8 login_23_51[29] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -122, @@ -149,12 +145,11 @@ /*****************************************************************************/ // It is fixed to 16 bytes 0x01 for QQ2003, // Any value works (or a random 16 bytes string) -static gchar *_gen_login_key(void) +static guint8 *_gen_login_key(void) { - return g_strnfill(QQ_KEY_LENGTH, 0x01); -} // _gen_login_key + return (guint8 *) g_strnfill(QQ_KEY_LENGTH, 0x01); +} -/*****************************************************************************/ // process login reply which says OK static gint _qq_process_login_ok(GaimConnection * gc, guint8 * data, gint len) { @@ -217,7 +212,7 @@ gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Fail parsing login info, expect %d bytes, read %d bytes\n", QQ_LOGIN_REPLY_OK_PACKET_LEN, bytes); - } // but we still goes on as login OK + } // but we still go on as login OK qd->session_key = g_memdup(lrop.session_key, QQ_KEY_LENGTH); qd->my_ip = gen_ip_str(lrop.client_ip); @@ -229,7 +224,6 @@ g_free(lrop.session_key); gaim_connection_set_state(gc, GAIM_CONNECTED); -// serv_finish_login(gc); //by gfhuang qd->logged_in = TRUE; // must be defined after sev_finish_login // now initiate QQ Qun, do it first as it may take longer to finish @@ -247,9 +241,8 @@ //qq_send_packet_get_all_list_with_group(gc, QQ_FRIENDS_LIST_POSITION_START); return QQ_LOGIN_REPLY_OK; -} // _qq_process_login_ok +} -/*****************************************************************************/ // process login reply packet which includes redirected new server address static gint _qq_process_login_redirect(GaimConnection * gc, guint8 * data, gint len) { @@ -285,12 +278,11 @@ qq_connect(gc->account, new_server_str, lrrp.new_server_port, qd->use_tcp, TRUE); g_free(new_server_str); ret = QQ_LOGIN_REPLY_REDIRECT; - } // if bytes != QQ_LOGIN_REPLY_MISC_ERROR + } return ret; -} // _qq_process_login_redirect +} -/*****************************************************************************/ // process login reply which says wrong password static gint _qq_process_login_wrong_pwd(GaimConnection * gc, guint8 * data, gint len) { @@ -303,10 +295,9 @@ g_free(server_reply_utf8); return QQ_LOGIN_REPLY_PWD_ERROR; -} // _qq_process_login_wrong_pwd +} - -// request before login, new protocal, by gfhuang +// request before login void qq_send_packet_request_login_token(GaimConnection *gc) { qq_data *qd; @@ -332,9 +323,12 @@ gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail create request login token packet\n"); } -/*****************************************************************************/ +// TODO: The login packet and its response have changed by QQ2006 Beta2. In that version, +// the login OK response packet does not appear to be decryptable with qd->pwkey or qd->inikey. +// Fortunately, this older system still works. + // send login packet to QQ server -void qq_send_packet_login(GaimConnection * gc, guint8 token_length, guint8 *token) +static void qq_send_packet_login(GaimConnection * gc, guint8 token_length, guint8 *token) { qq_data *qd; guint8 *buf, *cursor, *raw_data, *encrypted_data; @@ -352,7 +346,7 @@ // now generate the encrypted data // 000-015 use pwkey as key to encrypt empty string - qq_crypt(ENCRYPT, "", 0, qd->pwkey, raw_data, &encrypted_len); + qq_crypt(ENCRYPT, (guint8 *) "", 0, qd->pwkey, raw_data, &encrypted_len); // 016-016 raw_data[16] = 0x00; // 017-020, used to be IP, now zero @@ -366,7 +360,7 @@ // 053-068, fixed value, maybe related to per machine g_memmove(raw_data + 53, login_53_68, 16); - // 069 , login token length, by gfhuang + // 069, login token length raw_data[69] = token_length; pos = 70; // 070-093, login token //normally 24 bytes @@ -392,10 +386,8 @@ _qq_send_packet(gc, buf, bytes, QQ_CMD_LOGIN); else gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail create login packet\n"); -} // qq_send_packet_login +} - -//added by gfhuang void qq_process_request_login_token_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { qq_data *qd; @@ -406,9 +398,15 @@ qd = (qq_data *) gc->proto_data; if (buf[0] == QQ_REQUEST_LOGIN_TOKEN_REPLY_OK) { + if (buf[1] != buf_len-2) { + gaim_debug(GAIM_DEBUG_INFO, "QQ", + "Malformed login token reply packet. Packet specifies length of %d, actual length is %d\n", buf[1], buf_len-2); + gaim_debug(GAIM_DEBUG_INFO, "QQ", + "Attempting to proceed with the actual packet length.\n"); + } gaim_debug(GAIM_DEBUG_INFO, "QQ", - "<<< got a token with %d bytes -> [default] decrypt and dump\n%s",buf[1], hex_dump_to_str(buf+2, buf[1])); - qq_send_packet_login(gc, buf[1], buf + 2); + "<<< got a token with %d bytes -> [default] decrypt and dump\n%s",buf_len-2, hex_dump_to_str(buf+2, buf_len-2)); + qq_send_packet_login(gc, buf_len-2, buf+2); } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Unknown request login token reply code : %d\n", buf[0]); gaim_debug(GAIM_DEBUG_WARNING, "QQ", @@ -419,7 +417,6 @@ } } -/*****************************************************************************/ // send logout packets to QQ server void qq_send_packet_logout(GaimConnection * gc) { @@ -435,7 +432,6 @@ qd->logged_in = FALSE; // update login status AFTER sending logout packets } // qq_send_packet_logout -/*****************************************************************************/ // process the login reply packet void qq_process_login_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { @@ -474,7 +470,6 @@ break; default: gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Unknown reply code: %d\n", data[0]); - // dump by gfhuang gaim_debug(GAIM_DEBUG_WARNING, "QQ", ">>> %d bytes -> [default] decrypt and dump\n%s", buf_len, hex_dump_to_str(data, len)); @@ -504,8 +499,5 @@ break; default:{; } - } // switch ret -} // qq_process_login_reply - -/*****************************************************************************/ -// END OF FILE + } +} Modified: trunk/src/protocols/qq/login_logout.h =================================================================== --- trunk/src/protocols/qq/login_logout.h 2006-08-01 00:05:14 UTC (rev 16604) +++ trunk/src/protocols/qq/login_logout.h 2006-08-01 13:08:03 UTC (rev 16605) @@ -20,8 +20,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ #ifndef _QQ_LOGIN_LOGOUT_H_ #define _QQ_LOGIN_LOGOUT_H_ @@ -31,14 +29,9 @@ #define QQ_LOGIN_MODE_NORMAL 0x0a #define QQ_LOGIN_MODE_HIDDEN 0x28 -//void qq_send_packet_login(GaimConnection * gc); //for internal usage, by gfhuang -void qq_send_packet_request_login_token(GaimConnection *gc); //by gfhuang - +void qq_send_packet_request_login_token(GaimConnection *gc); +void qq_process_request_login_token_reply(guint8 *buf, gint buf_len, GaimConnection *gc); +void qq_process_login_reply(guint8 * buf, gint buf_len, GaimConnection * gc); void qq_send_packet_logout(GaimConnection * gc); -void qq_process_login_reply(guint8 * buf, gint buf_len, GaimConnection * gc); -void qq_process_request_login_token_reply(guint8 *buf, gint buf_len, GaimConnection *gc); // by gfhuang - #endif -/*****************************************************************************/ -// END OF FILE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-01 16:16:16
|
Revision: 16606 Author: markhuetsch Date: 2006-08-01 09:15:39 -0700 (Tue, 01 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16606&view=rev Log Message: ----------- QQ no longer supports changing one's password through the client. Users must go to password.qq.com instead. I also squashed a compiler warning. Modified Paths: -------------- trunk/src/protocols/qq/buddy_info.c trunk/src/protocols/qq/buddy_info.h trunk/src/protocols/qq/qq.c Modified: trunk/src/protocols/qq/buddy_info.c =================================================================== --- trunk/src/protocols/qq/buddy_info.c 2006-08-01 13:08:03 UTC (rev 16605) +++ trunk/src/protocols/qq/buddy_info.c 2006-08-01 16:15:39 UTC (rev 16606) @@ -180,7 +180,7 @@ } // info_fields are compared by their group positions -static gint info_field_compare(gconstpointer a, gconstpointer b, gpointer unused) +static gint info_field_compare(gconstpointer a, gconstpointer b) { return ((info_field *) a)->group_pos - ((info_field *) b)->group_pos; } @@ -318,31 +318,22 @@ } } -// send packet to modify personal information, and/or change password -void qq_send_packet_modify_info(GaimConnection *gc, contact_info *info, gchar *new_passwd) +// send packet to modify personal information +void qq_send_packet_modify_info(GaimConnection *gc, contact_info *info) { - GaimAccount *a; - gchar *old_passwd, *info_field[QQ_CONTACT_FIELDS]; + gchar *info_field[QQ_CONTACT_FIELDS]; gint i; guint8 *raw_data, *cursor, bar; g_return_if_fail(gc != NULL && info != NULL); - a = gc->account; - old_passwd = a->password; bar = 0x1f; raw_data = g_newa(guint8, MAX_PACKET_SIZE - 128); cursor = raw_data; g_memmove(info_field, info, sizeof(gchar *) * QQ_CONTACT_FIELDS); - if (new_passwd == NULL || strlen(new_passwd) == 0) - create_packet_b(raw_data, &cursor, bar); - else { // we're gonna change passwd - create_packet_data(raw_data, &cursor, (guint8 *) old_passwd, strlen(old_passwd)); - create_packet_b(raw_data, &cursor, bar); - create_packet_data(raw_data, &cursor, (guint8 *) new_passwd, strlen(new_passwd)); - } + create_packet_b(raw_data, &cursor, bar); // important!, skip the first uid entry for (i = 1; i < QQ_CONTACT_FIELDS; i++) { @@ -427,7 +418,7 @@ } info = (contact_info *) info_field; - qq_send_packet_modify_info(gc, info, NULL); + qq_send_packet_modify_info(gc, info); g_free(mid); for (i = 0; i < QQ_CONTACT_FIELDS; i++) g_free(info_field[i]); Modified: trunk/src/protocols/qq/buddy_info.h =================================================================== --- trunk/src/protocols/qq/buddy_info.h 2006-08-01 13:08:03 UTC (rev 16605) +++ trunk/src/protocols/qq/buddy_info.h 2006-08-01 16:15:39 UTC (rev 16606) @@ -114,7 +114,7 @@ void qq_refresh_buddy_and_myself(contact_info *info, GaimConnection *gc); void qq_send_packet_get_info(GaimConnection *gc, guint32 uid, gboolean show_window); -void qq_send_packet_modify_info(GaimConnection *gc, contact_info *info, gchar *new_passwd); +void qq_send_packet_modify_info(GaimConnection *gc, contact_info *info); void qq_prepare_modify_info(GaimConnection *gc); void qq_process_modify_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc); void qq_process_get_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc); Modified: trunk/src/protocols/qq/qq.c =================================================================== --- trunk/src/protocols/qq/qq.c 2006-08-01 13:08:03 UTC (rev 16605) +++ trunk/src/protocols/qq/qq.c 2006-08-01 16:15:39 UTC (rev 16606) @@ -447,6 +447,12 @@ qq_prepare_modify_info(gc); } + +static void _qq_menu_change_password(GaimPluginAction * action) +{ + gaim_notify_uri(NULL, "https://password.qq.com"); +} + /* remove a buddy from my list and remove myself from his list */ /* TODO: re-enable this static void _qq_menu_block_buddy(GaimBlistNode * node) @@ -668,6 +674,9 @@ act = gaim_plugin_action_new(_("Modify My Information"), _qq_menu_modify_my_info); m = g_list_append(m, act); + act = gaim_plugin_action_new(_("Change Password"), _qq_menu_change_password); + m = g_list_append(m, act); + act = gaim_plugin_action_new(_("Show Login Information"), _qq_menu_show_login_info); m = g_list_append(m, act); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-01 17:40:13
|
Revision: 16607 Author: markhuetsch Date: 2006-08-01 10:39:47 -0700 (Tue, 01 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16607&view=rev Log Message: ----------- Added a debugging tool for firing custom packets at the QQ server. Modified Paths: -------------- trunk/src/protocols/qq/qq.c trunk/src/protocols/qq/utils.c trunk/src/protocols/qq/utils.h Modified: trunk/src/protocols/qq/qq.c =================================================================== --- trunk/src/protocols/qq/qq.c 2006-08-01 16:15:39 UTC (rev 16606) +++ trunk/src/protocols/qq/qq.c 2006-08-01 17:39:47 UTC (rev 16607) @@ -51,6 +51,7 @@ #include "keep_alive.h" #include "ip_location.h" /* qq_ip_get_location */ #include "login_logout.h" +#include "packet_parse.h" /* MAX_PACKET_SIZE */ #include "qq_proxy.h" /* qq_connect, qq_disconnect */ #include "send_core.h" #include "qq.h" @@ -447,10 +448,9 @@ qq_prepare_modify_info(gc); } - static void _qq_menu_change_password(GaimPluginAction * action) { - gaim_notify_uri(NULL, "https://password.qq.com"); + gaim_notify_uri(NULL, "https://password.qq.com"); } /* remove a buddy from my list and remove myself from his list */ @@ -663,7 +663,58 @@ // } } */ +/* +static void _qq_send_custom_packet(GaimConnection *gc, const gchar *packet) +{ + guint16 cmd; + guint8 *buffer; + gint len; + if (!packet) { + gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Null packet inputted!\n"); + return; + } + if (strlen(packet) > MAX_PACKET_SIZE * 2) { + gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Packet inputted is too large!\n"); + return; + } + if (strlen(packet) < 4) { + gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Packet is impossibly short!\n"); + return; + } + + buffer = hex_str_to_bytes(packet); + if (!buffer) { + gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Invalid packet inputted!\n"); + return; + } + // big endian + cmd = 256 * buffer[0] + buffer[1]; + gaim_debug(GAIM_DEBUG_INFO, "QQ", "Inputted CMD: %d\n", cmd); + + len = strlen(buffer) - 2; + packet = buffer + 2; + + qq_send_cmd(gc, cmd, TRUE, 0, TRUE, packet, len); + + g_free(buffer); +} +*/ + +/* send a custom packet to the server - for protocol testing */ +/* +static void _qq_menu_send_custom_packet(GaimPluginAction *action) +{ + GaimConnection *gc = (GaimConnection *) action->context; + g_return_if_fail(gc != NULL); + gaim_request_input(gc, _("Send Custom Packet"), + _("Enter the packet in hex here"), + _("Include the command and everything following"), + NULL, FALSE, FALSE, NULL, + _("Send"), G_CALLBACK(_qq_send_custom_packet), _("Cancel"), NULL, gc); +} +*/ + /* protocol related menus */ static GList *_qq_actions(GaimPlugin * plugin, gpointer context) { @@ -680,6 +731,11 @@ act = gaim_plugin_action_new(_("Show Login Information"), _qq_menu_show_login_info); m = g_list_append(m, act); + /* + act = gaim_plugin_action_new(_("Send Custom Packet"), _qq_menu_send_custom_packet); + m = g_list_append(m, act); + */ + /* XXX consider re-enabling this act = gaim_plugin_action_new(_("Show System Message"), _qq_menu_show_system_message); m = g_list_append(m, act); Modified: trunk/src/protocols/qq/utils.c =================================================================== --- trunk/src/protocols/qq/utils.c 2006-08-01 16:15:39 UTC (rev 16606) +++ trunk/src/protocols/qq/utils.c 2006-08-01 17:39:47 UTC (rev 16607) @@ -20,8 +20,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ #include "stdlib.h" // strtol #include "limits.h" #include "string.h" // strlen @@ -46,7 +44,7 @@ #endif /*****************************************************************************/ -gchar *get_name_by_index_str(gchar ** array, const gchar * index_str, gint amount) { +gchar *get_name_by_index_str(gchar **array, const gchar *index_str, gint amount) { gint index; index = atoi(index_str); @@ -57,7 +55,7 @@ } // get_name_by_index_str /*****************************************************************************/ -gchar *get_index_str_by_name(gchar ** array, const gchar * name, gint amount) { +gchar *get_index_str_by_name(gchar **array, const gchar *name, gint amount) { gint index; for (index = 0; index <= amount; index++) @@ -70,7 +68,7 @@ } // get_index_str_by_name /*****************************************************************************/ -gint qq_string_to_dec_value(const gchar * str) +gint qq_string_to_dec_value(const gchar *str) { g_return_val_if_fail(str != NULL, 0); return strtol(str, NULL, 10); @@ -80,7 +78,7 @@ // split the given data(len) with delimit, // check the number of field matches the expected_fields (<=0 means all) // return gchar* array (needs to be freed by g_strfreev later), or NULL -gchar **split_data(guint8 * data, gint len, const gchar * delimit, gint expected_fields) { +gchar **split_data(guint8 *data, gint len, const gchar *delimit, gint expected_fields) { guint8 *input; gchar **segments; @@ -111,19 +109,19 @@ // free up those not used for (j = expected_fields; j < i; j++) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "field[%d] is %s\n", j, segments[j]); - g_free(segments[j]); // bug found by gfhuang ! i -> j + g_free(segments[j]); } segments[expected_fields] = NULL; - } // if i + } return segments; -} // split_data +} /*****************************************************************************/ // given a four-byte ip data, convert it into a human readable ip string // the return needs to be freed -gchar *gen_ip_str(guint8 * ip) +gchar *gen_ip_str(guint8 *ip) { if (ip == NULL || ip[0] == 0) return g_strdup_printf(""); @@ -131,7 +129,6 @@ return g_strdup_printf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); } -// by gfhuang guint8 *str_ip_gen(gchar *str) { guint8 *ip = g_new(guint8, 4); int a, b, c, d; @@ -161,7 +158,7 @@ /*****************************************************************************/ // convert GAIM name to original QQ UID -guint32 gaim_name_to_uid(const gchar * name) +guint32 gaim_name_to_uid(const gchar *name) { gchar *p; @@ -175,7 +172,7 @@ /*****************************************************************************/ // try to dump the data as GBK -void try_dump_as_gbk(guint8 * data, gint len) +void try_dump_as_gbk(guint8 *data, gint len) { gint i; guint8 *incoming; @@ -201,11 +198,76 @@ } // try_dump_gbk /*****************************************************************************/ +// strips whitespace +static gchar *strstrip(const gchar *buffer) +{ + GString *stripped; + gchar *ret; + int i; -// dump a chunk of raw data into hex string -// the return should be freed later -gchar *hex_dump_to_str(const guint8 * buffer, gint bytes) + stripped = g_string_new(""); + for (i=0; i<strlen(buffer); i++) { + if ((int) buffer[i] != 32) { + g_string_append_c(stripped, buffer[i]); + } + } + ret = stripped->str; + g_string_free(stripped, FALSE); + + return ret; +} + +/*****************************************************************************/ +// Dumps an ASCII hex string to a string of bytes. The return should be freed later. +// Returns NULL if a string with an odd number of nibbles is passed in or if buffer +// isn't a valid hex string +guint8 *hex_str_to_bytes(const gchar *buffer) { + gchar *hex_str, *hex_buffer, *cursor, tmp; + guint8 *bytes, nibble1, nibble2; + gint index, len; + + hex_buffer = strstrip(buffer); + + if (strlen(hex_buffer) % 2 != 0) { + gaim_debug(GAIM_DEBUG_WARNING, "QQ", + "Unable to convert an odd number of nibbles to a string of bytes!\n"); + g_free(hex_buffer); + return NULL; + } + bytes = g_newa(guint8, strlen(hex_buffer) / 2); + hex_str = g_ascii_strdown(hex_buffer, -1); + g_free(hex_buffer); + index = 0; + for (cursor = hex_str; cursor < hex_str + sizeof(gchar) * (strlen(hex_str)) - 1; cursor++) { + if (g_ascii_isdigit(*cursor)) {tmp = *cursor; nibble1 = atoi(&tmp); } + else if (g_ascii_isalpha(*cursor) && (gint) *cursor - 87 < 16) + nibble1 = (gint) *cursor - 87; + else { + gaim_debug(GAIM_DEBUG_WARNING, "QQ", + "Invalid char found in hex string!\n"); + g_free(hex_str); + return NULL; + } + nibble1 = nibble1 << 4; + cursor++; + if (g_ascii_isdigit(*cursor)) {tmp = *cursor; nibble2 = atoi(&tmp); } + else if (g_ascii_isalpha(*cursor) && (gint) (*cursor - 87) < 16) + nibble2 = (gint) *cursor - 87; + else { + g_free(hex_str); + return NULL; + } + bytes[index++] = nibble1 + nibble2; + } + len = strlen(hex_str) / 2; + g_free(hex_str); + return g_memdup(bytes, len); +} + +// Dumps a chunk of raw data into an ASCII hex string. The return should be freed later. +gchar *hex_dump_to_str(const guint8 *buffer, gint bytes) +{ GString *str; gchar *ret; gint i, j, ch; @@ -240,6 +302,3 @@ return ret; } - -/*****************************************************************************/ -// ENF OF FILE Modified: trunk/src/protocols/qq/utils.h =================================================================== --- trunk/src/protocols/qq/utils.h 2006-08-01 16:15:39 UTC (rev 16606) +++ trunk/src/protocols/qq/utils.h 2006-08-01 17:39:47 UTC (rev 16607) @@ -28,21 +28,22 @@ #define QQ_NAME_PREFIX "qq-" -gchar *get_name_by_index_str(gchar ** array, const gchar * index_str, gint amount); -gchar *get_index_str_by_name(gchar ** array, const gchar * name, gint amount); -gint qq_string_to_dec_value(const gchar * str); +gchar *get_name_by_index_str(gchar **array, const gchar *index_str, gint amount); +gchar *get_index_str_by_name(gchar **array, const gchar *name, gint amount); +gint qq_string_to_dec_value(const gchar *str); -gchar **split_data(guint8 * data, gint len, const gchar * delimit, gint expected_fields); -gchar *gen_ip_str(guint8 * ip); +gchar **split_data(guint8 *data, gint len, const gchar *delimit, gint expected_fields); +gchar *gen_ip_str(guint8 *ip); guint8 *str_ip_gen(gchar *str); gchar *uid_to_gaim_name(guint32 uid); -guint32 gaim_name_to_uid(const gchar * name); +guint32 gaim_name_to_uid(const gchar *name); gchar *get_icon_name(gint set, gint suffix); -void try_dump_as_gbk(guint8 * data, gint len); +void try_dump_as_gbk(guint8 *data, gint len); -gchar *hex_dump_to_str(const guint8 * buf, gint buf_len); +guint8 *hex_str_to_bytes(const gchar *buf); +gchar *hex_dump_to_str(const guint8 *buf, gint buf_len); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-01 19:53:05
|
Revision: 16610 Author: markhuetsch Date: 2006-08-01 12:52:51 -0700 (Tue, 01 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16610&view=rev Log Message: ----------- Silenced a few warnings. Modified Paths: -------------- trunk/src/protocols/qq/qq.c trunk/src/protocols/qq/utils.c Modified: trunk/src/protocols/qq/qq.c =================================================================== --- trunk/src/protocols/qq/qq.c 2006-08-01 19:52:48 UTC (rev 16609) +++ trunk/src/protocols/qq/qq.c 2006-08-01 19:52:51 UTC (rev 16610) @@ -444,7 +444,6 @@ g_return_if_fail(gc != NULL && gc->proto_data != NULL); qd = (qq_data *) gc->proto_data; - //_qq_get_info(gc, uid_to_gaim_name(qd->uid)); qq_prepare_modify_info(gc); } Modified: trunk/src/protocols/qq/utils.c =================================================================== --- trunk/src/protocols/qq/utils.c 2006-08-01 19:52:48 UTC (rev 16609) +++ trunk/src/protocols/qq/utils.c 2006-08-01 19:52:51 UTC (rev 16610) @@ -92,7 +92,7 @@ g_memmove(input, data, len); input[len] = 0x00; - segments = g_strsplit(input, delimit, 0); + segments = g_strsplit((gchar *) input, delimit, 0); if (expected_fields <= 0) return segments; @@ -123,9 +123,12 @@ // the return needs to be freed gchar *gen_ip_str(guint8 *ip) { - if (ip == NULL || ip[0] == 0) - return g_strdup_printf(""); - else + gchar *ret; + if (ip == NULL || ip[0] == 0) { + ret = g_new(gchar, 1); + *ret = '\0'; + return ret; + } else return g_strdup_printf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); } @@ -189,7 +192,7 @@ if (incoming[i] >= 0x81) break; - msg_utf8 = i < len ? qq_to_utf8(&incoming[i], QQ_CHARSET_DEFAULT) : NULL; + msg_utf8 = i < len ? qq_to_utf8((gchar *) &incoming[i], QQ_CHARSET_DEFAULT) : NULL; if (msg_utf8 != NULL) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Try extract GB msg: %s\n", msg_utf8); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-02 15:39:51
|
Revision: 16618 Author: markhuetsch Date: 2006-08-02 08:35:36 -0700 (Wed, 02 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16618&view=rev Log Message: ----------- Replaced all C++-style comments with C-style ones. Cleaned up some comments and implemented a more consistent formatting scheme. Modified Paths: -------------- trunk/src/protocols/qq/buddy_info.c trunk/src/protocols/qq/buddy_info.h trunk/src/protocols/qq/buddy_list.c trunk/src/protocols/qq/buddy_list.h trunk/src/protocols/qq/buddy_opt.c trunk/src/protocols/qq/buddy_opt.h trunk/src/protocols/qq/buddy_status.c trunk/src/protocols/qq/buddy_status.h trunk/src/protocols/qq/char_conv.c trunk/src/protocols/qq/char_conv.h trunk/src/protocols/qq/crypt.c trunk/src/protocols/qq/crypt.h trunk/src/protocols/qq/file_trans.c trunk/src/protocols/qq/file_trans.h trunk/src/protocols/qq/group.c trunk/src/protocols/qq/group.h trunk/src/protocols/qq/group_conv.c trunk/src/protocols/qq/group_conv.h trunk/src/protocols/qq/group_find.c trunk/src/protocols/qq/group_find.h trunk/src/protocols/qq/group_free.c trunk/src/protocols/qq/group_free.h trunk/src/protocols/qq/group_hash.c trunk/src/protocols/qq/group_hash.h trunk/src/protocols/qq/group_im.c trunk/src/protocols/qq/group_im.h trunk/src/protocols/qq/group_info.c trunk/src/protocols/qq/group_info.h trunk/src/protocols/qq/group_join.c trunk/src/protocols/qq/group_join.h trunk/src/protocols/qq/group_misc.c trunk/src/protocols/qq/group_misc.h trunk/src/protocols/qq/group_network.c trunk/src/protocols/qq/group_network.h trunk/src/protocols/qq/group_opt.c trunk/src/protocols/qq/group_opt.h trunk/src/protocols/qq/group_search.c trunk/src/protocols/qq/group_search.h trunk/src/protocols/qq/header_info.c trunk/src/protocols/qq/header_info.h trunk/src/protocols/qq/im.c trunk/src/protocols/qq/im.h trunk/src/protocols/qq/ip_location.c trunk/src/protocols/qq/ip_location.h trunk/src/protocols/qq/keep_alive.c trunk/src/protocols/qq/keep_alive.h trunk/src/protocols/qq/login_logout.c trunk/src/protocols/qq/login_logout.h trunk/src/protocols/qq/packet_parse.c trunk/src/protocols/qq/packet_parse.h trunk/src/protocols/qq/qq.c trunk/src/protocols/qq/qq.h trunk/src/protocols/qq/qq_proxy.c trunk/src/protocols/qq/qq_proxy.h trunk/src/protocols/qq/recv_core.c trunk/src/protocols/qq/recv_core.h trunk/src/protocols/qq/send_core.c trunk/src/protocols/qq/send_core.h trunk/src/protocols/qq/send_file.c trunk/src/protocols/qq/send_file.h trunk/src/protocols/qq/sendqueue.c trunk/src/protocols/qq/sendqueue.h trunk/src/protocols/qq/sys_msg.c trunk/src/protocols/qq/sys_msg.h trunk/src/protocols/qq/udp_proxy_s5.c trunk/src/protocols/qq/udp_proxy_s5.h trunk/src/protocols/qq/utils.c Modified: trunk/src/protocols/qq/buddy_info.c =================================================================== --- trunk/src/protocols/qq/buddy_info.c 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_info.c 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,34 +20,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "internal.h" // strlen, _("get_text) -#include "debug.h" // gaim_debug -#include "notify.h" // gaim_notify -#include "request.h" // gaim_request_fields_new +#include "internal.h" +#include "debug.h" +#include "notify.h" +#include "request.h" -#include "utils.h" // uid_to_gaim_name -#include "packet_parse.h" // MAX_PACKET_SIZE -#include "buddy_info.h" // -#include "char_conv.h" // qq_to_utf8 -#include "crypt.h" // qq_crypt -#include "header_info.h" // cmd alias -#include "keep_alive.h" // qq_update_buddy_contact -#include "send_core.h" // qq_send_cmd +#include "utils.h" +#include "packet_parse.h" +#include "buddy_info.h" +#include "char_conv.h" +#include "crypt.h" +#include "header_info.h" +#include "keep_alive.h" +#include "send_core.h" -// Below is all of the information necessary to reconstruct the various -// information fields that one can set in the official client. When we need -// to know about a specific field (e.g., should "city" be a choice -// or text field?), we can simply look it up from the template. Note that -// there are a number of unidentified fields. - +/* Below is all of the information necessary to reconstruct the various + * information fields that one can set in the official client. When we need + * to know about a specific field (e.g., should "city" be a choice + * or text field?), we can simply look it up from the template. Note that + * there are a number of unidentified fields. */ typedef struct _info_field { gchar *title; - gchar *id; // used by gaim_request fields + gchar *id; /* used by gaim_request fields */ gint pos; gchar *group; - gint group_pos; // for display order in the UI - gint choice; // indicates which character array contains the choices - gboolean customizable; // whether a user can enter any text as a value, regardless of choice arrays + gint group_pos; /* for display order in the UI */ + gint choice; /* indicates which character array contains the choices */ + gboolean customizable; /* whether a user can enter any text as a value, regardless of choice arrays */ gchar *value; } info_field; @@ -89,11 +88,11 @@ { N_("Blood Type"), "blood", 34, QQ_EXTRA_INFO, 3, QQ_BLOOD, FALSE, NULL }, { "qq_show", "qq_show", 35, QQ_MISC, 15, QQ_NO_CHOICE, TRUE, NULL }, { "unknown6", "unknown6", 36, QQ_MISC, 16, QQ_NO_CHOICE, TRUE, NULL }, - { NULL, NULL, 0, NULL, 0, 0, 0, NULL } //NULL termination + { NULL, NULL, 0, NULL, 0, 0, 0, NULL } }; -//TODO: translate these arrays to their English equivalents -// and move these characters to the zh_CN po file +/* TODO: translate these arrays to their English equivalents + * and move these characters to the zh_CN po file */ static const gchar *horoscope_names[] = { "-", "水瓶座", "双鱼座", "牡羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", @@ -159,10 +158,10 @@ occupation_names }; -/*************** info and info_field methods *****************/ +/************************ info and info_field methods ************************/ -// Given an id, return the template for that field. -// Returns NULL if the id is not found. +/* Given an id, return the template for that field. + * Returns NULL if the id is not found. */ static const info_field *info_field_get_template(const gchar *id) { const info_field *cur_field; @@ -171,7 +170,8 @@ cur_field = info_template_data; cur_id = cur_field->id; while(cur_id != NULL) { - if (g_ascii_strcasecmp(cur_id, id) == 0) return cur_field; + if (g_ascii_strcasecmp(cur_id, id) == 0) + return cur_field; cur_field++; cur_id = cur_field->id; } @@ -179,7 +179,7 @@ return NULL; } -// info_fields are compared by their group positions +/* info_fields are compared by their group positions */ static gint info_field_compare(gconstpointer a, gconstpointer b) { return ((info_field *) a)->group_pos - ((info_field *) b)->group_pos; @@ -191,9 +191,9 @@ g_free(i); } -// Parses the info_template_data above and returns a newly-allocated list -// containing the desired fields from segments. This list is ordered by -// group_pos. +/* Parses the info_template_data above and returns a newly-allocated list + * containing the desired fields from segments. This list is ordered by + * group_pos. */ static GList *info_get_group(const gchar **info, const gchar *group_name) { const info_field *cur; @@ -213,25 +213,27 @@ return group; } -// determines if the given text value and choice group require -// a lookup from the choice arrays +/* Determines if the given text value and choice group require + * a lookup from the choice arrays. */ static gboolean is_valid_index(gchar *value, gint choice) { gint len, i; if (choice == 0) return FALSE; len = strlen(value); - // the server sends us an ascii index and none of the arrays has more than 99 - // elements + /* the server sends us an ascii index and none of the arrays has more than 99 + * elements */ if (len > 3 || len == 0) return FALSE; for (i = 0; i < len; i++) - if (!g_ascii_isdigit(value[i])) return FALSE; + if (!g_ascii_isdigit(value[i])) + return FALSE; i = atoi(value); - if (i < 0 || i >= choice_sizes[choice]) return FALSE; + if (i < 0 || i >= choice_sizes[choice]) + return FALSE; return TRUE; } -// formats a field for printing +/* formats a field for printing */ static void append_field_to_str(gpointer field, gpointer str) { info_field *f; @@ -250,7 +252,7 @@ info_field_free(f); } -// formats a group of information for printing +/* formats a group of information for printing */ static void append_group_to_str(GString *str, const gchar *group_name, const gchar **info) { GList *group; @@ -262,8 +264,8 @@ g_string_append_printf(str, "<br />"); } -// takes a contact_info struct and outputs the appropriate fields in -// a printable format for our upcoming call to gaim_notify_userinfo +/* Takes a contact_info struct and outputs the appropriate fields in + * a printable format for our upcoming call to gaim_notify_userinfo. */ static GString *info_to_str(const gchar **info) { GString *info_text; @@ -272,14 +274,14 @@ append_group_to_str(info_text, QQ_MAIN_INFO, info); append_group_to_str(info_text, QQ_EXTRA_INFO, info); append_group_to_str(info_text, QQ_PERSONAL_INTRO, info); - //if (QQ_DEBUG) append_group_to_str(info_text, QQ_MISC, info); + /* append_group_to_str(info_text, QQ_MISC, info); */ return info_text; } -/*************** packets and UI management *****************/ +/************************ packets and UI management **************************/ -// send a packet to get detailed information of uid +/* send a packet to get detailed information of uid */ void qq_send_packet_get_info(GaimConnection * gc, guint32 uid, gboolean show_window) { qq_data *qd; @@ -301,8 +303,8 @@ g_free(uid_str); } -// set up the fields requesting personal information and send a get_info packet -// for myself +/* set up the fields requesting personal information and send a get_info packet + * for myself */ void qq_prepare_modify_info(GaimConnection *gc) { qq_data *qd; @@ -311,14 +313,15 @@ qd = (qq_data *) gc->proto_data; qq_send_packet_get_info(gc, qd->uid, FALSE); - // traverse backwards so we get the most recent info_query + /* traverse backwards so we get the most recent info_query */ for (ql = g_list_last(qd->info_query); ql != NULL; ql = g_list_previous(ql)) { query = ql->data; - if (query->uid == qd->uid) query->modify_info = TRUE; + if (query->uid == qd->uid) + query->modify_info = TRUE; } } -// send packet to modify personal information +/* send packet to modify personal information */ void qq_send_packet_modify_info(GaimConnection *gc, contact_info *info) { gchar *info_field[QQ_CONTACT_FIELDS]; @@ -335,7 +338,7 @@ create_packet_b(raw_data, &cursor, bar); - // important!, skip the first uid entry + /* important!, skip the first uid entry */ for (i = 1; i < QQ_CONTACT_FIELDS; i++) { create_packet_b(raw_data, &cursor, bar); create_packet_data(raw_data, &cursor, (guint8 *) info_field[i], strlen(info_field[i])); @@ -357,8 +360,8 @@ g_free(mid); } -// runs through all of the fields in the modify info UI and put -// their values into the outgoing packet +/* Runs through all of the fields in the modify info UI and puts + * their values into the outgoing packet. */ static void parse_field(gpointer field, gpointer outgoing_info) { GaimRequestField *f; @@ -370,17 +373,19 @@ segments = (gchar **) outgoing_info; id = gaim_request_field_get_id(f); ft = info_field_get_template(id); - if (ft->choice && !ft->customizable) + if (ft->choice && !ft->customizable) { value = g_strdup_printf("%d", gaim_request_field_choice_get_value(f)); - else { + } else { value = (gchar *) gaim_request_field_string_get_value(f); - if (value == NULL) value = g_strdup("-"); - else value = utf8_to_qq(value, QQ_CHARSET_DEFAULT); + if (value == NULL) + value = g_strdup("-"); + else + value = utf8_to_qq(value, QQ_CHARSET_DEFAULT); } segments[ft->pos] = value; } -// dumps the uneditable information straight into the outgoing packet +/* dumps the uneditable information straight into the outgoing packet */ static void parse_misc_field(gpointer field, gpointer outgoing_info) { info_field *f; @@ -392,8 +397,8 @@ info_field_free(f); } -// runs through all of the information fields and copies them into an -// outgoing packet, then sends that packet +/* Runs through all of the information fields and copies them into an + * outgoing packet, then sends that packet. */ static void modify_info_ok_cb(modify_info_data *mid, GaimRequestFields *fields) { GaimConnection *gc; @@ -424,9 +429,9 @@ g_free(info_field[i]); } -// Sets up the display for one group of information. This includes -// managing which fields in the UI should be textfields and -// which choices, and also mapping ints to choice values when appropriate. +/* Sets up the display for one group of information. This includes + * managing which fields in the UI should be textfields and + * which choices, and also mapping ints to choice values when appropriate. */ static void setup_group(gpointer field, gpointer group) { info_field *f; @@ -449,7 +454,9 @@ if (valid_index) { index = atoi(f->value); value = (gchar *) choices[choice][index]; - } else value = qq_to_utf8(f->value, QQ_CHARSET_DEFAULT); + } else { + value = qq_to_utf8(f->value, QQ_CHARSET_DEFAULT); + } rf = gaim_request_field_string_new(id, f->title, value, multiline); } else { index = atoi(f->value); @@ -460,12 +467,13 @@ gaim_request_field_choice_add(rf, choices[choice][j++]); } gaim_request_field_group_add_field(g, rf); - if (!valid_index) g_free(value); + if (!valid_index) + g_free(value); info_field_free(f); } -// Takes the info returned by a get_info packet for the user and sets up -// a form using those values and the info_template. +/* Takes the info returned by a get_info packet for the user and sets up + * a form using those values and the info_template. */ static void create_modify_info_dialogue(GaimConnection *gc, const gchar **info) { qq_data *qd; @@ -476,14 +484,14 @@ modify_info_data *mid; gint i; - // so we only have one dialog open at a time + /* so we only have one dialog open at a time */ qd = (qq_data *) gc->proto_data; if (!qd->modifying_info) { qd->modifying_info = TRUE; fields = gaim_request_fields_new(); - // we only care about the first 3 groups, not the miscellaneous stuff + /* we only care about the first 3 groups, not the miscellaneous stuff */ for (i = 0; i < 3; i++) { group = gaim_request_field_group_new(info_group_headers[i]); gaim_request_fields_add_group(fields, group); @@ -492,12 +500,9 @@ g_list_free(group_list); } - //set this manually here instead of generating a new template column field = gaim_request_fields_get_field(fields, "uid"); gaim_request_field_string_set_editable(field, FALSE); - //we need to pass the info that doesn't get modified as aux data - //because we'll still need it when we send the modify_info packet mid = g_new0(modify_info_data, 1); mid->gc = gc; mid->misc = info_get_group(info, info_group_headers[3]); @@ -510,7 +515,7 @@ } } -// process the reply of modify_info packet +/* process the reply of modify_info packet */ void qq_process_modify_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { qq_data *qd; @@ -526,16 +531,16 @@ if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { data[len] = '\0'; - if (qd->uid == atoi((gchar *) data)) { // return should be my uid + if (qd->uid == atoi((gchar *) data)) { /* return should be my uid */ gaim_debug(GAIM_DEBUG_INFO, "QQ", "Update info ACK OK\n"); gaim_notify_info(gc, NULL, _("Your information has been updated"), NULL); } - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt modify info reply\n"); - + } } -// after getting info or modify myself, refresh the buddy list accordingly +/* after getting info or modify myself, refresh the buddy list accordingly */ void qq_refresh_buddy_and_myself(contact_info *info, GaimConnection *gc) { GaimBuddy *b; @@ -547,15 +552,15 @@ qd = (qq_data *) gc->proto_data; alias_utf8 = qq_to_utf8(info->nick, QQ_CHARSET_DEFAULT); - if (qd->uid == strtol(info->uid, NULL, 10)) { // it is me + if (qd->uid == strtol(info->uid, NULL, 10)) { /* it is me */ qd->my_icon = strtol(info->face, NULL, 10); if (alias_utf8 != NULL) gaim_account_set_alias(gc->account, alias_utf8); } - // update buddy list (including myself, if myself is the buddy) + /* update buddy list (including myself, if myself is the buddy) */ b = gaim_find_buddy(gc->account, uid_to_gaim_name(strtol(info->uid, NULL, 10))); q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; - if (q_bud != NULL) { // I have this buddy + if (q_bud != NULL) { /* I have this buddy */ q_bud->age = strtol(info->age, NULL, 10); q_bud->gender = strtol(info->gender, NULL, 10); q_bud->icon = strtol(info->face, NULL, 10); @@ -566,7 +571,7 @@ g_free(alias_utf8); } -// process reply to get_info packet +/* process reply to get_info packet */ void qq_process_get_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { gint len; @@ -595,7 +600,7 @@ qq_refresh_buddy_and_myself(info, gc); query_list = qd->info_query; - // ensure we're processing the right query + /* ensure we're processing the right query */ while (query_list) { query = (qq_info_query *) query_list->data; if (query->uid == atoi(info->uid)) { @@ -614,12 +619,12 @@ } g_strfreev(segments); - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt get info reply\n"); - + } } -void qq_info_query_free(qq_data * qd) +void qq_info_query_free(qq_data *qd) { gint i; qq_info_query *p; Modified: trunk/src/protocols/qq/buddy_info.h =================================================================== --- trunk/src/protocols/qq/buddy_info.h 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_info.h 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,15 +20,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ #ifndef _QQ_BUDDY_INFO_H_ #define _QQ_BUDDY_INFO_H_ #include <glib.h> -#include "connection.h" // GaimConnection -#include "buddy_opt.h" // gc_and_uid -#include "qq.h" // qq_data +#include "connection.h" +#include "buddy_opt.h" +#include "qq.h" #define QQ_COMM_FLAG_QQ_MEMBER 0x02 #define QQ_COMM_FLAG_TCP_MODE 0x10 @@ -41,56 +39,56 @@ #define QQ_BUDDY_GENDER_UNKNOWN 0xff typedef struct _contact_info { - gchar *uid; //0 - gchar *nick; //1 - gchar *country; //2 - gchar *province; //3 - gchar *zipcode; //4 - gchar *address; //5 - gchar *tel; //6 - gchar *age; //7 - gchar *gender; //8 - gchar *name; //9 - gchar *email; //10 - gchar *pager_sn; //11 - gchar *pager_num; //12 - gchar *pager_sp; //13 - gchar *pager_base_num; //14 - gchar *pager_type; //15 - gchar *occupation; //16 - gchar *homepage; //17 - gchar *auth_type; //18 - gchar *unknown1; //19 - gchar *unknown2; //20 - gchar *face; //21 - gchar *hp_num; //22 - gchar *hp_type; //23 - gchar *intro; //24 - gchar *city; //25 - gchar *unknown3; //26 - gchar *unknown4; //27 - gchar *unknown5; //28 - gchar *is_open_hp; //29 - gchar *is_open_contact; //30 - gchar *college; //31 - gchar *horoscope; //32 - gchar *zodiac; //33 sheng xiao - gchar *blood; //34 - gchar *qq_show; //35 - gchar *unknown6; //36, always 0x2D + gchar *uid; + gchar *nick; + gchar *country; + gchar *province; + gchar *zipcode; + gchar *address; + gchar *tel; + gchar *age; + gchar *gender; + gchar *name; + gchar *email; + gchar *pager_sn; + gchar *pager_num; + gchar *pager_sp; + gchar *pager_base_num; + gchar *pager_type; + gchar *occupation; + gchar *homepage; + gchar *auth_type; + gchar *unknown1; + gchar *unknown2; + gchar *face; + gchar *hp_num; + gchar *hp_type; + gchar *intro; + gchar *city; + gchar *unknown3; + gchar *unknown4; + gchar *unknown5; + gchar *is_open_hp; + gchar *is_open_contact; + gchar *college; + gchar *horoscope; + gchar *zodiac; + gchar *blood; + gchar *qq_show; + gchar *unknown6; /* always 0x2D */ } contact_info; -// There is no user id stored in the reply packet for information query -// we have to manually store the query, so that we know the query source +/* There is no user id stored in the reply packet for information query + * we have to manually store the query, so that we know the query source */ typedef struct _qq_info_query { guint32 uid; gboolean show_window; gboolean modify_info; } qq_info_query; -// We get an info packet on ourselves before we modify our information. -// Even though not all of the information is currently modifiable, it still -// all needs to be there when we send out the modify info packet +/* We get an info packet on ourselves before we modify our information. + * Even though not all of the information is currently modifiable, it still + * all needs to be there when we send out the modify info packet */ typedef struct _modify_info_data { GaimConnection *gc; GList *misc, *node; Modified: trunk/src/protocols/qq/buddy_list.c =================================================================== --- trunk/src/protocols/qq/buddy_list.c 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_list.c 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,32 +20,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ -#include <string.h> // g_memmove, memmove -#include "debug.h" // gaim_debug +#include <string.h> +#include "debug.h" -#include "notify.h" // gaim_notify -#include "utils.h" // get_ip_str -#include "packet_parse.h" // create_packet, read_packet +#include "notify.h" +#include "utils.h" +#include "packet_parse.h" #include "buddy_list.h" -#include "buddy_status.h" // qq_buddy_status -#include "buddy_opt.h" // qq_add_buddy_by_recv_packet -#include "char_conv.h" // qq_to_utf8 -#include "crypt.h" // qq_crypt -#include "header_info.h" // cmd alias -#include "keep_alive.h" // qq_refresh_all_buddy_status -#include "send_core.h" // qq_send_cmd -#include "qq.h" // qq_data -#include "group.h" // qq_group, by gfhuang -#include "group_find.h" // qq_group_find -#include "group_hash.h" //qq_group_create_by_id -#include "group_info.h" //qq_send_cmd_group_get_group_info +#include "buddy_status.h" +#include "buddy_opt.h" +#include "char_conv.h" +#include "crypt.h" +#include "header_info.h" +#include "keep_alive.h" +#include "send_core.h" +#include "qq.h" +#include "group.h" +#include "group_find.h" +#include "group_hash.h" +#include "group_info.h" #include "qq_proxy.h" #define QQ_GET_ONLINE_BUDDY_02 0x02 -#define QQ_GET_ONLINE_BUDDY_03 0x03 // unknown function +#define QQ_GET_ONLINE_BUDDY_03 0x03 /* unknown function */ #define QQ_ONLINE_BUDDY_ENTRY_LEN 38 @@ -55,12 +53,11 @@ guint8 flag1; guint8 comm_flag; guint16 unknown2; - guint8 ending; //0x00 + guint8 ending; /* 0x00 */ } qq_friends_online_entry; -/*****************************************************************************/ -// get a list of online_buddies -void qq_send_packet_get_buddies_online(GaimConnection * gc, guint8 position) +/* get a list of online_buddies */ +void qq_send_packet_get_buddies_online(GaimConnection *gc, guint8 position) { qq_data *qd; guint8 *raw_data, *cursor; @@ -71,27 +68,25 @@ raw_data = g_newa(guint8, 5); cursor = raw_data; - // 000-000 get online friends cmd - // only 0x02 and 0x03 returns info from server, other valuse all return 0xff - // I can also only send the first byte (0x02, or 0x03) - // and the result is the same + /* 000-000 get online friends cmd + * only 0x02 and 0x03 returns info from server, other valuse all return 0xff + * I can also only send the first byte (0x02, or 0x03) + * and the result is the same */ create_packet_b(raw_data, &cursor, QQ_GET_ONLINE_BUDDY_02); - // 001-001 seems it supports 255 online buddies at most + /* 001-001 seems it supports 255 online buddies at most */ create_packet_b(raw_data, &cursor, position); - // 002-002 + /* 002-002 */ create_packet_b(raw_data, &cursor, 0x00); - // 003-004 + /* 003-004 */ create_packet_w(raw_data, &cursor, 0x0000); qq_send_cmd(gc, QQ_CMD_GET_FRIENDS_ONLINE, TRUE, 0, TRUE, raw_data, 5); qd->last_get_online = time(NULL); +} -} // qq_send_packet_get_buddies_online - -/*****************************************************************************/ -// position starts with 0x0000, -// server may return a position tag if list is too long for one packet -void qq_send_packet_get_buddies_list(GaimConnection * gc, guint16 position) +/* position starts with 0x0000, + * server may return a position tag if list is too long for one packet */ +void qq_send_packet_get_buddies_list(GaimConnection *gc, guint16 position) { guint8 *raw_data, *cursor; gint data_len; @@ -101,20 +96,19 @@ data_len = 3; raw_data = g_newa(guint8, data_len); cursor = raw_data; - // 000-001 starting position, can manually specify + /* 000-001 starting position, can manually specify */ create_packet_w(raw_data, &cursor, position); - // before Mar 18, 2004, any value can work, and we sent 00 - // I do not know what data QQ server is expecting, as QQ2003iii 0304 itself - // even can sending packets 00 and get no response. - // Now I tested that 00,00,00,00,00,01 work perfectly - // March 22, fount the 00,00,00 starts to work as well + /* before Mar 18, 2004, any value can work, and we sent 00 + * I do not know what data QQ server is expecting, as QQ2003iii 0304 itself + * even can sending packets 00 and get no response. + * Now I tested that 00,00,00,00,00,01 work perfectly + * March 22, found the 00,00,00 starts to work as well */ create_packet_b(raw_data, &cursor, 0x00); qq_send_cmd(gc, QQ_CMD_GET_FRIENDS_LIST, TRUE, 0, TRUE, raw_data, data_len); +} -} // qq_send_packet_get_buddies_list - -// get all list, buddies & Quns with groupsid support, written by gfhuang +/* get all list, buddies & Quns with groupsid support */ void qq_send_packet_get_all_list_with_group(GaimConnection *gc, guint32 position) { guint8 *raw_data, *cursor; @@ -125,19 +119,18 @@ data_len = 10; raw_data = g_newa(guint8, data_len); cursor = raw_data; - // 0x01 download, 0x02, upload + /* 0x01 download, 0x02, upload */ create_packet_b(raw_data, &cursor, 0x01); - //unknown 0x02 + /* unknown 0x02 */ create_packet_b(raw_data, &cursor, 0x02); - //unknown 00 00 00 00 + /* unknown 00 00 00 00 */ create_packet_dw(raw_data, &cursor, 0x00000000); create_packet_dw(raw_data, &cursor, position); qq_send_cmd(gc, QQ_CMD_GET_ALL_LIST_WITH_GROUP, TRUE, 0, TRUE, raw_data, data_len); } -/*****************************************************************************/ -static void _qq_buddies_online_reply_dump_unclear(qq_friends_online_entry * fe) +static void _qq_buddies_online_reply_dump_unclear(qq_friends_online_entry *fe) { GString *dump; @@ -154,12 +147,11 @@ gaim_debug(GAIM_DEBUG_INFO, "QQ", "Online buddy entry, %s", dump->str); g_string_free(dump, TRUE); -} // _qq_buddies_online_reply_dump_unknown +} -/*****************************************************************************/ -// process the reply packet for get_buddies_online packet -void qq_process_get_buddies_online_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { - +/* process the reply packet for get_buddies_online packet */ +void qq_process_get_buddies_online_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; gint len, bytes; guint8 *data, *cursor, position; @@ -187,57 +179,59 @@ fe->s = g_newa(qq_buddy_status, 1); while (cursor < (data + len)) { - // based on one online buddy entry + /* based on one online buddy entry */ bytes = 0; - // 000-030 qq_buddy_status + /* 000-030 qq_buddy_status */ bytes += qq_buddy_status_read(data, &cursor, len, fe->s); - // 031-032: unknown4 + /* 031-032: unknown4 */ bytes += read_packet_w(data, &cursor, len, &fe->unknown1); - // 033-033: flag1 + /* 033-033: flag1 */ bytes += read_packet_b(data, &cursor, len, &fe->flag1); - // 034-034: comm_flag + /* 034-034: comm_flag */ bytes += read_packet_b(data, &cursor, len, &fe->comm_flag); - // 035-036: + /* 035-036: */ bytes += read_packet_w(data, &cursor, len, &fe->unknown2); - // 037-037: - bytes += read_packet_b(data, &cursor, len, &fe->ending); // 0x00 + /* 037-037: */ + bytes += read_packet_b(data, &cursor, len, &fe->ending); /* 0x00 */ if (fe->s->uid == 0 || bytes != QQ_ONLINE_BUDDY_ENTRY_LEN) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "uid=0 or entry complete len(%d) != %d", bytes, QQ_ONLINE_BUDDY_ENTRY_LEN); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "uid=0 or entry complete len(%d) != %d", + bytes, QQ_ONLINE_BUDDY_ENTRY_LEN); g_free(fe->s->ip); g_free(fe->s->unknown_key); continue; - } // check if it is a valid entry + } /* check if it is a valid entry */ if (QQ_DEBUG) _qq_buddies_online_reply_dump_unclear(fe); - // update buddy information + /* update buddy information */ b = gaim_find_buddy(gaim_connection_get_account(gc), uid_to_gaim_name(fe->s->uid)); q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; - if (q_bud != NULL) { // we find one and update qq_buddy + if (q_bud != NULL) { /* we find one and update qq_buddy */ if(0 != fe->s->client_version) - q_bud->client_version = fe->s->client_version; //by gfhuang - // if(0 != *((guint32 *)fe->s->ip)) { // by gfhuang - g_memmove(q_bud->ip, fe->s->ip, 4); - q_bud->port = fe->s->port; - // } + q_bud->client_version = fe->s->client_version; + g_memmove(q_bud->ip, fe->s->ip, 4); + q_bud->port = fe->s->port; q_bud->status = fe->s->status; q_bud->flag1 = fe->flag1; q_bud->comm_flag = fe->comm_flag; qq_update_buddy_contact(gc, q_bud); - } // if q_bud + } else { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Got an online buddy %d, but not in my buddy list", fe->s->uid); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "Got an online buddy %d, but not in my buddy list", fe->s->uid); } g_free(fe->s->ip); g_free(fe->s->unknown_key); - } // while cursor + } if(cursor > (data + len)) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "qq_process_get_buddies_online_reply: Dangerous error! maybe protocal changed, notify me!"); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "qq_process_get_buddies_online_reply: Dangerous error! maybe protocol changed, notify developers!"); } if (position != QQ_FRIENDS_ONLINE_POSITION_END) { @@ -245,17 +239,18 @@ qq_send_packet_get_buddies_online(gc, position); } - else + else { qq_refresh_all_buddy_status(gc); + } - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt buddies online"); + } +} -} // qq_process_get_buddies_online_reply - -/*****************************************************************************/ -// process reply for get_buddies_list -void qq_process_get_buddies_list_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { +/* process reply for get_buddies_list */ +void qq_process_get_buddies_list_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; qq_buddy *q_bud; gint len, bytes, bytes_expected, i; @@ -274,20 +269,20 @@ if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { read_packet_w(data, &cursor, len, &position); - // the following data is buddy list in this packet + /* the following data is buddy list in this packet */ i = 0; while (cursor < (data + len)) { q_bud = g_new0(qq_buddy, 1); bytes = 0; - // 000-003: uid + /* 000-003: uid */ bytes += read_packet_dw(data, &cursor, len, &q_bud->uid); - // 004-004: 0xff if buddy is self, 0x00 otherwise + /* 004-004: 0xff if buddy is self, 0x00 otherwise */ bytes += read_packet_b(data, &cursor, len, &bar); - // 005-005: icon index (1-255) + /* 005-005: icon index (1-255) */ bytes += read_packet_b(data, &cursor, len, &q_bud->icon); - // 006-006: age + /* 006-006: age */ bytes += read_packet_b(data, &cursor, len, &q_bud->age); - // 007-007: gender + /* 007-007: gender */ bytes += read_packet_b(data, &cursor, len, &q_bud->gender); pascal_len = convert_as_pascal_string(cursor, &q_bud->nickname, QQ_CHARSET_DEFAULT); cursor += pascal_len; @@ -313,13 +308,15 @@ g_free(q_bud->nickname); g_free(q_bud); continue; - } else + } else { i++; + } - if (QQ_DEBUG) + if (QQ_DEBUG) { gaim_debug(GAIM_DEBUG_INFO, "QQ", "buddy [%09d]: flag1=0x%02x, comm_flag=0x%02x\n", q_bud->uid, q_bud->flag1, q_bud->comm_flag); + } name = uid_to_gaim_name(q_bud->uid); b = gaim_find_buddy(gc->account, name); @@ -331,25 +328,24 @@ b->proto_data = q_bud; qd->buddies = g_list_append(qd->buddies, q_bud); qq_update_buddy_contact(gc, q_bud); - } // while cursor + } if(cursor > (data + len)) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "qq_process_get_buddies_list_reply: Dangerous error! maybe protocal changed, notify me!"); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "qq_process_get_buddies_list_reply: Dangerous error! maybe protocol changed, notify developers!"); } if (position == QQ_FRIENDS_LIST_POSITION_END) { gaim_debug(GAIM_DEBUG_INFO, "QQ", "Get friends list done, %d buddies\n", i); qq_send_packet_get_buddies_online(gc, QQ_FRIENDS_ONLINE_POSITION_START); - } else + } else { qq_send_packet_get_buddies_list(gc, position); - - } else + } + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt buddies list"); + } +} -} // qq_process_get_buddies_list_reply - - -// written by gfhuang -void qq_process_get_all_list_with_group_reply(guint8 * buf, gint buf_len, GaimConnection * gc) +void qq_process_get_all_list_with_group_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { qq_data *qd; gint len, i, j; @@ -377,27 +373,28 @@ g_return_if_fail(sub_cmd == 0x01); read_packet_b(data, &cursor, len, &reply_code); if(0 != reply_code) { - gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Get all list with group reply, reply_code(%d) is not zero", reply_code); + gaim_debug(GAIM_DEBUG_WARNING, "QQ", + "Get all list with group reply, reply_code(%d) is not zero", reply_code); } read_packet_dw(data, &cursor, len, &unknown); read_packet_dw(data, &cursor, len, &position); - // the following data is all list in this packet + /* the following data is all list in this packet */ i = 0; j = 0; while (cursor < (data + len)) { - // 00-03: uid + /* 00-03: uid */ read_packet_dw(data, &cursor, len, &uid); - // 04: type 0x1:buddy 0x4:Qun + /* 04: type 0x1:buddy 0x4:Qun */ read_packet_b(data, &cursor, len, &type); - // 05: groupid*4 + /* 05: groupid*4 */ read_packet_b(data, &cursor, len, &groupid); - groupid >>= 2; // these 2 bits might not be 0, faint! + groupid >>= 2; /* these 2 bits might not be 0, faint! */ if (uid == 0 || (type != 0x1 && type != 0x4)) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Buddy entry, uid=%d, type=%d", uid, type); continue; } - if(0x1 == type) { // a buddy + if(0x1 == type) { /* a buddy */ name = uid_to_gaim_name(uid); b = gaim_find_buddy(gc->account, name); g_free(name); @@ -408,23 +405,23 @@ } else { q_bud = NULL; - b->proto_data = q_bud; //wrong !!!! + b->proto_data = q_bud; /* wrong !!!! */ } qd->buddies = g_list_append(qd->buddies, q_bud); qq_update_buddy_contact(gc, q_bud); ++i; - } - else { //a group - group = qq_group_find_by_internal_group_id(gc, uid); + } else { /* a group */ + group = qq_group_find_by_internal_group_id(gc, uid); if(group == NULL) { - /* not working, gfhuang + /* not working group = qq_group_create_by_id(gc, uid, 0); qq_send_cmd_group_get_group_info(gc, group); */ - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Get a Qun with internel group %d\n", uid); - gaim_notify_info(gc, _("QQ Qun Operation"), _("Find one Qun in the server list, but i don't know its external id, please re-rejoin it manually"), NULL); - } - else { + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "Get a Qun with internal group %d\n", uid); + gaim_notify_info(gc, _("QQ Qun Operation"), + _("Find one Qun in the server list, but i don't know its external id, please re-rejoin it manually"), NULL); + } else { group->my_status = QQ_GROUP_MEMBER_STATUS_IS_MEMBER; qq_group_refresh(gc, group); qq_send_cmd_group_get_group_info(gc, group); @@ -433,12 +430,11 @@ } } if(cursor > (data + len)) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "qq_process_get_all_list_with_group_reply: Dangerous error! maybe protocal changed, notify me!"); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "qq_process_get_all_list_with_group_reply: Dangerous error! maybe protocol changed, notify developers!"); } - gaim_debug(GAIM_DEBUG_INFO, "QQ", "Get all list done, %d buddies and %d Quns\n", i, j); - } else + gaim_debug(GAIM_DEBUG_INFO, "QQ", "Get all list done, %d buddies and %d Quns\n", i, j); + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt all list with group"); - + } } -/*****************************************************************************/ -// END OF FILE Modified: trunk/src/protocols/qq/buddy_list.h =================================================================== --- trunk/src/protocols/qq/buddy_list.h 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_list.h 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,28 +20,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ #ifndef _QQ_BUDDY_LIST_H_ #define _QQ_BUDDY_LIST_H_ #include <glib.h> -#include "connection.h" // GaimConnection +#include "connection.h" #define QQ_FRIENDS_LIST_POSITION_START 0x0000 #define QQ_FRIENDS_LIST_POSITION_END 0xffff #define QQ_FRIENDS_ONLINE_POSITION_START 0x00 #define QQ_FRIENDS_ONLINE_POSITION_END 0xff -void qq_send_packet_get_buddies_online(GaimConnection * gc, guint8 position); -void qq_process_get_buddies_online_reply(guint8 * buf, gint buf_len, GaimConnection * gc); -void qq_send_packet_get_buddies_list(GaimConnection * gc, guint16 position); -void qq_process_get_buddies_list_reply(guint8 * buf, gint buf_len, GaimConnection * gc); +void qq_send_packet_get_buddies_online(GaimConnection *gc, guint8 position); +void qq_process_get_buddies_online_reply(guint8 *buf, gint buf_len, GaimConnection *gc); +void qq_send_packet_get_buddies_list(GaimConnection *gc, guint16 position); +void qq_process_get_buddies_list_reply(guint8 *buf, gint buf_len, GaimConnection *gc); +void qq_send_packet_get_all_list_with_group(GaimConnection *gc, guint32 position); +void qq_process_get_all_list_with_group_reply(guint8 *buf, gint buf_len, GaimConnection *gc); -//added by gfhuang -void qq_send_packet_get_all_list_with_group(GaimConnection * gc, guint32 position); -void qq_process_get_all_list_with_group_reply(guint8 * buf, gint buf_len, GaimConnection * gc); - #endif -/*****************************************************************************/ -// END OF FILE Modified: trunk/src/protocols/qq/buddy_opt.c =================================================================== --- trunk/src/protocols/qq/buddy_opt.c 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_opt.c 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,24 +20,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ -#include "debug.h" // gaim_debug -#include "internal.h" // strlen, _("get_text") -#include "notify.h" // gaim_notify -#include "request.h" // gaim_request_input +#include "debug.h" +#include "internal.h" +#include "notify.h" +#include "request.h" -#include "utils.h" // uid_to_gaim_name, gaim_name_to_uid -#include "packet_parse.h" // create_packet, read_packet -#include "buddy_info.h" // qq_send_packet_get_info -#include "buddy_list.h" // qq_send_packet_get_buddies_online +#include "buddy_info.h" +#include "buddy_list.h" #include "buddy_opt.h" -#include "char_conv.h" // qq_to_utf8 -#include "crypt.h" // qq_crypt -#include "header_info.h" // cmd alias -#include "keep_alive.h" // qq_update_buddy_contact -#include "im.h" // QQ_MSG_IM_MAX -#include "send_core.h" // qq_send_cmd +#include "char_conv.h" +#include "crypt.h" +#include "header_info.h" +#include "im.h" +#include "keep_alive.h" +#include "packet_parse.h" +#include "send_core.h" +#include "utils.h" #define GAIM_GROUP_QQ_FORMAT "QQ (%s)" #define GAIM_GROUP_QQ_UNKNOWN "QQ Unknown" @@ -45,12 +43,12 @@ #define QQ_REMOVE_BUDDY_REPLY_OK 0x00 #define QQ_REMOVE_SELF_REPLY_OK 0x00 -#define QQ_ADD_BUDDY_AUTH_REPLY_OK 0x30 // ASCii value of "0" +#define QQ_ADD_BUDDY_AUTH_REPLY_OK 0x30 /* ASCII value of "0" */ enum { - QQ_MY_AUTH_APPROVE = 0x30, // ASCii value of "0" - QQ_MY_AUTH_REJECT = 0x31, // ASCii value of "1" - QQ_MY_AUTH_REQUEST = 0x32, // ASCii value of "2" + QQ_MY_AUTH_APPROVE = 0x30, /* ASCII value of "0" */ + QQ_MY_AUTH_REJECT = 0x31, /* ASCII value of "1" */ + QQ_MY_AUTH_REQUEST = 0x32, /* ASCII value of "2" */ }; typedef struct _qq_add_buddy_request { @@ -58,9 +56,8 @@ guint16 seq; } qq_add_buddy_request; -/*****************************************************************************/ -// send packet to remove a buddy from my buddy list -static void _qq_send_packet_remove_buddy(GaimConnection * gc, guint32 uid) +/* send packet to remove a buddy from my buddy list */ +static void _qq_send_packet_remove_buddy(GaimConnection *gc, guint32 uid) { gchar *uid_str; @@ -70,11 +67,10 @@ qq_send_cmd(gc, QQ_CMD_DEL_FRIEND, TRUE, 0, TRUE, uid_str, strlen(uid_str)); g_free(uid_str); -} // _qq_send_packet_remove_buddy +} -/*****************************************************************************/ -// try to remove myself from someone's buddy list -static void _qq_send_packet_remove_self_from(GaimConnection * gc, guint32 uid) +/* try to remove myself from someone's buddy list */ +static void _qq_send_packet_remove_self_from(GaimConnection *gc, guint32 uid) { guint8 *raw_data, *cursor; @@ -85,12 +81,10 @@ create_packet_dw(raw_data, &cursor, uid); qq_send_cmd(gc, QQ_CMD_REMOVE_SELF, TRUE, 0, TRUE, raw_data, 4); +} -} // _qq_send_packet_add_buddy - -/*****************************************************************************/ -// try to add a buddy without authentication -static void _qq_send_packet_add_buddy(GaimConnection * gc, guint32 uid) +/* try to add a buddy without authentication */ +static void _qq_send_packet_add_buddy(GaimConnection *gc, guint32 uid) { qq_data *qd; qq_add_buddy_request *req; @@ -98,22 +92,21 @@ g_return_if_fail(gc != NULL && gc->proto_data != NULL && uid > 0); - // we need to send the ascii code of this uid to qq server + /* we need to send the ascii code of this uid to qq server */ uid_str = g_strdup_printf("%d", uid); qq_send_cmd(gc, QQ_CMD_ADD_FRIEND_WO_AUTH, TRUE, 0, TRUE, uid_str, strlen(uid_str)); g_free(uid_str); - // must be set after sending packet to get the correct send_seq + /* must be set after sending packet to get the correct send_seq */ qd = (qq_data *) gc->proto_data; req = g_new0(qq_add_buddy_request, 1); req->seq = qd->send_seq; req->uid = uid; qd->add_buddy_request = g_list_append(qd->add_buddy_request, req); -} // _qq_send_packet_add_buddy +} -/*****************************************************************************/ -// this buddy needs authentication, text conversion is done at lowest level -static void _qq_send_packet_buddy_auth(GaimConnection * gc, guint32 uid, const gchar response, const gchar * text) +/* this buddy needs authentication, text conversion is done at lowest level */ +static void _qq_send_packet_buddy_auth(GaimConnection *gc, guint32 uid, const gchar response, const gchar *text) { gchar *text_qq, *uid_str; guint8 bar, *cursor, *raw_data; @@ -138,11 +131,10 @@ qq_send_cmd(gc, QQ_CMD_BUDDY_AUTH, TRUE, 0, TRUE, raw_data, cursor - raw_data); g_free(uid_str); -} // _qq_send_packet_buddy_auth +} - -/*****************************************************************************/ -static void _qq_send_packet_add_buddy_auth_with_gc_and_uid(gc_and_uid * g, const gchar * text) { +static void _qq_send_packet_add_buddy_auth_with_gc_and_uid(gc_and_uid *g, const gchar *text) +{ GaimConnection *gc; guint32 uid; g_return_if_fail(g != NULL); @@ -153,11 +145,10 @@ _qq_send_packet_buddy_auth(gc, uid, QQ_MY_AUTH_REQUEST, text); g_free(g); -} // qq_send_packet_add_buddy_auth +} -/*****************************************************************************/ -// the real packet to reject and request is sent from here -static void _qq_reject_add_request_real(gc_and_uid * g, const gchar * reason) +/* the real packet to reject and request is sent from here */ +static void _qq_reject_add_request_real(gc_and_uid *g, const gchar *reason) { gint uid; GaimConnection *gc; @@ -170,11 +161,10 @@ _qq_send_packet_buddy_auth(gc, uid, QQ_MY_AUTH_REJECT, reason); g_free(g); -} // _qq_reject_add_request_real +} -/*****************************************************************************/ -// we approve other's request of adding me as friend -void qq_approve_add_request_with_gc_and_uid(gc_and_uid * g) +/* we approve other's request of adding me as friend */ +void qq_approve_add_request_with_gc_and_uid(gc_and_uid *g) { gint uid; GaimConnection *gc; @@ -187,17 +177,15 @@ _qq_send_packet_buddy_auth(gc, uid, QQ_MY_AUTH_APPROVE, NULL); g_free(g); -} // qq_approve_add_request_with_gc_and_uid +} -/*****************************************************************************/ -void qq_do_nothing_with_gc_and_uid(gc_and_uid * g, const gchar * msg) +void qq_do_nothing_with_gc_and_uid(gc_and_uid *g, const gchar *msg) { g_free(g); -} // qq_do_nothing_with_gc_and_uid +} -/*****************************************************************************/ -// we reject other's request of adding me as friend -void qq_reject_add_request_with_gc_and_uid(gc_and_uid * g) +/* we reject other's request of adding me as friend */ +void qq_reject_add_request_with_gc_and_uid(gc_and_uid *g) { gint uid; gchar *msg1, *msg2; @@ -222,11 +210,9 @@ gaim_request_input(gc, _("Reject request"), msg1, msg2, _("Sorry, you are not my type..."), TRUE, FALSE, NULL, _("Reject"), G_CALLBACK(_qq_reject_add_request_real), _("Cancel"), NULL, g2); +} -} // qq_reject_add_request_with_gc_and_uid - -/*****************************************************************************/ -void qq_add_buddy_with_gc_and_uid(gc_and_uid * g) +void qq_add_buddy_with_gc_and_uid(gc_and_uid *g) { gint uid; GaimConnection *gc; @@ -239,10 +225,9 @@ _qq_send_packet_add_buddy(gc, uid); g_free(g); -} // qq_add_buddy_with_gc_and_uid +} -/*****************************************************************************/ -void qq_block_buddy_with_gc_and_uid(gc_and_uid * g) +void qq_block_buddy_with_gc_and_uid(gc_and_uid *g) { guint32 uid; GaimConnection *gc; @@ -260,12 +245,11 @@ qq_remove_buddy(gc, &buddy, &group); _qq_send_packet_remove_self_from(gc, uid); +} -} // qq_block_buddy_with_gc_and_uid - -/*****************************************************************************/ -// process reply to add_buddy_auth request -void qq_process_add_buddy_auth_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { +/* process reply to add_buddy_auth request */ +void qq_process_add_buddy_auth_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; gint len; guint8 *data, *cursor, reply; @@ -288,16 +272,17 @@ msg_utf8 = qq_to_utf8(segments[1], QQ_CHARSET_DEFAULT); gaim_notify_error(gc, NULL, _("Add buddy with auth request fails"), msg_utf8); g_free(msg_utf8); - } else + } else { gaim_debug(GAIM_DEBUG_INFO, "QQ", "Add buddy with auth request OK\n"); - } else + } + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt add buddy with auth reply\n"); + } +} -} // qq_process_add_buddy_auth_reply - -/*****************************************************************************/ -// process the server reply for my request to remove a buddy -void qq_process_remove_buddy_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { +/* process the server reply for my request to remove a buddy */ +void qq_process_remove_buddy_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; gint len; guint8 *data, *cursor, reply; @@ -312,22 +297,21 @@ if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { cursor = data; read_packet_b(data, &cursor, len, &reply); - if (reply != QQ_REMOVE_BUDDY_REPLY_OK) - // there is no reason return from server + if (reply != QQ_REMOVE_BUDDY_REPLY_OK) { + /* there is no reason return from server */ gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Remove buddy fails\n"); - else { // if reply + } else { /* if reply */ gaim_debug(GAIM_DEBUG_INFO, "QQ", "Remove buddy OK\n"); gaim_notify_info(gc, NULL, _("You have successfully removed a buddy"), NULL); } - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt remove buddy reply\n"); + } +} -} // qq_process_remove_buddy_reply - - -/*****************************************************************************/ -// process the server reply for my request to remove myself from a buddy -void qq_process_remove_self_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { +/* process the server reply for my request to remove myself from a buddy */ +void qq_process_remove_self_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; gint len; guint8 *data, *cursor, reply; @@ -343,19 +327,19 @@ cursor = data; read_packet_b(data, &cursor, len, &reply); if (reply != QQ_REMOVE_SELF_REPLY_OK) - // there is no reason return from server + /* there is no reason return from server */ gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Remove self fails\n"); - else { // if reply + else { /* if reply */ gaim_debug(GAIM_DEBUG_INFO, "QQ", "Remove self from a buddy OK\n"); gaim_notify_info(gc, NULL, _("You have successfully removed yourself from a buddy"), NULL); } - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt remove self reply\n"); + } +} -} // qq_process_remove_buddy_reply - -/*****************************************************************************/ -void qq_process_add_buddy_reply(guint8 * buf, gint buf_len, guint16 seq, GaimConnection * gc) { +void qq_process_add_buddy_reply(guint8 *buf, gint buf_len, guint16 seq, GaimConnection *gc) +{ qq_data *qd; gint len, for_uid; gchar *msg, *data, **segments, *uid, *reply; @@ -374,20 +358,21 @@ list = qd->add_buddy_request; while (list != NULL) { req = (qq_add_buddy_request *) list->data; - if (req->seq == seq) { // reply to this + if (req->seq == seq) { /* reply to this */ for_uid = req->uid; qd->add_buddy_request = g_list_remove(qd->add_buddy_request, qd->add_buddy_request->data); g_free(req); break; } list = list->next; - } // while list + } - if (for_uid == 0) { // we have no record for this + if (for_uid == 0) { /* we have no record for this */ gaim_debug(GAIM_DEBUG_ERROR, "QQ", "We have no record for add buddy reply [%d], discard\n", seq); return; - } else + } else { gaim_debug(GAIM_DEBUG_INFO, "QQ", "Add buddy reply [%d] is for id [%d]\n", seq, for_uid); + } data = g_newa(guint8, len); @@ -396,13 +381,13 @@ return; uid = segments[0]; reply = segments[1]; - if (strtol(uid, NULL, 10) != qd->uid) { // should not happen + if (strtol(uid, NULL, 10) != qd->uid) { /* should not happen */ gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Add buddy reply is to [%s], not me!", uid); g_strfreev(segments); return; - } // if uid + } - if (strtol(reply, NULL, 10) > 0) { // need auth + if (strtol(reply, NULL, 10) > 0) { /* need auth */ gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Add buddy attempt fails, need authentication\n"); b = gaim_find_buddy(gc->account, uid_to_gaim_name(for_uid)); if (b != NULL) @@ -419,20 +404,19 @@ (_qq_send_packet_add_buddy_auth_with_gc_and_uid), _("Cancel"), G_CALLBACK(qq_do_nothing_with_gc_and_uid), g); g_free(msg); - } else { // add OK + } else { /* add OK */ qq_add_buddy_by_recv_packet(gc, for_uid, TRUE, TRUE); msg = g_strdup_printf(_("You have added %d in buddy list"), for_uid); gaim_notify_info(gc, NULL, msg, NULL); g_free(msg); - } // if reply + } g_strfreev(segments); - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt add buddy reply\n"); + } +} -} // qq_process_add_buddy_reply - -/*****************************************************************************/ -GaimGroup *qq_get_gaim_group(const gchar * group_name) +GaimGroup *qq_get_gaim_group(const gchar *group_name) { GaimGroup *g; @@ -443,15 +427,15 @@ g = gaim_group_new(group_name); gaim_blist_add_group(g, NULL); gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Add new group: %s\n", group_name); - } // if (g == NULL) + } return g; -} // qq_get_gaim_group +} -/*****************************************************************************/ -// we add new buddy, if the received packet is from someone not in my list -// return the GaimBuddy that is just created -GaimBuddy *qq_add_buddy_by_recv_packet(GaimConnection * gc, guint32 uid, gboolean is_known, gboolean create) { +/* we add new buddy, if the received packet is from someone not in my list + * return the GaimBuddy that is just created */ +GaimBuddy *qq_add_buddy_by_recv_packet(GaimConnection *gc, guint32 uid, gboolean is_known, gboolean create) +{ GaimAccount *a; GaimBuddy *b; GaimGroup *g; @@ -472,8 +456,8 @@ name = uid_to_gaim_name(uid); b = gaim_find_buddy(gc->account, name); - // remove old, we can not simply return here - // because there might be old local copy of this buddy + /* remove old, we can not simply return here + * because there might be old local copy of this buddy */ if (b != NULL) gaim_blist_remove_buddy(b); @@ -488,7 +472,7 @@ qd->buddies = g_list_append(qd->buddies, q_bud); qq_send_packet_get_info(gc, q_bud->uid, FALSE); qq_send_packet_get_buddies_online(gc, QQ_FRIENDS_ONLINE_POSITION_START); - } // if !create + } gaim_blist_add_buddy(b, NULL, g, NULL); gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Add new buddy: [%s]\n", name); @@ -497,14 +481,14 @@ g_free(group_name); return b; -} // qq_add_buddy_by_recv_packet +} -/*****************************************************************************/ -// add a buddy and send packet to QQ server -// note that when gaim load local cached buddy list into its blist -// it also calls this funtion, so we have to -// define qd->logged_in=TRUE AFTER serv_finish_login(gc) -void qq_add_buddy(GaimConnection * gc, GaimBuddy * buddy, GaimGroup * group) { +/* add a buddy and send packet to QQ server + * note that when gaim load local cached buddy list into its blist + * it also calls this funtion, so we have to + * define qd->logged_in=TRUE AFTER serv_finish_login(gc) */ +void qq_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) +{ qq_data *qd; guint32 uid; GaimBuddy *b; @@ -513,7 +497,7 @@ qd = (qq_data *) gc->proto_data; if (!qd->logged_in) - return; // IMPORTANT ! + return; /* IMPORTANT ! */ uid = gaim_name_to_uid(buddy->name); if (uid > 0) @@ -526,11 +510,11 @@ _("QQid Error"), _("Invalid QQid, to add buddy 1234567, \nyou should input qq-1234567")); } -} // _qq_add_buddy +} -/*****************************************************************************/ -// remove a buddy and send packet to QQ server accordingly -void qq_remove_buddy(GaimConnection * gc, GaimBuddy * buddy, GaimGroup * group) { +/* remove a buddy and send packet to QQ server accordingly */ +void qq_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) +{ qq_data *qd; GaimBuddy *b; qq_buddy *q_bud; @@ -554,18 +538,16 @@ qd->buddies = g_list_remove(qd->buddies, q_bud); else gaim_debug(GAIM_DEBUG_WARNING, "QQ", "We have no qq_buddy record for %s\n", buddy->name); - // remove buddy on blist, this does not trigger qq_remove_buddy again - // do this only if the request comes from block request, - // otherwise gaim segmentation fault - if (g_ascii_strcasecmp(group->name, GAIM_GROUP_QQ_BLOCKED) - == 0) + /* remove buddy on blist, this does not trigger qq_remove_buddy again + * do this only if the request comes from block request, + * otherwise gaim segmentation fault */ + if (g_ascii_strcasecmp(group->name, GAIM_GROUP_QQ_BLOCKED) == 0) gaim_blist_remove_buddy(b); - } // if b != NULL -} // _qq_remove_buddy + } +} -/*****************************************************************************/ -// free add buddy request queue -void qq_add_buddy_request_free(qq_data * qd) +/* free add buddy request queue */ +void qq_add_buddy_request_free(qq_data *qd) { gint i; qq_add_buddy_request *p; @@ -580,11 +562,10 @@ i++; } gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d add buddy requests are freed!\n", i); -} // qq_add_buddy_request_free +} -/*****************************************************************************/ -// free up all qq_buddy -void qq_buddies_list_free(GaimAccount *account, qq_data * qd) +/* free up all qq_buddy */ +void qq_buddies_list_free(GaimAccount *account, qq_data *qd) { gint i; qq_buddy *p; @@ -597,21 +578,16 @@ while (qd->buddies) { p = (qq_buddy *) (qd->buddies->data); qd->buddies = g_list_remove(qd->buddies, p); - // added by gfhuang, for relogin crash bug name = uid_to_gaim_name(p->uid); b = gaim_find_buddy(account, name); - if(b != NULL) b->proto_data = NULL; - else { + if(b != NULL) + b->proto_data = NULL; + else gaim_debug(GAIM_DEBUG_INFO, "QQ", "qq_buddy %s not found in gaim proto_data\n", name); - } g_free(name); g_free(p); i++; } gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d qq_buddy structures are freed!\n", i); - -} // qq_buddies_list_free - -/*****************************************************************************/ -// END OF FILE +} Modified: trunk/src/protocols/qq/buddy_opt.h =================================================================== --- trunk/src/protocols/qq/buddy_opt.h 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_opt.h 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,15 +20,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ #ifndef _QQ_BUDDY_OPT_H_ #define _QQ_BUDDY_OPT_H_ #include <glib.h> -#include "connection.h" // GaimConnection +#include "connection.h" -#include "qq.h" // qq_buddy +#include "qq.h" typedef struct _gc_and_uid gc_and_uid; @@ -37,29 +35,26 @@ GaimConnection *gc; }; -void qq_approve_add_request_with_gc_and_uid(gc_and_uid * g); +void qq_approve_add_request_with_gc_and_uid(gc_and_uid *g); +void qq_reject_add_request_with_gc_and_uid(gc_and_uid *g); -void qq_reject_add_request_with_gc_and_uid(gc_and_uid * g); +void qq_add_buddy_with_gc_and_uid(gc_and_uid *g); +void qq_block_buddy_with_gc_and_uid(gc_and_uid *g); -void qq_add_buddy_wi... [truncated message content] |
From: <mar...@us...> - 2006-08-06 21:03:20
|
Revision: 16657 Author: markhuetsch Date: 2006-08-06 14:03:10 -0700 (Sun, 06 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16657&view=rev Log Message: ----------- Took care of some signedness issues. Modified Paths: -------------- trunk/src/protocols/qq/char_conv.c trunk/src/protocols/qq/file_trans.c trunk/src/protocols/qq/im.c trunk/src/protocols/qq/im.h trunk/src/protocols/qq/qq_proxy.c trunk/src/protocols/qq/qq_proxy.h trunk/src/protocols/qq/send_file.c trunk/src/protocols/qq/udp_proxy_s5.c Modified: trunk/src/protocols/qq/char_conv.c =================================================================== --- trunk/src/protocols/qq/char_conv.c 2006-08-06 18:19:36 UTC (rev 16656) +++ trunk/src/protocols/qq/char_conv.c 2006-08-06 21:03:10 UTC (rev 16657) @@ -38,7 +38,7 @@ #define QQ_NULL_SMILEY "(SM)" /* return this if smiley conversion fails */ /* a debug function */ -void _qq_show_packet(gchar * desc, gchar * buf, gint len); +void _qq_show_packet(const gchar *desc, const guint8 *buf, gint len); const gchar qq_smiley_map[QQ_SMILEY_AMOUNT] = { 0x41, 0x43, 0x42, 0x44, 0x45, 0x46, 0x47, 0x48, Modified: trunk/src/protocols/qq/file_trans.c =================================================================== --- trunk/src/protocols/qq/file_trans.c 2006-08-06 18:19:36 UTC (rev 16656) +++ trunk/src/protocols/qq/file_trans.c 2006-08-06 21:03:10 UTC (rev 16657) @@ -282,7 +282,7 @@ return bytes; } -extern gchar *_gen_session_md5(gint uid, gchar *session_key); +extern gchar *_gen_session_md5(gint uid, guint8 *session_key); /* send a file to udp channel with QQ_FILE_CONTROL_PACKET_TAG */ void qq_send_file_ctl_packet(GaimConnection *gc, guint16 packet_type, guint32 to_uid, guint8 hellobyte) Modified: trunk/src/protocols/qq/im.c =================================================================== --- trunk/src/protocols/qq/im.c 2006-08-06 18:19:36 UTC (rev 16656) +++ trunk/src/protocols/qq/im.c 2006-08-06 21:03:10 UTC (rev 16657) @@ -45,7 +45,7 @@ #define DEFAULT_FONT_NAME_LEN 4 /* a debug function */ -void _qq_show_packet(gchar *desc, gchar *buf, gint len); +void _qq_show_packet(const gchar *desc, const guint8 *buf, gint len); enum { @@ -94,7 +94,7 @@ guint8 is_there_font_attr; guint8 unknown3[4]; guint8 msg_type; - guint8 *msg; /* no fixed length, ends with 0x00 */ + gchar *msg; /* no fixed length, ends with 0x00 */ guint8 *font_attr; gint font_attr_len; }; @@ -121,11 +121,11 @@ guint8 *qq_get_send_im_tail(const gchar *font_color, const gchar *font_size, const gchar *font_name, - gboolean is_bold, gboolean is_italic, gboolean is_underline, guint tail_len) + gboolean is_bold, gboolean is_italic, gboolean is_underline, gint tail_len) { gchar *s1, *s2; unsigned char *rgb; - guint font_name_len; + gint font_name_len; guint8 *send_im_tail; const guint8 simsun[] = { 0xcb, 0xce, 0xcc, 0xe5 }; @@ -133,14 +133,14 @@ font_name_len = strlen(font_name); } else { font_name_len = DEFAULT_FONT_NAME_LEN; - font_name = simsun; + font_name = (const gchar *) simsun; } send_im_tail = g_new0(guint8, tail_len); - g_strlcpy(send_im_tail + QQ_SEND_IM_AFTER_MSG_HEADER_LEN, + g_strlcpy((gchar *) (send_im_tail + QQ_SEND_IM_AFTER_MSG_HEADER_LEN), font_name, tail_len - QQ_SEND_IM_AFTER_MSG_HEADER_LEN); - send_im_tail[tail_len - 1] = tail_len; + send_im_tail[tail_len - 1] = (guint8) tail_len; send_im_tail[0] = 0x00; if (font_size) { @@ -210,14 +210,13 @@ } /* generate a md5 key using uid and session_key */ -gchar *_gen_session_md5(gint uid, gchar *session_key) +gchar *_gen_session_md5(gint uid, guint8 *session_key) { - gchar *src, md5_str[QQ_KEY_LENGTH]; - guint8 *cursor; + guint8 *src, md5_str[QQ_KEY_LENGTH], *cursor; GaimCipher *cipher; GaimCipherContext *context; - src = g_newa(gchar, 20); + src = g_newa(guint8, 20); cursor = src; create_packet_dw(src, &cursor, uid); create_packet_data(src, &cursor, session_key, QQ_KEY_LENGTH); @@ -309,15 +308,15 @@ * even the is_there_font_attr shows 0x01, and msg does not ends with 0x00 */ if (im_text->msg_type == QQ_IM_AUTO_REPLY) { im_text->is_there_font_attr = 0x00; /* indeed there is no this flag */ - im_text->msg = g_strndup(*cursor, data + len - *cursor); + im_text->msg = g_strndup(*(gchar **) cursor, data + len - *cursor); } else { /* it is normal mesasge */ if (im_text->is_there_font_attr) { - im_text->msg = g_strdup(*cursor); + im_text->msg = g_strdup(*(gchar **) cursor); *cursor += strlen(im_text->msg) + 1; im_text->font_attr_len = data + len - *cursor; im_text->font_attr = g_memdup(*cursor, im_text->font_attr_len); } else /* not im_text->is_there_font_attr */ - im_text->msg = g_strndup(*cursor, data + len - *cursor); + im_text->msg = g_strndup(*(gchar **) cursor, data + len - *cursor); } /* if im_text->msg_type */ _qq_show_packet("QQ_MESG recv", data, *cursor - data); @@ -450,9 +449,9 @@ void qq_send_packet_im(GaimConnection *gc, guint32 to_uid, gchar *msg, gint type) { qq_data *qd; - guint8 *cursor, *raw_data; + guint8 *cursor, *raw_data, *send_im_tail; guint16 client_tag, normal_im_type; - gint msg_len, raw_len, bytes; + gint msg_len, raw_len, font_name_len, tail_len, bytes; time_t now; gchar *md5, *msg_filtered; GData *attribs; @@ -512,7 +511,6 @@ now = time(NULL); md5 = _gen_session_md5(qd->uid, qd->session_key); - guint font_name_len, tail_len; font_name_len = (font_name) ? strlen(font_name) : DEFAULT_FONT_NAME_LEN; tail_len = font_name_len + QQ_SEND_IM_AFTER_MSG_HEADER_LEN + 1; @@ -553,11 +551,11 @@ /* 052-052: text message type (normal/auto-reply) */ bytes += create_packet_b(raw_data, &cursor, type); /* 053- : msg ends with 0x00 */ - bytes += create_packet_data(raw_data, &cursor, msg_filtered, msg_len); - guint8 *send_im_tail = qq_get_send_im_tail(font_color, font_size, font_name, is_bold, + bytes += create_packet_data(raw_data, &cursor, (guint8 *) msg_filtered, msg_len); + send_im_tail = qq_get_send_im_tail(font_color, font_size, font_name, is_bold, is_italic, is_underline, tail_len); _qq_show_packet("QQ_MESG debug", send_im_tail, tail_len); - bytes += create_packet_data(raw_data, &cursor, (gchar *) send_im_tail, tail_len); + bytes += create_packet_data(raw_data, &cursor, send_im_tail, tail_len); _qq_show_packet("QQ_MESG raw", raw_data, cursor - raw_data); Modified: trunk/src/protocols/qq/im.h =================================================================== --- trunk/src/protocols/qq/im.h 2006-08-06 18:19:36 UTC (rev 16656) +++ trunk/src/protocols/qq/im.h 2006-08-06 21:03:10 UTC (rev 16657) @@ -54,7 +54,7 @@ guint8 *qq_get_send_im_tail(const gchar *font_color, const gchar *font_size, const gchar *font_name, - gboolean is_bold, gboolean is_italic, gboolean is_underline, guint len); + gboolean is_bold, gboolean is_italic, gboolean is_underline, gint len); void qq_send_packet_im(GaimConnection *gc, guint32 to_uid, gchar *msg, gint type); void qq_process_recv_im(guint8 *buf, gint buf_len, guint16 seq, GaimConnection *gc); Modified: trunk/src/protocols/qq/qq_proxy.c =================================================================== --- trunk/src/protocols/qq/qq_proxy.c 2006-08-06 18:19:36 UTC (rev 16656) +++ trunk/src/protocols/qq/qq_proxy.c 2006-08-06 21:03:10 UTC (rev 16657) @@ -54,7 +54,7 @@ } */ -void _qq_show_packet(gchar *desc, gchar *buf, gint len) +void _qq_show_packet(const gchar *desc, const guint8 *buf, gint len) { char buf1[8*len+2], buf2[10]; int i; @@ -73,11 +73,11 @@ GaimCipher *cipher; GaimCipherContext *context; - gchar pwkey_tmp[QQ_KEY_LENGTH]; + guchar pwkey_tmp[QQ_KEY_LENGTH]; cipher = gaim_ciphers_find_cipher("md5"); context = gaim_cipher_context_new(cipher, NULL); - gaim_cipher_context_append(context, pwd, strlen(pwd)); + gaim_cipher_context_append(context, (guchar *) pwd, strlen(pwd)); gaim_cipher_context_digest(context, sizeof(pwkey_tmp), pwkey_tmp, NULL); gaim_cipher_context_destroy(context); context = gaim_cipher_context_new(cipher, NULL); Modified: trunk/src/protocols/qq/qq_proxy.h =================================================================== --- trunk/src/protocols/qq/qq_proxy.h 2006-08-06 18:19:36 UTC (rev 16656) +++ trunk/src/protocols/qq/qq_proxy.h 2006-08-06 21:03:10 UTC (rev 16657) @@ -46,8 +46,10 @@ gint qq_proxy_write(qq_data *qd, guint8 *data, gint len); gint qq_connect(GaimAccount *account, const gchar *host, guint16 port, gboolean use_tcp, gboolean is_redirect); - void qq_disconnect(GaimConnection *gc); -void _qq_show_packet(gchar *des, gchar *buf, gint len); +gint _qq_fill_host(struct sockaddr_in *addr, const gchar *host, guint16 port); + +void _qq_show_packet(const gchar *desc, const guint8 *buf, gint len); + #endif Modified: trunk/src/protocols/qq/send_file.c =================================================================== --- trunk/src/protocols/qq/send_file.c 2006-08-06 18:19:36 UTC (rev 16656) +++ trunk/src/protocols/qq/send_file.c 2006-08-06 21:03:10 UTC (rev 16657) @@ -269,7 +269,7 @@ } -extern gchar *_gen_session_md5(gint uid, gchar *session_key); +extern gchar *_gen_session_md5(gint uid, guint8 *session_key); /* fill in the common information of file transfer */ static gint _qq_create_packet_file_header Modified: trunk/src/protocols/qq/udp_proxy_s5.c =================================================================== --- trunk/src/protocols/qq/udp_proxy_s5.c 2006-08-06 18:19:36 UTC (rev 16656) +++ trunk/src/protocols/qq/udp_proxy_s5.c 2006-08-06 21:03:10 UTC (rev 16657) @@ -33,7 +33,7 @@ unsigned char buf[512]; struct PHB *phb = data; struct sockaddr_in sin; - int len; + int len, error; gaim_input_remove(phb->inpa); gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Able to read again.\n"); @@ -82,7 +82,7 @@ return; } - int error = ETIMEDOUT; + error = ETIMEDOUT; gaim_debug(GAIM_DEBUG_INFO, "QQ", "Connect didn't block\n"); len = sizeof(error); if (getsockopt(phb->udpsock, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { @@ -209,12 +209,15 @@ static void _qq_s5_canread(gpointer data, gint source, GaimInputCondition cond) { unsigned char buf[512]; - struct PHB *phb = data; + struct PHB *phb; + int ret; + phb = data; + gaim_input_remove(phb->inpa); gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Able to read.\n"); - int ret = read(source, buf, 2); + ret = read(source, buf, 2); if (ret < 2) { gaim_debug(GAIM_DEBUG_INFO, "s5_canread", "packet smaller than 2 octet\n"); close(source); @@ -275,7 +278,7 @@ } } -void _qq_s5_canwrite(gpointer data, gint source, GaimInputCondition cond) +static void _qq_s5_canwrite(gpointer data, gint source, GaimInputCondition cond) { unsigned char buf[512]; int i; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-07 06:17:18
|
Revision: 16662 Author: markhuetsch Date: 2006-08-06 23:17:13 -0700 (Sun, 06 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16662&view=rev Log Message: ----------- Enhanced protocol testing tools, primarily by designing a more useful interface for sending customized packets. Modified Paths: -------------- trunk/src/protocols/qq/qq.c trunk/src/protocols/qq/recv_core.c trunk/src/protocols/qq/send_core.h trunk/src/protocols/qq/utils.c trunk/src/protocols/qq/utils.h Modified: trunk/src/protocols/qq/qq.c =================================================================== --- trunk/src/protocols/qq/qq.c 2006-08-07 03:24:39 UTC (rev 16661) +++ trunk/src/protocols/qq/qq.c 2006-08-07 06:17:13 UTC (rev 16662) @@ -28,6 +28,7 @@ #include "accountopt.h" #include "debug.h" +#include "gtkroomlist.h" #include "notify.h" #include "prefs.h" #include "prpl.h" @@ -586,12 +587,10 @@ } */ -/* static void _qq_menu_search_or_add_permanent_group(GaimPluginAction * action) { gaim_gtk_roomlist_dialog_show(); } -*/ /* static void _qq_menu_create_permanent_group(GaimPluginAction * action) @@ -659,57 +658,160 @@ // } } */ -/* -static void _qq_send_custom_packet(GaimConnection *gc, const gchar *packet) + +static gboolean _qq_parse_custom_packet_field(GaimRequestFields *fields, + const gchar *id, guint8 **value) { - guint16 cmd; - guint8 *buffer; - gint len; + GaimRequestField *field; + const gchar *str; + gint len, i; + gboolean success; - if (!packet) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Null packet inputted!\n"); - return; + success = FALSE; + field = gaim_request_fields_get_field(fields, id); + str = gaim_request_field_string_get_value(field); + if (str) { + success = TRUE; + if (strcmp(id, "uid") != 0) { + *value = hex_str_to_bytes(str, &len); + if (!*value || len != 2) + success = FALSE; + } else { + for (i = 0; i < strlen(str); i++) { + if (!g_ascii_isdigit(str[i])) { + success = FALSE; + break; + } + } + if (success) { + *(guint32 *) value = strtoul(str, NULL, 10); + if (errno == ERANGE) + success = FALSE; + } + } } - if (strlen(packet) > MAX_PACKET_SIZE * 2) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Packet inputted is too large!\n"); - return; + if (!success) + gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Invalid entry: %s\n", id); + return success; +} + +static gboolean _qq_parse_custom_packet_fields(GaimRequestFields *fields, + guint8 **client, guint8 **cmd, guint8 **seq, guint32 *uid, + guint8 **body, gint *body_len) +{ + GaimRequestField *field; + gboolean success; + + success = TRUE; + *client = *cmd = *seq = *body = NULL; + *uid = 0; + success = _qq_parse_custom_packet_field(fields, "client", client); + if (success) + success = _qq_parse_custom_packet_field(fields, "cmd", cmd); + if (success) + success = _qq_parse_custom_packet_field(fields, "uid", (guint8 **) uid); + if (success) + success = _qq_parse_custom_packet_field(fields, "seq", seq); + if (success) { + field = gaim_request_fields_get_field(fields, "body"); + *body = hex_str_to_bytes(gaim_request_field_string_get_value(field), + body_len); + } else { + if (*client) + g_free(*client); + if (*cmd) + g_free(*cmd); + if (*seq) + g_free(*seq); } - if (strlen(packet) < 4) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Packet is impossibly short!\n"); - return; - } + return success; +} - buffer = hex_str_to_bytes(packet); - if (!buffer) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Invalid packet inputted!\n"); +static void _qq_send_custom_packet_cb(GaimConnection *gc, GaimRequestFields *fields) +{ + guint32 uid; + guint8 *buf, *client, *cmd, *seq, *body, *cursor; + gint bytes, len; + qq_data *qd; + gboolean success; + + qd = (qq_data *) gc->proto_data; + + success = _qq_parse_custom_packet_fields(fields, &client, &cmd, + &seq, &uid, &body, &len); + if (!success) { + gaim_notify_error(gc, _("Error"), _("Invalid packet entry"), NULL); return; } - // big endian - cmd = 256 * buffer[0] + buffer[1]; - gaim_debug(GAIM_DEBUG_INFO, "QQ", "Inputted CMD: %d\n", cmd); - len = strlen(buffer) - 2; - packet = buffer + 2; + if (body) + g_return_if_fail(len+12 <= MAX_PACKET_SIZE); - qq_send_cmd(gc, cmd, TRUE, 0, TRUE, packet, len); + bytes = 0; + buf = g_newa(guint8, MAX_PACKET_SIZE); + cursor = buf; + /* QQ TCP packet has two bytes in the beginning to define packet length + * so I leave room here for size */ + if (qd->use_tcp) + bytes += create_packet_w(buf, &cursor, 0x0000); + bytes += create_packet_b(buf, &cursor, QQ_PACKET_TAG); + bytes += create_packet_w(buf, &cursor, *(guint16 *) client); + bytes += create_packet_w(buf, &cursor, *(guint16 *) cmd); + bytes += create_packet_w(buf, &cursor, *(guint16 *) seq); + bytes += create_packet_dw(buf, &cursor, uid); + if (body) { + bytes += create_packet_data(buf, &cursor, body, len); + g_free(body); + } + bytes += create_packet_b(buf, &cursor, QQ_PACKET_TAIL); - g_free(buffer); + gaim_debug(GAIM_DEBUG_INFO, "QQ", "Custom packet of length %i\n", bytes); + _qq_show_packet("Outgoing custom packet", buf, bytes); + + _qq_send_packet(gc, buf, bytes, *(guint16 *) cmd); + g_free(client); + g_free(cmd); + g_free(seq); } -*/ /* send a custom packet to the server - for protocol testing */ -/* static void _qq_menu_send_custom_packet(GaimPluginAction *action) { - GaimConnection *gc = (GaimConnection *) action->context; - g_return_if_fail(gc != NULL); - gaim_request_input(gc, _("Send Custom Packet"), - _("Enter the packet in hex here"), - _("Include the command and everything following"), - NULL, FALSE, FALSE, NULL, - _("Send"), G_CALLBACK(_qq_send_custom_packet), _("Cancel"), NULL, gc); + GaimConnection *gc; + GaimRequestFields *fields; + GaimRequestFieldGroup *group; + GaimRequestField *field; + gchar *tmp; + qq_data *qd; + + gc = (GaimConnection *) action->context; + qd = (qq_data *) gc->proto_data; + g_return_if_fail(gc != NULL && qd != NULL); + + fields = gaim_request_fields_new(); + group = gaim_request_field_group_new(_("Packet Elements")); + gaim_request_fields_add_group(fields, group); + tmp = g_strdup_printf("%04X", QQ_CLIENT); + field = gaim_request_field_string_new("client", _("Client (hex)"), tmp, FALSE); + g_free(tmp); + gaim_request_field_group_add_field(group, field); + field = gaim_request_field_string_new("cmd", _("Command (hex)"), "0000", FALSE); + gaim_request_field_group_add_field(group, field); + field = gaim_request_field_string_new("seq", _("Sequence (hex)"), "0000", FALSE); + gaim_request_field_group_add_field(group, field); + tmp = g_strdup_printf("%u", qd->uid); + field = gaim_request_field_string_new("uid", _("QQ Number (decimal)"), tmp, FALSE); + g_free(tmp); + gaim_request_field_group_add_field(group, field); + field = gaim_request_field_string_new("body", _("Body (hex)"), NULL, FALSE); + gaim_request_field_group_add_field(group, field); + + gaim_request_fields(gc, _("Send a custom packet"), + _("Send a custom packet"), NULL, fields, + _("Send"), G_CALLBACK(_qq_send_custom_packet_cb), + _("Cancel"), NULL, + gc); } -*/ /* protocol related menus */ static GList *_qq_actions(GaimPlugin *plugin, gpointer context) @@ -727,7 +829,7 @@ act = gaim_plugin_action_new(_("Show Login Information"), _qq_menu_show_login_info); m = g_list_append(m, act); - /* + /* act = gaim_plugin_action_new(_("Send Custom Packet"), _qq_menu_send_custom_packet); m = g_list_append(m, act); */ @@ -737,7 +839,7 @@ m = g_list_append(m, act); */ - /* XXX the old group gtk code needs to moved to the gaim UI before this can be used + /* act = gaim_plugin_action_new(_("Qun: Search a permanent Qun"), _qq_menu_search_or_add_permanent_group); m = g_list_append(m, act); Modified: trunk/src/protocols/qq/recv_core.c =================================================================== --- trunk/src/protocols/qq/recv_core.c 2006-08-07 03:24:39 UTC (rev 16661) +++ trunk/src/protocols/qq/recv_core.c 2006-08-07 06:17:13 UTC (rev 16662) @@ -90,6 +90,7 @@ data = g_newa(guint8, len); msg_utf8 = NULL; + _qq_show_packet("Processing unknown packet", buf, len); if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", ">>> [%d] %s, %d bytes -> [default] decrypt and dump\n%s", Modified: trunk/src/protocols/qq/send_core.h =================================================================== --- trunk/src/protocols/qq/send_core.h 2006-08-07 03:24:39 UTC (rev 16661) +++ trunk/src/protocols/qq/send_core.h 2006-08-07 06:17:13 UTC (rev 16662) @@ -28,9 +28,10 @@ #define QQ_CLIENT 0x0E1B +/* #define QQ_CLIENT 0x0F3F */ -gint -qq_send_cmd(GaimConnection *gc, - guint16 cmd, gboolean is_auto_seq, guint16 seq, gboolean need_ack, guint8 *data, gint len); +gint qq_send_cmd(GaimConnection *gc, guint16 cmd, gboolean is_auto_seq, guint16 seq, + gboolean need_ack, guint8 *data, gint len); +gint _qq_send_packet(GaimConnection * gc, guint8 *buf, gint len, guint16 cmd); #endif Modified: trunk/src/protocols/qq/utils.c =================================================================== --- trunk/src/protocols/qq/utils.c 2006-08-07 03:24:39 UTC (rev 16661) +++ trunk/src/protocols/qq/utils.c 2006-08-07 06:17:13 UTC (rev 16662) @@ -199,6 +199,8 @@ gchar *ret; int i; + g_return_val_if_fail(buffer != NULL, NULL); + stripped = g_string_new(""); for (i=0; i<strlen(buffer); i++) { if ((int) buffer[i] != 32) { @@ -214,12 +216,14 @@ /* Dumps an ASCII hex string to a string of bytes. The return should be freed later. * Returns NULL if a string with an odd number of nibbles is passed in or if buffer * isn't a valid hex string */ -guint8 *hex_str_to_bytes(const gchar *buffer) +guint8 *hex_str_to_bytes(const gchar *buffer, gint *out_len) { gchar *hex_str, *hex_buffer, *cursor, tmp; guint8 *bytes, nibble1, nibble2; - gint index, len; + gint index; + g_return_val_if_fail(buffer != NULL, NULL); + hex_buffer = strstrip(buffer); if (strlen(hex_buffer) % 2 != 0) { @@ -233,10 +237,11 @@ g_free(hex_buffer); index = 0; for (cursor = hex_str; cursor < hex_str + sizeof(gchar) * (strlen(hex_str)) - 1; cursor++) { - if (g_ascii_isdigit(*cursor)) {tmp = *cursor; nibble1 = atoi(&tmp); } - else if (g_ascii_isalpha(*cursor) && (gint) *cursor - 87 < 16) + if (g_ascii_isdigit(*cursor)) { + tmp = *cursor; nibble1 = atoi(&tmp); + } else if (g_ascii_isalpha(*cursor) && (gint) *cursor - 87 < 16) { nibble1 = (gint) *cursor - 87; - else { + } else { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Invalid char found in hex string!\n"); g_free(hex_str); @@ -244,18 +249,21 @@ } nibble1 = nibble1 << 4; cursor++; - if (g_ascii_isdigit(*cursor)) {tmp = *cursor; nibble2 = atoi(&tmp); } - else if (g_ascii_isalpha(*cursor) && (gint) (*cursor - 87) < 16) + if (g_ascii_isdigit(*cursor)) { + tmp = *cursor; nibble2 = atoi(&tmp); + } else if (g_ascii_isalpha(*cursor) && (gint) (*cursor - 87) < 16) { nibble2 = (gint) *cursor - 87; - else { + } else { + gaim_debug(GAIM_DEBUG_WARNING, "QQ", + "Invalid char found in hex string!\n"); g_free(hex_str); return NULL; } bytes[index++] = nibble1 + nibble2; } - len = strlen(hex_str) / 2; + *out_len = strlen(hex_str) / 2; g_free(hex_str); - return g_memdup(bytes, len); + return g_memdup(bytes, *out_len); } /* Dumps a chunk of raw data into an ASCII hex string. The return should be freed later. */ Modified: trunk/src/protocols/qq/utils.h =================================================================== --- trunk/src/protocols/qq/utils.h 2006-08-07 03:24:39 UTC (rev 16661) +++ trunk/src/protocols/qq/utils.h 2006-08-07 06:17:13 UTC (rev 16662) @@ -43,7 +43,7 @@ void try_dump_as_gbk(guint8 *data, gint len); -guint8 *hex_str_to_bytes(const gchar *buf); +guint8 *hex_str_to_bytes(const gchar *buf, gint *out_len); gchar *hex_dump_to_str(const guint8 *buf, gint buf_len); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-07 07:39:05
|
Revision: 16663 Author: markhuetsch Date: 2006-08-07 00:39:00 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16663&view=rev Log Message: ----------- Eliminated some warnings. Modified Paths: -------------- trunk/src/protocols/qq/buddy_list.c trunk/src/protocols/qq/group_im.c trunk/src/protocols/qq/group_join.c trunk/src/protocols/qq/group_opt.c Modified: trunk/src/protocols/qq/buddy_list.c =================================================================== --- trunk/src/protocols/qq/buddy_list.c 2006-08-07 06:17:13 UTC (rev 16662) +++ trunk/src/protocols/qq/buddy_list.c 2006-08-07 07:39:00 UTC (rev 16663) @@ -413,7 +413,7 @@ } else { /* a group */ group = qq_group_find_by_internal_group_id(gc, uid); if(group == NULL) { - /* not working + /*XXX not working group = qq_group_create_by_id(gc, uid, 0); qq_send_cmd_group_get_group_info(gc, group); */ Modified: trunk/src/protocols/qq/group_im.c =================================================================== --- trunk/src/protocols/qq/group_im.c 2006-08-07 06:17:13 UTC (rev 16662) +++ trunk/src/protocols/qq/group_im.c 2006-08-07 07:39:00 UTC (rev 16663) @@ -45,7 +45,7 @@ guint16 msg_seq; time_t send_time; guint16 msg_len; - guint8 *msg; + gchar *msg; guint8 *font_attr; gint font_attr_len; } qq_recv_group_im; @@ -54,7 +54,7 @@ void qq_send_packet_group_im(GaimConnection *gc, qq_group *group, const gchar *msg) { gint data_len, bytes; - guint8 *raw_data, *cursor; + guint8 *raw_data, *cursor, *send_im_tail; guint16 msg_len; gchar *msg_filtered; @@ -70,11 +70,11 @@ bytes += create_packet_b(raw_data, &cursor, QQ_GROUP_CMD_SEND_MSG); bytes += create_packet_dw(raw_data, &cursor, group->internal_group_id); bytes += create_packet_w(raw_data, &cursor, msg_len + QQ_SEND_IM_AFTER_MSG_LEN); - bytes += create_packet_data(raw_data, &cursor, (gchar *) msg_filtered, msg_len); - guint8 *send_im_tail = qq_get_send_im_tail(NULL, NULL, NULL, + bytes += create_packet_data(raw_data, &cursor, (guint8 *) msg_filtered, msg_len); + send_im_tail = qq_get_send_im_tail(NULL, NULL, NULL, FALSE, FALSE, FALSE, QQ_SEND_IM_AFTER_MSG_LEN); - bytes += create_packet_data(raw_data, &cursor, (gchar *) send_im_tail, QQ_SEND_IM_AFTER_MSG_LEN); + bytes += create_packet_data(raw_data, &cursor, send_im_tail, QQ_SEND_IM_AFTER_MSG_LEN); g_free(send_im_tail); g_free(msg_filtered); @@ -296,8 +296,8 @@ } /* recv an IM from a group chat */ -void qq_process_recv_group_im - (guint8 *data, guint8 **cursor, gint data_len, guint32 internal_group_id, GaimConnection *gc, guint16 im_type) +void qq_process_recv_group_im(guint8 *data, guint8 **cursor, gint data_len, + guint32 internal_group_id, GaimConnection *gc, guint16 im_type) { gchar *msg_with_gaim_smiley, *msg_utf8_encoded, *im_src_name; guint16 unknown; @@ -362,7 +362,7 @@ skip_len = 0; *cursor += skip_len; - im_group->msg = g_strdup(*cursor); + im_group->msg = g_strdup((gchar *) *cursor); *cursor += strlen(im_group->msg) + 1; /* there might not be any font_attr, check it */ im_group->font_attr_len = im_group->msg_len - strlen(im_group->msg) - 1 - skip_len; Modified: trunk/src/protocols/qq/group_join.c =================================================================== --- trunk/src/protocols/qq/group_join.c 2006-08-07 06:17:13 UTC (rev 16662) +++ trunk/src/protocols/qq/group_join.c 2006-08-07 07:39:00 UTC (rev 16663) @@ -154,7 +154,7 @@ bytes += create_packet_b(raw_data, &cursor, opt); bytes += create_packet_dw(raw_data, &cursor, uid); bytes += create_packet_b(raw_data, &cursor, strlen(reason_qq)); - bytes += create_packet_data(raw_data, &cursor, reason_qq, strlen(reason_qq)); + bytes += create_packet_data(raw_data, &cursor, (guint8 *) reason_qq, strlen(reason_qq)); if (bytes != data_len) gaim_debug(GAIM_DEBUG_ERROR, "QQ", @@ -335,7 +335,6 @@ } } -/*****************************************************************************/ void qq_group_exit(GaimConnection *gc, GHashTable *data) { gchar *internal_group_id_ptr; Modified: trunk/src/protocols/qq/group_opt.c =================================================================== --- trunk/src/protocols/qq/group_opt.c 2006-08-07 06:17:13 UTC (rev 16662) +++ trunk/src/protocols/qq/group_opt.c 2006-08-07 07:39:00 UTC (rev 16663) @@ -37,6 +37,7 @@ #include "qq.h" #include "utils.h" +/* TODO: can't we use qsort here? */ /* This implement quick sort algorithm (low->high) */ static void _quick_sort(gint *numbers, gint left, gint right) { @@ -228,7 +229,6 @@ gaim_notify_info(gc, _("QQ Qun Operation"), _("You have successfully modify Qun member"), NULL); } -/*****************************************************************************/ void qq_group_modify_info(GaimConnection *gc, qq_group *group) { gint data_len, data_written; @@ -262,15 +262,15 @@ data_written += create_packet_w(data, &cursor, group->group_category); data_written += create_packet_b(data, &cursor, strlen(group_name)); - data_written += create_packet_data(data, &cursor, group_name, strlen(group_name)); + data_written += create_packet_data(data, &cursor, (guint8 *) group_name, strlen(group_name)); data_written += create_packet_w(data, &cursor, 0x0000); data_written += create_packet_b(data, &cursor, strlen(notice)); - data_written += create_packet_data(data, &cursor, notice, strlen(notice)); + data_written += create_packet_data(data, &cursor, (guint8 *) notice, strlen(notice)); data_written += create_packet_b(data, &cursor, strlen(group_desc)); - data_written += create_packet_data(data, &cursor, group_desc, strlen(group_desc)); + data_written += create_packet_data(data, &cursor, (guint8 *) group_desc, strlen(group_desc)); if (data_written != data_len) gaim_debug(GAIM_DEBUG_ERROR, "QQ", @@ -326,7 +326,7 @@ data_written += create_packet_w(data, &cursor, 0x0003); /* 007 */ data_written += create_packet_b(data, &cursor, strlen(name)); - data_written += create_packet_data(data, &cursor, (gchar *) name, strlen(name)); + data_written += create_packet_data(data, &cursor, (guint8 *) name, strlen(name)); data_written += create_packet_w(data, &cursor, 0x0000); data_written += create_packet_b(data, &cursor, 0x00); /* no group notice */ data_written += create_packet_b(data, &cursor, 0x00); /* no group desc */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-07 08:30:41
|
Revision: 16664 Author: markhuetsch Date: 2006-08-07 01:30:36 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16664&view=rev Log Message: ----------- Removed code for looking up specific Chinese geolocation info from a user's IP address. The code was defunct for two reasons: First, the file holding the geolocation data (QQWry.dat) was simply too large to package with Gaim. Second, the current version of QQ seems to have stopped broadcasting the user's IP address with his/her status. Modified Paths: -------------- trunk/src/protocols/qq/Makefile.am trunk/src/protocols/qq/Makefile.mingw trunk/src/protocols/qq/qq.c Removed Paths: ------------- trunk/src/protocols/qq/ip_location.c trunk/src/protocols/qq/ip_location.h Modified: trunk/src/protocols/qq/Makefile.am =================================================================== --- trunk/src/protocols/qq/Makefile.am 2006-08-07 07:39:00 UTC (rev 16663) +++ trunk/src/protocols/qq/Makefile.am 2006-08-07 08:30:36 UTC (rev 16664) @@ -50,8 +50,6 @@ header_info.h \ im.c \ im.h \ - ip_location.c \ - ip_location.h \ keep_alive.c \ keep_alive.h \ login_logout.c \ Modified: trunk/src/protocols/qq/Makefile.mingw =================================================================== --- trunk/src/protocols/qq/Makefile.mingw 2006-08-07 07:39:00 UTC (rev 16663) +++ trunk/src/protocols/qq/Makefile.mingw 2006-08-07 08:30:36 UTC (rev 16664) @@ -95,7 +95,6 @@ group_search.c \ header_info.c \ im.c \ - ip_location.c \ keep_alive.c \ login_logout.c \ packet_parse.c \ Deleted: trunk/src/protocols/qq/ip_location.c =================================================================== --- trunk/src/protocols/qq/ip_location.c 2006-08-07 07:39:00 UTC (rev 16663) +++ trunk/src/protocols/qq/ip_location.c 2006-08-07 08:30:36 UTC (rev 16664) @@ -1,240 +0,0 @@ -/** - * The QQ2003C protocol plugin - * - * for gaim - * - * Copyright (C) 2004 Puzzlebird - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * This code is based on - * * qqwry.c, by lvxiang <sr...@16...> - * * IpChecker.m, by Jeff_Ye - */ - -#include "internal.h" -#include <string.h> -#include "debug.h" -#include "prefs.h" - -#include "utils.h" -#include "ip_location.h" - -#define DEFAULT_IP_LOCATION_FILE "gaim/QQWry.dat" - -typedef struct _ip_finder ip_finder; - -/* all offset is based the begining of the file */ -struct _ip_finder { - guint32 offset_first_start_ip; /* first abs offset of start ip */ - guint32 offset_last_start_ip; /* last abs offset of start ip */ - guint32 cur_start_ip; /* start ip of current search range */ - guint32 cur_end_ip; /* end ip of current search range */ - guint32 offset_cur_end_ip; /* where is the current end ip saved */ - GIOChannel *io; /* IO Channel to read file */ -}; /* struct _ip_finder */ - -/* convert 1-4 bytes array to integer. - * Small endian (higher bytes in lower place) */ -static guint32 _byte_array_to_int(guint8 *ip, gint count) -{ - guint32 ret, i; - g_return_val_if_fail(count >= 1 && count <= 4, 0); - ret = ip[0]; - for (i = 0; i < count; i++) - ret |= ((guint32) ip[i]) << (8 * i); - return ret; -} - -/* read len of bytes to buf, from io at offset */ -static void _read_from(GIOChannel *io, guint32 offset, guint8 *buf, gint len) -{ - GError *err; - GIOStatus status; - - err = NULL; - status = g_io_channel_seek_position(io, offset, G_SEEK_SET, &err); - if (err != NULL) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail seek file @offset[%d]: %s", offset, err->message); - g_error_free(err); - memset(buf, 0, len); - return; - } - - status = g_io_channel_read_chars(io, buf, len, NULL, &err); - if (err != NULL) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail read %d bytes from file: %s", len, err->message); - g_error_free(err); - memset(buf, 0, len); - return; - } -} - -/* read len of bytes to buf, from io at offset */ -static gsize _read_line_from(GIOChannel *io, guint32 offset, gchar **ret_str) -{ - gsize bytes_read; - GError *err; - GIOStatus status; - - err = NULL; - status = g_io_channel_seek_position(io, offset, G_SEEK_SET, &err); - if (err != NULL) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail seek file @offset[%d]: %s", offset, err->message); - g_error_free(err); - ret_str = NULL; - return -1; - } - - status = g_io_channel_read_line(io, ret_str, &bytes_read, NULL, &err); - if (err != NULL) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail read from file: %s", err->message); - g_error_free(err); - ret_str = NULL; - return -1; - } - - return bytes_read; -} - -/* read the string from io, at offset, it may jump several times - * returns the offset of next readable string for area */ -static guint32 _get_string(GIOChannel *io, guint32 offset, gchar **ret) -{ - guint8 *buf; - g_return_val_if_fail(io != NULL, 0); - - buf = g_new0(guint8, 3); - _read_from(io, offset, buf, 1); - - switch (buf[0]) { /* fixed by bluestar11 at gmail dot com, 04/12/20 */ - case 0x01: /* jump together */ - _read_from(io, offset + 1, buf, 3); - return _get_string(io, _byte_array_to_int(buf, 3), ret); - case 0x02: /* jump separately */ - _read_from(io, offset + 1, buf, 3); - _get_string(io, _byte_array_to_int(buf, 3), ret); - return offset + 4; - default: - _read_line_from(io, offset, ret); - return offset + strlen(*ret) + 1; - } -} - -/* extract country and area starting from offset */ -static void _get_country_city(GIOChannel *io, guint32 offset, gchar **country, gchar **area) -{ - guint32 next_offset; - g_return_if_fail(io != NULL); - - next_offset = _get_string(io, offset, country); - if (next_offset == 0) - *area = g_strdup(""); - else - _get_string(io, next_offset, area); -} - -/* set start_ip and end_ip of current range */ -static void _set_ip_range(gint rec_no, ip_finder *f) -{ - guint8 *buf; - guint32 offset; - - g_return_if_fail(f != NULL); - - buf = g_newa(guint8, 7); - offset = f->offset_first_start_ip + rec_no * 7; - - _read_from(f->io, offset, buf, 7); - f->cur_start_ip = _byte_array_to_int(buf, 4); - f->offset_cur_end_ip = _byte_array_to_int(buf + 4, 3); - - _read_from(f->io, f->offset_cur_end_ip, buf, 4); - f->cur_end_ip = _byte_array_to_int(buf, 4); -} - -/* set the country and area for given IP. - * country and area needs to be freed later */ -gboolean qq_ip_get_location(guint32 ip, gchar **country, gchar **area) -{ - gint rec, record_count, B, E; - guint8 *buf; - gchar *addr_file; - ip_finder *f; - GError *err; - const char *ip_fn; - - if (ip == 0) - return FALSE; - - f = g_new0(ip_finder, 1); - err = NULL; - ip_fn = gaim_prefs_get_string("/plugins/prpl/qq/ipfile"); - if (ip_fn == NULL || strlen(ip_fn) == 0 || strncmp(ip_fn, "(null)", strlen("(null)")) == 0) { - addr_file = g_build_filename(DATADIR, DEFAULT_IP_LOCATION_FILE, NULL); - } else { - addr_file = g_build_filename(ip_fn, NULL); - } - - f->io = g_io_channel_new_file(addr_file, "r", &err); - g_free(addr_file); - if (err != NULL) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Unable to open (%s): %s\n", addr_file, err->message); - g_error_free(err); - return FALSE; - } else { - g_io_channel_set_encoding(f->io, NULL, NULL); /* set binary */ - } - - buf = g_newa(guint8, 4); - - _read_from(f->io, 0, buf, 4); - f->offset_first_start_ip = _byte_array_to_int(buf, 4); - _read_from(f->io, 4, buf, 4); - f->offset_last_start_ip = _byte_array_to_int(buf, 4); - - record_count = (f->offset_last_start_ip - f->offset_first_start_ip) / 7; - if (record_count <= 1) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "File data error, no records found\n"); - g_io_channel_shutdown(f->io, FALSE, NULL); - return FALSE;; - } - /* search for right range */ - B = 0; - E = record_count; - while (B < E - 1) { - rec = (B + E) / 2; - _set_ip_range(rec, f); - if (ip == f->cur_start_ip) { - B = rec; - break; - } - if (ip > f->cur_start_ip) - B = rec; - else - E = rec; - } - _set_ip_range(B, f); - - if (f->cur_start_ip <= ip && ip <= f->cur_end_ip) { - _get_country_city(f->io, f->offset_cur_end_ip + 4, country, area); - } else { /* not in this range... miss */ - *country = g_strdup("unkown"); - *area = g_strdup(" "); - } /* if ip_start<=ip<=ip_end */ - - g_io_channel_shutdown(f->io, FALSE, NULL); - return TRUE; -} Deleted: trunk/src/protocols/qq/ip_location.h =================================================================== --- trunk/src/protocols/qq/ip_location.h 2006-08-07 07:39:00 UTC (rev 16663) +++ trunk/src/protocols/qq/ip_location.h 2006-08-07 08:30:36 UTC (rev 16664) @@ -1,30 +0,0 @@ -/** - * The QQ2003C protocol plugin - * - * for gaim - * - * Copyright (C) 2004 Puzzlebird - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _QQ_IP_LOCATION_H_ -#define _QQ_IP_LOCATION_H_ - -#include "glib.h" - -gboolean qq_ip_get_location(guint32 ip, gchar **country, gchar **city); - -#endif Modified: trunk/src/protocols/qq/qq.c =================================================================== --- trunk/src/protocols/qq/qq.c 2006-08-07 07:39:00 UTC (rev 16663) +++ trunk/src/protocols/qq/qq.c 2006-08-07 08:30:36 UTC (rev 16664) @@ -48,7 +48,6 @@ #include "group_opt.h" #include "header_info.h" #include "im.h" -#include "ip_location.h" #include "keep_alive.h" #include "login_logout.h" #include "packet_parse.h" @@ -245,21 +244,10 @@ if (GAIM_BUDDY_IS_ONLINE(b) && q_bud != NULL) { - /* - ip_value = ntohl(*(guint32 *) (q_bud->ip)); - if (qq_ip_get_location(ip_value, &country, &city)) { - country_utf8 = qq_to_utf8(country, QQ_CHARSET_DEFAULT); - city_utf8 = qq_to_utf8(city, QQ_CHARSET_DEFAULT); - g_string_append_printf(tooltip, "\n%s, %s", country_utf8, city_utf8); - g_free(country); - g_free(city); - g_free(country_utf8); - g_free(city_utf8); - } - */ ip_str = gen_ip_str(q_bud->ip); if (strlen(ip_str) != 0) { - g_string_append_printf(tooltip, "\n<b>%s Address:</b> %s:%d", (q_bud->comm_flag & QQ_COMM_FLAG_TCP_MODE) + g_string_append_printf(tooltip, "\n<b>%s Address:</b> %s:%d", + (q_bud->comm_flag & QQ_COMM_FLAG_TCP_MODE) ? "TCP" : "UDP", ip_str, q_bud->port); } g_free(ip_str); @@ -519,74 +507,6 @@ g_string_free(info, TRUE); } -/* -static void _qq_menu_locate_ip_cb(GaimConnection * gc, GaimRequestFields * fields) -{ - GList *groups, *flds; - GaimRequestField *field; - const gchar *id, *value; - gchar *ip_str = NULL, *ip_dupstr = NULL; - guint8 *ip; - gchar *country, *country_utf8, *city, *city_utf8; - guint32 ip_value; - - for (groups = gaim_request_fields_get_groups(fields); groups && !ip_str; groups = groups->next) { - for (flds = gaim_request_field_group_get_fields(groups->data); flds && !ip_str; flds = flds->next) { - field = flds->data; - id = gaim_request_field_get_id(field); - value = gaim_request_field_string_get_value(field); - - if (!g_ascii_strcasecmp(id, "ip")) { - ip_str = g_strdup(value); - break; - } - } - } - - if(ip_str) { - ip = str_ip_gen(ip_str); - ip_dupstr = gen_ip_str(ip); - - ip_value = ntohl(*(guint32 *)ip); - if (qq_ip_get_location(ip_value, &country, &city)) { - country_utf8 = qq_to_utf8(country, QQ_CHARSET_DEFAULT); - city_utf8 = qq_to_utf8(city, QQ_CHARSET_DEFAULT); - gaim_notify_info(gc, ip_dupstr, country_utf8, city_utf8); - g_free(country); - g_free(city); - g_free(country_utf8); - g_free(city_utf8); - } - else - gaim_notify_info(gc, ip_dupstr, "IP not found", NULL); - g_free(ip); - g_free(ip_dupstr); - g_free(ip_str); - } -} - -static void _qq_menu_locate_ip(GaimPluginAction *action) -{ - GaimConnection *gc = (GaimConnection *) action->context; - GaimRequestField *field; - GaimRequestFields *fields; - GaimRequestFieldGroup *group; - - g_return_if_fail(gc != NULL); - - fields = gaim_request_fields_new(); - group = gaim_request_field_group_new(NULL); - gaim_request_fields_add_group(fields, group); - - field = gaim_request_field_string_new("ip", _("IP Address"), NULL, FALSE); - gaim_request_field_group_add_field(group, field); - - gaim_request_fields(gc, _("Locate an IP"), - _("Locate an IP address"), NULL, fields, - _("Check"), G_CALLBACK(_qq_menu_locate_ip_cb), _("Cancel"), NULL, gc); -} -*/ - static void _qq_menu_search_or_add_permanent_group(GaimPluginAction * action) { gaim_gtk_roomlist_dialog_show(); @@ -847,11 +767,6 @@ m = g_list_append(m, act); */ - /* XXX consider re-enabling this - act = gaim_plugin_action_new(_("Locate an IP"), _qq_menu_locate_ip); - m = g_list_append(m, act); - */ - return m; } @@ -1066,7 +981,6 @@ my_protocol = plugin; gaim_prefs_add_none("/plugins/prpl/qq"); - gaim_prefs_add_string("/plugins/prpl/qq/ipfile", ""); gaim_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE); gaim_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE); gaim_prefs_add_string("/plugins/prpl/qq/datadir", DATADIR); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rl...@us...> - 2006-08-08 00:25:27
|
Revision: 16668 Author: rlaager Date: 2006-08-07 17:25:19 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16668&view=rev Log Message: ----------- We have gaim_str_has_prefix() to use in place of g_str_has_prefix(). Modified Paths: -------------- trunk/src/protocols/bonjour/jabber.c trunk/src/protocols/qq/group_find.c trunk/src/protocols/qq/utils.c Modified: trunk/src/protocols/bonjour/jabber.c =================================================================== --- trunk/src/protocols/bonjour/jabber.c 2006-08-07 23:10:37 UTC (rev 16667) +++ trunk/src/protocols/bonjour/jabber.c 2006-08-08 00:25:19 UTC (rev 16668) @@ -359,7 +359,7 @@ * using a magic string, but xmlnode won't play nice when just * parsing an end tag */ - if (g_str_has_prefix(message, STREAM_END) || (closed_conversation == TRUE)) { + if (gaim_str_has_prefix(message, STREAM_END) || (closed_conversation == TRUE)) { /* Close the socket, clear the watcher and free memory */ if (bb->conversation != NULL) { close(bb->conversation->socket); Modified: trunk/src/protocols/qq/group_find.c =================================================================== --- trunk/src/protocols/qq/group_find.c 2006-08-07 23:10:37 UTC (rev 16667) +++ trunk/src/protocols/qq/group_find.c 2006-08-08 00:25:19 UTC (rev 16668) @@ -22,6 +22,7 @@ #include "conversation.h" #include "debug.h" +#include "util.h" #include "group_find.h" #include "group_network.h" @@ -39,7 +40,7 @@ /* if it starts with QQ_NAME_PREFIX, we think it is valid name already * otherwise we think it is nickname and try to find the matching gaim_name */ - if (g_str_has_prefix(who, QQ_NAME_PREFIX) && gaim_name_to_uid(who) > 0) + if (gaim_str_has_prefix(who, QQ_NAME_PREFIX) && gaim_name_to_uid(who) > 0) return (gchar *) who; group = qq_group_find_by_channel(gc, channel); Modified: trunk/src/protocols/qq/utils.c =================================================================== --- trunk/src/protocols/qq/utils.c 2006-08-07 23:10:37 UTC (rev 16667) +++ trunk/src/protocols/qq/utils.c 2006-08-08 00:25:19 UTC (rev 16668) @@ -31,18 +31,11 @@ #include "char_conv.h" #include "debug.h" #include "prefs.h" +#include "util.h" #include "utils.h" #define QQ_NAME_FORMAT "qq-%d" -#if !GLIB_CHECK_VERSION(2, 1, 0) -gint g_str_has_prefix(const gchar *str, const gchar *prefix) -{ - gint len = strlen(prefix); - return !strncmp(str, prefix, len); -} -#endif - gchar *get_name_by_index_str(gchar **array, const gchar *index_str, gint amount) { gint index; @@ -160,7 +153,7 @@ { gchar *p; - g_return_val_if_fail(g_str_has_prefix(name, QQ_NAME_PREFIX), 0); + g_return_val_if_fail(gaim_str_has_prefix(name, QQ_NAME_PREFIX), 0); p = g_strrstr(name, QQ_NAME_PREFIX); return (p == NULL) ? 0 : strtol(p + strlen(QQ_NAME_PREFIX), NULL, 10); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-08 01:02:59
|
Revision: 16670 Author: markhuetsch Date: 2006-08-07 18:02:56 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16670&view=rev Log Message: ----------- Eliminated calls to bindtextdomain() and bind_textdomain_codeset(), which have already and more appropriately been called in gtkmain.c. Also removed the definition of LOCALEDIR, which is no longer needed. Modified Paths: -------------- trunk/src/protocols/qq/Makefile.am trunk/src/protocols/qq/qq.c Modified: trunk/src/protocols/qq/Makefile.am =================================================================== --- trunk/src/protocols/qq/Makefile.am 2006-08-08 00:27:13 UTC (rev 16669) +++ trunk/src/protocols/qq/Makefile.am 2006-08-08 01:02:56 UTC (rev 16670) @@ -93,7 +93,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -DDATADIR=\"${datadir}\" \ - -DLOCALEDIR=\"${datadir}/locale\" \ -DVERSION=\"$(VERSION)\" \ $(DEBUG_CFLAGS) \ $(GLIB_CFLAGS) \ Modified: trunk/src/protocols/qq/qq.c =================================================================== --- trunk/src/protocols/qq/qq.c 2006-08-08 00:27:13 UTC (rev 16669) +++ trunk/src/protocols/qq/qq.c 2006-08-08 01:02:56 UTC (rev 16670) @@ -963,9 +963,6 @@ { GaimAccountOption *option; - bindtextdomain(PACKAGE, LOCALEDIR); - bind_textdomain_codeset(PACKAGE, "UTF-8"); - option = gaim_account_option_bool_new(_("Login in TCP"), "use_tcp", FALSE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-08 01:13:01
|
Revision: 16671 Author: markhuetsch Date: 2006-08-07 18:12:58 -0700 (Mon, 07 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16671&view=rev Log Message: ----------- Removed an unused gaim_prefs string for "datadir" and the corresponding DATADIR definition. Both of these should have been removed with the ip_location code. Modified Paths: -------------- trunk/src/protocols/qq/Makefile.am trunk/src/protocols/qq/qq.c Modified: trunk/src/protocols/qq/Makefile.am =================================================================== --- trunk/src/protocols/qq/Makefile.am 2006-08-08 01:02:56 UTC (rev 16670) +++ trunk/src/protocols/qq/Makefile.am 2006-08-08 01:12:58 UTC (rev 16671) @@ -92,7 +92,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ - -DDATADIR=\"${datadir}\" \ -DVERSION=\"$(VERSION)\" \ $(DEBUG_CFLAGS) \ $(GLIB_CFLAGS) \ Modified: trunk/src/protocols/qq/qq.c =================================================================== --- trunk/src/protocols/qq/qq.c 2006-08-08 01:02:56 UTC (rev 16670) +++ trunk/src/protocols/qq/qq.c 2006-08-08 01:12:58 UTC (rev 16671) @@ -980,7 +980,6 @@ gaim_prefs_add_none("/plugins/prpl/qq"); gaim_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE); gaim_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE); - gaim_prefs_add_string("/plugins/prpl/qq/datadir", DATADIR); gaim_prefs_add_bool("/plugins/prpl/qq/prompt_for_missing_packet", TRUE); gaim_prefs_add_bool("/plugins/prpl/qq/prompt_group_msg_on_recv", TRUE); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2006-08-08 23:20:30
|
Revision: 16673 Author: markhuetsch Date: 2006-08-08 16:20:08 -0700 (Tue, 08 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16673&view=rev Log Message: ----------- Eliminated a number of warnings. Generally, this consisted of fixing incorrectly declared data types and adding a few casts. I also moved some declarations that occurred in the middle of code. Minor formatting changes. Modified Paths: -------------- trunk/src/protocols/qq/buddy_opt.c trunk/src/protocols/qq/char_conv.c trunk/src/protocols/qq/file_trans.c trunk/src/protocols/qq/group_info.c trunk/src/protocols/qq/group_network.c trunk/src/protocols/qq/keep_alive.c trunk/src/protocols/qq/recv_core.c trunk/src/protocols/qq/send_file.c trunk/src/protocols/qq/sendqueue.h trunk/src/protocols/qq/sys_msg.c Modified: trunk/src/protocols/qq/buddy_opt.c =================================================================== --- trunk/src/protocols/qq/buddy_opt.c 2006-08-08 13:20:32 UTC (rev 16672) +++ trunk/src/protocols/qq/buddy_opt.c 2006-08-08 23:20:08 UTC (rev 16673) @@ -64,7 +64,8 @@ g_return_if_fail(gc != NULL && uid > 0); uid_str = g_strdup_printf("%d", uid); - qq_send_cmd(gc, QQ_CMD_DEL_FRIEND, TRUE, 0, TRUE, uid_str, strlen(uid_str)); + qq_send_cmd(gc, QQ_CMD_DEL_FRIEND, TRUE, 0, + TRUE, (guint8 *) uid_str, strlen(uid_str)); g_free(uid_str); } @@ -94,7 +95,8 @@ /* we need to send the ascii code of this uid to qq server */ uid_str = g_strdup_printf("%d", uid); - qq_send_cmd(gc, QQ_CMD_ADD_FRIEND_WO_AUTH, TRUE, 0, TRUE, uid_str, strlen(uid_str)); + qq_send_cmd(gc, QQ_CMD_ADD_FRIEND_WO_AUTH, TRUE, 0, + TRUE, (guint8 *) uid_str, strlen(uid_str)); g_free(uid_str); /* must be set after sending packet to get the correct send_seq */ @@ -118,14 +120,14 @@ raw_data = g_newa(guint8, QQ_MSG_IM_MAX); cursor = raw_data; - create_packet_data(raw_data, &cursor, uid_str, strlen(uid_str)); + create_packet_data(raw_data, &cursor, (guint8 *) uid_str, strlen(uid_str)); create_packet_b(raw_data, &cursor, bar); create_packet_b(raw_data, &cursor, response); if (text != NULL) { text_qq = utf8_to_qq(text, QQ_CHARSET_DEFAULT); create_packet_b(raw_data, &cursor, bar); - create_packet_data(raw_data, &cursor, text_qq, strlen(text_qq)); + create_packet_data(raw_data, &cursor, (guint8 *) text_qq, strlen(text_qq)); g_free(text_qq); } @@ -342,7 +344,8 @@ { qq_data *qd; gint len, for_uid; - gchar *msg, *data, **segments, *uid, *reply; + gchar *msg, **segments, *uid, *reply; + guint8 *data; GList *list; GaimBuddy *b; gc_and_uid *g; Modified: trunk/src/protocols/qq/char_conv.c =================================================================== --- trunk/src/protocols/qq/char_conv.c 2006-08-08 13:20:32 UTC (rev 16672) +++ trunk/src/protocols/qq/char_conv.c 2006-08-08 23:20:08 UTC (rev 16673) @@ -114,7 +114,8 @@ else { /* conversion error */ gaim_debug(GAIM_DEBUG_ERROR, "QQ", "%s\n", error->message); gaim_debug(GAIM_DEBUG_WARNING, "QQ", - "Dump failed text\n%s", hex_dump_to_str(str, (len == -1) ? strlen(str) : len)); + "Dump failed text\n%s", + hex_dump_to_str((guint8 *) str, (len == -1) ? strlen(str) : len)); g_error_free(error); return g_strdup(QQ_NULL_MSG); } @@ -130,7 +131,7 @@ g_return_val_if_fail(data != NULL && from_charset != NULL, -1); len = data[0]; - *ret = _my_convert(data + 1, (gssize) len, UTF8, from_charset); + *ret = _my_convert((gchar *) (data + 1), (gssize) len, UTF8, from_charset); return len + 1; } @@ -154,7 +155,7 @@ read_packet_b(data, &cursor, len, &bar); /* skip, not sure of its use */ read_packet_w(data, &cursor, len, &charset_code); - font_name = g_strndup(cursor, data + len - cursor); + font_name = g_strndup((gchar *) cursor, data + len - cursor); font_size = _get_size(font_attr); is_bold = _check_bold(font_attr); @@ -223,7 +224,7 @@ GString *converted; converted = g_string_new(""); - segments = split_data(text, strlen(text), "\x14", 0); + segments = split_data((guint8 *) text, strlen(text), "\x14", 0); g_string_append(converted, segments[0]); while ((*(++segments)) != NULL) { Modified: trunk/src/protocols/qq/file_trans.c =================================================================== --- trunk/src/protocols/qq/file_trans.c 2006-08-08 13:20:32 UTC (rev 16672) +++ trunk/src/protocols/qq/file_trans.c 2006-08-08 23:20:08 UTC (rev 16673) @@ -85,7 +85,7 @@ cipher = gaim_ciphers_find_cipher("md5"); context = gaim_cipher_context_new(cipher, NULL); - gaim_cipher_context_append(context, filename, strlen(filename)); + gaim_cipher_context_append(context, (guint8 *) filename, strlen(filename)); gaim_cipher_context_digest(context, 16, md5, NULL); gaim_cipher_context_destroy(context); } @@ -93,7 +93,7 @@ static void _fill_file_md5(const gchar *filename, gint filelen, gchar *md5) { FILE *fp; - gchar *buffer; + guint8 *buffer; GaimCipher *cipher; GaimCipherContext *context; @@ -106,7 +106,7 @@ fp = fopen(filename, "rb"); g_return_if_fail(fp != NULL); - buffer = g_newa(gchar, filelen); + buffer = g_newa(guint8, filelen); g_return_if_fail(buffer != NULL); fread(buffer, filelen, 1, fp); @@ -398,10 +398,11 @@ gchar file_md5[16], filename_md5[16], *filename; gint filename_len, filesize; qq_data *qd; + ft_info *info; g_return_if_fail(gc != NULL && gc->proto_data != NULL); qd = (qq_data *) gc->proto_data; - ft_info *info = (ft_info *) qd->xfer->data; + info = (ft_info *) qd->xfer->data; filename = (gchar *) gaim_xfer_get_filename(qd->xfer); filesize = gaim_xfer_get_size(qd->xfer); @@ -664,10 +665,12 @@ static void _qq_update_send_progess(GaimConnection *gc, guint32 fragment_index) { + guint32 mask; + guint8 *buffer; + gint readbytes; qq_data *qd = (qq_data *) gc->proto_data; GaimXfer *xfer = qd->xfer; ft_info *info = (ft_info *) xfer->data; - guint32 mask; gaim_debug(GAIM_DEBUG_INFO, "QQ", "receiving %dth fragment ack, slide window status %o, max_fragment_index %d\n", @@ -698,8 +701,6 @@ { /* move the slide window */ info->window &= ~mask; - guint8 *buffer; - gint readbytes; buffer = g_newa(guint8, info->fragment_len); readbytes = _qq_xfer_read_file(buffer, info->max_fragment_index + sizeof(info->window), Modified: trunk/src/protocols/qq/group_info.c =================================================================== --- trunk/src/protocols/qq/group_info.c 2006-08-08 13:20:32 UTC (rev 16672) +++ trunk/src/protocols/qq/group_info.c 2006-08-08 23:20:08 UTC (rev 16673) @@ -157,7 +157,9 @@ void qq_process_group_cmd_get_group_info(guint8 *data, guint8 **cursor, gint len, GaimConnection *gc) { qq_group *group; + qq_buddy *member; qq_data *qd; + GaimConversation *gaim_conv; guint8 orgnization, role; guint16 unknown; guint32 member_uid, internal_group_id; @@ -206,7 +208,7 @@ if(orgnization != 0 || role != 0) { gaim_debug(GAIM_DEBUG_INFO, "QQ", "group member %d: orgnizatio=%d, role=%d\n", member_uid, orgnization, role); } - qq_buddy *member = qq_group_find_or_add_member(gc, group, member_uid); + member = qq_group_find_or_add_member(gc, group, member_uid); member->role = role; } if(*cursor > (data + len)) { @@ -220,7 +222,8 @@ qq_group_refresh(gc, group); - GaimConversation *gaim_conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,group->group_name_utf8, gaim_connection_get_account(gc)); + gaim_conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, + group->group_name_utf8, gaim_connection_get_account(gc)); if(NULL == gaim_conv) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Conv windows for \"%s\" is not on, do not set topic\n", group->group_name_utf8); Modified: trunk/src/protocols/qq/group_network.c =================================================================== --- trunk/src/protocols/qq/group_network.c 2006-08-08 13:20:32 UTC (rev 16672) +++ trunk/src/protocols/qq/group_network.c 2006-08-08 23:20:08 UTC (rev 16673) @@ -81,7 +81,7 @@ gchar *msg, *msg_utf8; g_return_if_fail(cursor != NULL && len > 0 && gc != NULL); - msg = g_strndup(cursor, len); /* it will append 0x00 */ + msg = g_strndup((gchar *) cursor, len); /* it will append 0x00 */ msg_utf8 = qq_to_utf8(msg, QQ_CHARSET_DEFAULT); g_free(msg); msg = g_strdup_printf(_("Code [0x%02X]: %s"), reply, msg_utf8); Modified: trunk/src/protocols/qq/keep_alive.c =================================================================== --- trunk/src/protocols/qq/keep_alive.c 2006-08-08 13:20:32 UTC (rev 16672) +++ trunk/src/protocols/qq/keep_alive.c 2006-08-08 23:20:08 UTC (rev 16673) @@ -61,10 +61,11 @@ } /* parse the return of keep-alive packet, it includes some system information */ -void qq_process_keep_alive_reply(guint8 * buf, gint buf_len, GaimConnection *gc) { +void qq_process_keep_alive_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { qq_data *qd; gint len; - gchar *data, **segments; /* the returns are gchar, no need guint8 */ + gchar **segments; + guint8 *data; g_return_if_fail(gc != NULL && gc->proto_data != NULL); g_return_if_fail(buf != NULL && buf_len != 0); @@ -125,6 +126,8 @@ { gchar *name; GaimBuddy *bud; + gchar *status_id; + g_return_if_fail(gc != NULL && q_bud != NULL); name = uid_to_gaim_name(q_bud->uid); @@ -138,7 +141,7 @@ /* gaim supports signon and idle time * but it is not much use for QQ, I do not use them */ /* serv_got_update(gc, name, online, 0, q_bud->signon, q_bud->idle, bud->uc); */ - char *status_id = "available"; + status_id = "available"; switch(q_bud->status) { case QQ_BUDDY_OFFLINE: status_id = "offline"; Modified: trunk/src/protocols/qq/recv_core.c =================================================================== --- trunk/src/protocols/qq/recv_core.c 2006-08-08 13:20:32 UTC (rev 16672) +++ trunk/src/protocols/qq/recv_core.c 2006-08-08 23:20:08 UTC (rev 16673) @@ -61,7 +61,7 @@ static gboolean _qq_check_packet_set_window(guint16 seq, GaimConnection *gc) { qq_data *qd; - gchar *byte, mask; + guint8 *byte, mask; g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, FALSE); qd = (qq_data *) gc->proto_data; @@ -291,7 +291,7 @@ void qq_input_pending(gpointer data, gint source, GaimInputCondition cond) { GaimConnection *gc; - qq_data *qd;; + qq_data *qd; guint8 *buf; gint len; Modified: trunk/src/protocols/qq/send_file.c =================================================================== --- trunk/src/protocols/qq/send_file.c 2006-08-08 13:20:32 UTC (rev 16672) +++ trunk/src/protocols/qq/send_file.c 2006-08-08 23:20:08 UTC (rev 16673) @@ -77,12 +77,12 @@ } /* these 2 functions send and recv buffer from/to UDP channel */ -static ssize_t _qq_xfer_udp_recv(char *buf, size_t len, GaimXfer *xfer) +static ssize_t _qq_xfer_udp_recv(guint8 *buf, size_t len, GaimXfer *xfer) { struct sockaddr_in sin; - int sinlen; + socklen_t sinlen; ft_info *info; - int r; + gint r; info = (ft_info *) xfer->data; sinlen = sizeof(sin); @@ -102,7 +102,7 @@ return send(info->sender_fd, buf, len, 0); } */ -static ssize_t _qq_xfer_udp_send(const char *buf, size_t len, GaimXfer *xfer) +static ssize_t _qq_xfer_udp_send(const guint8 *buf, size_t len, GaimXfer *xfer) { struct sockaddr_in sin; ft_info *info; @@ -140,7 +140,7 @@ } */ -gssize _qq_xfer_write(const guchar *buf, size_t len, GaimXfer *xfer) +gssize _qq_xfer_write(const guint8 *buf, size_t len, GaimXfer *xfer) { return _qq_xfer_udp_send(buf, len, xfer); } @@ -219,7 +219,7 @@ g_free(info); } -void qq_show_conn_info(ft_info *info) +static void qq_show_conn_info(ft_info *info) { gchar *internet_ip_str, *real_ip_str; guint32 ip; @@ -375,7 +375,8 @@ static void _qq_xfer_init_socket(GaimXfer *xfer) { - int sockfd, listen_port = 0, i, sin_len; + gint sockfd, listen_port = 0, i; + socklen_t sin_len; struct sockaddr_in sin; ft_info *info; @@ -446,27 +447,28 @@ info->conn_method = 0x00; qd->xfer->data = info; - filename_len = strlen (filename); - filelen_str = g_strdup_printf ("%d \xD7ֽ\xDA", filesize); - filelen_strlen = strlen (filelen_str); + filename_len = strlen(filename); + filelen_str = g_strdup_printf("%d \xD7ֽ\xDA", filesize); + filelen_strlen = strlen(filelen_str); packet_len = 82 + filename_len + filelen_strlen; - raw_data = g_newa (guint8, packet_len); + raw_data = g_newa(guint8, packet_len); cursor = raw_data; - bytes = _qq_create_packet_file_header(raw_data, &cursor, to_uid, QQ_FILE_TRANS_REQ, qd, FALSE); + bytes = _qq_create_packet_file_header(raw_data, &cursor, to_uid, + QQ_FILE_TRANS_REQ, qd, FALSE); bytes += qq_fill_conn_info(raw_data, &cursor, info); /* 079: 0x20 */ bytes += create_packet_b (raw_data, &cursor, 0x20); /* 080: 0x1f */ bytes += create_packet_b (raw_data, &cursor, 0x1f); /* undetermined len: filename */ - bytes += create_packet_data (raw_data, &cursor, filename, + bytes += create_packet_data (raw_data, &cursor, (guint8 *) filename, filename_len); /* 0x1f */ bytes += create_packet_b (raw_data, &cursor, 0x1f); /* file length */ - bytes += create_packet_data (raw_data, &cursor, filelen_str, + bytes += create_packet_data (raw_data, &cursor, (guint8 *) filelen_str, filelen_strlen); if (packet_len == bytes) @@ -485,6 +487,8 @@ { qq_data *qd; guint8 *cursor, *raw_data; + guint16 minor_port; + guint32 real_ip; gint packet_len, bytes; ft_info *info; @@ -494,8 +498,6 @@ gaim_debug(GAIM_DEBUG_INFO, "QQ", "I've accepted the file transfer request from %d\n", to_uid); _qq_xfer_init_socket(qd->xfer); - guint16 minor_port; - guint32 real_ip; packet_len = 79; raw_data = g_newa (guint8, packet_len); @@ -779,7 +781,7 @@ { qq_data *qd; GaimXfer *xfer; - gchar *sender_name; + gchar *sender_name, **fileinfo; ft_info *info; GaimBuddy *b; qq_buddy *q_bud; @@ -803,8 +805,7 @@ *cursor = data + 18 + 12; qq_get_conn_info(data, cursor, data_len, info); - gchar **fileinfo; - fileinfo = g_strsplit(data + 81 + 12, "\x1f", 2); + fileinfo = g_strsplit((gchar *) (data + 81 + 12), "\x1f", 2); g_return_if_fail (fileinfo != NULL && fileinfo[0] != NULL && fileinfo[1] != NULL); sender_name = uid_to_gaim_name(sender_uid); Modified: trunk/src/protocols/qq/sendqueue.h =================================================================== --- trunk/src/protocols/qq/sendqueue.h 2006-08-08 13:20:32 UTC (rev 16672) +++ trunk/src/protocols/qq/sendqueue.h 2006-08-08 23:20:08 UTC (rev 16673) @@ -33,7 +33,7 @@ struct _qq_sendpacket { gint fd; gint len; - gchar *buf; + guint8 *buf; guint16 cmd; guint16 send_seq; gint resend_times; Modified: trunk/src/protocols/qq/sys_msg.c =================================================================== --- trunk/src/protocols/qq/sys_msg.c 2006-08-08 13:20:32 UTC (rev 16672) +++ trunk/src/protocols/qq/sys_msg.c 2006-08-08 23:20:08 UTC (rev 16673) @@ -119,7 +119,7 @@ bytes += create_packet_b(ack, &cursor, code); bytes += create_packet_b(ack, &cursor, bar); - bytes += create_packet_data(ack, &cursor, str, strlen(str)); + bytes += create_packet_data(ack, &cursor, (guint8 *) str, strlen(str)); bytes += create_packet_b(ack, &cursor, bar); bytes += create_packet_w(ack, &cursor, seq); @@ -263,7 +263,7 @@ qd = (qq_data *) gc->proto_data; len = buf_len; - data = g_newa(gchar, len); + data = g_newa(guint8, len); if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { if (NULL == (segments = split_data(data, len, "\x1f", 4))) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-14 07:27:44
|
Revision: 16749 Author: thekingant Date: 2006-08-14 00:27:41 -0700 (Mon, 14 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16749&view=rev Log Message: ----------- Fix a bunch of warnings that I caused. Sorry, I should have compiled before committing. Modified Paths: -------------- trunk/src/protocols/qq/qq_proxy.c trunk/src/protocols/qq/qq_proxy.h trunk/src/protocols/qq/udp_proxy_s5.c Modified: trunk/src/protocols/qq/qq_proxy.c =================================================================== --- trunk/src/protocols/qq/qq_proxy.c 2006-08-14 07:23:11 UTC (rev 16748) +++ trunk/src/protocols/qq/qq_proxy.c 2006-08-14 07:27:41 UTC (rev 16749) @@ -246,7 +246,7 @@ } else { /* connect returns 0 */ gaim_debug(GAIM_DEBUG_INFO, "QQ", "Connected.\n"); fcntl(fd, F_SETFL, 0); - phb->func(phb->data, fd, GAIM_INPUT_READ); + phb->func(phb->data, fd, NULL); } return fd; @@ -255,7 +255,7 @@ /* returns the socket handler, or -1 if there is any error */ static gint _qq_udp_proxy_connect(GaimAccount *account, const gchar *server, - guint16 port, void callback(gpointer, gint, GaimInputCondition), GaimConnection *gc) + guint16 port, void callback(gpointer, gint, const gchar *error_message), GaimConnection *gc) { struct sockaddr_in sin; struct PHB *phb; Modified: trunk/src/protocols/qq/qq_proxy.h =================================================================== --- trunk/src/protocols/qq/qq_proxy.h 2006-08-14 07:23:11 UTC (rev 16748) +++ trunk/src/protocols/qq/qq_proxy.h 2006-08-14 07:27:41 UTC (rev 16749) @@ -31,7 +31,7 @@ #define QQ_CONNECT_STEPS 2 /* steps in connection */ struct PHB { - GaimInputFunction func; + GaimProxyConnectFunction func; gpointer data; gchar *host; gint port; Modified: trunk/src/protocols/qq/udp_proxy_s5.c =================================================================== --- trunk/src/protocols/qq/udp_proxy_s5.c 2006-08-14 07:23:11 UTC (rev 16748) +++ trunk/src/protocols/qq/udp_proxy_s5.c 2006-08-14 07:27:41 UTC (rev 16749) @@ -45,7 +45,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, source, GAIM_INPUT_READ); + phb->func(phb->data, source, NULL); } g_free(phb->host); @@ -61,7 +61,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, GAIM_INPUT_READ); + phb->func(phb->data, -1, NULL); } g_free(phb->host); @@ -93,7 +93,7 @@ fcntl(phb->udpsock, F_SETFL, 0); if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, phb->udpsock, GAIM_INPUT_READ); + phb->func(phb->data, phb->udpsock, NULL); } g_free(phb->host); @@ -158,7 +158,7 @@ gaim_debug(GAIM_DEBUG_INFO, "s5_sendconnect", "packet too small\n"); if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, GAIM_INPUT_READ); + phb->func(phb->data, -1, NULL); } g_free(phb->host); @@ -182,7 +182,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, GAIM_INPUT_READ); + phb->func(phb->data, -1, NULL); } g_free(phb->host); @@ -195,7 +195,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, GAIM_INPUT_READ); + phb->func(phb->data, -1, NULL); } g_free(phb->host); @@ -224,7 +224,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, source, GAIM_INPUT_READ); + phb->func(phb->data, source, NULL); } g_free(phb->host); @@ -238,7 +238,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, GAIM_INPUT_READ); + phb->func(phb->data, -1, NULL); } g_free(phb->host); @@ -263,7 +263,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, GAIM_INPUT_READ); + phb->func(phb->data, -1, NULL); } g_free(phb->host); @@ -297,7 +297,7 @@ close(source); if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, GAIM_INPUT_READ); + phb->func(phb->data, -1, NULL); } g_free(phb->host); @@ -327,7 +327,7 @@ if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { - phb->func(phb->data, -1, GAIM_INPUT_READ); + phb->func(phb->data, -1, NULL); } g_free(phb->host); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |