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

📄 nmuser.h

📁 Linux下的多协议即时通讯程序源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * nmuser.h * * Copyright (c) 2004 Novell, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA	02111-1307	USA * */#ifndef __NM_USER_H__#define __NM_USER_H__#include <glib.h>#include <stdio.h>#include <stdlib.h>typedef guint32 NMERR_T;typedef int NMSTATUS_T;typedef struct _NMUser NMUser;typedef enum{	NMREQUEST_TYPE_LOGIN = 0,	NMREQUEST_TYPE_LOGOUT,	NMREQUEST_TYPE_SETSTATUS,	NMREQUEST_TYPE_GETDETAILS,	NMREQUEST_TYPE_CREATECONF,	NMREQUEST_TYPE_SENDMESSAGE,	NMREQUEST_TYPE_JOINCONF,	NMREQUEST_TYPE_LEAVECONF,	NMREQUEST_TYPE_REJECTCONF,	NMREQUEST_TYPE_SENDTYPING,	NMREQUEST_TYPE_CREATECONTACT,	NMREQUEST_TYPE_DELETECONTACT} NMRequestType;#include "debug.h"#include "nmmessage.h"#include "nmconference.h"#include "nmcontact.h"#include "nmuserrecord.h"#include "nmfield.h"#include "nmevent.h"/* Callback typedefs */typedef void (*nm_response_cb) (NMUser * user, NMERR_T ret_code,								gpointer resp_data, gpointer user_data);typedef void (*nm_event_cb) (NMUser * user, NMEvent * event);#include "nmrequest.h"#include "nmconn.h"/* This represents user that we are currently logged in as */struct _NMUser{	char *name;	NMSTATUS_T status;	/* A copy of the login response fields */	NMField *fields;	/* The user record for this user */	NMUserRecord *user_record;	/* Our connection information */	NMConn *conn;	/* Our public IP address */	char *address;	/* This is the contact list */	NMFolder *root_folder;	/* All contacts that we know about hashed by dn */	GHashTable *contacts;	/* All user records hashed by dn */	GHashTable *user_records;	/* DN lookup */	GHashTable *display_id_to_dn;	/* One on one conversations indexed by recipient's dn */	GSList *conferences;	guint32 conference_count;	/* Called when we receive an event */	nm_event_cb evt_callback;	/* Privacy settings */	gboolean privacy_locked;	gboolean default_deny;	GSList *allow_list;	GSList *deny_list;	/* Pending requests. If we need to go to the server to more info	 * before processing a request we will queue it up and process when	 * we get a response	 */	GSList *pending_requests;	/* Pending events. Same as above except for events. */	GSList *pending_events;	/* Generic pointer to data needed by the client	 * using the API	 */	gpointer client_data;	/* Have the privacy lists been synched yet */	gboolean privacy_synched;	/* Has the contact list been synched */	gboolean clist_synched;};#define	NM_STATUS_UNKNOWN			0#define	NM_STATUS_OFFLINE			1#define NM_STATUS_AVAILABLE			2#define	NM_STATUS_BUSY				3#define	NM_STATUS_AWAY				4#define	NM_STATUS_AWAY_IDLE			5#define	NM_STATUS_INVALID			6#define NMERR_BASE							0x2000L#define NM_OK								0L#define NMERR_BAD_PARM						(NMERR_BASE + 0x0001)#define NMERR_TCP_WRITE						(NMERR_BASE + 0x0002)#define NMERR_TCP_READ						(NMERR_BASE + 0x0003)#define NMERR_PROTOCOL						(NMERR_BASE + 0x0004)#define NMERR_SERVER_REDIRECT				(NMERR_BASE + 0x0005)#define NMERR_CONFERENCE_NOT_FOUND 			(NMERR_BASE + 0x0006)#define NMERR_CONFERENCE_NOT_INSTANTIATED 	(NMERR_BASE + 0x0007)#define NMERR_FOLDER_EXISTS					(NMERR_BASE + 0x0008)/* Errors that are returned from the server */#define NMERR_SERVER_BASE			 	0xD100L#define NMERR_ACCESS_DENIED			 	(NMERR_SERVER_BASE + 0x0006)#define NMERR_NOT_SUPPORTED          	(NMERR_SERVER_BASE + 0x000A)#define NMERR_PASSWORD_EXPIRED       	(NMERR_SERVER_BASE + 0x000B)#define NMERR_PASSWORD_INVALID       	(NMERR_SERVER_BASE + 0x000C)#define NMERR_USER_NOT_FOUND         	(NMERR_SERVER_BASE + 0x000D)#define NMERR_USER_DISABLED          	(NMERR_SERVER_BASE + 0x0010)#define NMERR_DIRECTORY_FAILURE      	(NMERR_SERVER_BASE + 0x0011)#define NMERR_HOST_NOT_FOUND		 	(NMERR_SERVER_BASE + 0x0019)#define NMERR_ADMIN_LOCKED           	(NMERR_SERVER_BASE + 0x001C)#define NMERR_DUPLICATE_PARTICIPANT  	(NMERR_SERVER_BASE + 0x001F)#define NMERR_SERVER_BUSY            	(NMERR_SERVER_BASE + 0x0023)#define NMERR_OBJECT_NOT_FOUND       	(NMERR_SERVER_BASE + 0x0024)#define NMERR_DIRECTORY_UPDATE       	(NMERR_SERVER_BASE + 0x0025)#define NMERR_DUPLICATE_FOLDER       	(NMERR_SERVER_BASE + 0x0026)#define NMERR_DUPLICATE_CONTACT      	(NMERR_SERVER_BASE + 0x0027)#define NMERR_USER_NOT_ALLOWED       	(NMERR_SERVER_BASE + 0x0028)#define NMERR_TOO_MANY_CONTACTS      	(NMERR_SERVER_BASE + 0x0029)#define NMERR_CONFERENCE_NOT_FOUND_2   	(NMERR_SERVER_BASE + 0x002B)#define NMERR_TOO_MANY_FOLDERS       	(NMERR_SERVER_BASE + 0x002C)#define NMERR_SERVER_PROTOCOL        	(NMERR_SERVER_BASE + 0x0030)#define NMERR_CONVERSATION_INVITE		(NMERR_SERVER_BASE + 0x0035)#define NMERR_USER_BLOCKED	         	(NMERR_SERVER_BASE + 0x0039)#define NMERR_MASTER_ARCHIVE_MISSING 	(NMERR_SERVER_BASE + 0x003A)#define NMERR_PASSWORD_EXPIRED_2     	(NMERR_SERVER_BASE + 0x0042)#define NMERR_CREDENTIALS_MISSING   	(NMERR_SERVER_BASE + 0x0046)#define NMERR_AUTHENTICATION_FAILED		(NMERR_SERVER_BASE + 0x0049)#define NMERR_EVAL_CONNECTION_LIMIT		(NMERR_SERVER_BASE + 0x004A)/** *	Initialize the user that we are going to login to the system as. * *	@param	name			The userid of the user *	@param	server			IP Address of server *	@param	port			Port to connect to on the server *  @param 	data			Client data to associate with the user *	@param	event_callback	Function to call when we receive an event * *	@return The initialized user object. Must be freed by calling *			nm_deinitialize_user */NMUser *nm_initialize_user(const char *name, const char *server, int port,						   gpointer data, nm_event_cb event_callback);/** *	Free up resources associated with the user object. * *  @param	user	The user to deinitialize */void nm_deinitialize_user(NMUser * user);/** *	Send a login request to the server. * *	The response data sent to the callback will be NULL. * *  @param	user		The User to login -- must be initialized *	@param	pwd			The password of the user *  @param  my_addr		The address of the client machine *  @param	user_agent	String describing the client (eg. "Purple/0.76 (Linux; 2.4.20)") *	@param	callback	Function to call when we get the response from the server *  @param 	data		User defined data to be passed to the callback function * * *	@return	NM_OK if login is sent successfully, error otherwise. */NMERR_T nm_send_login(NMUser * user, const char *pwd, const char *my_addr,					  const char *user_agent, nm_response_cb callback,					  gpointer data);/** *	Send a set status request to the server. * *	The response data sent to the callback will be NULL. * *  @param	user		The logged in User *	@param	dn			The DN of the user (if known, or NULL if not known) *	@param	address		IP Address of server *	@param	callback	Function to call when we get the response from the server * * *	@return	NM_OK if successfully sent, error otherwise */NMERR_T nm_send_set_status(NMUser * user, int status, const char *text,						   const char *auto_resp, nm_response_cb callback,						   gpointer data);/** *	Send a create conference to the server. * *	The response data sent to the callback will be NULL. * *  @param	user			 The logged in User *	@param	conference		 Conference to create *	@param	add_participants Add participant list on create? *	@param	callback		 Function to call when we get the response from the server *	@param	data			 User defined data to be passed to the callback function * *	@return	NM_OK if successfully sent, error otherwise */NMERR_T nm_send_create_conference(NMUser * user, NMConference * conference,								  nm_response_cb callback, gpointer data);/** *	Tell server we have left the conference. * *	The response data sent to the callback will be NULL. * *  @param	user		The logged in User *	@param	conference	Conference the user is leaving *	@param	callback	Function to call when we get the response from the server *	@param	data		User defined data to be passed to the callback function * *	@return	NM_OK if successfully sent, error otherwise */NMERR_T nm_send_leave_conference(NMUser * user, NMConference * conference,								 nm_response_cb callback, gpointer data);/** *	Send a join conference request to the server. * *	The response data sent to the callback will be NULL. * *  @param	user		The logged in User *	@param	conference	Conference the user is joining *	@param	callback	Function to call when we get the response from the server *	@param	data		User defined data to be passed to the callback function * * *	@return	NM_OK if successfully sent, error otherwise */NMERR_T nm_send_join_conference(NMUser * user, NMConference * conference,								nm_response_cb callback, gpointer data);/** *	Send a conference reject request to the server. * *	The response data sent to the callback will be NULL. * *  @param	user		The logged in User *	@param	conference	Conference the user is rejecting *	@param	callback	Function to call when we get the response from the server *	@param	data		User defined data to be passed to the callback function * * *	@return	NM_OK if successfully sent, error otherwise */NMERR_T nm_send_reject_conference(NMUser * user, NMConference * conference,								  nm_response_cb callback, gpointer data);/** *	Send a conference invitation to the server. * *	The response data sent to the callback will be NULL. * *  @param	user		The logged in User *	@param	conference	Conference the user is rejecting *  @param  user_record The user to invite *  @param  message		The invite message if there is one, NULL otherwise *	@param	callback	Function to call when we get the response from the server *	@param	data		User defined data to be passed to the callback function * * *	@return	NM_OK if successfully sent, error otherwise */NMERR_T nm_send_conference_invite(NMUser *user, NMConference *conference, NMUserRecord *user_record,								  const char *message, nm_response_cb callback, gpointer data);/** *	Get details for a more than one user from the server. * *	The response data sent to the callback will be an NMUserRecord which should be *  freed with nm_release_user_record * *  @param	user		The logged in User *	@param	names		Link list of user id's or dn's *	@param	callback	Function to call when we get the response from the server *	@param	data		User defined data to be passed to the callback function * *	@return	NM_OK if successfully sent, error otherwise */NMERR_T nm_send_multiple_get_details(NMUser * user, GSList *names,									 nm_response_cb callback, gpointer data);/** *	Get details for a user from the server.

⌨️ 快捷键说明

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