Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

evautil.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004-2005 by yunfan                                     *
00003  *   yunfan_zg@163.com                                                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef LIBEVAUTIL_H
00021 #define LIBEVAUTIL_H
00022 
00023 #include <string>
00024 #include "md5.h"
00025 #define KEY_LENGTH 16
00026 #define QQ_SMILEY_AMOUNT 96
00027 
00029 #ifdef WIN32
00030 #pragma warning(disable: 4309 4800)
00031 typedef unsigned int uint;
00032 typedef unsigned char uint8_t;
00033 #include <malloc.h>
00034 #endif
00035 
00036 // this class provides some utilities, like md5 function and parse text smiley into ready to send smiley code.
00037 
00038 class EvaUtil{
00039 public:
00040         EvaUtil();
00041         // the following 2 functions alway return 16 bytes due to the protocol used by QQ
00042         static char *doMd5(char *in, int len);
00043         static char *doMd5Md5(char *in, int len);
00044         
00045         static std::string smileyToText(const char smileyCode);     // get text description of the smiley code
00046         static char textToSmiley(const std::string &textTag);      // get smiley code of the text description
00047         static int textToFileIndex(const std::string &textTag);  // get the file name in integer of the smiley text description 
00048         static std::string fileIndexToText( const int fileIndex);
00049         static std::string convertToSend(const std::string &text);
00050         static std::string convertToSend(const std::string &text, bool *hasImage);
00051         static void initMap();
00052         
00053         static std::string customSmileyToText(const char *buf, int *smileyLength, const char *uuid);
00054         
00055         static void calcSuns(const unsigned short level, int *suns, int *moons, int *stars);
00056         typedef struct textMap{
00057                 //char gb[5];             // chinese charactor not supported, cuz only few people use them
00058                 char en[16];
00059                 char py[16];
00060         } textMap;
00061 
00062         static int write16(unsigned char *buf, const unsigned short value); // return number of bytes written
00063         static int write32(unsigned char *buf, const unsigned int value);   // return number of bytes writen
00064         static unsigned short read16(const unsigned char *buf); // return the short value
00065         static unsigned int read32(const unsigned char *buf);  // return the int value
00066 private:        
00067         static char md5Buf[KEY_LENGTH];
00068         static textMap map[QQ_SMILEY_AMOUNT];
00069         static const char smileyMap[QQ_SMILEY_AMOUNT];
00070         static int smileyToFileIndex( const char smileyCode);
00071         
00072 };
00073 
00074 #endif
00075  

Generated on Mon May 15 20:48:41 2006 for libeva by  doxygen 1.4.4