icqclient.h
上传用户:zslianheng
上传日期:2013-04-03
资源大小:946k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Visual C++

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *   This program is free software; you can redistribute it and/or modify  *
  4.  *   it under the terms of the GNU General Public License as published by  *
  5.  *   the Free Software Foundation; either version 2 of the License, or     *
  6.  *   (at your option) any later version.                                   *
  7.  *                                                                         *
  8.  *   copyright            : (C) 2002 by Zhang Yong                         *
  9.  *   email                : z-yong163@163.com                              *
  10.  ***************************************************************************/
  11. #ifndef _ICQ_CLIENT_H
  12. #define _ICQ_CLIENT_H
  13. #include "icqdb.h"
  14. #include "contactinfo.h"
  15. enum {
  16. LOGIN_SUCCESS,
  17. LOGIN_INVALID_UIN,
  18. LOGIN_WRONG_PASSWD,
  19. };
  20. enum {
  21. MSG_TEXT,
  22. MSG_AUTO_REPLY,
  23. MSG_AUTH_ACCEPTED,
  24. MSG_AUTH_REQUEST,
  25. MSG_AUTH_REJECTED,
  26. MSG_ADDED,
  27. MSG_TCP_REQUEST,
  28. MSG_TCP_ACCEPTED,
  29. MSG_TCP_REJECTED,
  30. };
  31. enum {
  32. ADD_FRIEND_ACCEPTED,
  33. ADD_FRIEND_AUTH_REQ,
  34. ADD_FRIEND_REJECTED,
  35. };
  36. enum {
  37. CONTACT_FRIEND,
  38. CONTACT_STRANGER,
  39. CONTACT_IGNORE
  40. };
  41. enum {
  42. CF_OPTION_INVISIBLE,
  43. CF_OPTION_POPUP_ONLINE,
  44. CF_OPTION_GREETING,
  45. CF_OPTION_POPUP_OFFLINE,
  46. CF_OPTION_IGNORE,
  47. CF_CUSTOMSOUND,
  48. CF_DIALOGMODE,
  49. CF_SENDENTER,
  50. NR_CONTACT_FLAGS
  51. };
  52. enum {
  53. UF_ALWAYS_ON_TOP,
  54. UF_TASKBAR_STYLE,
  55. UF_ONLINE_NOTIFY,
  56. UF_MONITOR_NETWORK,
  57. UF_COLORFUL_URL,
  58. UF_TASKBAR_ICON,
  59. UF_SHOW_ONLINE,
  60. UF_AUTO_POPUP_MSG,
  61. UF_IGNORE_STRANGER,
  62. UF_LOGIN_INVIS,
  63. UF_USE_HOTKEY,
  64. UF_DEFAULT_HOTKEY,
  65. UF_USE_PROXY,
  66. UF_SOUND_ON,
  67. UF_AUTO_REPLY,
  68. UF_AUTO_SWITCH_STATUS,
  69. UF_AUTO_CANCEL_AWAY,
  70. UF_STORE_PASSWD,
  71. NR_USER_FLAGS
  72. };
  73. enum {
  74. SOUND_ONLINE,
  75. SOUND_MSG,
  76. SOUND_SYSMSG,
  77. SOUND_FOLDER,
  78. NR_SOUNDS
  79. };
  80. enum {
  81. PROXY_SOCKS,
  82. PROXY_HTTP,
  83. NR_PROXY_TYPES
  84. };
  85. #define MYICQ_TCP_VER 1
  86. #define NR_CUSTOM_SOUNDS 2
  87. #define MF_RECEIVED 0x01
  88. #define MF_RELAY 0x02
  89. struct SEARCH_RESULT {
  90. uint32 uin;
  91. uint8 online;
  92. uint8 face;
  93. string nick;
  94. string province;
  95. };
  96. class IcqMsg : public DBSerialize {
  97. public:
  98. bool isSysMsg();
  99. void save(DBOutStream &out);
  100. void load(DBInStream &in);
  101. uint8 type;
  102. uint8 flags;
  103. uint32 uin;
  104. uint32 when;
  105. string text;
  106. };
  107. class IcqInfo : public ContactInfo, public DBSerialize {
  108. public:
  109. IcqInfo();
  110. void save(DBOutStream &out);
  111. void load(DBInStream &in);
  112. };
  113. class IcqContact : public IcqInfo {
  114. public:
  115. IcqContact();
  116. ~IcqContact();
  117. void load(DBInStream &in);
  118. void save(DBOutStream &out);
  119. int type;
  120. uint32 ip;
  121. uint16 port;
  122. uint32 realIP;
  123. bitset<NR_CONTACT_FLAGS> flags;
  124. string soundFiles[NR_CUSTOM_SOUNDS];
  125. string greeting;
  126. int winX, winY;
  127. };
  128. class IcqUser : public IcqInfo {
  129. public:
  130. IcqUser();
  131. void load(DBInStream &in);
  132. void save(DBOutStream &out);
  133. string passwd;
  134. uint8 auth;
  135. };
  136. class ProxyInfo : public DBSerialize {
  137. public:
  138. ProxyInfo() {
  139. port = 0;
  140. resolve = 0;
  141. }
  142. void load(DBInStream &in);
  143. void save(DBOutStream &out);
  144. string host;
  145. uint16 port;
  146. string username;
  147. string passwd;
  148. uint8 resolve;
  149. };
  150. class IcqOption : public DBSerialize {
  151. public:
  152. IcqOption();
  153. ~IcqOption();
  154. void load(DBInStream &in);
  155. void save(DBOutStream &out);
  156. void playSound(int sound, IcqContact *c = NULL);
  157. bitset<NR_USER_FLAGS> flags;
  158. uint32 hotKey;
  159. string soundFiles[NR_SOUNDS];
  160. string host;
  161. uint16 port;
  162. string autoReplyText;
  163. string quickReplyText;
  164. uint32 autoStatus;
  165. uint32 autoStatusTime;
  166. string skin;
  167. uint8 proxyType;
  168. ProxyInfo proxy[NR_PROXY_TYPES];
  169. private:
  170. bool playSound(const char *file);
  171. };
  172. #define MAX_MSG_LEN 512
  173. class TextOutStream {
  174. public:
  175. TextOutStream() {
  176. cursor = text;
  177. }
  178. TextOutStream &operator <<(uint32 dw);
  179. TextOutStream &operator <<(const char *str);
  180. operator const char *() {
  181. return text;
  182. }
  183. private:
  184. char text[MAX_MSG_LEN];
  185. char *cursor;
  186. };
  187. class TextInStream {
  188. public:
  189. TextInStream(const char *s);
  190. TextInStream &operator >>(uint8 &b);
  191. TextInStream &operator >>(uint16 &w);
  192. TextInStream &operator >>(uint32 &dw);
  193. TextInStream &operator >>(string &s);
  194. private:
  195. char text[MAX_MSG_LEN];
  196. char *cursor;
  197. };
  198. #endif