libmsn 4.2
|
00001 #ifndef __msn_soap_h__ 00002 #define __msn_soap_h__ 00003 /* 00004 * soap.h 00005 * libmsn 00006 * 00007 * Crated by Tiago Salem Herrmann on 08/2007. 00008 * Copyright (c) 2007 Tiago Salem Herrmann. All rights reserved 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 00025 00026 #include <msn/connection.h> 00027 #include <msn/authdata.h> 00028 #include <msn/errorcodes.h> 00029 #include <msn/buddy.h> 00030 #include <msn/passport.h> 00031 #include <stdexcept> 00032 #include <msn/externals.h> 00033 00034 #include <iostream> 00035 #include <vector> 00036 #include <map> 00037 00038 #include "xmlParser.h" 00039 00040 #include "libmsn_export.h" 00041 00042 namespace MSN 00043 { 00044 class NotificationServerConnection; 00045 00048 class LIBMSN_EXPORT Soap : public Connection 00049 { 00050 private: 00051 NotificationServerConnection & notificationServer; 00052 std::string request_body; 00053 std::string http_header_response; 00054 std::string response_body; 00055 int action; 00056 unsigned int response_length; 00057 ListSyncInfo *listInfo; 00058 std::string oim_id; 00059 std::string http_response_code; 00060 std::string tempDisplayName; 00061 std::string tempPassport; 00062 std::string contactId; 00063 std::string groupId; 00064 std::string groupName; 00065 MSN::ContactList tempList; 00066 std::string passport; 00067 std::string password; 00068 std::string policy; 00069 std::string mbi; 00070 std::string myDisplayName; 00071 bool markAsRead; 00072 00073 public: 00074 struct sitesToAuthTAG 00075 { 00076 std::string url; 00077 std::string URI; 00078 std::string BinarySecurityToken; 00079 std::string BinarySecret; 00080 }; 00081 00082 typedef sitesToAuthTAG sitesToAuth; 00083 00084 struct OIMTAG 00085 { 00086 int id; 00087 std::string toUsername; 00088 std::string myUsername; 00089 std::string myFname; 00090 std::string message; 00091 std::string full_msg; // includes b64 body 00092 }; 00093 00094 typedef OIMTAG OIM; 00095 00096 MSN::Soap::OIM oim; 00097 Soap(NotificationServerConnection & _myNotificationServer); 00098 Soap(NotificationServerConnection & _myNotificationServer, std::vector<sitesToAuth> sitesToAuthList); 00099 ~Soap(); 00100 std::string body; 00101 std::string ticket_token; 00102 std::string lockkey; 00103 00104 enum memberRoles { // the lists 00105 ALLOW_LIST = 2, 00106 BLOCK_LIST = 4, 00107 REVERSE_LIST = 8, 00108 PENDING_LIST = 16 00109 }; 00110 00111 typedef enum { 00112 AUTH, 00113 GET_LISTS, 00114 GET_ADDRESS_BOOK, 00115 ADD_CONTACT_TO_LIST, 00116 DEL_CONTACT_FROM_LIST, 00117 ADD_CONTACT_TO_ADDRESSBOOK, 00118 DEL_CONTACT_FROM_ADDRESSBOOK, 00119 ENABLE_CONTACT_ON_ADDRESSBOOK, 00120 DISABLE_CONTACT_ON_ADDRESSBOOK, 00121 ADD_GROUP, 00122 DEL_GROUP, 00123 RENAME_GROUP, 00124 BLOCK_CONTACT, 00125 UNBLOCK_CONTACT, 00126 ADD_CONTACT_TO_GROUP, 00127 DEL_CONTACT_FROM_GROUP, 00128 UPDATE_GROUP, 00129 GENERATE_LOCKKEY, 00130 RETRIEVE_OIM_MAIL_DATA, 00131 RETRIEVE_OIM, 00132 DELETE_OIM, 00133 SEND_OIM, 00134 CHANGE_DISPLAYNAME 00135 } soapAction; 00136 00137 static std::map<int,std::string> actionDomains; 00138 static std::map<int,std::string> actionPOSTURLs; 00139 static std::map<int,std::string> actionURLs; 00140 std::vector<sitesToAuth> sitesToAuthList; 00141 00142 void fillURLs(); 00143 void setMBI(std::string MBI); 00144 void requestSoapAction(soapAction action, std::string xml_body, std::string & xml_response); 00145 00146 void getTickets(std::string Passport, 00147 std::string password, 00148 std::string policy); 00149 void parseGetTicketsResponse(std::string response); 00150 00151 void getLists(ListSyncInfo* data); 00152 void parseGetListsResponse(std::string response); 00153 00154 void getAddressBook(ListSyncInfo *info); 00155 void parseGetAddressBookResponse(std::string response); 00156 00157 void getOIM(std::string id, bool markAsRead); 00158 void parseGetOIMResponse(std::string response); 00159 00160 void deleteOIM(std::string id); 00161 void parseDeleteOIMResponse(std::string response); 00162 00163 void getMailData(); 00164 void parseGetMailDataResponse(std::string response); 00165 00166 void sendOIM(OIM oim, std::string lockkey); 00167 void parseSendOIMResponse(std::string response); 00168 00169 void addContactToList(MSN::Passport passport, MSN::ContactList list); 00170 void parseAddContactToListResponse(std::string response); 00171 00172 void addContactToAddressBook(std::string passport, std::string displayName); 00173 void parseAddContactToAddressBookResponse(std::string response); 00174 00175 void delContactFromAddressBook(std::string contactId, std::string passport); 00176 void parseDelContactFromAddressBookResponse(std::string response); 00177 00178 void enableContactOnAddressBook(std::string contactId, 00179 std::string passport, 00180 std::string myDisplayName); 00181 00182 void parseEnableContactOnAddressBookResponse(std::string response); 00183 00184 void disableContactFromAddressBook(std::string contactId, std::string passport); 00185 void parseDisableContactFromAddressBookResponse(std::string response); 00186 00187 void addContactToGroup(std::string groupId, std::string contactId); 00188 void parseAddContactToGroupResponse(std::string response); 00189 00190 void delContactFromGroup(std::string groupId, std::string contactId); 00191 void parseDelContactFromGroupResponse(std::string response); 00192 00193 void removeContactFromList(MSN::Passport passport, MSN::ContactList list); 00194 void parseRemoveContactFromListResponse(std::string response); 00195 00196 void addGroup(std::string groupName); 00197 void parseAddGroupResponse(std::string response); 00198 00199 void delGroup(std::string groupId); 00200 void parseDelGroupResponse(std::string response); 00201 00202 void renameGroup(std::string groupId, std::string newGroupName); 00203 void parseRenameGroupResponse(std::string response); 00204 00205 void generateLockkey(OIM oim); 00206 void parseGenerateLockkeyResponse(std::string response); 00207 00208 void changeDisplayName(std::string newDisplayName); 00209 void parseChangeDisplayNameResponse(std::string); 00210 00211 Soap* manageSoapRedirect(XMLNode response1, soapAction action); 00212 00213 virtual void dispatchCommand(std::vector<std::string> &) {}; 00214 virtual void connect(const std::string &, unsigned int) {}; 00215 virtual void disconnect(); 00216 virtual void sendMessage(const Message *) {}; 00217 virtual void sendMessage(const std::string &) {}; 00218 virtual void socketConnectionCompleted(); 00219 virtual void handleIncomingData(); 00220 virtual NotificationServerConnection *myNotificationServer() { return ¬ificationServer; }; 00221 00222 }; 00223 00224 } 00225 #endif