⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iksdemo.h

📁 symbina上可以使用一个xml解析器,对开发网络应用很有好处
💻 H
字号:
/* ** Copyright (C) 2005 Darrell Karbott (djk2005@users.sf.net)** This code is free software; you can redistribute it and/or modify** it under the terms of the GNU Public Licence (GPL) version 2 See** http://www.gnu.org/ for further details of the GPL.*/#ifndef __IKSDEMO_h__#define __IKSDEMO_h__#include <iksemel.h>/*** This file contains declarations for a very simple platform** independant asynchronous iksemel demo application.** ** Platform specific implementations must a) Provide an** IUserInterface implementation and b) call the commands defined in** IUserInteractions from their GUI (via CIksDemo::cmd()).**** SUPPORTED FUNCTIONS:** - Connect to Jabber server (via deprecated plaintext auth)** - Send presence to the Jabber server** - Send and receive simple Jabber text messages.** - Rudimentary error reporting** - Disconnect**** LIMITATIONS:** - no registration (i.e. you can only log in using**   an account that already exists on the server)** - no support for the Jabber roster** - no SASL or TLS support** - does not support chat threads** - REQUIRES an ikstransport implementation which supports**   asynchronous socket operations (i.e. NOT io-posix.c).*//*** Abstract interface for a rudimentary UI.*/class IUserInterface { public:  virtual ~IUserInterface() = 0;  // NON-MODAL  virtual void displayJabberMsgFrom(const char* from, const char* msg ) = 0;  // NON-MODAL  virtual void displayStatusMsg(const char* msg) = 0;  // Can be MODAL  virtual void displayErrorMsg(const char* msg) = 0;  virtual void updateConnectionStatus(int bConnected) = 0;};/*** Abstract interface containing the set of operations** that the user can invoke from the UI.*/class IUserInteractions { public:  virtual ~IUserInteractions() = 0;  virtual int connect(const char* jid, const char* password, int port) = 0;  virtual void disconnect() = 0;  virtual int sendMsg(const char* toJid, const char* msg) = 0;};//These values include the trailing \0.const unsigned int MAX_JID_LEN      = 256;const unsigned int MAX_PASSWORD_LEN = 256;const unsigned int MAX_MSG_LEN      = 512;enum LoginStates {   QUIESCENT = 1,   CONNECTING,   RESOLVING,   RESOLVED,   CONNECTED,   AUTHORIZED,   ERROR, };/*** A simple Jabber client that handles commands via** method invocations on IUserInteractions and updates** UI state via callbacks into an IUserInterface** instance.*/class CInteractions;class CIksDemo { public:  // Doesn't take ownership of transport.  CIksDemo(ikstransport* transport);  ~CIksDemo();  // Doesn't take ownership of ui.  int init(IUserInterface* ui);  // Prevents further calls into the IUserInterface.  void releaseUi();  IUserInteractions* cmd(); private:  // iksemel callbacks  static int StreamHook(void *user_data, int type, iks *node);  static void LogHook(void *user_data, const char *data, size_t size, int is_incoming);  static int SocketHook(void *user_data, iksasyncevent* event_data);  int streamHook(int type, iks *node);  void logHook(const char *data, size_t size, int is_incoming);  int socketHook(int reason, int data0, int data1);  void state(const LoginStates& state);  int connect(const char* jid, const char* password, int port);  void disconnect(int bHard = 1);  // Handle normal packets.  void packet(ikspak* packet);    // Send a Jabber message.  int send(const char* toJid, const char* msg);  void checkIksReturnValue(int err, const char* file,  int line);  void displayErrorPacket(ikspak* pak);  void displaySocketError(int data0, int data1); private:  ikstransport* mTransport;  IUserInterface* mUi;  IUserInteractions* mInteractions;  iksparser* mPrs;  LoginStates mState;  char mJid[MAX_JID_LEN];  char mPassword[MAX_PASSWORD_LEN];  int mWriteCount;  int mWrittenCount;  int mReadCount;  int mIsDisconnecting;  friend class CInteractions;};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -