|
发表于 2008-6-25 08:11:49
|
显示全部楼层
以下是我gdb的输出,请楼主帮忙看看。
我用的fetion源码打了 http://linuxfire.com.cn/~moo/log/left/pidgin-2.5.0-fetion-fixes 补丁
- lijt@lijt-buptnu:~$ gdb --args pidgin -d
- GNU gdb 6.8-debian
- Copyright (C) 2008 Free Software Foundation, Inc.
- License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
- This is free software: you are free to change and redistribute it.
- There is NO WARRANTY, to the extent permitted by law. Type "show copying"
- and "show warranty" for details.
- This GDB was configured as "x86_64-linux-gnu"...
- (no debugging symbols found)
- (gdb) run
- Starting program: /usr/bin/pidgin -d
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- [Thread debugging using libthread_db enabled]
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- ---Type <return> to continue, or q <return> to quit---
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- [New Thread 0x7f4209e667a0 (LWP 13130)]
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (12:38:24) prefs: Reading /home/lijt/.purple/prefs.xml
- (12:38:24) prefs: Finished reading /home/lijt/.purple/prefs.xml
- (12:38:24) prefs: purple_prefs_get_string: /pidgin/browsers/command not a string pref
- (12:38:24) dbus: okkk
- (12:38:24) plugins: probing /usr/lib/pidgin/nautilus.so
- (no debugging symbols found)
- (12:38:24) plugins: probing /usr/lib/pidgin/cap.so
- (no debugging symbols found)
- (no debugging symbols found)
- (12:38:24) plugins: probing /usr/lib/pidgin/gestures.so
- (no debugging symbols found)
- (12:38:24) plugins: probing /usr/lib/pidgin/gevolution.so
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- ---Type <return> to continue, or q <return> to quit---
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/musicmessaging.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/ticker.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/convcolors.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/extplacement.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/gtkbuddynote.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/history.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/iconaway.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/markerline.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/notify.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/pidginrc.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/spellchk.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/timestamp.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/timestamp_format.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/pidgin/xmppconsole.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/purple-2/libicq.so
- (no debugging symbols found)
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/purple-2/libqq.so
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/purple-2/libsametime.so
- (no debugging symbols found)
- (no debugging symbols found)
- (12:38:25) plugins: /usr/lib/purple-2/libsametime.so has a prefs_info, but is a prpl. This is no longer supported.
- (12:38:25) plugins: probing /usr/lib/purple-2/libzephyr.so
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (no debugging symbols found)
- (12:38:25) plugins: probing /usr/lib/purple-2/libjabber.so
- (no debugging symbols found)
- (no debugging symbols found)
- (12:38:25) plugins: /usr/lib/purple-2/libjabber.so is not usable because the 'purple_init_plugin' symbol could not be found. Does the plugin call the PURPLE_INIT_PLUGIN() macro?
- (12:38:25) plugins: probing /usr/lib/purple-2/liboscar.so
- (12:38:25) plugins: /usr/lib/purple-2/liboscar.so is not usable because the 'purple_init_plugin' symbol could not be found. Does the plugin call the PURPLE_INIT_PLUGIN() macro?
- (12:38:25) plugins: probing /usr/lib/purple-2/libfetion.so
- (12:38:25) plugins: probing /usr/lib/purple-2/perl.so
- (12:38:25) plugins: probing /usr/lib/purple-2/ssl.so
- (12:38:25) plugins: probing /usr/lib/purple-2/ssl-gnutls.so
- (12:38:25) plugins: probing /usr/lib/purple-2/ssl-nss.so
- (12:38:25) plugins: probing /usr/lib/purple-2/tcl.so
- [New Thread 0x4104d950 (LWP 13134)]
- (12:38:25) plugins: probing /usr/lib/purple-2/autoaccept.so
- (12:38:25) plugins: probing /usr/lib/purple-2/buddynote.so
- (12:38:25) plugins: probing /usr/lib/purple-2/idle.so
- (12:38:25) plugins: probing /usr/lib/purple-2/joinpart.so
- (12:38:25) plugins: probing /usr/lib/purple-2/log_reader.so
- (12:38:25) plugins: probing /usr/lib/purple-2/newline.so
- (12:38:25) plugins: probing /usr/lib/purple-2/offlinemsg.so
- (12:38:25) plugins: probing /usr/lib/purple-2/psychic.so
- (12:38:25) plugins: probing /usr/lib/purple-2/statenotify.so
- (12:38:25) plugins: probing /usr/lib/purple-2/dbus-example.so
- (12:38:25) plugins: probing /usr/lib/purple-2/libbonjour.so
- (12:38:25) plugins: probing /usr/lib/purple-2/libgg.so
- (12:38:25) plugins: probing /usr/lib/purple-2/libirc.so
- (12:38:25) plugins: probing /usr/lib/purple-2/libxmpp.so
- (12:38:25) util: Reading file xmpp-caps.xml from directory /home/lijt/.purple
- (12:38:25) plugins: probing /usr/lib/purple-2/libmsn.so
- (12:38:25) plugins: probing /usr/lib/purple-2/libmyspace.so
- (12:38:25) plugins: probing /usr/lib/purple-2/libnovell.so
- (12:38:25) plugins: probing /usr/lib/purple-2/libaim.so
- (12:38:25) plugins: probing /usr/lib/purple-2/libsimple.so
- (12:38:25) plugins: probing /usr/lib/purple-2/libyahoo.so
- (12:38:25) prefs: /purple/status/scores/offline changed, scheduling save.
- (12:38:25) prefs: /purple/status/scores/available changed, scheduling save.
- (12:38:25) prefs: /purple/status/scores/invisible changed, scheduling save.
- (12:38:25) prefs: /purple/status/scores/away changed, scheduling save.
- (12:38:25) prefs: /purple/status/scores/extended_away changed, scheduling save.
- (12:38:25) prefs: /purple/status/scores/idle changed, scheduling save.
- (12:38:25) prefs: /purple/status/scores/offline_msg changed, scheduling save.
- (12:38:25) util: Reading file accounts.xml from directory /home/lijt/.purple
- (12:38:25) myspace: returning status types
- (12:38:25) g_log: purple_find_buddies: assertion `purplebuddylist != NULL' failed
- (12:38:25) msim: msim_uid2username_from_blist: no buddies?
- (12:38:25) g_log: purple_find_buddies: assertion `purplebuddylist != NULL' failed
- (12:38:25) msim: msim_uid2username_from_blist: no buddies?
- (12:38:25) g_log: purple_find_buddies: assertion `purplebuddylist != NULL' failed
- (12:38:25) msim: msim_uid2username_from_blist: no buddies?
- (12:38:25) g_log: purple_find_buddies: assertion `purplebuddylist != NULL' failed
- (12:38:25) msim: msim_uid2username_from_blist: no buddies?
- (12:38:25) util: Reading file status.xml from directory /home/lijt/.purple
- (12:38:25) g_log: purple_find_buddies: assertion `purplebuddylist != NULL' failed
- (12:38:25) msim: msim_uid2username_from_blist: no buddies?
- (12:38:25) g_log: purple_find_buddies: assertion `purplebuddylist != NULL' failed
- (12:38:25) msim: msim_uid2username_from_blist: no buddies?
- (12:38:25) g_log: purple_find_buddies: assertion `purplebuddylist != NULL' failed
- (12:38:25) msim: msim_uid2username_from_blist: no buddies?
- (12:38:25) g_log: purple_find_buddies: assertion `purplebuddylist != NULL' failed
- (12:38:25) msim: msim_uid2username_from_blist: no buddies?
- (12:38:25) certificate: CertificateVerifier x509, singleuse requested but not found.
- (12:38:25) certificate: CertificateVerifier singleuse registered
- (12:38:25) certificate: CertificatePool x509, ca requested but not found.
- (12:38:25) certificate: CertificateScheme x509 requested but not found.
- (12:38:25) certificate/x509/ca: Lazy init failed because an X.509 Scheme is not yet registered. Maybe it will be better later.
- (12:38:25) certificate/x509/ca: Init failed, probably because a dependency is not yet registered. It has been deferred to later.
- (12:38:25) certificate: CertificatePool ca registered
- (12:38:25) certificate: CertificatePool x509, tls_peers requested but not found.
- (12:38:25) certificate: CertificatePool tls_peers registered
- (12:38:25) certificate: CertificateVerifier x509, tls_cached requested but not found.
- (12:38:25) certificate: CertificateVerifier tls_cached registered
- (12:38:25) prefs: /purple/logging/format changed, scheduling save.
- (12:38:25) prefs: /purple/logging/format changed, scheduling save.
- [New Thread 0x41a5c950 (LWP 13135)]
- (12:38:25) prefs: /purple/proxy/type changed, scheduling save.
- (12:38:25) prefs: /purple/proxy/host changed, scheduling save.
- (12:38:25) prefs: /purple/proxy/port changed, scheduling save.
- (12:38:25) prefs: /purple/proxy/username changed, scheduling save.
- (12:38:25) prefs: /purple/proxy/password changed, scheduling save.
- (12:38:25) certificate: CertificateScheme x509 requested but not found.
- (12:38:25) certificate: CertificateScheme x509 registered
- (12:38:25) stun: using server
- (12:38:25) sound: Initializing sound output drivers.
- (12:38:25) prefs: /pidgin/conversations/placement changed, scheduling save.
- (12:38:25) prefs: purple_prefs_connect_callback: Unknown pref /pidgin/conversations/im/show_protocol_icons
- (12:38:25) gtkblist: added visibility manager: 1
- (12:38:25) docklet: created
- (12:38:25) util: Reading file blist.xml from directory /home/lijt/.purple
- (12:38:26) msim: msim_uid2username_from_blist: no buddies?
- (12:38:26) msim: msim_uid2username_from_blist: no buddies?
- (12:38:26) msim: msim_uid2username_from_blist: no buddies?
- (12:38:26) plugins: probing /usr/lib/gaim/docklet.so
- (12:38:26) plugins: Unable to find saved plugin /usr/lib/gaim/docklet.so
- (12:38:26) plugins: Loading saved plugin /usr/lib/pidgin/notify.so
- (12:38:26) pounce: Error reading pounces: 打开文件“/home/lijt/.purple/pounces.xml”失败:没有该文件或目录
- (12:38:26) ui_main: Failed to load the default window icon (scalablepx version)!
- (12:38:26) Session Management: ICE initialized.
- (12:38:26) Session Management: Connecting with no previous ID
- (12:38:26) Session Management: Handling new ICE connection...
- (12:38:26) done.
- (12:38:26) Session Management: Connected to manager (GnomeSM) with client ID 11c0a8648c000121436870600000063400026
- (12:38:26) Session Management: Using /usr/bin/pidgin as command
- (12:38:26) gtkspell: Failed to setup GtkSpell: aspell: No word lists can be found for the language "zh_CN".
- (12:38:26) dbus: Need to register an object with the dbus subsystem. (If you are not a developer, please ignore this message.)
- (12:38:26) dbus: The signal "gtkblist-hiding" caused some dbus error. (If you are not a developer, please ignore this message.)
- (12:38:26) util: Writing file /home/lijt/.purple/icons/c4e0fb5a029d14c244d2862ad9653e4fa80cbc2f.png
- (12:38:26) util: Writing file /home/lijt/.purple/icons/c4e0fb5a029d14c244d2862ad9653e4fa80cbc2f.png
- (12:38:26) util: Writing file /home/lijt/.purple/icons/c4e0fb5a029d14c244d2862ad9653e4fa80cbc2f.png
- (12:38:26) util: Writing file /home/lijt/.purple/icons/e57c5121bd4ce975be31db3025dfc108fea9bf10.jpg
- (12:38:26) util: Writing file /home/lijt/.purple/icons/c4e0fb5a029d14c244d2862ad9653e4fa80cbc2f.png
- (12:38:26) util: Writing file /home/lijt/.purple/icons/c4e0fb5a029d14c244d2862ad9653e4fa80cbc2f.png
- (12:38:26) util: Writing file /home/lijt/.purple/icons/c4e0fb5a029d14c244d2862ad9653e4fa80cbc2f.png
- (12:38:26) util: Writing file /home/lijt/.purple/icons/c4e0fb5a029d14c244d2862ad9653e4fa80cbc2f.png
- (12:38:26) Session Management: Received first save_yourself
- (12:38:26) Session Management: Received save_complete
- (12:38:26) docklet: embedded
- (12:38:26) network: Entering nm_callback_func!
- (12:38:29) account: Connecting to account 138xxxxxxxx@
- (12:38:29) connection: Connecting. gc = 0xe80ce0
- (12:38:29) fetion:: IsCMccNo:[1381132]
- (12:38:29) util: Reading file 138xxxxxxxx-SysCfg.xml from directory /home/lijt/.purple
- (12:38:29) fetion: systemconfig:cfg_ver[(null)]
- (12:38:29) dns: DNS query for 'nav.fetion.com.cn' queued
- (12:38:29) dns: Debugger detected, performing useless query...
- (12:38:29) dns: Created new DNS child 13138, there are now 1 children.
- (12:38:29) dns: Successfully sent DNS request to child 13138
- (12:38:29) dns: Got response for 'nav.fetion.com.cn'
- (12:38:29) dnsquery: IP resolved for nav.fetion.com.cn
- (12:38:29) proxy: Attempting connection to 221.130.45.201
- (12:38:29) proxy: Connecting to nav.fetion.com.cn:80 with no proxy
- (12:38:29) proxy: Connection in progress
- (12:38:29) proxy: Connected to nav.fetion.com.cn:80.
- (12:38:29) Fetion:: send:POST /nav/getsystemconfig.aspx HTTP/1.1
- User-Agent: IIC2.0/pc 2.3.0230
- Host: nav.fetion.com.cn
- Content-Length: 272
- Connection: Close
- <config><user mobile-no="138xxxxxxxx" /><client type="PC" version="2.3.0230" platform="W5.1" /><servers version="63" /><service-no version="27" /><parameters version="34" /><hints version="28" /><http-applications version="31" /><client-config version="35" /></config>
- B
- (12:38:29) account: Disconnecting account 0x867d60
- (12:38:29) connection: Disconnecting connection 0xe80ce0
- (12:38:29) connection: Destroying connection 0xe80ce0
- Program received signal SIGSEGV, Segmentation fault.
- [Switching to Thread 0x7f4209e667a0 (LWP 13130)]
- 0x00007f42069ff060 in strlen () from /lib/libc.so.6
- (gdb) bt
- #0 0x00007f42069ff060 in strlen () from /lib/libc.so.6
- #1 0x00007f42069cbe1a in vfprintf () from /lib/libc.so.6
- #2 0x00007f42069ef6ed in vasprintf () from /lib/libc.so.6
- #3 0x00007f42071eb470 in g_vasprintf () from /usr/lib/libglib-2.0.so.0
- #4 0x00007f42071d94d0 in g_strdup_vprintf () from /usr/lib/libglib-2.0.so.0
- #5 0x00007f42071d956d in g_strdup_printf () from /usr/lib/libglib-2.0.so.0
- #6 0x00007f41f839b248 in RetriveSysCfg_cb (sodata=0xe7a2b0, source=21, error_message=0x1 <Address 0x1 out of bounds>) at f_login.c:366
- #7 0x000000000046be51 in ?? ()
- #8 0x00007f42071ba262 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
- #9 0x00007f42071bd516 in ?? () from /usr/lib/libglib-2.0.so.0
- #10 0x00007f42071bd7d7 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
- #11 0x00007f4208900f03 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
- #12 0x0000000000486c0a in main ()
- (gdb) bt full
- #0 0x00007f42069ff060 in strlen () from /lib/libc.so.6
- No symbol table info available.
- #1 0x00007f42069cbe1a in vfprintf () from /lib/libc.so.6
- No symbol table info available.
- #2 0x00007f42069ef6ed in vasprintf () from /lib/libc.so.6
- No symbol table info available.
- #3 0x00007f42071eb470 in g_vasprintf () from /usr/lib/libglib-2.0.so.0
- No symbol table info available.
- #4 0x00007f42071d94d0 in g_strdup_vprintf () from /usr/lib/libglib-2.0.so.0
- No symbol table info available.
- #5 0x00007f42071d956d in g_strdup_printf () from /usr/lib/libglib-2.0.so.0
- No symbol table info available.
- #6 0x00007f41f839b248 in RetriveSysCfg_cb (sodata=0xe7a2b0, source=21, error_message=0x1 <Address 0x1 out of bounds>) at f_login.c:366
- buf = '\0' <repeats 10239 times>
- cur = (
- gchar *) 0x1483c1d "\217�\235�添�\212�好�\217\213�\200\202" /><item key="online-garden-desc" value="" /><item key="mobile-no-dist" value="<r><c v="cmcc"><d s="13500000000" e="13999999999"/>&l"...
- msg_server = (gchar *) 0x8 <Address 0x8 out of bounds>
- ssic_server = (gchar *) 0xda7910 "\200\223\201"
- por_server = (gchar *) 0x145ef20 ""
- upload_server = (gchar *) 0x3ff0000000000000 <Address 0x3ff0000000000000 out of bounds>
- cfg_size = (gchar *) 0x0
- cfg_filename = (gchar *) 0x0
- sip = (struct fetion_account_data *) 0xe7a2b0
- len = 0
- rcv_len = 0
- root = (xmlnode *) 0xd97680
- son_node = (xmlnode *) 0x7f4208b050d3
- item = (xmlnode *) 0x7fff11e94970
- __PRETTY_FUNCTION__ = "RetriveSysCfg_cb"
- #7 0x000000000046be51 in ?? ()
- No symbol table info available.
- #8 0x00007f42071ba262 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
- No symbol table info available.
- #9 0x00007f42071bd516 in ?? () from /usr/lib/libglib-2.0.so.0
- No symbol table info available.
- #10 0x00007f42071bd7d7 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
- No symbol table info available.
- #11 0x00007f4208900f03 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
- No symbol table info available.
- #12 0x0000000000486c0a in main ()
- No symbol table info available.
- (gdb) quit
- The program is running. Exit anyway? (y or n) y
- lijt@lijt-buptnu:~$
复制代码
f_login.c:
- #include "internal.h"
- #include "accountopt.h"
- #include "blist.h"
- #include "conversation.h"
- #include "dnsquery.h"
- #include "debug.h"
- #include "notify.h"
- #include "privacy.h"
- #include "prpl.h"
- #include "plugin.h"
- #include "util.h"
- #include "version.h"
- #include "network.h"
- #include "xmlnode.h"
- #include "request.h"
- #include "imgstore.h"
- #include "sslconn.h"
- #include "sipmsg.h"
- #include "dnssrv.h"
- #include "ntlm.h"
- #include "sipmsg.h"
- #include "f_login.h"
- void fetion_subscribe_exp(struct fetion_account_data *sip, struct fetion_buddy *buddy)
- {
- GSList *buddy_list;
- gchar body[10240],*hdr;
- memset(body,0,sizeof(body));
- g_strlcat(body,"<args><subscription><contacts>",10240);
- hdr = g_strdup_printf("N: presence\r\n");
- if(buddy==NULL)
- {
- buddy_list = purple_find_buddies(sip->account,NULL);
- for(;buddy_list;buddy_list = g_slist_next(buddy_list))
- {
- if((strncmp( ((PurpleBuddy *) buddy_list->data)->name,"sip",3)==0) &&(strcmp( ((PurpleBuddy *) buddy_list->data)->name,sip->uri)!=0))
- {
- g_strlcat(body,"<contact uri="",10240);
- purple_debug_info("fetion:sub","name=[%s]\n",((PurpleBuddy *) buddy_list->data)->name);
- g_strlcat(body,((PurpleBuddy *) buddy_list->data)->name,10240);
- g_strlcat(body,"" />",10240);
- }
- else
- continue;
- }
- }
- else
- {
- g_strlcat(body,"<contact uri="",10240);
- g_strlcat(body,buddy->name,10240);
- g_strlcat(body,"" />",10240);
- }
- g_strlcat(body,"</contacts>",10240);
- g_strlcat(body,"<presence><basic attributes="all" /><personal attributes="all" /><extended types="sms;location;listening;ring-back-tone" /></presence></subscription><subscription><contacts><contact uri="",10240);
- g_strlcat(body,sip->uri,10240);
- g_strlcat(body,"" /></contacts><presence><extended types="sms;location;listening;ring-back-tone" /></presence></subscription></args>",10240);
- purple_debug_info("fetion:sub","name=[%s]\n",body);
- send_sip_request(sip->gc, "SUB", "", "",hdr, body,NULL,
- process_subscribe_response );
- }
- void do_register_exp(struct fetion_account_data *sip, gint expire)
- {
- gchar *body=NULL;
- gchar *hdr=NULL;
- sip->reregister = time(NULL) + expire - 100;
- body = g_strdup_printf(" <args><device type="PC" version="0" client-version="2.3.0230" /><caps value="fetion-im;im-session;temp-group" /><events value="contact;permission;system-message" /><user-info attributes="all" /><presence><basic value="400" desc="" /></presence></args>");
- if(sip->registerstatus == FETION_REGISTER_RETRY)
- {
- hdr = g_strdup_printf("A: Digest response="%s",cnonce="%s"\r\n",
- sip->registrar.digest_session_key,sip->registrar.cnonce );
- }
- else if(sip->registerstatus == FETION_REGISTER_COMPLETE)
- {
- if(expire==0)
- hdr = g_strdup_printf("X: 0\r\n");
- g_free(body);
- body=NULL;
- }
- else
- {
- sip->registerstatus = FETION_REGISTER_SENT;
- hdr=NULL;
- }
- send_sip_request(sip->gc, "R", "", "", hdr, body, NULL,
- process_register_response);
- if(body!=NULL)
- g_free(body);
- if(hdr!=NULL)
- g_free(hdr);
- }
- void do_register(struct fetion_account_data *sip)
- {
- do_register_exp(sip, sip->registerexpire);
- }
- gboolean read_cookie(gpointer sodata, PurpleSslConnection * source, gint con)
- {
- gchar buf[10240];
- gchar *cur=NULL;
- gchar *end=NULL;
- const gchar *uri=NULL;
- xmlnode *isc,*item;
- gint len,rcv_len;
- PurpleSslConnection* gsc;
- struct fetion_account_data *sip;
- sip=sodata;
- purple_debug_info("fetion:","read cookie\n");
- gsc=(PurpleSslConnection*) source;
- rcv_len=purple_ssl_read(gsc,buf,10240);
- if(rcv_len>0)
- {
- buf[rcv_len]='\0';
- purple_debug_info("fetion:","read_cookie:%s\n",buf);
- cur=strstr(buf,"Cookie: ssic=");
- if(cur!=NULL)
- {
- cur+=13;
- end=strstr(cur,";");
- sip->ssic = g_strndup(cur,end-cur);
- purple_debug_info("fetion:","read_cookie:[%s]\n",sip->ssic);
- // end=purple_url_encode(sip->ssic);
- // purple_debug_info("fetion:","read_cookie:[%s]\n",end);
- }
- if( (cur = strstr(buf,"\r\n\r\n")))
- {
- if (((strncmp(buf, "HTTP/1.1 200 OK\r\n", 17) != 0) &&
- (strncmp(buf, "HTTP/1.1 100 Continue\r\n", 23) != 0)))
- {
- purple_connection_error_reason(sip->gc,
- PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
- _("Invalid Password or Mobileno"));
- return FALSE;
- }
- cur+=4;
- len = strlen(cur);
- isc = xmlnode_from_str(cur, len);
- g_return_val_if_fail(isc!=NULL,FALSE);
- item = xmlnode_get_child(isc,"user");
- g_return_val_if_fail(item!=NULL,FALSE);
- uri = xmlnode_get_attrib(item,"uri");
- g_return_val_if_fail(uri!=NULL,FALSE);
- sip->uri = g_strdup(uri);
- cur = strstr(uri,"@");
- g_return_val_if_fail(cur!=NULL,FALSE);
- *cur='\0';
- sip->username = g_strdup_printf("%s",uri+4);
- purple_debug_info("fetion:","cookie[%s]\n",sip->username);
- purple_timeout_remove(sip->registertimeout);
- srvresolved(sip);
- xmlnode_free(isc);
- purple_ssl_close(gsc);
- return TRUE;
- }
- }
- purple_ssl_close(gsc);
- return FALSE;
- }
- gboolean Ssi_cb(gpointer sodata, PurpleSslConnection * gsc, gint con)
- {
- gchar *head;
- struct fetion_account_data *sip;
- sip=sodata;
- purple_debug_info("Fetion:","Ssi_cb\n");
- if(sip->mobileno!=NULL)
- {
- head = g_strdup_printf(
- "GET /ssiportal/SSIAppSignIn.aspx?mobileno=%s&pwd=%s HTTP/1.1\r\n"
- "User-Agent: IIC2.0/pc 2.3.0230\r\n"
- "Host: %s\r\n"
- "Connection: Keep-Alive\r\n\r\n",
- sip->mobileno,sip->password,sip->SsicServer
- );
- }
- else
- {
- head = g_strdup_printf(
- "GET /ssiportal/SSIAppSignIn.aspx?sid=%s&pwd=%s HTTP/1.1\r\n"
- "User-Agent: IIC2.0/pc 2.3.0230\r\n"
- "Host: %s\r\n"
- "Connection: Keep-Alive\r\n\r\n",
- sip->username,sip->password,sip->SsicServer
- );
- }
- purple_ssl_write(gsc,head,strlen(head));
- purple_ssl_input_add(gsc,(PurpleSslInputFunction) read_cookie, sip);
- return TRUE;
- }
- void LoginToSsiPortal(gpointer sodata)
- {
- PurpleSslConnection *gsc;
- struct fetion_account_data *sip;
- sip=sodata;
- purple_debug_info("Fetion:","LoginToSsiPortal\n");
- gsc = purple_ssl_connect(sip->account,sip->SsicServer,
- PURPLE_SSL_DEFAULT_PORT,(PurpleSslInputFunction) Ssi_cb,NULL,sip);
- g_return_if_fail(gsc != NULL);
- purple_debug_info("Fetion:","SSL connected\n");
- }
- /* ret: 0 ok
- * -1 no file
- * -2 error in parse node
- * -3 NULL mobile && NULL sid
- */
- gint ParseCfg(struct fetion_account_data *sip)
- {
- xmlnode *root,*son_node,*item;
- gchar *cur;
- gchar *msg_server,*ssic_server,*por_server,*upload_server;
- gchar *server_ver;
- gchar *cfg_filename;
- if(sip->mobileno!=NULL)
- cfg_filename = g_strdup_printf("%s-SysCfg.xml",sip->mobileno);
- else if(sip->username!=NULL)
- cfg_filename = g_strdup_printf("%s-SysCfg.xml",sip->username);
- else
- return -3;
- root = purple_util_read_xml_from_file(cfg_filename,"SysCfg.xml");
- if(root==NULL)
- return -1;
- son_node = xmlnode_get_child(root,"servers");
- g_return_val_if_fail(son_node!=NULL,-2);
- server_ver = xmlnode_get_attrib(son_node,"version");
- sip->ServerVersion = g_strdup(server_ver);
- purple_debug_info("fetion","systemconfig:cfg_ver[%s]\n",sip->CfgVersion);
- item = xmlnode_get_child(son_node,"sipc-proxy");
- g_return_val_if_fail(item!=NULL,-2);
- msg_server = g_strdup(xmlnode_get_data(item));
- item = xmlnode_get_child(son_node,"ssi-app-sign-in");
- g_return_val_if_fail(item!=NULL,-2);
- ssic_server = g_strdup(xmlnode_get_data(item));
- item = xmlnode_get_child(root,"http-applications/get-portrait");
- g_return_val_if_fail(item!=NULL,-2);
- por_server = g_strdup(xmlnode_get_data(item));
- item = xmlnode_get_child(root,"http-applications/set-portrait");
- g_return_val_if_fail(item!=NULL,-2);
- upload_server = g_strdup(xmlnode_get_data(item));
- cur = strstr(msg_server,":");
- *cur='\0';
- cur++;
- sip->MsgServer = g_strdup(msg_server);
- sip->MsgPort = atoi(cur);
- cur = strstr(ssic_server,"/ssiportal");
- *cur='\0';
- cur = ssic_server+8;
- sip->SsicServer=g_strdup(cur);
- cur = strstr(por_server,"/hds");
- *cur = '\0';
- cur = por_server+7;
- sip->PortraitServer = g_strdup(cur);
- cur = strstr(upload_server,"/hds");
- *cur = '\0';
- cur = upload_server+7;
- sip->UploadServer = g_strdup(cur);
- son_node = xmlnode_get_child(root,"service-no");
- g_return_val_if_fail(son_node!=NULL,-2);
- sip->ServiceNoVersion = g_strdup(xmlnode_get_attrib(son_node,"version"));
- son_node = xmlnode_get_child(root,"parameters");
- g_return_val_if_fail(son_node!=NULL,-2);
- sip->ParaVersion = g_strdup(xmlnode_get_attrib(son_node,"version"));
- son_node = xmlnode_get_child(root,"hints");
- g_return_val_if_fail(son_node!=NULL,-2);
- sip->HintsVersion = g_strdup(xmlnode_get_attrib(son_node,"version"));
- son_node = xmlnode_get_child(root,"http-applications");
- g_return_val_if_fail(son_node!=NULL,-2);
- sip->HttpAppVersion = g_strdup(xmlnode_get_attrib(son_node,"version"));
- son_node = xmlnode_get_child(root,"client-config");
- g_return_val_if_fail(son_node!=NULL,-2);
- sip->ClientCfgVersion = g_strdup(xmlnode_get_attrib(son_node,"version"));
- //LoginToSsiPortal(sip);
- xmlnode_free(root);
- g_free(msg_server);
- g_free(ssic_server);
- g_free(por_server);
- g_free(cfg_filename);
- return 0;
- }
- void RetriveSysCfg_cb(gpointer sodata, gint source, const gchar *error_message)
- {
- gchar buf[10240];
- gchar *cur;
- gchar *msg_server,*ssic_server,*por_server,*upload_server;
- gchar *cfg_size=NULL;
- gchar *cfg_filename=NULL;
- struct fetion_account_data *sip=sodata;
- gint len,rcv_len;
- xmlnode *root,*son_node, *item;
- memset(buf,0,10240);
- rcv_len = read(source,buf,10240);
- if(rcv_len>0)
- {
- if( (cur = strstr(buf,"\r\n\r\n")) )
- {
- if (strncmp(buf, "HTTP/1.1 200 OK\r\n", 17) != 0)
- purple_connection_error_reason(sip->gc,
- PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
- _("Invalid Password or Mobileno"));
- cfg_size = get_token(buf, "Content-Length: ", "\r\n");
- if(cfg_size==NULL)
- return;
- cur+=4;
- sip->SysCfg.size=atoi(cfg_size);
- sip->SysCfg.buf = g_malloc(sip->SysCfg.size);
- len=rcv_len-(cur-buf);
- sip->SysCfg.rcv_len=len;
- memcpy((sip->SysCfg.buf),cur,len);
- }
- else
- {
- cur = sip->SysCfg.buf + sip->SysCfg.rcv_len;
- if((sip->SysCfg.rcv_len)+rcv_len>(sip->SysCfg.size))
- memcpy(cur,buf,(sip->SysCfg.size)-(sip->SysCfg.rcv_len));
- else
- memcpy(cur,buf,rcv_len);
- sip->SysCfg.rcv_len+=rcv_len;
- }
- }
- else {
- purple_input_remove( sip->SysCfg.inpa );
- if(sip->mobileno!=NULL)
- cfg_filename = g_strdup_printf("%s-SysCfg.xml",sip->mobileno);
- else if(sip->username!=NULL)
- cfg_filename = g_strdup_printf("%s-SysCfg.xml",sip->username);
- else
- cfg_filename = g_strdup_printf("SysCfg.xml");
- root = xmlnode_from_str(sip->SysCfg.buf,sip->SysCfg.size);
- g_return_if_fail(root!=NULL);
- son_node = xmlnode_get_child(root,"servers");
- if(son_node==NULL)
- {
- LoginToSsiPortal(sip);
- return ;
- }
- purple_debug_info("fetion","systemconfig:after servers");
- item = xmlnode_get_child(son_node,"sipc-proxy");
- g_return_if_fail(item!=NULL);
- msg_server = g_strdup(xmlnode_get_data(item));
- item = xmlnode_get_child(son_node,"ssi-app-sign-in");
- g_return_if_fail(item!=NULL);
- ssic_server = g_strdup(xmlnode_get_data(item));
- item = xmlnode_get_child(root,"http-applications/get-portrait");
- g_return_if_fail(item!=NULL);
- por_server = g_strdup(xmlnode_get_data(item));
- item = xmlnode_get_child(root,"http-applications/set-portrait");
- g_return_if_fail(item!=NULL);
- upload_server = g_strdup(xmlnode_get_data(item));
- cur = strstr(msg_server,":");
- *cur='\0';
- cur++;
- sip->MsgServer = g_strdup(msg_server);
- sip->MsgPort = atoi(cur);
- cur = strstr(ssic_server,"/ssiportal");
- *cur='\0';
- cur = ssic_server+8;
- sip->SsicServer=g_strdup(cur);
- cur = strstr(por_server,"/hds");
- *cur = '\0';
- cur = por_server+7;
- sip->PortraitServer = g_strdup(cur);
- cur = strstr(upload_server,"/hds");
- *cur = '\0';
- cur = upload_server+7;
- sip->UploadServer = g_strdup(cur);
- LoginToSsiPortal(sip);
- purple_util_write_data_to_file(cfg_filename, sip->SysCfg.buf,sip->SysCfg.size);
- g_free(msg_server);
- g_free(ssic_server);
- g_free(por_server);
- g_free(upload_server);
- }
- }
- gint RetriveSysCfg(gpointer sodata, gint source, const gchar *error_message)
- {
- gchar *data,*body;
- gint body_len,header_len,writed_len;
- gint fd;
- struct fetion_account_data *sip=sodata;
- if(sip->ServerVersion==NULL)
- sip->ServerVersion = g_strdup("0");
- if(sip->ServiceNoVersion==NULL)
- sip->ServiceNoVersion = g_strdup("0");
- if(sip->ParaVersion==NULL)
- sip->ParaVersion = g_strdup("0");
- if(sip->HintsVersion==NULL)
- sip->HintsVersion = g_strdup("0");
- if(sip->HttpAppVersion==NULL)
- sip->HttpAppVersion = g_strdup("0");
- if(sip->ClientCfgVersion==NULL)
- sip->ClientCfgVersion = g_strdup("0");
- fd=source;
- body_len = 75;
- if(sip->mobileno!=NULL)
- {
- body = g_strdup_printf("<config><user mobile-no="%s" /><client type="PC" version="2.3.0230" platform="W5.1" /><servers version="%s" /><service-no version="%s" /><parameters version="%s" /><hints version="%s" /><http-applications version="%s" /><client-config version="%s" /></config>\r\n\r\n",sip->mobileno,sip->ServerVersion,sip->ServiceNoVersion,sip->ParaVersion,sip->HintsVersion,sip->HttpAppVersion,sip->ClientCfgVersion);
- }
- else
- {
- body = g_strdup_printf("<config><user sid="%s" /><client type="PC" version="2.3.0230" platform="W5.1" /><servers version="%s" /><service-no version="%s" /><parameters version="%s" /><hints version="%s" /><http-applications version="%s" /><client-config version="%s" /></config>\r\n\r\n",sip->username,sip->ServerVersion,sip->ServiceNoVersion,sip->ParaVersion,sip->HintsVersion,sip->HttpAppVersion,sip->ClientCfgVersion);
- }
- body_len = strlen(body);
- data = g_strdup_printf("POST /nav/getsystemconfig.aspx HTTP/1.1\r\n"
- "User-Agent: IIC2.0/pc 2.3.0230\r\n"
- "Host: %s\r\n"
- "Content-Length: %d\r\n"
- "Connection: Close\r\n\r\n",
- sip->SysCfgServer,
- (int) body_len);
- header_len = strlen(data);
- data = g_realloc(data, header_len + body_len);
- memcpy(data + header_len, body, body_len);
- (sip->SysCfg).inpa = purple_input_add(fd, PURPLE_INPUT_READ,(PurpleInputFunction) RetriveSysCfg_cb, sip);
- writed_len = write(fd,data, header_len+body_len);
- purple_debug_info("Fetion:","send:%s\n",data);
- g_free(data);
- g_free(body);
- return 0;
- }
- void fetion_login(PurpleAccount *account)
- {
- PurpleConnection *gc;
- struct fetion_account_data *sip;
- gchar **userserver;
- gint ret;
- const char *username = purple_account_get_username(account);
- gc = purple_account_get_connection(account);
- gc->proto_data = sip = g_new0(struct fetion_account_data, 1);
- sip->gc = gc;
- sip->tg = 0; //temp group chat id
- sip->account = account;
- sip->registerexpire = 400;
- sip->txbuf = purple_circ_buffer_new(0);
- sip->impresa=NULL;
- sip->icon_buf = purple_circ_buffer_new(0);
- sip->GetContactFlag = 0;
- userserver = g_strsplit(username, "@", 2);
- purple_connection_set_display_name(gc, userserver[0]);
- if(IsCMccNo(userserver[0]))
- {
- sip->username = NULL;
- sip->mobileno = g_strdup(userserver[0]);
- }
- else
- {
- sip->mobileno = NULL;
- sip->username = g_strdup(userserver[0]);
- }
- // sip->servername = g_strdup(userserver[1]);
- sip->SysCfgServer = g_strdup("nav.fetion.com.cn");
- sip->password = g_strdup(purple_connection_get_password(gc));
- g_strfreev(userserver);
- sip->buddies = g_hash_table_new((GHashFunc)fetion_ht_hash_nick, (GEqualFunc)fetion_ht_equals_nick);
- sip->tempgroup = g_hash_table_new((GHashFunc)fetion_ht_hash_nick, (GEqualFunc)fetion_ht_equals_nick);
- sip->group = g_hash_table_new((GHashFunc)fetion_ht_hash_nick, (GEqualFunc)fetion_ht_equals_nick);
- sip->group2id = g_hash_table_new((GHashFunc)fetion_ht_hash_nick, (GEqualFunc)fetion_ht_equals_nick);
- purple_connection_update_progress(gc, _("Connecting"), 1, 2);
- /* TODO: Set the status correctly. */
- sip->status = g_strdup("available");
- sip->registertimeout = purple_timeout_add(12000,(GSourceFunc) LoginToSsiPortal,sip);
- //Try to get systemconfig
- sip->ServerVersion = NULL;
- sip->ServiceNoVersion = NULL;
- sip->ParaVersion = NULL;
- sip->HttpAppVersion = NULL;
- sip->ClientCfgVersion = NULL;
- sip->HintsVersion = NULL;
- ret = ParseCfg(sip);
- //if(ret!=0)
- sip->SysCfg.conn = purple_proxy_connect(NULL,sip->account,sip->SysCfgServer,80,(PurpleProxyConnectFunction) RetriveSysCfg,sip);
- }
复制代码 |
|