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

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_PLUGIN_H
  12. #define _ICQ_PLUGIN_H
  13. #include "icqtypes.h"
  14. #include "plugin.h"
  15. #include <map>
  16. using namespace std;
  17. class IcqLink;
  18. class TcpSessionListener;
  19. class TcpSessionBase;
  20. class IcqContact;
  21. class FaceLoader;
  22. class IcqProfile;
  23. typedef int (*GETTYPE)();
  24. typedef TcpSessionListener *(*CREATESESSION)(TcpSessionBase *tcp);
  25. typedef void *(*GETNAMEICON)(string &name);
  26. typedef bool (*INIT)(IcqLink *link, IcqProfile *profile);
  27. typedef void (*CONFIGURE)(IcqProfile *profile);
  28. typedef void (*ABOUT)();
  29. class IcqPlugin {
  30. public:
  31. virtual ~IcqPlugin() {}
  32. string name;
  33. int type;
  34. };
  35. class NetPlugin : public IcqPlugin {
  36. public:
  37. GETNAMEICON getNameIcon;
  38. CREATESESSION createSession;
  39. };
  40. class ToyPlugin : public IcqPlugin {
  41. public:
  42. GETNAMEICON getNameIcon;
  43. INIT init;
  44. CONFIGURE configure;
  45. ABOUT about;
  46. };
  47. class ExePlugin : public IcqPlugin {
  48. public:
  49. void execClient(IcqContact *c);
  50. void execServer(IcqContact *c);
  51. string locName;
  52. void *icon;
  53. string clientCmd;
  54. string serverCmd;
  55. private:
  56. void getCmd(string &cmd, const char *line, IcqContact *c);
  57. void execCmd(const char *cmd);
  58. };
  59. typedef map<string, IcqPlugin *> PLUGINMAP;
  60. class PluginFactory {
  61. public:
  62. static bool init();
  63. static void destroy();
  64. static bool registerPlugin(IcqPlugin *p);
  65. static IcqPlugin *getPlugin(const string &name) {
  66. return pluginMap[name];
  67. }
  68. static PtrList getPluginList() {
  69. return pluginList;
  70. }
  71. private:
  72. static PtrList pluginList;
  73. static PLUGINMAP pluginMap;
  74. };
  75. #endif