1 | /********************************************************************\ |
---|
2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
3 | * * |
---|
4 | * Copyright 2002-2010 Wilmer van der Gaast and others * |
---|
5 | \********************************************************************/ |
---|
6 | |
---|
7 | /* MSN module - All the SOAPy XML stuff. |
---|
8 | Some manager at Microsoft apparently thought MSNP wasn't XMLy enough so |
---|
9 | someone stepped up and changed that. This is the result. Kilobytes and |
---|
10 | more kilobytes of XML vomit to transfer tiny bits of informaiton. */ |
---|
11 | |
---|
12 | /* |
---|
13 | This program is free software; you can redistribute it and/or modify |
---|
14 | it under the terms of the GNU General Public License as published by |
---|
15 | the Free Software Foundation; either version 2 of the License, or |
---|
16 | (at your option) any later version. |
---|
17 | |
---|
18 | This program is distributed in the hope that it will be useful, |
---|
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
21 | GNU General Public License for more details. |
---|
22 | |
---|
23 | You should have received a copy of the GNU General Public License with |
---|
24 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
25 | if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
---|
26 | Suite 330, Boston, MA 02111-1307 USA |
---|
27 | */ |
---|
28 | |
---|
29 | /* Thanks to http://msnpiki.msnfanatic.com/ for lots of info on this! */ |
---|
30 | |
---|
31 | #ifndef __SOAP_H__ |
---|
32 | #define __SOAP_H__ |
---|
33 | |
---|
34 | #include <stdio.h> |
---|
35 | #include <stdlib.h> |
---|
36 | #include <string.h> |
---|
37 | #include <sys/types.h> |
---|
38 | #ifndef _WIN32 |
---|
39 | #include <sys/socket.h> |
---|
40 | #include <netinet/in.h> |
---|
41 | #include <arpa/inet.h> |
---|
42 | #include <unistd.h> |
---|
43 | #endif |
---|
44 | #include "nogaim.h" |
---|
45 | |
---|
46 | |
---|
47 | #define SOAP_HTTP_REQUEST \ |
---|
48 | "POST %s HTTP/1.0\r\n" \ |
---|
49 | "Host: %s\r\n" \ |
---|
50 | "Accept: */*\r\n" \ |
---|
51 | "User-Agent: BitlBee " BITLBEE_VERSION "\r\n" \ |
---|
52 | "Content-Type: text/xml; charset=utf-8\r\n" \ |
---|
53 | "%s" \ |
---|
54 | "Content-Length: %zd\r\n" \ |
---|
55 | "Cache-Control: no-cache\r\n" \ |
---|
56 | "\r\n" \ |
---|
57 | "%s" |
---|
58 | |
---|
59 | |
---|
60 | #define SOAP_PASSPORT_SSO_URL "https://login.live.com/RST.srf" |
---|
61 | #define SOAP_PASSPORT_SSO_URL_MSN "https://msnia.login.live.com/pp550/RST.srf" |
---|
62 | |
---|
63 | #define SOAP_PASSPORT_SSO_PAYLOAD \ |
---|
64 | "<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\" " \ |
---|
65 | "xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" " \ |
---|
66 | "xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" " \ |
---|
67 | "xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\" " \ |
---|
68 | "xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" " \ |
---|
69 | "xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\" " \ |
---|
70 | "xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\" " \ |
---|
71 | "xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">" \ |
---|
72 | "<Header>" \ |
---|
73 | "<ps:AuthInfo " \ |
---|
74 | "xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" " \ |
---|
75 | "Id=\"PPAuthInfo\">" \ |
---|
76 | "<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>" \ |
---|
77 | "<ps:BinaryVersion>4</ps:BinaryVersion>" \ |
---|
78 | "<ps:UIVersion>1</ps:UIVersion>" \ |
---|
79 | "<ps:Cookies></ps:Cookies>" \ |
---|
80 | "<ps:RequestParams>AQAAAAIAAABsYwQAAAAxMDMz</ps:RequestParams>" \ |
---|
81 | "</ps:AuthInfo>" \ |
---|
82 | "<wsse:Security>" \ |
---|
83 | "<wsse:UsernameToken Id=\"user\">" \ |
---|
84 | "<wsse:Username>%s</wsse:Username>" \ |
---|
85 | "<wsse:Password>%s</wsse:Password>" \ |
---|
86 | "</wsse:UsernameToken>" \ |
---|
87 | "</wsse:Security>" \ |
---|
88 | "</Header>" \ |
---|
89 | "<Body>" \ |
---|
90 | "<ps:RequestMultipleSecurityTokens " \ |
---|
91 | "xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" " \ |
---|
92 | "Id=\"RSTS\">" \ |
---|
93 | "<wst:RequestSecurityToken Id=\"RST0\">" \ |
---|
94 | "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \ |
---|
95 | "<wsp:AppliesTo>" \ |
---|
96 | "<wsa:EndpointReference>" \ |
---|
97 | "<wsa:Address>http://Passport.NET/tb</wsa:Address>" \ |
---|
98 | "</wsa:EndpointReference>" \ |
---|
99 | "</wsp:AppliesTo>" \ |
---|
100 | "</wst:RequestSecurityToken>" \ |
---|
101 | "<wst:RequestSecurityToken Id=\"RST1\">" \ |
---|
102 | "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \ |
---|
103 | "<wsp:AppliesTo>" \ |
---|
104 | "<wsa:EndpointReference>" \ |
---|
105 | "<wsa:Address>messengerclear.live.com</wsa:Address>" \ |
---|
106 | "</wsa:EndpointReference>" \ |
---|
107 | "</wsp:AppliesTo>" \ |
---|
108 | "<wsse:PolicyReference URI=\"%s\"></wsse:PolicyReference>" \ |
---|
109 | "</wst:RequestSecurityToken>" \ |
---|
110 | "<wst:RequestSecurityToken Id=\"RST2\">" \ |
---|
111 | "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \ |
---|
112 | "<wsp:AppliesTo>" \ |
---|
113 | "<wsa:EndpointReference>" \ |
---|
114 | "<wsa:Address>contacts.msn.com</wsa:Address>" \ |
---|
115 | "</wsa:EndpointReference>" \ |
---|
116 | "</wsp:AppliesTo>" \ |
---|
117 | "<wsse:PolicyReference xmlns=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" URI=\"MBI\"></wsse:PolicyReference>" \ |
---|
118 | "</wst:RequestSecurityToken>" \ |
---|
119 | "<wst:RequestSecurityToken Id=\"RST3\">" \ |
---|
120 | "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \ |
---|
121 | "<wsp:AppliesTo>" \ |
---|
122 | "<wsa:EndpointReference>" \ |
---|
123 | "<wsa:Address>messengersecure.live.com</wsa:Address>" \ |
---|
124 | "</wsa:EndpointReference>" \ |
---|
125 | "</wsp:AppliesTo>" \ |
---|
126 | "<wsse:PolicyReference xmlns=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" URI=\"MBI_SSL\"></wsse:PolicyReference>" \ |
---|
127 | "</wst:RequestSecurityToken>" \ |
---|
128 | "</ps:RequestMultipleSecurityTokens>" \ |
---|
129 | "</Body>" \ |
---|
130 | "</Envelope>" |
---|
131 | |
---|
132 | int msn_soap_passport_sso_request( struct im_connection *ic, const char *policy, const char *nonce ); |
---|
133 | |
---|
134 | |
---|
135 | #define SOAP_OIM_SEND_URL "https://ows.messenger.msn.com/OimWS/oim.asmx" |
---|
136 | #define SOAP_OIM_SEND_ACTION "http://messenger.live.com/ws/2006/09/oim/Store2" |
---|
137 | |
---|
138 | #define SOAP_OIM_SEND_PAYLOAD \ |
---|
139 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ |
---|
140 | "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ |
---|
141 | "<soap:Header>" \ |
---|
142 | "<From memberName=\"%s\" friendlyName=\"=?utf-8?B?%s?=\" xml:lang=\"nl-nl\" proxy=\"MSNMSGR\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\" msnpVer=\"%s\" buildVer=\"%s\"/>" \ |
---|
143 | "<To memberName=\"%s\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\"/>" \ |
---|
144 | "<Ticket passport=\"%s\" appid=\"%s\" lockkey=\"%s\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\"/>" \ |
---|
145 | "<Sequence xmlns=\"http://schemas.xmlsoap.org/ws/2003/03/rm\">" \ |
---|
146 | "<Identifier xmlns=\"http://schemas.xmlsoap.org/ws/2002/07/utility\">http://messenger.msn.com</Identifier>" \ |
---|
147 | "<MessageNumber>%d</MessageNumber>" \ |
---|
148 | "</Sequence>" \ |
---|
149 | "</soap:Header>" \ |
---|
150 | "<soap:Body>" \ |
---|
151 | "<MessageType xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\">text</MessageType>" \ |
---|
152 | "<Content xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\">" \ |
---|
153 | "MIME-Version: 1.0\r\n" \ |
---|
154 | "Content-Type: text/plain; charset=UTF-8\r\n" \ |
---|
155 | "Content-Transfer-Encoding: base64\r\n" \ |
---|
156 | "X-OIM-Message-Type: OfflineMessage\r\n" \ |
---|
157 | "X-OIM-Run-Id: {F9A6C9DD-0D94-4E85-9CC6-F9D118CC1CAF}\r\n" \ |
---|
158 | "X-OIM-Sequence-Num: %d\r\n" \ |
---|
159 | "\r\n" \ |
---|
160 | "%s" \ |
---|
161 | "</Content>" \ |
---|
162 | "</soap:Body>" \ |
---|
163 | "</soap:Envelope>" |
---|
164 | |
---|
165 | int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg ); |
---|
166 | int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq ); |
---|
167 | |
---|
168 | |
---|
169 | #define SOAP_ABSERVICE_PAYLOAD \ |
---|
170 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ |
---|
171 | "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ |
---|
172 | "<soap:Header xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ |
---|
173 | "<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
174 | "<ApplicationId xmlns=\"http://www.msn.com/webservices/AddressBook\">CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>" \ |
---|
175 | "<IsMigration xmlns=\"http://www.msn.com/webservices/AddressBook\">false</IsMigration>" \ |
---|
176 | "<PartnerScenario xmlns=\"http://www.msn.com/webservices/AddressBook\">%s</PartnerScenario>" \ |
---|
177 | "</ABApplicationHeader>" \ |
---|
178 | "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
179 | "<ManagedGroupRequest xmlns=\"http://www.msn.com/webservices/AddressBook\">false</ManagedGroupRequest>" \ |
---|
180 | "<TicketToken>%s</TicketToken>" \ |
---|
181 | "</ABAuthHeader>" \ |
---|
182 | "</soap:Header>" \ |
---|
183 | "<soap:Body xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ |
---|
184 | "%%s" \ |
---|
185 | "</soap:Body>" \ |
---|
186 | "</soap:Envelope>" |
---|
187 | |
---|
188 | #define SOAP_MEMLIST_URL "http://contacts.msn.com/abservice/SharingService.asmx" |
---|
189 | #define SOAP_MEMLIST_ACTION "http://www.msn.com/webservices/AddressBook/FindMembership" |
---|
190 | |
---|
191 | #define SOAP_MEMLIST_PAYLOAD \ |
---|
192 | "<FindMembership xmlns=\"http://www.msn.com/webservices/AddressBook\"><serviceFilter xmlns=\"http://www.msn.com/webservices/AddressBook\"><Types xmlns=\"http://www.msn.com/webservices/AddressBook\"><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Messenger</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Invitation</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">SocialNetwork</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Space</ServiceType><ServiceType xmlns=\"http://www.msn.com/webservices/AddressBook\">Profile</ServiceType></Types></serviceFilter>" \ |
---|
193 | "</FindMembership>" |
---|
194 | |
---|
195 | #define SOAP_MEMLIST_ADD_ACTION "http://www.msn.com/webservices/AddressBook/AddMember" |
---|
196 | #define SOAP_MEMLIST_DEL_ACTION "http://www.msn.com/webservices/AddressBook/DeleteMember" |
---|
197 | |
---|
198 | #define SOAP_MEMLIST_EDIT_PAYLOAD \ |
---|
199 | "<%sMember xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
200 | "<serviceHandle>" \ |
---|
201 | "<Id>0</Id>" \ |
---|
202 | "<Type>Messenger</Type>" \ |
---|
203 | "<ForeignId></ForeignId>" \ |
---|
204 | "</serviceHandle>" \ |
---|
205 | "<memberships>" \ |
---|
206 | "<Membership>" \ |
---|
207 | "<MemberRole>%s</MemberRole>" \ |
---|
208 | "<Members>" \ |
---|
209 | "<Member xsi:type=\"PassportMember\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" \ |
---|
210 | "<Type>Passport</Type>" \ |
---|
211 | "<State>Accepted</State>" \ |
---|
212 | "<PassportName>%s</PassportName>" \ |
---|
213 | "</Member>" \ |
---|
214 | "</Members>" \ |
---|
215 | "</Membership>" \ |
---|
216 | "</memberships>" \ |
---|
217 | "</%sMember>" |
---|
218 | |
---|
219 | int msn_soap_memlist_request( struct im_connection *ic ); |
---|
220 | int msn_soap_memlist_edit( struct im_connection *ic, const char *handle, gboolean add, int list ); |
---|
221 | |
---|
222 | |
---|
223 | #define SOAP_ADDRESSBOOK_URL "http://contacts.msn.com/abservice/abservice.asmx" |
---|
224 | #define SOAP_ADDRESSBOOK_ACTION "http://www.msn.com/webservices/AddressBook/ABFindAll" |
---|
225 | |
---|
226 | #define SOAP_ADDRESSBOOK_PAYLOAD \ |
---|
227 | "<ABFindAll xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
228 | "<abId>00000000-0000-0000-0000-000000000000</abId>" \ |
---|
229 | "<abView>Full</abView>" \ |
---|
230 | "<deltasOnly>false</deltasOnly>" \ |
---|
231 | "<lastChange>0001-01-01T00:00:00.0000000-08:00</lastChange>" \ |
---|
232 | "</ABFindAll>" |
---|
233 | |
---|
234 | #define SOAP_AB_NAMECHANGE_ACTION "http://www.msn.com/webservices/AddressBook/ABContactUpdate" |
---|
235 | |
---|
236 | #define SOAP_AB_NAMECHANGE_PAYLOAD \ |
---|
237 | "<ABContactUpdate xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
238 | "<abId>00000000-0000-0000-0000-000000000000</abId>" \ |
---|
239 | "<contacts>" \ |
---|
240 | "<Contact xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
241 | "<contactInfo>" \ |
---|
242 | "<contactType>Me</contactType>" \ |
---|
243 | "<displayName>%s</displayName>" \ |
---|
244 | "</contactInfo>" \ |
---|
245 | "<propertiesChanged>DisplayName</propertiesChanged>" \ |
---|
246 | "</Contact>" \ |
---|
247 | "</contacts>" \ |
---|
248 | "</ABContactUpdate>" |
---|
249 | |
---|
250 | int msn_soap_addressbook_request( struct im_connection *ic ); |
---|
251 | int msn_soap_addressbook_set_display_name( struct im_connection *ic, const char *new ); |
---|
252 | |
---|
253 | |
---|
254 | #endif /* __SOAP_H__ */ |
---|