libmsn 4.2.1

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

/home/salem/libmsn/tags/libmsn-4.2/msn/util.h

    00001 #ifndef __msn_util_h__
    00002 #define __msn_util_h__
    00003
    00004 /*
    00005  * util.h
    00006  * libmsn
    00007  *
    00008  * Created by Mark Rowe on Mon Mar 22 2004.
    00009  * Refactored by Tiago Salem Herrmann on 08/2007.
    00010  * Copyright (c) 2004 Mark Rowe. All rights reserved.
    00011  * Copyright (c) 2007 Tiago Salem Herrmann. All rights reserved
    00012  *
    00013  * This program is free software; you can redistribute it and/or modify
    00014  * it under the terms of the GNU General Public License as published by
    00015  * the Free Software Foundation; either version 2 of the License, or
    00016  * (at your option) any later version.
    00017  *
    00018  * This program is distributed in the hope that it will be useful,
    00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00021  * GNU General Public License for more details.
    00022  *
    00023  * You should have received a copy of the GNU General Public License
    00024  * along with this program; if not, write to the Free Software
    00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00026  */
    00027 #include <openssl/bio.h>
    00028 #include <openssl/evp.h>
    00029 #include <openssl/sha.h>
    00030 #include <openssl/hmac.h>
    00031 #include <openssl/des.h>
    00032
    00033 #include <string>
    00034 #include <sstream>
    00035 #include <map>
    00036 #include <vector>
    00037 #include <stdexcept>
    00038 #include <string>
    00039
    00040 #ifdef _MSC_VER
    00041 #pragma warning( disable : 4290 )
    00042 #endif
    00043
    00044 // this is for CHL command
    00045 #define szClientID "PROD0114ES4Z%Q5W"
    00046 #define szClientCode "PK}_A_0N_K%O?A9S"
    00047
    00048 #ifndef U8
    00049 #define U8 unsigned char
    00050 #endif
    00051 #ifndef U16
    00052 #define U16 unsigned short
    00053 #endif
    00054 #ifndef U32
    00055 #define U32 unsigned int
    00056 #endif
    00057 #define FB_UNI 0xFFFd
    00058
    00059 // for libsiren
    00060 #define RIFF_ID 0x46464952
    00061 #define WAVE_ID 0x45564157
    00062 #define FMT_ID 0x20746d66
    00063 #define DATA_ID 0x61746164
    00064 #define FACT_ID 0x74636166
    00065
    00066 typedef struct
    00067 {
    00068     unsigned int chunk_id;
    00069     unsigned int chunk_size;
    00070 } wav_data;
    00071
    00072 typedef struct
    00073 {
    00074     unsigned int chunk_id;
    00075     unsigned int chunk_size;
    00076     unsigned int type_id;
    00077 } riff_data;
    00078
    00079 typedef struct
    00080 {
    00081     unsigned short format;
    00082     unsigned short channels;
    00083     unsigned int sample_rate;
    00084     unsigned int byte_rate;
    00085     unsigned short block_align;
    00086     unsigned short bits_per_sample;
    00087 } fmt_chunk;
    00088
    00089 typedef struct
    00090 {
    00091     fmt_chunk fmt;
    00092     unsigned short extra_size;
    00093     unsigned char *extra_content;
    00094 } fmt_chunk_ex;
    00095
    00096 #define IDX(val, i) ((unsigned int) ((unsigned char *) &val)[i])
    00097
    00098 #define GUINT16_FROM_LE(val) ((unsigned short) (IDX (val, 0) + (unsigned short) IDX (val, 1) * 256))
    00099 #define GUINT32_FROM_LE(val) ((unsigned int) (IDX (val, 0) + IDX (val, 1) * 256 + \
    00100                                               IDX (val, 2) * 65536 + IDX (val, 3) * 16777216))
    00101
    00102 namespace MSN
    00103 {
    00110     std::string encodeURL(const std::string & s);
    00111
    00118     std::string decodeURL(const std::string & s);
    00119
    00126     std::pair<std::string, int> splitServerAddress(const std::string & address, int default_port=1863);
    00127
    00130     int nocase_cmp(const std::string & s1, const std::string & s2);
    00131
    00134     std::vector<std::string> splitString(const std::string & string, const std::string & separator, bool suppressBlanks=true);
    00135
    00136     std::string toStr(int var);
    00137     std::string unsignedToStr(unsigned int var);
    00140     unsigned int decimalFromString(const std::string & s) throw (std::logic_error);
    00141
    00142     U32 _ucs2_utf8(U8 *dst, U8 *src, U32 nchar);
    00143     U32 _utf8_ucs2(U8 *dst, U8 *src);
    00144
    00146     struct personalInfo
    00147     {
    00148         std::string PSM;
    00149         std::string mediaApp;
    00150         std::string mediaType;
    00151         bool mediaIsEnabled;
    00152         std::string mediaFormat;
    00153         std::vector<std::string> mediaLines;
    00155         personalInfo() {
    00156             mediaIsEnabled = false;
    00157         }
    00158     };
    00159
    00160     struct hotmailInfo
    00161     {
    00162         std::string rru;
    00163         std::string url;
    00164         std::string id;
    00165         std::string sl;
    00166         std::string kv;
    00167         std::string sid;
    00168         std::string MSPAuth;
    00169         std::string creds;
    00170     };
    00171
    00173     typedef enum
    00174     {
    00175         LST_AB = 1,
    00176         LST_AL = 2,
    00177         LST_BL = 4,
    00178         LST_RL = 8,
    00179         LST_PL = 16
    00180     }ContactList;
    00181
    00182     struct tagMSGRUSRKEY
    00183     {
    00184          unsigned int uStructHeaderSize; // 28. Does not count data
    00185          unsigned int uCryptMode; // CRYPT_MODE_CBC (1)
    00186          unsigned int uCipherType; // TripleDES (0x6603)
    00187          unsigned int uHashType; // SHA1 (0x8004)
    00188          unsigned int uIVLen;    // 8
    00189          unsigned int uHashLen;  // 20
    00190          unsigned int uCipherLen; // 72
    00191          // Data
    00192          unsigned char aIVBytes[8];
    00193          unsigned char aHashBytes[20];
    00194          unsigned char aCipherBytes[72];
    00195     };
    00196
    00198     typedef struct
    00199     {
    00200          std::string from;
    00201          std::string fromFN;
    00202          std::string id;
    00203     } eachOIM;
    00204
    00205     std::string new_branch();
    00206     std::string generate_soap_auth(std::string user, std::string pass, std::string ticket);
    00207     std::string mdi_encrypt(std::string key, std::string nonce);
    00208     std::string b64_decode(const char *input);
    00209     std::string b64_encode(const char *input, int size);
    00210
    00211     unsigned int little2big_endian(unsigned int i);
    00212     int FileSize(const char* sFileName);
    00213     void DoMSNP11Challenge(const char *szChallenge, char *szOutput);
    00214
    00215     // stolen from kopete
    00217     typedef enum
    00218     {
    00219         WindowsMobile = 0x1,
    00220         InkGifSupport = 0x4,
    00221         InkIsfSupport = 0x8,
    00222         SupportWebcam = 0x10,
    00223         SupportMultiPacketMessaging = 0x20,
    00224         MSNMobileDevice = 0x40,
    00225         MSNDirectDevice = 0x80,
    00226         WebMessenger = 0x100,
    00227         OtherSideWebMessenger = 0x200,
    00228         InternalMicrosoftClient = 0x800, //Internal Microsoft client and/or Microsoft Office Live client.
    00229         MSNSpace = 0x1000,
    00230         WinXPMediaCenter = 0x2000, // This means you are using Windows XP Media Center Edition.
    00231         SupportDirectIM =  0x4000,
    00232         SupportWinks = 0x8000,
    00233         MSNSearch = 0x10000,
    00234         VoiceClips = 0x40000,
    00235         SecureChannel = 0x80000,
    00236         SIPInvitations = 0x100000,
    00237         SharingFolders = 0x400000,
    00238         MSNC1 = 0x10000000,
    00239         MSNC2 = 0x20000000,
    00240         MSNC3 = 0x30000000,
    00241         MSNC4 = 0x40000000,
    00242         MSNC5 = 0x50000000,
    00243         MSNC6 = 0x60000000,
    00244         MSNC7 = 0x70000000
    00245     } MSNClientInformationFields;
    00246
    00248     enum fileTransferType
    00249     {
    00250         FILE_TRANSFER_WITH_PREVIEW = 0x0,
    00251         FILE_TRANSFER_WITHOUT_PREVIEW = 0x1,
    00252         FILE_TRANSFER_BACKGROUND_SHARING = 0x4,
    00253         // it is not a simple jpg file, there is a cab file inside it
    00254         FILE_TRANSFER_BACKGROUND_SHARING_CUSTOM = 0xC
    00255     };
    00256
    00258     enum fileTransferError
    00259     {
    00260         FILE_TRANSFER_ERROR_USER_CANCELED,
    00261         FILE_TRANSFER_ERROR_UNKNOWN
    00262     };
    00263
    00265     typedef struct
    00266     {
    00267         int type;
    00268         unsigned int sessionId;
    00269         std::string userPassport;
    00270         std::string filename;
    00271         std::string friendlyname;
    00272         std::string preview;
    00273         unsigned long long filesize;
    00274     } fileTransferInvite;
    00275
    00276     void libmsn_Siren7_DecodeVoiceClip(std::string input_file);
    00277     void libmsn_Siren7_EncodeVoiceClip(std::string input_file);
    00278 }
    00279 #endif

All Classes Namespaces Functions Variables Enumerations Enumerator