Thu, 10 Dec 2009 07:49:34 +0000
Missed a few more xmlnode_free's.
| 5361 | 1 | /** |
| 2 | * @file state.c State functions and definitions | |
| 3 | * | |
| 15884 | 4 | * purple |
| 5361 | 5 | * |
| 15884 | 6 | * Purple is the legal property of its developers, whose names are too numerous |
|
9198
e8eb6d5eb9eb
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
7 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
e8eb6d5eb9eb
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
8 | * source distribution. |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5824
diff
changeset
|
9 | * |
| 5361 | 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by | |
| 12 | * the Free Software Foundation; either version 2 of the License, or | |
| 13 | * (at your option) any later version. | |
| 14 | * | |
| 15 | * This program is distributed in the hope that it will be useful, | |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | * GNU General Public License for more details. | |
| 19 | * | |
| 20 | * You should have received a copy of the GNU General Public License | |
| 21 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15884
diff
changeset
|
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 5361 | 23 | */ |
|
25579
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
24 | |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
25 | #include "internal.h" |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
26 | #include "core.h" |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
27 | |
| 5361 | 28 | #include "msn.h" |
|
29420
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
29 | #include "notification.h" |
| 5361 | 30 | #include "state.h" |
| 31 | ||
| 32 | static const char *away_text[] = | |
| 33 | { | |
| 34 | N_("Available"), | |
| 35 | N_("Available"), | |
| 36 | N_("Busy"), | |
| 37 | N_("Idle"), | |
| 38 | N_("Be Right Back"), | |
| 39 | N_("Away From Computer"), | |
| 40 | N_("On The Phone"), | |
| 41 | N_("Out To Lunch"), | |
| 42 | N_("Available"), | |
| 43 | N_("Available") | |
| 44 | }; | |
| 45 | ||
| 13866 | 46 | /* |
| 47 | * WLM media PSM info build prcedure | |
| 48 | * | |
| 49 | * Result can like: | |
|
20591
8469ac3acbec
Various (untested) changes to the CurrentMedia parsing. This code is a
Richard Laager <rlaager@pidgin.im>
parents:
20590
diff
changeset
|
50 | * <CurrentMedia>\0Music\01\0{0} - {1}\0Song Title\0Song Artist\0Song Album\0\0</CurrentMedia>\ |
| 13866 | 51 | * <CurrentMedia>\0Games\01\0Playing {0}\0Game Name\0</CurrentMedia>\ |
| 52 | * <CurrentMedia>\0Office\01\0Office Message\0Office App Name\0</CurrentMedia>" | |
| 53 | */ | |
|
20474
b0ef257ef8d4
The second msn.tgz from SF Patch #1621854 from Ka-Hing Cheung.
Ka-Hing Cheung <khc@pidgin.im>
parents:
20472
diff
changeset
|
54 | static char * |
|
29420
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
55 | msn_build_psm(const char *psmstr,const char *mediastr, const char *guidstr, guint protocol_ver) |
| 13856 | 56 | { |
| 57 | xmlnode *dataNode,*psmNode,*mediaNode,*guidNode; | |
| 58 | char *result; | |
| 59 | int length; | |
| 60 | ||
| 61 | dataNode = xmlnode_new("Data"); | |
| 62 | ||
| 63 | psmNode = xmlnode_new("PSM"); | |
| 64 | if(psmstr != NULL){ | |
|
24025
7827cb5dabe2
Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <resiak@pidgin.im>
parents:
23830
diff
changeset
|
65 | xmlnode_insert_data(psmNode, psmstr, -1); |
| 13856 | 66 | } |
|
24025
7827cb5dabe2
Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <resiak@pidgin.im>
parents:
23830
diff
changeset
|
67 | xmlnode_insert_child(dataNode, psmNode); |
| 13856 | 68 | |
| 69 | mediaNode = xmlnode_new("CurrentMedia"); | |
| 70 | if(mediastr != NULL){ | |
|
24025
7827cb5dabe2
Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <resiak@pidgin.im>
parents:
23830
diff
changeset
|
71 | xmlnode_insert_data(mediaNode, mediastr, -1); |
| 13856 | 72 | } |
|
24025
7827cb5dabe2
Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <resiak@pidgin.im>
parents:
23830
diff
changeset
|
73 | xmlnode_insert_child(dataNode, mediaNode); |
| 13856 | 74 | |
| 75 | guidNode = xmlnode_new("MachineGuid"); | |
| 76 | if(guidstr != NULL){ | |
|
24025
7827cb5dabe2
Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <resiak@pidgin.im>
parents:
23830
diff
changeset
|
77 | xmlnode_insert_data(guidNode, guidstr, -1); |
| 13856 | 78 | } |
|
24025
7827cb5dabe2
Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <resiak@pidgin.im>
parents:
23830
diff
changeset
|
79 | xmlnode_insert_child(dataNode, guidNode); |
| 13856 | 80 | |
|
29420
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
81 | if (protocol_ver >= 16) { |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
82 | /* TODO: What is this for? */ |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
83 | xmlnode *ddpNode = xmlnode_new("DDP"); |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
84 | xmlnode_insert_child(dataNode, ddpNode); |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
85 | } |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
86 | |
|
24025
7827cb5dabe2
Rely on xmlnode_insert_data to call strlen on a bunch of MSN status strings.
Will Thompson <resiak@pidgin.im>
parents:
23830
diff
changeset
|
87 | result = xmlnode_to_str(dataNode, &length); |
|
20574
41544383ab30
Plug some leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20551
diff
changeset
|
88 | xmlnode_free(dataNode); |
| 13856 | 89 | return result; |
| 90 | } | |
| 91 | ||
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
92 | /* parse CurrentMedia string */ |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
93 | gboolean |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
94 | msn_parse_currentmedia(const char *cmedia, CurrentMedia *media) |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
95 | { |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
96 | char **cmedia_array; |
|
22965
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
97 | int strings = 0; |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
98 | gboolean parsed = FALSE; |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
99 | |
|
20589
312d830f7169
Improve the current-media parsing a little bit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20578
diff
changeset
|
100 | if ((cmedia == NULL) || (*cmedia == '\0')) { |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
101 | purple_debug_info("msn", "No currentmedia string\n"); |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
102 | return FALSE; |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
103 | } |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
104 | |
|
20522
177cad886d4c
A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20508
diff
changeset
|
105 | purple_debug_info("msn", "Parsing currentmedia string: \"%s\"\n", cmedia); |
|
177cad886d4c
A bunch of MSNP14 stuff:
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20508
diff
changeset
|
106 | |
|
20589
312d830f7169
Improve the current-media parsing a little bit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20578
diff
changeset
|
107 | cmedia_array = g_strsplit(cmedia, "\\0", 0); |
|
312d830f7169
Improve the current-media parsing a little bit.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20578
diff
changeset
|
108 | |
|
21194
c2da1eed951e
Remove commented out code, and add soem notes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21193
diff
changeset
|
109 | /* |
|
24771
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
110 | * 0: Application |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
111 | * 1: 'Music'/'Games'/'Office' |
|
21194
c2da1eed951e
Remove commented out code, and add soem notes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21193
diff
changeset
|
112 | * 2: '1' if enabled, '0' if not |
|
c2da1eed951e
Remove commented out code, and add soem notes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21193
diff
changeset
|
113 | * 3: Format (eg. {0} by {1}) |
|
c2da1eed951e
Remove commented out code, and add soem notes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21193
diff
changeset
|
114 | * 4: Title |
|
24771
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
115 | * If 'Music': |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
116 | * 5: Artist |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
117 | * 6: Album |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
118 | * 7: ? |
|
21194
c2da1eed951e
Remove commented out code, and add soem notes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21193
diff
changeset
|
119 | */ |
|
22965
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
120 | #if GLIB_CHECK_VERSION(2,6,0) |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
121 | strings = g_strv_length(cmedia_array); |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
122 | #else |
|
20591
8469ac3acbec
Various (untested) changes to the CurrentMedia parsing. This code is a
Richard Laager <rlaager@pidgin.im>
parents:
20590
diff
changeset
|
123 | while (cmedia_array[++strings] != NULL); |
|
22965
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
124 | #endif |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
125 | |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
126 | if (strings >= 4 && !strcmp(cmedia_array[2], "1")) { |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
127 | parsed = TRUE; |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
128 | |
|
24771
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
129 | if (!strcmp(cmedia_array[1], "Music")) |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
130 | media->type = CURRENT_MEDIA_MUSIC; |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
131 | else if (!strcmp(cmedia_array[1], "Games")) |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
132 | media->type = CURRENT_MEDIA_GAMES; |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
133 | else if (!strcmp(cmedia_array[1], "Office")) |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
134 | media->type = CURRENT_MEDIA_OFFICE; |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
135 | else |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
136 | media->type = CURRENT_MEDIA_UNKNOWN; |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
137 | |
|
22965
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
138 | g_free(media->title); |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
139 | if (strings == 4) { |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
140 | media->title = g_strdup(cmedia_array[3]); |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
141 | } else { |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
142 | media->title = g_strdup(cmedia_array[4]); |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
143 | } |
|
20591
8469ac3acbec
Various (untested) changes to the CurrentMedia parsing. This code is a
Richard Laager <rlaager@pidgin.im>
parents:
20590
diff
changeset
|
144 | |
|
22965
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
145 | g_free(media->artist); |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
146 | if (strings > 5) |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
147 | media->artist = g_strdup(cmedia_array[5]); |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
148 | else |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
149 | media->artist = NULL; |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
150 | |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
151 | g_free(media->album); |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
152 | if (strings > 6) |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
153 | media->album = g_strdup(cmedia_array[6]); |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
154 | else |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
155 | media->album = NULL; |
|
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
156 | |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
157 | } |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
158 | |
|
22965
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
159 | g_strfreev(cmedia_array); |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
160 | |
|
22965
f19cc28257f8
Leak plug in parsing MSN currentmedia.
Daniel Atallah <datallah@pidgin.im>
parents:
21906
diff
changeset
|
161 | return parsed; |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
162 | } |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
163 | |
|
29426
60dc51885de1
Avoid calling xmlnode_from_str twice when parsing the UBX data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29420
diff
changeset
|
164 | /* get the CurrentMedia info from the XML node */ |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
165 | char * |
|
29426
60dc51885de1
Avoid calling xmlnode_from_str twice when parsing the UBX data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29420
diff
changeset
|
166 | msn_get_currentmedia(xmlnode *payloadNode) |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
167 | { |
|
29426
60dc51885de1
Avoid calling xmlnode_from_str twice when parsing the UBX data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29420
diff
changeset
|
168 | xmlnode *currentmediaNode; |
|
20578
82571739414b
Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20574
diff
changeset
|
169 | char *currentmedia; |
|
23441
fd45c23a3eb2
Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
22969
diff
changeset
|
170 | |
|
23830
1436e3de5d6c
The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23441
diff
changeset
|
171 | purple_debug_info("msn", "Get CurrentMedia\n"); |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
172 | currentmediaNode = xmlnode_get_child(payloadNode, "CurrentMedia"); |
|
23830
1436e3de5d6c
The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23441
diff
changeset
|
173 | if (currentmediaNode == NULL) { |
|
26474
69f112d09563
Add some missing newlines in debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25638
diff
changeset
|
174 | purple_debug_info("msn", "No CurrentMedia Node\n"); |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
175 | return NULL; |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
176 | } |
|
20578
82571739414b
Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20574
diff
changeset
|
177 | currentmedia = xmlnode_get_data(currentmediaNode); |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
178 | |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
179 | return currentmedia; |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
180 | } |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
181 | |
|
29426
60dc51885de1
Avoid calling xmlnode_from_str twice when parsing the UBX data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29420
diff
changeset
|
182 | /* Get the PSM info from the XML node */ |
|
20474
b0ef257ef8d4
The second msn.tgz from SF Patch #1621854 from Ka-Hing Cheung.
Ka-Hing Cheung <khc@pidgin.im>
parents:
20472
diff
changeset
|
183 | char * |
|
29426
60dc51885de1
Avoid calling xmlnode_from_str twice when parsing the UBX data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29420
diff
changeset
|
184 | msn_get_psm(xmlnode *payloadNode) |
| 13888 | 185 | { |
|
29426
60dc51885de1
Avoid calling xmlnode_from_str twice when parsing the UBX data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29420
diff
changeset
|
186 | xmlnode *psmNode; |
|
20578
82571739414b
Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20574
diff
changeset
|
187 | char *psm; |
|
23441
fd45c23a3eb2
Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
22969
diff
changeset
|
188 | |
|
23830
1436e3de5d6c
The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23441
diff
changeset
|
189 | purple_debug_info("msn", "msn get PSM\n"); |
| 13888 | 190 | psmNode = xmlnode_get_child(payloadNode, "PSM"); |
|
25638
d0923c8063de
I thought I did this already, but anyway, a patch from Dimmuxx to stop the
Daniel Ljungborg <dimmuxx@yahoo.se>
parents:
24772
diff
changeset
|
191 | if (psmNode == NULL) { |
|
26474
69f112d09563
Add some missing newlines in debug messages.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25638
diff
changeset
|
192 | purple_debug_info("msn", "No PSM status Node\n"); |
| 13888 | 193 | return NULL; |
| 194 | } | |
|
20578
82571739414b
Fix some memory leaks. Free xmlnodes properly using xmlnode_free instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20574
diff
changeset
|
195 | psm = xmlnode_get_data(psmNode); |
| 13888 | 196 | |
| 197 | return psm; | |
| 198 | } | |
| 199 | ||
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
200 | static char * |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
201 | create_media_string(PurplePresence *presence) |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
202 | { |
|
24772
c87747478d71
Only get the artist and album if we are setting a Music mediatype.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24771
diff
changeset
|
203 | const char *title, *game, *office; |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
204 | char *ret; |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
205 | PurpleStatus *status = purple_presence_get_status(presence, "tune"); |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
206 | if (!status || !purple_status_is_active(status)) |
|
25638
d0923c8063de
I thought I did this already, but anyway, a patch from Dimmuxx to stop the
Daniel Ljungborg <dimmuxx@yahoo.se>
parents:
24772
diff
changeset
|
207 | return NULL; |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
208 | |
|
24771
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
209 | title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE); |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
210 | game = purple_status_get_attr_string(status, "game"); |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
211 | office = purple_status_get_attr_string(status, "office"); |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
212 | |
|
24772
c87747478d71
Only get the artist and album if we are setting a Music mediatype.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24771
diff
changeset
|
213 | if (title && *title) { |
|
c87747478d71
Only get the artist and album if we are setting a Music mediatype.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24771
diff
changeset
|
214 | const char *artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); |
|
c87747478d71
Only get the artist and album if we are setting a Music mediatype.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24771
diff
changeset
|
215 | const char *album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM); |
|
24771
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
216 | ret = g_strdup_printf("WMP\\0Music\\01\\0{0}%s%s\\0%s\\0%s\\0%s\\0", |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
217 | artist ? " - {1}" : "", |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
218 | album ? " ({2})" : "", |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
219 | title, |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
220 | artist ? artist : "", |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
221 | album ? album : ""); |
|
24772
c87747478d71
Only get the artist and album if we are setting a Music mediatype.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24771
diff
changeset
|
222 | } |
|
24771
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
223 | else if (game && *game) |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
224 | ret = g_strdup_printf("\\0Games\\01\\0Playing {0}\\0%s\\0", game); |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
225 | else if (office && *office) |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
226 | ret = g_strdup_printf("\\0Office\\01\\0Editing {0}\\0%s\\0", office); |
|
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
227 | else |
|
25638
d0923c8063de
I thought I did this already, but anyway, a patch from Dimmuxx to stop the
Daniel Ljungborg <dimmuxx@yahoo.se>
parents:
24772
diff
changeset
|
228 | ret = NULL; |
|
24771
7a17ecc0c85b
Add the Games and Office media to MSN as attributes tacked on to the tune
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24025
diff
changeset
|
229 | |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
230 | return ret; |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
231 | } |
|
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
232 | |
|
23441
fd45c23a3eb2
Delete trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
22969
diff
changeset
|
233 | /* set the MSN's PSM info,Currently Read from the status Line |
| 13891 | 234 | * Thanks for Cris Code |
| 235 | */ | |
| 13856 | 236 | void |
| 237 | msn_set_psm(MsnSession *session) | |
| 238 | { | |
|
27495
8fd70382bf7b
We shouldn't de-reference variables before checking if they're not NULL.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27296
diff
changeset
|
239 | PurpleAccount *account; |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
240 | PurplePresence *presence; |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
241 | PurpleStatus *status; |
|
20474
b0ef257ef8d4
The second msn.tgz from SF Patch #1621854 from Ka-Hing Cheung.
Ka-Hing Cheung <khc@pidgin.im>
parents:
20472
diff
changeset
|
242 | char *payload; |
|
b0ef257ef8d4
The second msn.tgz from SF Patch #1621854 from Ka-Hing Cheung.
Ka-Hing Cheung <khc@pidgin.im>
parents:
20472
diff
changeset
|
243 | const char *statusline; |
|
21453
a90cf329cd48
propagate from branch 'im.pidgin.pidgin.next.minor' (head 2f91b326b3f073672c2475a8c30a06826da9b82f)
Ka-Hing Cheung <khc@pidgin.im>
diff
changeset
|
244 | gchar *statusline_stripped, *media = NULL; |
| 13891 | 245 | |
| 246 | g_return_if_fail(session != NULL); | |
| 247 | g_return_if_fail(session->notification != NULL); | |
| 13856 | 248 | |
|
27495
8fd70382bf7b
We shouldn't de-reference variables before checking if they're not NULL.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27296
diff
changeset
|
249 | account = session->account; |
|
21073
a2f27248579c
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 <evands@pidgin.im>
parents:
20608
diff
changeset
|
250 | |
|
a2f27248579c
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 <evands@pidgin.im>
parents:
20608
diff
changeset
|
251 | /* Get the PSM string from Purple's Status Line */ |
|
16183
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
252 | presence = purple_account_get_presence(account); |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
253 | status = purple_presence_get_active_status(presence); |
|
92409c474659
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@pidgin.im>
parents:
15884
diff
changeset
|
254 | statusline = purple_status_get_attr_string(status, "message"); |
|
21073
a2f27248579c
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 <evands@pidgin.im>
parents:
20608
diff
changeset
|
255 | |
|
a2f27248579c
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 <evands@pidgin.im>
parents:
20608
diff
changeset
|
256 | /* MSN expects plain text, not HTML */ |
|
a2f27248579c
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 <evands@pidgin.im>
parents:
20608
diff
changeset
|
257 | statusline_stripped = purple_markup_strip_html(statusline); |
|
21193
e918a1846d03
Use an independant status type for 'current media' stuff, instead of using
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20608
diff
changeset
|
258 | media = create_media_string(presence); |
|
21073
a2f27248579c
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 <evands@pidgin.im>
parents:
20608
diff
changeset
|
259 | g_free(session->psm); |
|
29420
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
260 | session->psm = msn_build_psm(statusline_stripped, media, session->protocol_ver >= 16 ? session->guid : NULL, session->protocol_ver); |
|
21073
a2f27248579c
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 <evands@pidgin.im>
parents:
20608
diff
changeset
|
261 | |
| 13856 | 262 | payload = session->psm; |
|
29420
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
263 | |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
264 | msn_notification_send_uux(session, payload); |
| 21906 | 265 | |
| 266 | g_free(statusline_stripped); | |
| 267 | g_free(media); | |
| 13856 | 268 | } |
| 269 | ||
|
9193
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
270 | void |
|
11992
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
271 | msn_change_status(MsnSession *session) |
|
9193
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
272 | { |
| 15884 | 273 | PurpleAccount *account; |
|
9193
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
274 | MsnCmdProc *cmdproc; |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
275 | MsnUser *user; |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
276 | MsnObject *msnobj; |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
277 | const char *state_text; |
|
25579
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
278 | GHashTable *ui_info = purple_core_get_ui_info(); |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
279 | MsnClientCaps caps = MSN_CLIENT_ID; |
|
27292
1e8a952548f9
Whitespace + a change cluttering up the diff with im.pidgin.pidgin
Paul Aurich <darkrain42@pidgin.im>
parents:
26684
diff
changeset
|
280 | |
|
10481
a5d6b8e1717d
[gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
9262
diff
changeset
|
281 | g_return_if_fail(session != NULL); |
|
a5d6b8e1717d
[gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
9262
diff
changeset
|
282 | g_return_if_fail(session->notification != NULL); |
|
a5d6b8e1717d
[gaim-migrate @ 11769]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
9262
diff
changeset
|
283 | |
|
25579
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
284 | /* set client caps based on what the UI tells us it is... */ |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
285 | if (ui_info) { |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
286 | const gchar *client_type = g_hash_table_lookup(ui_info, "client_type"); |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
287 | if (client_type) { |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
288 | if (strcmp(client_type, "phone") == 0 || |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
289 | strcmp(client_type, "handheld") == 0) { |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
290 | caps |= MSN_CLIENT_CAP_WIN_MOBILE; |
|
27296
31e4b491abae
These strcmp checks are for equality, meaning a return of 0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27292
diff
changeset
|
291 | } else if (strcmp(client_type, "web") == 0) { |
|
25579
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
292 | caps |= MSN_CLIENT_CAP_WEBMSGR; |
|
27296
31e4b491abae
These strcmp checks are for equality, meaning a return of 0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27292
diff
changeset
|
293 | } else if (strcmp(client_type, "bot") == 0) { |
|
25579
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
294 | caps |= MSN_CLIENT_CAP_BOT; |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
295 | } |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
296 | /* MSN doesn't a "console" type... |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
297 | What, they have no ncurses UI? :-) */ |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
298 | } |
|
256aa4861079
Sätt client type on MSN.
Marcus Lundblad <malu@pidgin.im>
parents:
24772
diff
changeset
|
299 | } |
|
27292
1e8a952548f9
Whitespace + a change cluttering up the diff with im.pidgin.pidgin
Paul Aurich <darkrain42@pidgin.im>
parents:
26684
diff
changeset
|
300 | |
|
14453
1cc75906700c
[gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
301 | account = session->account; |
|
9193
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
302 | cmdproc = session->notification->cmdproc; |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
303 | user = session->user; |
|
11992
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
304 | state_text = msn_state_get_text(msn_state_from_account(account)); |
|
10908
15694532c3c6
[gaim-migrate @ 12640]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10481
diff
changeset
|
305 | |
|
15694532c3c6
[gaim-migrate @ 12640]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10481
diff
changeset
|
306 | /* If we're not logged in yet, don't send the status to the server, |
|
15694532c3c6
[gaim-migrate @ 12640]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10481
diff
changeset
|
307 | * it will be sent when login completes |
|
15694532c3c6
[gaim-migrate @ 12640]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10481
diff
changeset
|
308 | */ |
|
15694532c3c6
[gaim-migrate @ 12640]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10481
diff
changeset
|
309 | if (!session->logged_in) |
|
15694532c3c6
[gaim-migrate @ 12640]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10481
diff
changeset
|
310 | return; |
|
9193
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
311 | |
|
29420
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
312 | msn_set_psm(session); |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
313 | |
|
9193
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
314 | msnobj = msn_user_get_object(user); |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
315 | |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
316 | if (msnobj == NULL) |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
317 | { |
|
29420
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
318 | if (session->protocol_ver >= 16) |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
319 | msn_cmdproc_send(cmdproc, "CHG", "%s %u:%02u 0", state_text, caps, MSN_CLIENT_ID_EXT_CAPS); |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
320 | else |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
321 | msn_cmdproc_send(cmdproc, "CHG", "%s %d", state_text, caps); |
|
9193
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
322 | } |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
323 | else |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
324 | { |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
325 | char *msnobj_str; |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
326 | |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
327 | msnobj_str = msn_object_to_string(msnobj); |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
328 | |
|
29420
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
329 | if (session->protocol_ver >= 16) |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
330 | msn_cmdproc_send(cmdproc, "CHG", "%s %u:%02u %s", state_text, |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
331 | caps, MSN_CLIENT_ID_EXT_CAPS, purple_url_encode(msnobj_str)); |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
332 | else |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
333 | msn_cmdproc_send(cmdproc, "CHG", "%s %d %s", state_text, |
|
c81c525111db
Initial support for msnp16, based on patch by Masca.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27495
diff
changeset
|
334 | caps, purple_url_encode(msnobj_str)); |
|
9193
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
335 | |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
336 | g_free(msnobj_str); |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
337 | } |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
338 | } |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
339 | |
| 5361 | 340 | const char * |
| 341 | msn_away_get_text(MsnAwayType type) | |
| 342 | { | |
| 7631 | 343 | g_return_val_if_fail(type <= MSN_HIDDEN, NULL); |
| 5361 | 344 | |
|
5824
cbae51183b18
[gaim-migrate @ 6254]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
5361
diff
changeset
|
345 | return _(away_text[type]); |
| 5361 | 346 | } |
|
9193
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
347 | |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
348 | const char * |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
349 | msn_state_get_text(MsnAwayType state) |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
350 | { |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
351 | static char *status_text[] = |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
352 | { "NLN", "NLN", "BSY", "IDL", "BRB", "AWY", "PHN", "LUN", "HDN", "HDN" }; |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
353 | |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
354 | return status_text[state]; |
|
6e76f1367896
[gaim-migrate @ 9988]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
355 | } |
|
11992
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
356 | |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
357 | MsnAwayType |
| 15884 | 358 | msn_state_from_account(PurpleAccount *account) |
|
11992
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
359 | { |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
360 | MsnAwayType msnstatus; |
| 15884 | 361 | PurplePresence *presence; |
| 362 | PurpleStatus *status; | |
|
11992
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
363 | const char *status_id; |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
364 | |
| 15884 | 365 | presence = purple_account_get_presence(account); |
| 366 | status = purple_presence_get_active_status(presence); | |
| 367 | status_id = purple_status_get_id(status); | |
|
11992
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
368 | |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
369 | if (!strcmp(status_id, "away")) |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
370 | msnstatus = MSN_AWAY; |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
371 | else if (!strcmp(status_id, "brb")) |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
372 | msnstatus = MSN_BRB; |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
373 | else if (!strcmp(status_id, "busy")) |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
374 | msnstatus = MSN_BUSY; |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
375 | else if (!strcmp(status_id, "phone")) |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
376 | msnstatus = MSN_PHONE; |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
377 | else if (!strcmp(status_id, "lunch")) |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
378 | msnstatus = MSN_LUNCH; |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
379 | else if (!strcmp(status_id, "invisible")) |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
380 | msnstatus = MSN_HIDDEN; |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
381 | else |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
382 | msnstatus = MSN_ONLINE; |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
383 | |
| 15884 | 384 | if ((msnstatus == MSN_ONLINE) && purple_presence_is_idle(presence)) |
|
11992
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
385 | msnstatus = MSN_IDLE; |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
386 | |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
387 | return msnstatus; |
|
906176cc9b22
[gaim-migrate @ 14285]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10908
diff
changeset
|
388 | } |