annotate libpurple/protocols/msn/state.c @ 28093:4362f871369c

Using g_convert instead of g_utf16_to_utf8 so that we can explicitly set the input byte order. It should always be little-endian and not depend on the host order.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 31 Jul 2009 04:04:24 +0000
parents 47c0795eb4fd
children 99d1b433dba0 39716f7d2c93 e30865b62859
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file state.c State functions and definitions
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
4 * purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 15823
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
25838
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
24
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
25 #include "internal.h"
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
26 #include "core.h"
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
27
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "msn.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "state.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 static const char *away_text[] =
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 N_("Available"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 N_("Available"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 N_("Busy"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 N_("Idle"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 N_("Be Right Back"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 N_("Away From Computer"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 N_("On The Phone"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 N_("Out To Lunch"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 N_("Available"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 N_("Available")
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
45 /* Local Function Prototype*/
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
46 static char *msn_build_psm(const char *psmstr,const char *mediastr,
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
47 const char *guidstr);
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
48
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
49 /*
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
50 * WLM media PSM info build prcedure
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
51 *
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
52 * Result can like:
20508
34abe3faeaab Various (untested) changes to the CurrentMedia parsing. This code is a
Richard Laager <rlaager@wiktel.com>
parents: 20507
diff changeset
53 * <CurrentMedia>\0Music\01\0{0} - {1}\0Song Title\0Song Artist\0Song Album\0\0</CurrentMedia>\
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
54 * <CurrentMedia>\0Games\01\0Playing {0}\0Game Name\0</CurrentMedia>\
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
55 * <CurrentMedia>\0Office\01\0Office Message\0Office App Name\0</CurrentMedia>"
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
56 */
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
57 static char *
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
58 msn_build_psm(const char *psmstr,const char *mediastr, const char *guidstr)
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
59 {
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
60 xmlnode *dataNode,*psmNode,*mediaNode,*guidNode;
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
61 char *result;
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
62 int length;
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
63
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
64 dataNode = xmlnode_new("Data");
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
65
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
66 psmNode = xmlnode_new("PSM");
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
67 if(psmstr != NULL){
23762
187b0e2ff49d Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <will.thompson@collabora.co.uk>
parents: 23564
diff changeset
68 xmlnode_insert_data(psmNode, psmstr, -1);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
69 }
23762
187b0e2ff49d Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <will.thompson@collabora.co.uk>
parents: 23564
diff changeset
70 xmlnode_insert_child(dataNode, psmNode);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
71
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
72 mediaNode = xmlnode_new("CurrentMedia");
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
73 if(mediastr != NULL){
23762
187b0e2ff49d Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <will.thompson@collabora.co.uk>
parents: 23564
diff changeset
74 xmlnode_insert_data(mediaNode, mediastr, -1);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
75 }
23762
187b0e2ff49d Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <will.thompson@collabora.co.uk>
parents: 23564
diff changeset
76 xmlnode_insert_child(dataNode, mediaNode);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
77
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
78 guidNode = xmlnode_new("MachineGuid");
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
79 if(guidstr != NULL){
23762
187b0e2ff49d Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <will.thompson@collabora.co.uk>
parents: 23564
diff changeset
80 xmlnode_insert_data(guidNode, guidstr, -1);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
81 }
23762
187b0e2ff49d Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <will.thompson@collabora.co.uk>
parents: 23564
diff changeset
82 xmlnode_insert_child(dataNode, guidNode);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
83
23762
187b0e2ff49d Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <will.thompson@collabora.co.uk>
parents: 23564
diff changeset
84 result = xmlnode_to_str(dataNode, &length);
20491
e43f419e6d28 Plug some leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20472
diff changeset
85 xmlnode_free(dataNode);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
86 return result;
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
87 }
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
88
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
89 /* parse CurrentMedia string */
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
90 gboolean
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
91 msn_parse_currentmedia(const char *cmedia, CurrentMedia *media)
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
92 {
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
93 char **cmedia_array;
22793
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
94 int strings = 0;
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
95 gboolean parsed = FALSE;
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
96
20506
42365ba802c0 Improve the current-media parsing a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20495
diff changeset
97 if ((cmedia == NULL) || (*cmedia == '\0')) {
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
98 purple_debug_info("msn", "No currentmedia string\n");
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
99 return FALSE;
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
100 }
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
101
20439
bee467c81570 A bunch of MSNP14 stuff:
Stu Tomlinson <stu@nosnilmot.com>
parents: 20425
diff changeset
102 purple_debug_info("msn", "Parsing currentmedia string: \"%s\"\n", cmedia);
bee467c81570 A bunch of MSNP14 stuff:
Stu Tomlinson <stu@nosnilmot.com>
parents: 20425
diff changeset
103
20506
42365ba802c0 Improve the current-media parsing a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20495
diff changeset
104 cmedia_array = g_strsplit(cmedia, "\\0", 0);
42365ba802c0 Improve the current-media parsing a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20495
diff changeset
105
20572
1933f2084eb3 Remove commented out code, and add soem notes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20570
diff changeset
106 /*
24455
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
107 * 0: Application
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
108 * 1: 'Music'/'Games'/'Office'
20572
1933f2084eb3 Remove commented out code, and add soem notes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20570
diff changeset
109 * 2: '1' if enabled, '0' if not
1933f2084eb3 Remove commented out code, and add soem notes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20570
diff changeset
110 * 3: Format (eg. {0} by {1})
1933f2084eb3 Remove commented out code, and add soem notes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20570
diff changeset
111 * 4: Title
24455
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
112 * If 'Music':
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
113 * 5: Artist
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
114 * 6: Album
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
115 * 7: ?
20572
1933f2084eb3 Remove commented out code, and add soem notes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20570
diff changeset
116 */
22793
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
117 #if GLIB_CHECK_VERSION(2,6,0)
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
118 strings = g_strv_length(cmedia_array);
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
119 #else
20508
34abe3faeaab Various (untested) changes to the CurrentMedia parsing. This code is a
Richard Laager <rlaager@wiktel.com>
parents: 20507
diff changeset
120 while (cmedia_array[++strings] != NULL);
22793
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
121 #endif
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
122
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
123 if (strings >= 4 && !strcmp(cmedia_array[2], "1")) {
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
124 parsed = TRUE;
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
125
24455
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
126 if (!strcmp(cmedia_array[1], "Music"))
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
127 media->type = CURRENT_MEDIA_MUSIC;
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
128 else if (!strcmp(cmedia_array[1], "Games"))
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
129 media->type = CURRENT_MEDIA_GAMES;
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
130 else if (!strcmp(cmedia_array[1], "Office"))
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
131 media->type = CURRENT_MEDIA_OFFICE;
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
132 else
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
133 media->type = CURRENT_MEDIA_UNKNOWN;
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
134
22793
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
135 g_free(media->title);
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
136 if (strings == 4) {
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
137 media->title = g_strdup(cmedia_array[3]);
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
138 } else {
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
139 media->title = g_strdup(cmedia_array[4]);
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
140 }
20508
34abe3faeaab Various (untested) changes to the CurrentMedia parsing. This code is a
Richard Laager <rlaager@wiktel.com>
parents: 20507
diff changeset
141
22793
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
142 g_free(media->artist);
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
143 if (strings > 5)
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
144 media->artist = g_strdup(cmedia_array[5]);
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
145 else
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
146 media->artist = NULL;
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
147
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
148 g_free(media->album);
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
149 if (strings > 6)
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
150 media->album = g_strdup(cmedia_array[6]);
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
151 else
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
152 media->album = NULL;
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
153
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
154 }
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
155
22793
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
156 g_strfreev(cmedia_array);
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
157
22793
6b182ab4bc05 Leak plug in parsing MSN currentmedia.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21791
diff changeset
158 return parsed;
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
159 }
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
160
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
161 /* get the CurrentMedia info from the XML string */
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
162 char *
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
163 msn_get_currentmedia(char *xml_str, gsize len)
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
164 {
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
165 xmlnode *payloadNode, *currentmediaNode;
20495
7f5564ebde7f Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20491
diff changeset
166 char *currentmedia;
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 22798
diff changeset
167
23564
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23300
diff changeset
168 purple_debug_info("msn", "Get CurrentMedia\n");
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
169 payloadNode = xmlnode_from_str(xml_str, len);
23564
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23300
diff changeset
170 if (!payloadNode) {
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23300
diff changeset
171 purple_debug_error("msn", "PSM XML parse Error!\n");
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
172 return NULL;
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
173 }
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
174 currentmediaNode = xmlnode_get_child(payloadNode, "CurrentMedia");
23564
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23300
diff changeset
175 if (currentmediaNode == NULL) {
26278
399776a9ad98 Add some missing newlines in debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25128
diff changeset
176 purple_debug_info("msn", "No CurrentMedia Node\n");
20495
7f5564ebde7f Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20491
diff changeset
177 xmlnode_free(payloadNode);
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
178 return NULL;
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
179 }
20495
7f5564ebde7f Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20491
diff changeset
180 currentmedia = xmlnode_get_data(currentmediaNode);
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
181
20495
7f5564ebde7f Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20491
diff changeset
182 xmlnode_free(payloadNode);
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
183
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
184 return currentmedia;
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
185 }
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
186
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
187 /*get the PSM info from the XML string*/
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
188 char *
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
189 msn_get_psm(char *xml_str, gsize len)
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
190 {
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
191 xmlnode *payloadNode, *psmNode;
20495
7f5564ebde7f Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20491
diff changeset
192 char *psm;
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 22798
diff changeset
193
23564
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23300
diff changeset
194 purple_debug_info("msn", "msn get PSM\n");
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
195 payloadNode = xmlnode_from_str(xml_str, len);
25128
4ea0f3edd973 I thought I did this already, but anyway, a patch from Dimmuxx to stop the
Daniel Lj <dimmuxx@yahoo.se>
parents: 24456
diff changeset
196 if (!payloadNode) {
23564
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23300
diff changeset
197 purple_debug_error("msn", "PSM XML parse Error!\n");
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
198 return NULL;
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
199 }
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
200 psmNode = xmlnode_get_child(payloadNode, "PSM");
25128
4ea0f3edd973 I thought I did this already, but anyway, a patch from Dimmuxx to stop the
Daniel Lj <dimmuxx@yahoo.se>
parents: 24456
diff changeset
201 if (psmNode == NULL) {
26278
399776a9ad98 Add some missing newlines in debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25128
diff changeset
202 purple_debug_info("msn", "No PSM status Node\n");
20495
7f5564ebde7f Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20491
diff changeset
203 xmlnode_free(payloadNode);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
204 return NULL;
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
205 }
20495
7f5564ebde7f Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20491
diff changeset
206 psm = xmlnode_get_data(psmNode);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
207
20495
7f5564ebde7f Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20491
diff changeset
208 xmlnode_free(payloadNode);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
209
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
210 return psm;
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
211 }
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
212
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
213 static char *
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
214 create_media_string(PurplePresence *presence)
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
215 {
24456
7a5f6ddd11b1 Only get the artist and album if we are setting a Music mediatype.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24455
diff changeset
216 const char *title, *game, *office;
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
217 char *ret;
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
218 PurpleStatus *status = purple_presence_get_status(presence, "tune");
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
219 if (!status || !purple_status_is_active(status))
25128
4ea0f3edd973 I thought I did this already, but anyway, a patch from Dimmuxx to stop the
Daniel Lj <dimmuxx@yahoo.se>
parents: 24456
diff changeset
220 return NULL;
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
221
24455
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
222 title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
223 game = purple_status_get_attr_string(status, "game");
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
224 office = purple_status_get_attr_string(status, "office");
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
225
24456
7a5f6ddd11b1 Only get the artist and album if we are setting a Music mediatype.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24455
diff changeset
226 if (title && *title) {
7a5f6ddd11b1 Only get the artist and album if we are setting a Music mediatype.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24455
diff changeset
227 const char *artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
7a5f6ddd11b1 Only get the artist and album if we are setting a Music mediatype.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24455
diff changeset
228 const char *album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM);
24455
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
229 ret = g_strdup_printf("WMP\\0Music\\01\\0{0}%s%s\\0%s\\0%s\\0%s\\0",
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
230 artist ? " - {1}" : "",
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
231 album ? " ({2})" : "",
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
232 title,
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
233 artist ? artist : "",
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
234 album ? album : "");
24456
7a5f6ddd11b1 Only get the artist and album if we are setting a Music mediatype.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24455
diff changeset
235 }
24455
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
236 else if (game && *game)
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
237 ret = g_strdup_printf("\\0Games\\01\\0Playing {0}\\0%s\\0", game);
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
238 else if (office && *office)
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
239 ret = g_strdup_printf("\\0Office\\01\\0Editing {0}\\0%s\\0", office);
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
240 else
25128
4ea0f3edd973 I thought I did this already, but anyway, a patch from Dimmuxx to stop the
Daniel Lj <dimmuxx@yahoo.se>
parents: 24456
diff changeset
241 ret = NULL;
24455
e344426d7c28 Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23762
diff changeset
242
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
243 return ret;
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
244 }
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
245
23300
5cdd93dac7a2 Delete trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 22798
diff changeset
246 /* set the MSN's PSM info,Currently Read from the status Line
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
247 * Thanks for Cris Code
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
248 */
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
249 void
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
250 msn_set_psm(MsnSession *session)
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
251 {
27311
47c0795eb4fd We shouldn't de-reference variables before checking if they're not NULL.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27143
diff changeset
252 PurpleAccount *account;
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
253 PurplePresence *presence;
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
254 PurpleStatus *status;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
255 MsnCmdProc *cmdproc;
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
256 MsnTransaction *trans;
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
257 char *payload;
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
258 const char *statusline;
21284
6de09629f091 propagate from branch 'im.pidgin.pidgin.next.minor' (head 0c9637482b845cc65e95a26e144697391c51133f)
Ka-Hing Cheung <khc@hxbc.us>
parents: 20572 20997
diff changeset
259 gchar *statusline_stripped, *media = NULL;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
260
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
261 g_return_if_fail(session != NULL);
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
262 g_return_if_fail(session->notification != NULL);
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
263
27311
47c0795eb4fd We shouldn't de-reference variables before checking if they're not NULL.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27143
diff changeset
264 account = session->account;
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
265 cmdproc = session->notification->cmdproc;
20997
4495a311b959 MSN personal status messages are plain text, not HTML. Previously, we were unescaping the message but not stripping it, which left any HTML tags intact.
Evan Schoenberg <evan.s@dreskin.net>
parents: 20525
diff changeset
266
4495a311b959 MSN personal status messages are plain text, not HTML. Previously, we were unescaping the message but not stripping it, which left any HTML tags intact.
Evan Schoenberg <evan.s@dreskin.net>
parents: 20525
diff changeset
267 /* Get the PSM string from Purple's Status Line */
19797
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
268 presence = purple_account_get_presence(account);
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
269 status = purple_presence_get_active_status(presence);
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15823
diff changeset
270 statusline = purple_status_get_attr_string(status, "message");
20997
4495a311b959 MSN personal status messages are plain text, not HTML. Previously, we were unescaping the message but not stripping it, which left any HTML tags intact.
Evan Schoenberg <evan.s@dreskin.net>
parents: 20525
diff changeset
271
4495a311b959 MSN personal status messages are plain text, not HTML. Previously, we were unescaping the message but not stripping it, which left any HTML tags intact.
Evan Schoenberg <evan.s@dreskin.net>
parents: 20525
diff changeset
272 /* MSN expects plain text, not HTML */
4495a311b959 MSN personal status messages are plain text, not HTML. Previously, we were unescaping the message but not stripping it, which left any HTML tags intact.
Evan Schoenberg <evan.s@dreskin.net>
parents: 20525
diff changeset
273 statusline_stripped = purple_markup_strip_html(statusline);
20570
5913725cbcd6 Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20525
diff changeset
274 media = create_media_string(presence);
20997
4495a311b959 MSN personal status messages are plain text, not HTML. Previously, we were unescaping the message but not stripping it, which left any HTML tags intact.
Evan Schoenberg <evan.s@dreskin.net>
parents: 20525
diff changeset
275 g_free(session->psm);
21284
6de09629f091 propagate from branch 'im.pidgin.pidgin.next.minor' (head 0c9637482b845cc65e95a26e144697391c51133f)
Ka-Hing Cheung <khc@hxbc.us>
parents: 20572 20997
diff changeset
276 session->psm = msn_build_psm(statusline_stripped, media, NULL);
20997
4495a311b959 MSN personal status messages are plain text, not HTML. Previously, we were unescaping the message but not stripping it, which left any HTML tags intact.
Evan Schoenberg <evan.s@dreskin.net>
parents: 20525
diff changeset
277
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
278 payload = session->psm;
23564
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23300
diff changeset
279 purple_debug_misc("msn", "Sending UUX command with payload: %s\n", payload);
22798
05cb3f04c01e This cleans up a bunch of warnings that stem from the fact that size_t and
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22793
diff changeset
280 trans = msn_transaction_new(cmdproc, "UUX", "%" G_GSIZE_FORMAT, strlen(payload));
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
281 msn_transaction_set_payload(trans, payload, strlen(payload));
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
282 msn_cmdproc_send_trans(cmdproc, trans);
21791
c80d0732fa40 memleak fixes
Ka-Hing Cheung <khc@hxbc.us>
parents: 21284
diff changeset
283
c80d0732fa40 memleak fixes
Ka-Hing Cheung <khc@hxbc.us>
parents: 21284
diff changeset
284 g_free(statusline_stripped);
c80d0732fa40 memleak fixes
Ka-Hing Cheung <khc@hxbc.us>
parents: 21284
diff changeset
285 g_free(media);
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
286 }
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
287
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 msn_change_status(MsnSession *session)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
291 PurpleAccount *account;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 MsnCmdProc *cmdproc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 MsnUser *user;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 MsnObject *msnobj;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 const char *state_text;
25838
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
296 GHashTable *ui_info = purple_core_get_ui_info();
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
297 MsnClientCaps caps = MSN_CLIENT_ID;
27136
dd7e7071d46d Whitespace + a change cluttering up the diff with im.pidgin.pidgin
Paul Aurich <paul@darkrain42.org>
parents: 26343
diff changeset
298
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 g_return_if_fail(session != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 g_return_if_fail(session->notification != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301
25838
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
302 /* set client caps based on what the UI tells us it is... */
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
303 if (ui_info) {
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
304 const gchar *client_type = g_hash_table_lookup(ui_info, "client_type");
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
305 if (client_type) {
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
306 if (strcmp(client_type, "phone") == 0 ||
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
307 strcmp(client_type, "handheld") == 0) {
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
308 caps |= MSN_CLIENT_CAP_WIN_MOBILE;
27143
8ab2309dfd68 These strcmp checks are for equality, meaning a return of 0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27136
diff changeset
309 } else if (strcmp(client_type, "web") == 0) {
25838
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
310 caps |= MSN_CLIENT_CAP_WEBMSGR;
27143
8ab2309dfd68 These strcmp checks are for equality, meaning a return of 0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27136
diff changeset
311 } else if (strcmp(client_type, "bot") == 0) {
25838
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
312 caps |= MSN_CLIENT_CAP_BOT;
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
313 }
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
314 /* MSN doesn't a "console" type...
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
315 What, they have no ncurses UI? :-) */
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
316 }
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
317 }
27136
dd7e7071d46d Whitespace + a change cluttering up the diff with im.pidgin.pidgin
Paul Aurich <paul@darkrain42.org>
parents: 26343
diff changeset
318
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 account = session->account;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 cmdproc = session->notification->cmdproc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 user = session->user;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 state_text = msn_state_get_text(msn_state_from_account(account));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 /* If we're not logged in yet, don't send the status to the server,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 * it will be sent when login completes
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 if (!session->logged_in)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 msnobj = msn_user_get_object(user);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 if (msnobj == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 {
25838
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
334 msn_cmdproc_send(cmdproc, "CHG", "%s %d", state_text, caps);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 char *msnobj_str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 msnobj_str = msn_object_to_string(msnobj);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 msn_cmdproc_send(cmdproc, "CHG", "%s %d %s", state_text,
25838
d971b6a6be2c S«Łtt client type on MSN.
Marcus Lundblad <ml@update.uu.se>
parents: 24456
diff changeset
343 caps, purple_url_encode(msnobj_str));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 g_free(msnobj_str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 }
20394
4a099e4d0d09 propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328)
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
347 msn_set_psm(session);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 const char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 msn_away_get_text(MsnAwayType type)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 g_return_val_if_fail(type <= MSN_HIDDEN, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 return _(away_text[type]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 const char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 msn_state_get_text(MsnAwayType state)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 static char *status_text[] =
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 { "NLN", "NLN", "BSY", "IDL", "BRB", "AWY", "PHN", "LUN", "HDN", "HDN" };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 return status_text[state];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 MsnAwayType
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
368 msn_state_from_account(PurpleAccount *account)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 MsnAwayType msnstatus;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
371 PurplePresence *presence;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
372 PurpleStatus *status;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 const char *status_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
375 presence = purple_account_get_presence(account);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
376 status = purple_presence_get_active_status(presence);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
377 status_id = purple_status_get_id(status);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 if (!strcmp(status_id, "away"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 msnstatus = MSN_AWAY;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 else if (!strcmp(status_id, "brb"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 msnstatus = MSN_BRB;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 else if (!strcmp(status_id, "busy"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 msnstatus = MSN_BUSY;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 else if (!strcmp(status_id, "phone"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 msnstatus = MSN_PHONE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 else if (!strcmp(status_id, "lunch"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 msnstatus = MSN_LUNCH;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 else if (!strcmp(status_id, "invisible"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 msnstatus = MSN_HIDDEN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 msnstatus = MSN_ONLINE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
394 if ((msnstatus == MSN_ONLINE) && purple_presence_is_idle(presence))
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 msnstatus = MSN_IDLE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 return msnstatus;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 }