view src/protocols/yahoo/yay.h @ 2154:cff133e0ec0c

[gaim-migrate @ 2164] part 2 of this. first was removing mail notifications; this is moving proto_opt stuff to multi.c and just having prpls say what they want. next it's on to the buddy right-click menu. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 22 Aug 2001 22:05:56 +0000
parents 424a40f12a6c
children
line wrap: on
line source

/*
 * libyay
 *
 * Copyright (C) 2001 Eric Warmenhoven <warmenhoven@yahoo.com>
 * 
 * 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; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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 _LIBYAY_H
#define _LIBYAY_H

#include <glib.h>
#include <unistd.h>
#include <errno.h>
#include <stdarg.h>
#include <sys/types.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>

struct yahoo_session;

#define YAHOO_PROXY_NONE 0
#define YAHOO_PROXY_HTTP 1

#define YAHOO_AUTH_HOST "msg.edit.yahoo.com"
#define YAHOO_AUTH_PORT 80
#define YAHOO_PAGER_HOST "cs.yahoo.com"
#define YAHOO_PAGER_PORT 5050

enum yahoo_status {
	YAHOO_STATUS_AVAILABLE,
	YAHOO_STATUS_BRB,
	YAHOO_STATUS_BUSY,
	YAHOO_STATUS_NOTATHOME,
	YAHOO_STATUS_NOTATDESK,
	YAHOO_STATUS_NOTINOFFICE,
	YAHOO_STATUS_ONPHONE,
	YAHOO_STATUS_ONVACATION,
	YAHOO_STATUS_OUTTOLUNCH,
	YAHOO_STATUS_STEPPEDOUT,
	YAHOO_STATUS_INVISIBLE = 12,
	YAHOO_STATUS_CUSTOM = 99,
	YAHOO_STATUS_IDLE = 999
};

struct yahoo_session *yahoo_new();
void yahoo_set_proxy(struct yahoo_session *session, int proxy_type, char *proxy_host, int proxy_port);
int yahoo_connect(struct yahoo_session *session, const char *host, int port);
int yahoo_send_login(struct yahoo_session *session, const char *name, const char *password);
int yahoo_major_connect(struct yahoo_session *session, const char *host, int port);
int yahoo_finish_logon(struct yahoo_session *session, enum yahoo_status status);
int yahoo_logoff(struct yahoo_session *session);
int yahoo_disconnect(struct yahoo_session *session);
int yahoo_delete(struct yahoo_session *session);

int yahoo_activate_id(struct yahoo_session *session, char *id);
int yahoo_deactivate_id(struct yahoo_session *session, char *id);
int yahoo_send_message(struct yahoo_session *session, const char *id, const char *user, const char *msg);
int yahoo_send_message_offline(struct yahoo_session *session, const char *id,
		const char *user, const char *msg);
int yahoo_away(struct yahoo_session *session, enum yahoo_status stats, char *msg);
int yahoo_back(struct yahoo_session *session, enum yahoo_status stats, char *msg);
int yahoo_ping(struct yahoo_session *session);

int yahoo_add_buddy(struct yahoo_session *session, const char *active_id,
		const char *group, const char *buddy, const char *message);
int yahoo_remove_buddy(struct yahoo_session *session, const char *active_id,
		const char *group, const char *buddy, const char *message);

extern void (*yahoo_socket_notify)(struct yahoo_session *session, int socket, int type, gboolean status);
#define YAHOO_SOCKET_READ  1
#define YAHOO_SOCKET_WRITE 2
void yahoo_socket_handler(struct yahoo_session *session, int socket, int type);

extern void (*yahoo_print)(struct yahoo_session *session, int level, const char *log);
#define YAHOO_LOG_DEBUG    4
#define YAHOO_LOG_NOTICE   3
#define YAHOO_LOG_WARNING  2
#define YAHOO_LOG_ERROR    1
#define YAHOO_LOG_CRITICAL 0

extern int (*yahoo_connector)(struct yahoo_session *session, const char *host, int port, gpointer data);
int yahoo_connected(struct yahoo_session *session, gpointer data, int fd);

typedef int (*yahoo_callback)(struct yahoo_session *session, ...);
void yahoo_add_handler(struct yahoo_session *session, int type, yahoo_callback function);
#define YAHOO_HANDLE_DISCONNECT   0
#define YAHOO_HANDLE_AUTHCONNECT  1
#define YAHOO_HANDLE_BADPASSWORD  2
#define YAHOO_HANDLE_LOGINCOOKIE  3
#define YAHOO_HANDLE_MAINCONNECT  4
#define YAHOO_HANDLE_ONLINE       5
#define YAHOO_HANDLE_NEWMAIL      6
#define YAHOO_HANDLE_MESSAGE      7
#define YAHOO_HANDLE_BOUNCE       8
#define YAHOO_HANDLE_STATUS       9
#define YAHOO_HANDLE_ACTIVATE    10
#define YAHOO_HANDLE_BUDDYADDED  11
#define YAHOO_HANDLE_MAX         12

struct callback {
	yahoo_callback function;
	void *data;
};

struct yahoo_group {
	char *name;
	char **buddies;
};

struct yahoo_session {
	void *user_data;
	struct callback callbacks[YAHOO_HANDLE_MAX];

	int proxy_type;
	char *proxy_host;
	int proxy_port;

	char *auth_host;
	int auth_port;
	char *pager_host;
	int pager_port;

	char *name;

	char *cookie;
	char *login_cookie;
	GList *connlist;

	GList *groups;
	GList *ignored;

	char **identities;
	int mail;
	char *login;
};

#endif