[e5a8118] | 1 | /* soap.h |
---|
| 2 | * |
---|
| 3 | * SOAP-related functions. Some manager at Microsoft apparently thought |
---|
| 4 | * MSNP wasn't XMLy enough so someone stepped up and changed that. This |
---|
| 5 | * is the result. |
---|
| 6 | * |
---|
| 7 | * Copyright (C) 2010 Wilmer van der Gaast <wilmer@gaast.net> |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or modify |
---|
| 10 | * it under the terms of the GNU General Public License version 2 |
---|
| 11 | * as published by the Free Software Foundation |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that is will be useful, |
---|
| 14 | * bit WITHOU ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | /* Thanks to http://msnpiki.msnfanatic.com/ for lots of info on this! */ |
---|
| 24 | |
---|
| 25 | #ifndef __SOAP_H__ |
---|
| 26 | #define __SOAP_H__ |
---|
| 27 | |
---|
| 28 | #include <stdio.h> |
---|
| 29 | #include <stdlib.h> |
---|
| 30 | #include <string.h> |
---|
| 31 | #include <sys/types.h> |
---|
| 32 | #ifndef _WIN32 |
---|
| 33 | #include <sys/socket.h> |
---|
| 34 | #include <netinet/in.h> |
---|
| 35 | #include <arpa/inet.h> |
---|
| 36 | #include <unistd.h> |
---|
| 37 | #endif |
---|
| 38 | #include "nogaim.h" |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | #define SOAP_HTTP_REQUEST \ |
---|
| 42 | "POST %s HTTP/1.0\r\n" \ |
---|
| 43 | "Host: %s\r\n" \ |
---|
| 44 | "Accept: */*\r\n" \ |
---|
| 45 | "User-Agent: BitlBee " BITLBEE_VERSION "\r\n" \ |
---|
| 46 | "Content-Type: text/xml; charset=utf-8\r\n" \ |
---|
[523fb23] | 47 | "%s" \ |
---|
| 48 | "Content-Length: %zd\r\n" \ |
---|
[e5a8118] | 49 | "Cache-Control: no-cache\r\n" \ |
---|
| 50 | "\r\n" \ |
---|
| 51 | "%s" |
---|
| 52 | |
---|
| 53 | |
---|
[523fb23] | 54 | #define SOAP_PASSPORT_SSO_URL "https://login.live.com/RST.srf" |
---|
| 55 | #define SOAP_PASSPORT_SSO_URL_MSN "https://msnia.login.live.com/pp550/RST.srf" |
---|
| 56 | |
---|
| 57 | #define SOAP_PASSPORT_SSO_PAYLOAD \ |
---|
| 58 | "<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\" " \ |
---|
| 59 | "xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" " \ |
---|
| 60 | "xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" " \ |
---|
| 61 | "xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\" " \ |
---|
| 62 | "xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" " \ |
---|
| 63 | "xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\" " \ |
---|
| 64 | "xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\" " \ |
---|
| 65 | "xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">" \ |
---|
| 66 | "<Header>" \ |
---|
| 67 | "<ps:AuthInfo " \ |
---|
| 68 | "xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" " \ |
---|
| 69 | "Id=\"PPAuthInfo\">" \ |
---|
| 70 | "<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>" \ |
---|
| 71 | "<ps:BinaryVersion>4</ps:BinaryVersion>" \ |
---|
| 72 | "<ps:UIVersion>1</ps:UIVersion>" \ |
---|
| 73 | "<ps:Cookies></ps:Cookies>" \ |
---|
| 74 | "<ps:RequestParams>AQAAAAIAAABsYwQAAAAxMDMz</ps:RequestParams>" \ |
---|
| 75 | "</ps:AuthInfo>" \ |
---|
| 76 | "<wsse:Security>" \ |
---|
| 77 | "<wsse:UsernameToken Id=\"user\">" \ |
---|
| 78 | "<wsse:Username>%s</wsse:Username>" \ |
---|
| 79 | "<wsse:Password>%s</wsse:Password>" \ |
---|
| 80 | "</wsse:UsernameToken>" \ |
---|
| 81 | "</wsse:Security>" \ |
---|
| 82 | "</Header>" \ |
---|
| 83 | "<Body>" \ |
---|
| 84 | "<ps:RequestMultipleSecurityTokens " \ |
---|
| 85 | "xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" " \ |
---|
| 86 | "Id=\"RSTS\">" \ |
---|
| 87 | "<wst:RequestSecurityToken Id=\"RST0\">" \ |
---|
| 88 | "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \ |
---|
| 89 | "<wsp:AppliesTo>" \ |
---|
| 90 | "<wsa:EndpointReference>" \ |
---|
| 91 | "<wsa:Address>http://Passport.NET/tb</wsa:Address>" \ |
---|
| 92 | "</wsa:EndpointReference>" \ |
---|
| 93 | "</wsp:AppliesTo>" \ |
---|
| 94 | "</wst:RequestSecurityToken>" \ |
---|
| 95 | "<wst:RequestSecurityToken Id=\"RST1\">" \ |
---|
| 96 | "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \ |
---|
| 97 | "<wsp:AppliesTo>" \ |
---|
| 98 | "<wsa:EndpointReference>" \ |
---|
| 99 | "<wsa:Address>messengerclear.live.com</wsa:Address>" \ |
---|
| 100 | "</wsa:EndpointReference>" \ |
---|
| 101 | "</wsp:AppliesTo>" \ |
---|
| 102 | "<wsse:PolicyReference URI=\"%s\"></wsse:PolicyReference>" \ |
---|
| 103 | "</wst:RequestSecurityToken>" \ |
---|
| 104 | "<wst:RequestSecurityToken Id=\"RST2\">" \ |
---|
| 105 | "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \ |
---|
| 106 | "<wsp:AppliesTo>" \ |
---|
| 107 | "<wsa:EndpointReference>" \ |
---|
| 108 | "<wsa:Address>contacts.msn.com</wsa:Address>" \ |
---|
| 109 | "</wsa:EndpointReference>" \ |
---|
| 110 | "</wsp:AppliesTo>" \ |
---|
| 111 | "<wsse:PolicyReference xmlns=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" URI=\"MBI\"></wsse:PolicyReference>" \ |
---|
| 112 | "</wst:RequestSecurityToken>" \ |
---|
[91d6e91] | 113 | "<wst:RequestSecurityToken Id=\"RST3\">" \ |
---|
| 114 | "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \ |
---|
| 115 | "<wsp:AppliesTo>" \ |
---|
| 116 | "<wsa:EndpointReference>" \ |
---|
| 117 | "<wsa:Address>messengersecure.live.com</wsa:Address>" \ |
---|
| 118 | "</wsa:EndpointReference>" \ |
---|
| 119 | "</wsp:AppliesTo>" \ |
---|
| 120 | "<wsse:PolicyReference xmlns=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" URI=\"MBI_SSL\"></wsse:PolicyReference>" \ |
---|
| 121 | "</wst:RequestSecurityToken>" \ |
---|
[523fb23] | 122 | "</ps:RequestMultipleSecurityTokens>" \ |
---|
| 123 | "</Body>" \ |
---|
| 124 | "</Envelope>" |
---|
| 125 | |
---|
| 126 | int msn_soap_passport_sso_request( struct im_connection *ic, const char *policy, const char *nonce ); |
---|
| 127 | |
---|
| 128 | |
---|
[e5a8118] | 129 | #define SOAP_OIM_SEND_URL "https://ows.messenger.msn.com/OimWS/oim.asmx" |
---|
[91d6e91] | 130 | #define SOAP_OIM_SEND_ACTION "http://messenger.live.com/ws/2006/09/oim/Store2" |
---|
[e5a8118] | 131 | |
---|
| 132 | #define SOAP_OIM_SEND_PAYLOAD \ |
---|
| 133 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ |
---|
| 134 | "<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/\">" \ |
---|
| 135 | "<soap:Header>" \ |
---|
[91d6e91] | 136 | "<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\"/>" \ |
---|
[e5a8118] | 137 | "<To memberName=\"%s\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\"/>" \ |
---|
| 138 | "<Ticket passport=\"%s\" appid=\"%s\" lockkey=\"%s\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\"/>" \ |
---|
| 139 | "<Sequence xmlns=\"http://schemas.xmlsoap.org/ws/2003/03/rm\">" \ |
---|
| 140 | "<Identifier xmlns=\"http://schemas.xmlsoap.org/ws/2002/07/utility\">http://messenger.msn.com</Identifier>" \ |
---|
| 141 | "<MessageNumber>%d</MessageNumber>" \ |
---|
| 142 | "</Sequence>" \ |
---|
| 143 | "</soap:Header>" \ |
---|
| 144 | "<soap:Body>" \ |
---|
| 145 | "<MessageType xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\">text</MessageType>" \ |
---|
[ffb6dea] | 146 | "<Content xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\">" \ |
---|
| 147 | "MIME-Version: 1.0\r\n" \ |
---|
[e5a8118] | 148 | "Content-Type: text/plain; charset=UTF-8\r\n" \ |
---|
| 149 | "Content-Transfer-Encoding: base64\r\n" \ |
---|
| 150 | "X-OIM-Message-Type: OfflineMessage\r\n" \ |
---|
[5fecede] | 151 | "X-OIM-Run-Id: {F9A6C9DD-0D94-4E85-9CC6-F9D118CC1CAF}\r\n" \ |
---|
[e5a8118] | 152 | "X-OIM-Sequence-Num: %d\r\n" \ |
---|
| 153 | "\r\n" \ |
---|
| 154 | "%s" \ |
---|
| 155 | "</Content>" \ |
---|
| 156 | "</soap:Body>" \ |
---|
| 157 | "</soap:Envelope>" |
---|
| 158 | |
---|
| 159 | int msn_soap_oim_send( struct im_connection *ic, const char *to, const char *msg ); |
---|
[bc090f0] | 160 | int msn_soap_oim_send_queue( struct im_connection *ic, GSList **msgq ); |
---|
[e5a8118] | 161 | |
---|
[7db65b7] | 162 | |
---|
[7f34ce2] | 163 | #define SOAP_MEMLIST_URL "http://contacts.msn.com/abservice/SharingService.asmx" |
---|
[7db65b7] | 164 | #define SOAP_MEMLIST_ACTION "http://www.msn.com/webservices/AddressBook/FindMembership" |
---|
| 165 | |
---|
| 166 | #define SOAP_MEMLIST_PAYLOAD \ |
---|
| 167 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ |
---|
| 168 | "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ |
---|
| 169 | "<soap:Header xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ |
---|
| 170 | "<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
| 171 | "<ApplicationId xmlns=\"http://www.msn.com/webservices/AddressBook\">CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>" \ |
---|
| 172 | "<IsMigration xmlns=\"http://www.msn.com/webservices/AddressBook\">false</IsMigration>" \ |
---|
| 173 | "<PartnerScenario xmlns=\"http://www.msn.com/webservices/AddressBook\">Initial</PartnerScenario>" \ |
---|
| 174 | "</ABApplicationHeader>" \ |
---|
| 175 | "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
| 176 | "<ManagedGroupRequest xmlns=\"http://www.msn.com/webservices/AddressBook\">false</ManagedGroupRequest>" \ |
---|
[7f34ce2] | 177 | "<TicketToken>%s</TicketToken>" \ |
---|
[7db65b7] | 178 | "</ABAuthHeader>" \ |
---|
| 179 | "</soap:Header>" \ |
---|
| 180 | "<soap:Body xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ |
---|
| 181 | "<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>" \ |
---|
| 182 | "</FindMembership>" \ |
---|
| 183 | "</soap:Body>" \ |
---|
| 184 | "</soap:Envelope>" |
---|
| 185 | |
---|
| 186 | int msn_soap_memlist_request( struct im_connection *ic ); |
---|
| 187 | |
---|
| 188 | |
---|
[7f34ce2] | 189 | #define SOAP_ADDRESSBOOK_URL "http://contacts.msn.com/abservice/abservice.asmx" |
---|
| 190 | #define SOAP_ADDRESSBOOK_ACTION "http://www.msn.com/webservices/AddressBook/ABFindAll" |
---|
| 191 | |
---|
| 192 | #define SOAP_ADDRESSBOOK_PAYLOAD \ |
---|
| 193 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ |
---|
| 194 | "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">" \ |
---|
| 195 | "<soap:Header>" \ |
---|
| 196 | "<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
| 197 | "<ApplicationId>CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>" \ |
---|
| 198 | "<IsMigration>false</IsMigration>" \ |
---|
| 199 | "<PartnerScenario>Initial</PartnerScenario>" \ |
---|
| 200 | "</ABApplicationHeader>" \ |
---|
| 201 | "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
| 202 | "<ManagedGroupRequest>false</ManagedGroupRequest>" \ |
---|
| 203 | "<TicketToken>%s</TicketToken>" \ |
---|
| 204 | "</ABAuthHeader>" \ |
---|
| 205 | "</soap:Header>" \ |
---|
| 206 | "<soap:Body>" \ |
---|
| 207 | "<ABFindAll xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ |
---|
| 208 | "<abId>00000000-0000-0000-0000-000000000000</abId>" \ |
---|
| 209 | "<abView>Full</abView>" \ |
---|
| 210 | "<deltasOnly>false</deltasOnly>" \ |
---|
| 211 | "<lastChange>0001-01-01T00:00:00.0000000-08:00</lastChange>" \ |
---|
| 212 | "</ABFindAll>" \ |
---|
| 213 | "</soap:Body>" \ |
---|
| 214 | "</soap:Envelope>" |
---|
| 215 | |
---|
| 216 | int msn_soap_addressbook_request( struct im_connection *ic ); |
---|
| 217 | |
---|
| 218 | |
---|
[e5a8118] | 219 | #endif /* __SOAP_H__ */ |
---|