Index: unk/instant_messenger/setup/setup.inc.php
===================================================================
--- /trunk/instant_messenger/setup/setup.inc.php	(revision 151)
+++ 	(revision )
@@ -1,31 +1,0 @@
-<?php
-	/******************************************************\
-	 * Im - Instant Messenger										*
-	 * Alexandre Correia												*
-	 * Rodrigo Souza													*
-	\******************************************************/
-	
-	$setup_info['instant_messenger']['name']      	= 'instant_messenger';
-	$setup_info['instant_messenger']['title']     	= 'Mensageiro Instantâneo';
-	$setup_info['instant_messenger']['version']   	= '0.3';
-	$setup_info['instant_messenger']['app_order'] 	= 9;
-	$setup_info['instant_messenger']['enable']    	= 1;
-	
-	/* Conf Table */
-	
-	$setup_info['instant_messenger']['author'] 			= '<b>Coordenadores do Projeto</b> : <br> - Joao Alfredo Knopik Junior (jakjr@celepar.pr.gov.br)<br> - Nilton Emilio Buhrer Neto (niltonneto@celepar.pr.gov.br)<br> <b>Desenvolvedores</b> <br> - Alexandre Correia (alexandrecorreia@celepar.pr.gov.br)<br>- Rodrigo Souza Santos (rodsouza@celepar.pr.gov.br)';
-	$setup_info['instant_messenger']['maintainer']	 	=  'Os mesmos';
-	$setup_info['instant_messenger']['maintainer_email']= '';
-
-	$setup_info['instant_messenger']['license']  	= 'GPL';
-	$setup_info['instant_messenger']['description'] = 'Módulo de IM com Jabber';
-
-	/* The hooks this app includes, needed for hooks registration */
-	$setup_info['instant_messenger']['hooks'][] = 'admin';
-		
-	/* Dependencies for this app to work */
-	$setup_info['instant_messenger']['depends'][] = array(
-		'appname' => 'phpgwapi',
-		'versions' => Array('0.9.14','0.9.15','1.0.0')
-	);
-?>
Index: unk/instant_messenger/webjabber/webjabber.cfg
===================================================================
--- /trunk/instant_messenger/webjabber/webjabber.cfg	(revision 238)
+++ 	(revision )
@@ -1,5 +1,0 @@
-10.15.20.202
-10.15.20.205
-10.15.20.42
-10.15.20.6
-127.0.0.1
Index: unk/instant_messenger/webjabber/webjabber.c
===================================================================
--- /trunk/instant_messenger/webjabber/webjabber.c	(revision 238)
+++ 	(revision )
@@ -1,1191 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <signal.h>
-#include <sys/wait.h>
-/*
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-*/
-#include <fcntl.h>
-
-// Buffer size, in bytes, used for copying in the Cat() function.
-const size_t BUF_SIZE = 4096;
-
-// Typedef for a signal handler function.
-typedef void (*signal_handler_t) (int);
-
-// Global variables
-char g_program_name[100];	// Initialised from argv[0] in ParseArgs()
-struct allowed_ip * allowed_ips = (struct allowed_ip *)NULL;
-int quantity_of_fd = 0;		// quantity of file descriptor
-
-static struct connections * connections = (struct connections *)NULL;
-pthread_mutex_t mutexsum;
-
-// structs
-struct allowed_ip
-{
-	char * ip;
-	struct allowed_ip * next;
-};
-
-struct accept
-{
-	int * fd;
-	struct sockaddr_in sa;
-	struct in_addr jabber_addr;
-	unsigned short jabber_port;
-	pthread_t accept_thread;
-};
-
-struct client
-{
-	char * user,
-		 * pass;
-	int * jabber_fd,
-		* read_fd;
-	time_t last_access;
-};
-
-struct connections
-{
-	struct client * client;
-	struct connections * next;
-};
-
-struct read_write
-{
-	int * jabber,
-		client,
-		type;
-	pthread_t read,
-			  write;
-};
-
-void recursive (int, struct in_addr, unsigned short);
-int getPermission(char *);
-void ParseArgs (int, char **, struct in_addr *, unsigned short *, struct in_addr *, unsigned short *);
-void Initialise (void);
-void sig_child (int);
-int CreateServerSocket (struct in_addr, unsigned short);
-void Daemonise (void);
-void MainLoop (int, struct in_addr, unsigned short);
-void ClearList(void);
-struct accept * AcceptClientConnection (int);
-void VerifyClient(void *);
-struct client * Handshake (struct accept *, struct read_write *);
-void * withConnections(void * (*func)(), ...);
-//struct client * LookFor (char *, char *);
-//void * LookFor (struct connections *, char *, char *);
-void * LookFor (char *, char *);
-void Reading (void *);
-void Writing (void *);
-int ConnectToServer (struct in_addr, unsigned short);
-int NameToAddr (const char *, struct in_addr *);
-int NameToPort (const char *, unsigned short *, const char *);
-#ifdef __GNUC__
-	void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *, ...);
-	void pbomb (const char *, ...);
-	void hbomb (const char *, ...);
-#endif
-void set_signal_handler (int, signal_handler_t);
-
-int main (int argc, char ** argv)
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	//pthread_t clear_list_thread;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise ();
-
-	// Create server socket before becoming a daemon so
-	// there is still a chance to print an error message.
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb ("Unable to create server socket");
-
-	//Daemonise ();
-
-	//pthread_mutex_init(&mutexsum, NULL);
-	//pthread_create(&clear_list_thread, NULL, (void *) &ClearList, (void *)NULL );
-
-	//MainLoop (listen_fd, remote_addr, remote_port); // never returns
-	recursive(listen_fd, remote_addr, remote_port);
-
-	//pthread_mutex_destroy(&mutexsum);
-
-	exit (EXIT_SUCCESS);
-}
-
-void recursive (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	//while ( 1 )
-	//	sleep(1);
-	//exit(0);
-
-	pid_t helper_pid;
-
-	syslog (LOG_INFO, "recursive()");
-
-	signal (SIGCHLD, SIG_IGN);
-
-	helper_pid = fork ();
-	if ( helper_pid == -1 )
-		syslog (LOG_ERR, "fork() on recursive(): %m"), exit (EXIT_FAILURE);
-
-	if ( helper_pid )               /* parent */
-	{
-		//syslog (LOG_INFO, "Forked child pid %d to help with MainLoop", helper_pid);
-		wait(0);                 /* wait for helper to exit */
-	}
-	else                          /* child (helper) */
-	{
-		MainLoop (listen_fd, rem_addr, rem_port);
-
-		syslog (LOG_INFO, "exiting");
-		exit (0);                 /* helper exits here */
-	}
-	recursive(listen_fd, rem_addr, rem_port);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char ** argv, struct in_addr * ra, unsigned short * rp, struct in_addr * la, unsigned short * lp)
-{
-	// argv[0] = program name
-	// argv[1] = remote_addr
-	// argv[2] = remote_port
-	// argv[3] = local_addr (optional)
-	// argv[4] = local_port (optional)
-
-	char * p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr (argv[1], ra) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort (argv[2], rp, "tcp") )
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl (INADDR_ANY);
-	else
-		if ( NameToAddr (argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy (lp, rp, sizeof (*lp));
-	else
-		if ( NameToPort (argv[4], lp, "tcp") )
-			quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-int getPermission(char * ip)
-{
-	struct allowed_ip * allow_ip = allowed_ips;
-	int allow = 0;
-
-	while ( !allow && allow_ip->next != (struct allowed_ip *)NULL )
-	{
-		//printf("strcmp(%s, %s)\n\n", ip, allow_ip->ip);
-		if ( strcmp(ip, allow_ip->ip) == 0 )
-			allow = 1;
-		else
-			allow_ip = allow_ip->next;
-	}
-
-	return allow;
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	FILE * allowed_ips_fd;
-	struct allowed_ip * allow_ip;
-
-	if ( !(allowed_ips_fd = fopen("webjabber.cfg", "r")) )
-		syslog (LOG_ERR, "Impossivel abrir o arquivo 'webjabber.cfg'"), exit (EXIT_FAILURE);
-
-	while ( !feof(allowed_ips_fd) )
-	{
-		char * line = (char *) malloc(16 * sizeof(char));
-
-		bzero(line, 16);
-		fgets(line, 16, allowed_ips_fd);
-
-		if ( strlen(line) )
-		{
-			if ( line[strlen(line) - 1] == '\n' )
-				line[strlen(line) - 1] = '\0';
-
-			if ( allowed_ips == (struct allowed_ip *)NULL )
-				allow_ip = allowed_ips = (struct allowed_ip *) malloc(sizeof(struct allowed_ip));
-			else
-			{
-				allow_ip = allowed_ips;
-				while ( allow_ip->next != (struct allowed_ip *)NULL )
-					allow_ip = allow_ip->next;
-				allow_ip->next = (struct allowed_ip *) malloc(sizeof(struct allowed_ip));
-				allow_ip = allow_ip->next;
-			}
-			allow_ip->next = (struct allowed_ip *)NULL;
-			allow_ip->ip = line;
-		}
-	}
-
-	char * initial_path = (char *) malloc(128 * sizeof(char));
-	getcwd(initial_path, 128);
-
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started in path [#%d] %s", g_program_name, strlen(initial_path), initial_path);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	set_signal_handler (SIGCHLD, sig_child);
-
-	signal (SIGPIPE, SIG_IGN);
-}
-
-// sig_child(): Handles SIGCHLD from exiting child processes.
-void sig_child (int signo)
-{
-	pid_t pid;
-
-	(void) signo; // suppress compiler warning
-
-	for ( ; ; )
-	{
-		pid = waitpid (WAIT_ANY, NULL, WNOHANG);
-
-		if (pid > 0)
-			syslog (LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		else
-			break;
-	}
-
-	if ((pid < 0) && (errno != ECHILD))
-		syslog (LOG_ERR, "waitpid(): %m"), exit (EXIT_FAILURE);
-
-	return;
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	//sa.sin_addr = addr;
-	sa.sin_addr.s_addr = htonl(INADDR_ANY);
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if ( err < 0 )
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-// Daemonise(): Put the program in the background, set PPID=1, create a new
-// session and process group, without a controlling tty.
-void Daemonise (void)
-{
-	pid_t pid;
-
-	/* Close stdin, stdout & stderr */
-	/* TODO: open /dev/null and dup the fd to stdin, stdout & stderr
-	 *      close(STDIN_FILENO);
-	 *           close(STDOUT_FILENO);
-	 *                close(STDERR_FILENO);
-	 *                   */
-
-	syslog (LOG_INFO, "%s daemonising", g_program_name);
-
-	/* Fork the process to put it in the background. */
-
-	pid = fork ();
-	if (pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	/* parent terminates here, so shell thinks the command is done. */
-	if (pid)
-		exit (0);
-
-	syslog (LOG_INFO, "%s in background", g_program_name);
-
-	/* 1st child continues to run in the background with PPID=1 */
-
-	/* Become leader of a new session and a new process group,
-	 *      with no controlling tty.  */
-	setsid ();
-
-	/* Fork again to guarantee the process will not be able to aquire a
-	 *      controlling tty. */
-
-	/*signal (SIGHUP, SIG_IGN); *//* required according to Stevens' UNP2 p333 */
-
-	pid = fork ();
-	if (pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if (pid)                      /* 1st child terminates */
-		exit (0);
-
-	/* 2nd child continues, no longer a session or group leader */
-
-	syslog (LOG_INFO, "%s daemonised", g_program_name);
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	//pid_t helper_pid;
-	pthread_t clear_list_thread;
-
-	syslog (LOG_INFO, "MainLoop :: listen_fd(fd%d)", listen_fd);
-	//signal (SIGCHLD, SIG_IGN);
-
-	pthread_mutex_init(&mutexsum, NULL);
-	pthread_create(&clear_list_thread, NULL, (void *) &ClearList, (void *)NULL );
-	while ( quantity_of_fd < 50 )
-	{
-		struct accept * client;
-
-		syslog (LOG_INFO, "[timestamp = %d] quantity_of_fd = %d", time(NULL), quantity_of_fd);
-
-		client = AcceptClientConnection (listen_fd);
-		client->jabber_addr = rem_addr;
-		client->jabber_port = rem_port;
-
-		pthread_create(&client->accept_thread, NULL, (void *) &VerifyClient, (void *) client);
-	}
-	pthread_mutex_destroy(&mutexsum);
-}
-
-void ClearList(void)
-{
-	for ( ; ; )
-	{
-		pthread_mutex_lock(&mutexsum);
-		struct connections * connection = connections;
-		while ( connection != (struct connections *)NULL )
-		{
-			if ( *(connection->client->jabber_fd) != (int)NULL && time(NULL) - connection->client->last_access > 70 )
-			{
-				shutdown(*(connection->client->jabber_fd), SHUT_RDWR);
-				close(*(connection->client->jabber_fd));
-				*(connection->client->jabber_fd) = (int)NULL;
-			}
-			connection = connection->next;
-		}
-		pthread_mutex_unlock(&mutexsum);
-		sleep(5);
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-//int AcceptClientConnection (int listen_fd)
-struct accept * AcceptClientConnection (int listen_fd)
-{
-	int * newfd = (int *) malloc(sizeof(int));
-	if ( newfd == NULL )
-	{
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-	}
-
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		*(newfd) = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (*(newfd) < 0) && (errno == EINTR) );
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", *(newfd));
-
-	if ( *(newfd) < 0 )
-		syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
-
-	if ( socklen != sizeof (sa) )
-		syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
-
-	quantity_of_fd++;
-
-	const int on = 1;
-	if ( setsockopt (*(newfd), SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", *(newfd));
-
-	struct accept * accepted = (struct accept *) malloc(sizeof(struct accept));
-	if ( accepted == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	accepted->fd = newfd;
-	accepted->sa = sa;
-
-	return (accepted);
-}
-
-void VerifyClient(void * accepted)
-{
-	//puts("\n\n:::::::::::::::: VERIFYCLIENT :::::::::::::::::::::\n");
-	unsigned int addr = 0;
-	char ip[250];
-	int * jabber_fd = (int *)NULL;
-	const int on = 1;
-
-	struct accept * accept = (struct accept *) accepted;
-	struct client * client = (struct client *)NULL;
-	struct read_write * read_write = (struct read_write *) malloc(sizeof(struct read_write));
-	if ( read_write == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	read_write->type = 0;
-
-	// ip from client
-	addr = ntohl(accept->sa.sin_addr.s_addr);
-	sprintf(ip, "%d.%d.%d.%d",
-			(addr >> 24), (addr >> 16) & 0xFF,
-			(addr >> 8) & 0xFF,  addr & 0xFF);
-	//printf("\nNew connection [#%d]: %s\n", *(accept->fd), ip);
-
-	if ( getPermission(ip) )
-		if ( (client = Handshake(accept, read_write)) == (struct client *)NULL )
-		{
-			close(*(accept->fd));
-			pthread_kill(accept->accept_thread, 0);
-		}
-		else
-		{
-			jabber_fd = client->jabber_fd;
-		}
-	else
-	{
-		jabber_fd = (int *) malloc(sizeof(int));
-		if ( jabber_fd == NULL )
-			syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-		*(jabber_fd) = (int)NULL;
-	}
-
-	//puts("\n\n:::::::::::::::: JABBER IN VERIFYCLIENT #1 :::::::::::::::::::::\n");
-	if ( *(jabber_fd) == (int)NULL )
-		*(jabber_fd) = ConnectToServer(accept->jabber_addr, accept->jabber_port);
-	//puts("\n\n:::::::::::::::: JABBER IN VERIFYCLIENT #2 :::::::::::::::::::::\n");
-
-	// Set SO_REUSEADDR socket option
-	//if ( setsockopt (*(jabber_fd), SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-	//	syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR) #2: %m", *(jabber_fd));
-
-	//if ( client != (struct client *)NULL )
-	//	client->jabber_fd = jabber_fd;
-
-	read_write->jabber = jabber_fd;
-	read_write->client = *(accept->fd);
-	//pthread_t cat_thread;
-	//fcntl(read_write->client, F_SETFL, fcntl(read_write->client, F_GETFL, 0) | O_NDELAY);
-
-	//puts("\n\n:::::::::::::::: THREADS :::::::::::::::::::::\n");
-	//pthread_create(&read_write->write, NULL, (void *) &Writing, (void *)read_write );
-	pthread_create(&read_write->read, NULL, (void *) &Reading, (void *)read_write );
-
-	//pthread_exit(0);
-	pthread_kill(accept->accept_thread, 0);
-}
-
-struct client * Handshake(struct accept * accept, struct read_write * read_write)
-{
-	//puts("\n\n:::::::::::::::: HANDSHAKE :::::::::::::::::::::\n");
-	struct client * client = (struct client *)NULL;
-	unsigned char * const buf = (char *) malloc (sizeof(char) * 5);
-	if ( buf == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	char * str = (char *) malloc(128 * sizeof(char)),
-		 * user = (char *)NULL,
-		 * pass = (char *)NULL,
-		 * pass_pos = (char *)NULL,
-		 * type = (char *)NULL,
-		 * type_pos = (char *)NULL;
-	if ( str == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	int bytes_rcvd,
-		bytes_sent,
-		i;
-
-	bzero(str, 128);
-
-	if ( (bytes_rcvd = recv (*(accept->fd), str, 128, 0)) < 1 )
-	{
-		//puts("error :: str");
-		close(*(accept->fd));
-		return client;
-	}
-
-	pass_pos = strstr(str, "##") + 2;
-	i = strlen(str) - strlen(pass_pos) - 1;
-	user = (char *) malloc(i * sizeof(char));
-	if ( user == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	bzero(user, i);
-	strncpy(user, str, i - 1);
-
-	type_pos = strstr(pass_pos, "##") + 2;
-	i = strlen(pass_pos) - strlen(type_pos) - 1;
-	pass = (char *) malloc(i * sizeof(char));
-	if ( pass == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	bzero(pass, i);
-	strncpy(pass, pass_pos, i - 1);
-
-	i = strlen(type_pos) + 1;
-	type = (char *) malloc(i * sizeof(char));
-	if ( type == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	bzero(type, i);
-	strcpy(type, type_pos);
-
-	//printf(" str[%2d]: %s\n", strlen(str), str);
-	//printf("user[%2d]: %s\n", strlen(user), user);
-	//printf("pass[%2d]: %s\n", strlen(pass), pass);
-	//printf("type[%2d]: %s\n", strlen(type), type);
-	//printf("  fd[%2d]: client\n", *(accept->fd));
-
-	//if ( (client = LookFor (user, pass)) != (struct client *)NULL )
-	if ( (client = (struct client *) withConnections(LookFor, user, pass)) != (struct client *)NULL )
-	{
-		//puts("\n\n:::::::::::::::: INFO #0 :::::::::::::::::::::\n");
-		bzero(buf, 5);
-
-		//if ( *(client->read_fd) != (int)NULL )
-		//{
-		//	shutdown(*(client->read_fd), SHUT_RDWR);
-		//	close(*(client->read_fd));
-		//}
-		//*(client->read_fd) = *(accept->fd);
-
-		//puts("\n\n:::::::::::::::: INFO #1 :::::::::::::::::::::\n");
-		if ( *(client->jabber_fd) == (int)NULL )
-		{
-			//puts("\n\n:::::::::::::::: JABBER IN HANDSHAKE #1 :::::::::::::::::::::\n");
-			*(client->jabber_fd) = ConnectToServer(accept->jabber_addr, accept->jabber_port);
-			sprintf(buf, "new ");
-			//puts("\n\n:::::::::::::::: JABBER IN HANDSHAKE #2 :::::::::::::::::::::\n");
-		}
-		else
-			sprintf(buf, "rec ");
-
-		//puts("\n\n:::::::::::::::: INFO #2 :::::::::::::::::::::\n");
-
-		//printf("connection: %s\n\n\n", buf);
-		for ( i = 0; i < sizeof(buf); i += bytes_sent )
-		{
-			bytes_sent = send (*(accept->fd), buf + i, sizeof(buf) - i, 0);
-
-			if ( bytes_sent < 0 )
-				break;
-		}
-
-		//puts("\n\n:::::::::::::::: INFO #3 :::::::::::::::::::::\n");
-
-		if ( strcmp(type, "read") == 0 )
-			read_write->type = 1;
-		else
-			if ( strcmp(type, "write") == 0 )
-				read_write->type = 2;
-		//puts("\n\n:::::::::::::::: INFO #4 :::::::::::::::::::::\n");
-
-	}
-	//free(str);
-	free(buf);
-
-	return client;
-}
-
-void * withConnections(void * (*func)(), ...)
-{
-	//static struct connections * connections = (struct connections *)NULL;
-	if ( (*func) == LookFor )
-	{
-		va_list ap;
-		char * user,
-			 * pass;
-		void * _return;
-
-		va_start(ap, (*func));
-		user = va_arg(ap, char *);
-		pass = va_arg(ap, char *);
-		va_end(ap);
-
-		pthread_mutex_lock(&mutexsum);
-		_return = (*func)(user, pass);
-		pthread_mutex_unlock(&mutexsum);
-		return _return;
-	}
-	else
-	{
-	}
-}
-
-//struct client * LookFor (char * user, char * pass)
-//void * LookFor (struct connections * connections, char * user, char * pass)
-void * LookFor (char * user, char * pass)
-{
-	//puts("\n\n:::::::::::::::: LOOKFOR :::::::::::::::::::::\n");
-	//static struct connections * connections = (struct connections *)NULL;
-
-	//pthread_mutex_lock(&mutexsum);
-	if ( connections == (struct connections *)NULL )
-	{
-		//puts("\n\n:::::::::::::::: FIRST CONNECTION :::::::::::::::::::::\n");
-		connections = (struct connections *) malloc(sizeof(struct connections));
-		if ( connections == NULL )
-			syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-		connections->client = (struct client *) malloc(sizeof(struct client));
-		if ( connections->client == NULL )
-			syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-		connections->client->user = user;
-		connections->client->pass = pass;
-
-		connections->client->read_fd = (int *) malloc(sizeof(int));
-		if ( connections->client->read_fd == NULL )
-			syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-		connections->client->jabber_fd = (int *) malloc(sizeof(int));
-		if ( connections->client->jabber_fd == NULL )
-			syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-		*(connections->client->read_fd) = (int)NULL;
-		*(connections->client->jabber_fd) = (int)NULL;
-
-		connections->client->last_access = time(NULL);
-
-		connections->next = (struct connections *)NULL;
-
-		//pthread_mutex_unlock(&mutexsum);
-		return connections->client;
-	}
-	else
-	{
-		//puts("\n\n:::::::::::::::: HAS CONNECTION :::::::::::::::::::::\n");
-		struct connections * connection = connections,
-						   * last;
-		while ( connection != (struct connections *)NULL )
-		{
-			//puts(":::::::::::::::: PROCURANDO :::::::::::::::::::::");
-			if ( strcmp(connection->client->user, user) == 0 )
-				if ( strcmp(connection->client->pass, pass) == 0 )
-				{
-					//pthread_mutex_unlock(&mutexsum);
-					//puts(":::::::::::::::: ACHOU #1 :::::::::::::::::::::");
-					connection->client->last_access = time(NULL);
-					return connection->client;
-				}
-				else
-				{
-					//pthread_mutex_unlock(&mutexsum);
-					//puts(":::::::::::::::: ACHOU #2 :::::::::::::::::::::");
-					return (struct client *)NULL;
-				}
-			last = connection;
-			connection = connection->next;
-		}
-		//puts(":::::::::::::::: ACHOU #3 :::::::::::::::::::::");
-
-		last->next = (struct connections *) malloc(sizeof(struct connections));
-		if ( last->next == NULL )
-			syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-		connection = last->next;
-
-		connection->client = (struct client *) malloc(sizeof(struct client));
-		if ( connection->client == NULL )
-			syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-		connection->client->user = user;
-		connection->client->pass = pass;
-		connection->client->jabber_fd = (int *) malloc(sizeof(int));
-		if ( connection->client->jabber_fd == NULL )
-			syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-		*(connection->client->jabber_fd) = (int)NULL;
-		connection->client->last_access = time(NULL);
-
-		connection->next = (struct connections *)NULL;
-		//pthread_mutex_unlock(&mutexsum);
-		return connection->client;
-	}
-}
-
-void Reading (void * read_write)
-{
-	unsigned char * const buf_2_jabber = (char *) malloc (sizeof(char) * BUF_SIZE);
-	unsigned char * const buf_2_client = (char *) malloc (sizeof(char) * BUF_SIZE);
-	bzero(buf_2_jabber, BUF_SIZE);
-	bzero(buf_2_client, BUF_SIZE);
-
-	if ( buf_2_jabber == NULL || buf_2_client == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	struct read_write * read = (struct read_write *) read_write;
-
-	int jabber_fd = *(read->jabber),
-		client_fd = read->client;
-
-	fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | O_NDELAY);
-	fcntl(client_fd, F_SETFL, fcntl(client_fd, F_GETFL, 0) | O_NDELAY);
-
-	int bytes_rcvd_jabber = (int) NULL,
-		bytes_sent_jabber = (int) NULL,
-		bytes_rcvd_client = (int) NULL,
-		bytes_sent_client = (int) NULL,
-		i;
-
-	//syslog (LOG_INFO, "Reading(fd%d, fd%d)", in_fd, out_fd);
-
-	// @TODO: verificar alocacao buffer
-	//if ( buf == NULL )
-	//	syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		bzero(buf_2_jabber, BUF_SIZE);
-		if ( (bytes_rcvd_client = recv (client_fd, buf_2_jabber, BUF_SIZE, 0)) != 0 && strlen(buf_2_client) > 0 )
-		{
-			// descomentar para ver oq esta passado de informacao
-			//printf("(jabber/client[#%d])[%d]:\n{\n%s.......\n}\n", client_fd, strlen(buf_2_client), buf_2_client);
-			for ( i = 0; i < bytes_rcvd_jabber; i += bytes_sent_client )
-			{
-				bytes_sent_client = send (client_fd, buf_2_client + i, bytes_rcvd_jabber - i, 0);
-
-				if ( bytes_sent_client < 0 )
-					break;
-			}
-		}
-
-		bzero(buf_2_client, BUF_SIZE);
-		if ( (bytes_rcvd_jabber = recv (jabber_fd, buf_2_client, BUF_SIZE, 0)) != 0 && strlen(buf_2_jabber) > 0 )
-		{
-			// descomentar para ver oq esta passado de informacao
-			//printf("(client/jabber[#%d])[%d]:\n{\n%s.......\n}\n", jabber_fd, strlen(buf_2_jabber), buf_2_jabber);
-			for ( i = 0; i < bytes_rcvd_client; i += bytes_sent_jabber )
-			{
-				bytes_sent_jabber = send (jabber_fd, buf_2_jabber + i, bytes_rcvd_client - i, 0);
-
-				if ( bytes_sent_jabber < 0 )
-					break;
-			}
-		}
-
-		usleep(500);
-		//sleep(2);
-	}
-	while ( (bytes_rcvd_client != 0) && (bytes_rcvd_jabber != 0) );
-
-	//puts("\n\n\nFIM.......................\n\n\n");
-
-	free(buf_2_jabber);
-	free(buf_2_client);
-
-	shutdown(read->client, SHUT_RDWR);
-	close (read->client);
-}
-
-/*
-void Reading (void * read_write)
-{
-	struct read_write * read = (struct read_write *) read_write;
-
-	//printf("read->type: %d\n\n\n", read->type);
-	if ( !read->type || read->type == 1 )
-	{
-		unsigned char * const buf = (char *) malloc (sizeof(char) * BUF_SIZE);
-		if ( buf == NULL )
-		{
-			puts("\n\nmalloc() : buf #2\n\n\n");
-			exit (EXIT_FAILURE);
-		}
-		int bytes_rcvd,
-			bytes_sent = (int) NULL,
-			i;
-
-		int in_fd = *(read->jabber),
-			out_fd = read->client;
-
-		//syslog (LOG_INFO, "Reading(fd%d, fd%d)", in_fd, out_fd);
-
-		// @TODO: verificar alocacao buffer
-		//if ( buf == NULL )
-		//	syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-		do
-		{
-			//puts("\n\n:::::::::::::::: DO - READ :::::::::::::::::::::\n");
-			bzero(buf, BUF_SIZE);
-			bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-			if ( strlen(buf) > 0 )
-			{
-				// descomentar para ver oq esta passado de informacao
-				printf("Reading(#%d/jabber,#%d/client)[%d]:\n{\n%s.......\n}\n", in_fd, out_fd, strlen(buf), buf);
-
-				for ( i = 0; i < bytes_rcvd && *(read->jabber) != (int)NULL; i += bytes_sent )
-				{
-					bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-					if ( bytes_sent < 0 )
-						break;
-				}
-			}
-		}
-		while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-		printf("\n[Reading] FINALIZANDO TREAD CLIENTE COM FD #%d\n\n", out_fd);
-		pthread_cancel(read->write);
-
-		//if ( bytes_rcvd < 1 )
-		//	*(read->jabber) = (int)NULL;
-
-		printf("\n\nFIM Reading [#%d#%d]\nbytes_rcvd = %d : bytes_sent = %d\n\n\n", in_fd, out_fd, bytes_rcvd, bytes_sent);
-
-		free (buf);
-	}
-	else
-		while ( 1 )	usleep(500);
-
-	//pthread_kill(read->write, 0);
-
-	shutdown(read->client, SHUT_RDWR);
-	close (read->client);
-	//pthread_exit(0);
-}
-*/
-
-void Writing (void * read_write)
-{
-	struct read_write * write = (struct read_write *) read_write;
-
-	//printf("write->type: %d\n\n\n", write->type);
-	//if ( !write->type || write->type == 2 )
-	//{
-		unsigned char * const buf = (char *) malloc (sizeof(char) * (BUF_SIZE + 1));
-		if ( buf == NULL )
-		{
-			syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-		}
-		int bytes_rcvd,
-			bytes_sent = (int) NULL,
-			i;
-
-		int in_fd = write->client,
-			out_fd = *(write->jabber);
-
-		//syslog (LOG_INFO, "Writing(fd%d, fd%d)", in_fd, out_fd);
-
-		// @TODO: verificar alocacao buffer
-		//if ( buf == NULL )
-		//	syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-		do
-		{
-			//puts("\n\n:::::::::::::::: DO - WRITE :::::::::::::::::::::");
-			bzero(buf, BUF_SIZE + 1);
-			//puts(":::::::::::::::: WRITE - RECV :::::::::::::::::::::");
-			bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-			//puts(":::::::::::::::: WRITE - IF #1 :::::::::::::::::::::");
-			if ( strlen(buf) > 0 )
-			{
-				// descomentar para ver oq esta passado de informacao
-				//printf("Writing(#%d/client,#%d/jabber)[%d]:\n{\n%s.......\n}\n", in_fd, out_fd, strlen(buf), buf);
-
-				for ( i = 0; i < bytes_rcvd && *(write->jabber) != (int)NULL; i += bytes_sent )
-				{
-					bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-					if ( bytes_sent < 0 )
-						break;
-				}
-			}
-			//puts(":::::::::::::::: WRITE - IF #2 :::::::::::::::::::::\n");
-		}
-		while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-		//printf("\n[Writing] FINALIZANDO TREAD CLIENTE COM FD #%d\n\n", in_fd);
-		pthread_cancel(write->read);
-
-		//if ( bytes_sent < 1 )
-		//	*(write->jabber) = (int)NULL;
-
-		//printf("\n\nFIM Writing [#%d#%d]\nbytes_rcvd = %d : bytes_sent = %d\n\n\n", in_fd, out_fd, bytes_rcvd, bytes_sent);
-
-		free (buf);
-	//}
-	//else
-	//	while ( 1 ) usleep(500);
-
-	//pthread_kill(write->read, 0);
-
-	shutdown(write->client, SHUT_RDWR);
-	close (write->client);
-	//pthread_exit(0);
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO: have a timeout for connect() - see Unix socket FAQ 6.2
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		exit (EXIT_FAILURE);
-	}
-
-	quantity_of_fd++;
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO: use inet_aton() instead
-	p_inaddr->s_addr = inet_addr (name);
-	if ( p_inaddr->s_addr != -1U ) // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname (name);
-	if ( he != NULL ) // Success
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul (name, &errpos, 0);
-	if ( (*errpos == 0) && (lport <= 65535) ) // Success
-	{
-		*port = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname (name, proto);
-	if ( se != NULL) // Success
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char * fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char * fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char * fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-// set_signal_handler(): Sets a signal handler function.  Similar to signal()
-// but this method is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if (sigaction (signum, &act, NULL) < 0)
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/webjabber/Makefile
===================================================================
--- /trunk/instant_messenger/webjabber/Makefile	(revision 216)
+++ 	(revision )
@@ -1,29 +1,0 @@
-#Makefile webjabber
-#CC=gcc
-#
-#all: server client
-#
-#server: server.o
-#	$(CC) -o server server.o -lpthread
-#server.o: server.c
-#	$(CC) -g -c server.c
-#
-#client: client.o
-#	$(CC) -o client client.o -lpthread
-#client.o: client.c
-#	$(CC) -g -c client.c
-#
-#clean:
-#	rm -f server client *.o *~
-
-CC=gcc
-
-all: webjabber
-
-webjabber: webjabber.o
-	$(CC) -o webjabber webjabber.o -lpthread
-webjabber.o: webjabber.c
-	$(CC) -g -c webjabber.c
-
-clean:
-	rm -f webjabber *.o *~
Index: unk/instant_messenger/xsl/layer.xsl
===================================================================
--- /trunk/instant_messenger/xsl/layer.xsl	(revision 164)
+++ 	(revision )
@@ -1,28 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/layer">
-   <div class="layer">	
-		<table border="0" cellpadding="0" cellspacing="0" class="font_menu">
-			<tr>
-				<td>
-					<img id="im_avatar" src="{path}templates/default/images/photo.png" style="margin:2px;"/>
-				</td>
-				<td style="valign:top">
-					<span style="font-weight:bold;"><xsl:value-of select="lang1" /> : </span> 
-					<br></br>
-					<span id="im_layer_nickname"><xsl:value-of select="nickname" /></span>
-					<br></br>
-					<br></br>
-					<img src="{path}templates/default/images/addBuddy1.gif" style="cursor:pointer;" onclick="javascript:templates.add_user();" title="{lang2}" alt="{lang2}"/>
-					<img src="{path}templates/default/images/console_prefs1.png" style="cursor:pointer;" onclick="javascript:templates.preferences('span_preferences');" title="{lang3}" alt="{lang3}"/>					
-					<span id="span_preferences"></span>
-					<br></br>
-				</td>	
-			</tr>		
-		</table>
-   </div>		
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/contacts.xsl
===================================================================
--- /trunk/instant_messenger/xsl/contacts.xsl	(revision 164)
+++ 	(revision )
@@ -1,52 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="iq/query">
-		<xsl:apply-templates select="." mode="list" />	
-</xsl:template>
-
-<xsl:template match="*" mode="list">
-   <div id="im_contact_list" style="margin:2px;width:auto;height:200px;overflow-y:auto;">
-	   <xsl:for-each select="item">
-			<xsl:sort select="group" case-order="upper-first" />
-			<xsl:choose>
-				<xsl:when test="not(group = preceding-sibling::item/group)">
-					<img id="group_{group[current()]}" src="instant_messenger/templates/default/images/group_open.gif" onclick="javascript:im.group_close('{group[current()]}');"/>
-					<b><xsl:value-of select="group[current()]" /><br/></b>
-					<xsl:apply-templates select="." mode="contacts"/>
-				</xsl:when>
-				<xsl:otherwise>
-					<xsl:apply-templates select="." mode="contacts"/>
-				</xsl:otherwise>
-			</xsl:choose>
-	   </xsl:for-each>
-	</div>	  
-</xsl:template>
-
-<xsl:template match="*" mode="contacts">
-
-	<xsl:choose>
-		<xsl:when test="@name">
-			<div style="margin-left:15px;cursor:pointer;display:block;" id="{@jid}" idgroup="{group}" idname="{@name}" onmousedown="templates.options(event, '{@jid}');">
-				<img id="img_{@jid}" src="instant_messenger/templates/default/images/unavailable.gif" style="margin:0px 2px" />
-				<xsl:value-of select="@name"/>
-				<br/>
-				<span id="status_{@jid}" style="font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none" />
-			</div>
-			<span id="sub_{@jid}"></span>							
-		</xsl:when>
-		<xsl:otherwise>
-			<div style="margin-left:15px;cursor:pointer;display:block;" id="{@jid}" idgroup="{group}" idname="" onmousedown="templates.options(event, '{@jid}');">
-				<img id="img_{@jid}" src="instant_messenger/templates/default/images/unavailable.gif" style="margin:0px 2px" />
-				<xsl:value-of select="@jid"/>
-				<br/>
-				<span id="status_{@jid}" style="font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;" />
-			</div>
-			<span id="sub_{@jid}"></span>			
-		</xsl:otherwise>
-	</xsl:choose>
-	
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/chat.xsl
===================================================================
--- /trunk/instant_messenger/xsl/chat.xsl	(revision 164)
+++ 	(revision )
@@ -1,49 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/window">
-	<div id="{name}_window_master" style="width:{width};" class="window" onmousedown="javascript:drag_drop.drag(event,this); javascript:im_window.window_focus(this);" dragdrop="true">
-		<b class="corner blackcorner">
-			<b class="corner1 blackcorner1"><b></b></b>
-			<b class="corner2 blackcorner2"><b></b></b>
-			<b class="corner3 blackcorner3"></b>
-			<b class="corner4 blackcorner4"></b>
-			<b class="corner5 blackcorner5"></b>
-		</b>
-		<div id="{name}_window_title" class="titulo" dragdrop="true">
-			<span id="{name}_window_title" style="float:left;" dragdrop="true">
-				<xsl:value-of select="title" />
-			</span>
-			<div id="{name}_window_title_buttons" style="float:right;">
-				<div id="{name}_button_minimize" style="display: {pButMin};" class="button_minimize" onclick="javascript:im_window.window_minimize('{name}');"></div>
-				<div id="{name}_button_maximize" style="display: {pButMax};" class="button_maximize1" onclick="javascript:im_window.window_maximize('{name}');"></div>
-				<div id="{name}_button_close" style="display: {pButClose};" class="button_close" onclick="javascript:im_window.window_close('{name}');"></div>
-			</div>
-		</div>
-		<div id="{name}_window_body" class="body">
-			<div id="{name}_window_body_content" class="content">
-				<div style="margin:3px 3px;">
-					<div class="history">
-					<div class="avatar" style="margin: 2px; position: absolute; right: 30px; top: 30px;">
-						<img id="{name}_avatar"/>
-					</div>
-					</div>
-					<div class="toolbar_buttons">
-						<div id="{name}_button_bold" class="button_bold" onclick="javascript:im.conf_font('{name}','button_bold');"></div>
-						<div id="{name}_button_italic" class="button_italic" onclick="javascript:im.conf_font('{name}','button_italic');"></div>
-						<div id="{name}_button_underline" class="button_underline" onclick="javascript:im.conf_font('{name}','button_underline');"></div>
-						<div id="{name}_button_color" class="button_color" onclick="javascript:im.conf_font('{name}','button_color');"></div>
-						<div id="{name}_button_emoticons" class="button_emoticons" onclick="javascript:im.conf_font('{name}','button_emoticons');"></div>
-						<div id="{name}_button_profile" class="button_profile" onclick="im.request_vcard('{name}','contact');"></div>
-						<div id="{name}_button_dest"></div>						
-					</div>
-					<div class="messages"></div>
-				</div>
-			</div>
-		</div>
-		<div id="{name}_window_bottom" class="rodape" dragdrop="false"></div>
-	</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/modelo.xsl
===================================================================
--- /trunk/instant_messenger/xsl/modelo.xsl	(revision 151)
+++ 	(revision )
@@ -1,33 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/window">
-	<div id="{name}_window_master" style="width:{width};" class="window" onmousedown="javascript:drag_drop.drag(event,this); javascript:im_window.window_focus(this);" dragdrop="true">
-		<b class="corner blackcorner">
-			<b class="corner1 blackcorner1"><b></b></b>
-			<b class="corner2 blackcorner2"><b></b></b>
-			<b class="corner3 blackcorner3"></b>
-			<b class="corner4 blackcorner4"></b>
-			<b class="corner5 blackcorner5"></b>
-		</b>
-		<div class="titulo" dragdrop="true">
-			<span id="{name}_window_title" style="float:left;" dragdrop="true">
-				<xsl:value-of select="title" />
-			</span>
-			<div id="{name}_window_title_buttons" style="float:right;">
-				<div id="{name}_button_minimize" style="display: {pButMin};" class="button_minimize" onclick="javascript:im_window.window_minimize('{name}');"></div>
-				<div id="{name}_button_maximize" style="display: {pButMax};" class="button_maximize1" onclick="javascript:im_window.window_maximize('{name}');"></div>
-				<div id="{name}_button_close" style="display: {pButClose};" class="button_close" onclick="javascript:im_window.window_close('{name}');"></div>
-			</div>
-		</div>
-		<div id="{name}_window_body" class="body">
-			<div id="{name}_window_body_content" class="content">
-				<xsl:copy-of select="content" />
-			</div>
-		</div>
-		<div id="{name}_window_bottom" class="rodape" dragdrop="false"></div>
-	</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/fast_menu.xsl
===================================================================
--- /trunk/instant_messenger/xsl/fast_menu.xsl	(revision 151)
+++ 	(revision )
@@ -1,17 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="fast_menu">
-
-	<dl style="background: #b4cfe5;margin:5px">
-		<dt><a href="javascript:void(0);" onclick="im.presence('available');"><img src="{img1}"/><xsl:value-of select="lang1"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="im.presence('away');"><img src="{img2}"/><xsl:value-of select="lang2"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="im.presence('dnd');"><img src="{img3}"/><xsl:value-of select="lang3"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="im.presence('unavailable');"><img src="{img4}"/><xsl:value-of select="lang4"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="im.presence('custom');"><img src="{img5}"/><xsl:value-of select="lang5"/></a></dt>
-	</dl>
-
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/list_ldap_org.xsl
===================================================================
--- /trunk/instant_messenger/xsl/list_ldap_org.xsl	(revision 151)
+++ 	(revision )
@@ -1,12 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="organizations">
-	<xsl:for-each select="ou">
-		<xsl:sort select="." case-order="upper-first" />
-		<option value="{.}"><xsl:value-of select="." /></option>
-	</xsl:for-each>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/message.xsl
===================================================================
--- /trunk/instant_messenger/xsl/message.xsl	(revision 151)
+++ 	(revision )
@@ -1,26 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="message">
-	<!-- <b><xsl:value-of select="@from" /> :</b><br /> -->
-	<b> :</b><br />	
-	<!--
-	linha abaixo apresenta problema quando envia mtas msg seguidas
-	entretanto linha que estÃ¡ habilitada na sequencia nÃ£ofunciona no psy
-	-->
-	
-	<xsl:apply-templates select="descendant::*[name()='body' and preceding::body]" mode='body' />
-	
-	<!--
-	<xsl:apply-templates select="html/body" mode='body' />
-	-->
-</xsl:template>
-
-<xsl:template match="*" mode="body">
-	<xsl:copy-of select="." />
-	<br />
-	<br />
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/nickname.xsl
===================================================================
--- /trunk/instant_messenger/xsl/nickname.xsl	(revision 151)
+++ 	(revision )
@@ -1,9 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="iq">
-	<xsl:value-of select="@from"/>,<xsl:value-of select="vCard/NICKNAME"/>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/add_user.xsl
===================================================================
--- /trunk/instant_messenger/xsl/add_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,42 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="adduser">
-
-	<div style="margin-left:5px;margin-top:5px">
-		<b><xsl:value-of select="top/lang1"/> .: </b>
-		<select id="im_ldap_ou" onchange="im.ldap_search_ou(this);"></select>
-		<span id="_span_load_im" style="background-color:#cc4444;color:white;display:none;position:absolute;right:5px;top:26px">Carregando .....</span>	
-		<br/>
-		<select id="im_ldap_user" size="10" class="add_user" onclick="im.ldap_adduser(this);"></select>
-	</div>
-
-	<table border="0" cellpadding="1" cellspacing="2" class="add_user">
-		<tr>
-			<td class="add_user"><b><xsl:value-of select="table/lang1"/>.:</b></td>
-			<td><input id="im_jid" type="text" size="40" maxlength="40" readonly="true" class="add_user" /></td>		
-		</tr>
-		<tr>
-			<td class="add_user"><b><xsl:value-of select="table/lang2"/>.:</b></td>
-			<td><input id="im_name" type="text" size="20" maxlength="20" class="add_user" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/></td>		
-		</tr>
-		<tr>
-			<td class="add_user"><b><xsl:value-of select="table/lang3"/>.:</b></td>
-			<td><input id="im_group" type="text" size="20" maxlength="20" class="add_user" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/></td>		
-		</tr>
-		<tr>
-			<td><input id="im_uid" type="hidden" size="30" maxlength="30" /></td>
-		</tr>							
-		<tr>
-			<td colspan="2">
-				<input type="button" value="{table/lang4}" onclick="javascript:im.adduser();"/>
-				<input type="button" value="{table/lang5}" onclick="javascript:im_window.window_close('add_user_im');" />
-				<span id="im_status_add" style="color:#f00;font-weight:bold;margin-left:10px;"></span>			
-			</td>
-		</tr>
-   	</table>
-
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/remove_user.xsl
===================================================================
--- /trunk/instant_messenger/xsl/remove_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,18 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/remove_user">
-		<div style="margin:20px 20px">
-			<span><b><xsl:value-of select="lang1"/> .: </b></span> 
-			<div style="margin-top:3px">
-				<select id="im_remove_contact"></select>
-				<span style="margin-left:7px">
-					<input type="button" value="{lang2}" onclick="javascript:im.remove_contact('im_remove_contact');"/>
-					<input type="button" value="{lang3}" onclick="javascript:im_window.window_close('remove_user_im');"/>
-				</span>
-			</div>
-		</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/options.xsl
===================================================================
--- /trunk/instant_messenger/xsl/options.xsl	(revision 151)
+++ 	(revision )
@@ -1,17 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="options">
-
-	<dl style="background:#b4cfe5;margin:5px;font:8pt;">
-		<dt><a href="javascript:void(0);" onclick="im.update_nickname('{jid}');"><img src="{path}templates/default/images/group_close.gif"/><xsl:value-of select="lang1"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="im.update_group('{jid}');"><img src="{path}templates/default/images/group_close.gif"/><xsl:value-of select="lang2"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="im.remove('{jid}');"><img src="{path}templates/default/images/group_close.gif"/><xsl:value-of select="lang3"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="im.subscription('{jid}','subscribe');"><img src="{path}templates/default/images/group_close.gif"/><xsl:value-of select="lang4"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="im.request_vcard('{jid}','contact');"><img src="{path}templates/default/images/group_close.gif"/><xsl:value-of select="lang5"/></a></dt>
-	</dl>
-
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/smiles.xsl
===================================================================
--- /trunk/instant_messenger/xsl/smiles.xsl	(revision 151)
+++ 	(revision )
@@ -1,54 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="smiles">
-	<div style="background: #b4cfe5;margin:1px;">
-		<table border="0" cellpadding="0" cellspacing="2">
-			<tr>
-				<td>
-					<img src="{path}templates/default/images/smiles/1.gif" onclick="javascript:im.addemotion(':)','{pjid}');"/>
-				</td>
-				<td>
-					<img src="{path}templates/default/images/smiles/2.gif" onclick="javascript:im.addemotion(':d','{pjid}');"/>
-				</td>
-				<td>
-					<img src="{path}templates/default/images/smiles/3.gif" onclick="javascript:im.addemotion(';)','{pjid}');"/>
-				</td>
-				<td>
-					<img src="{path}templates/default/images/smiles/4.gif" onclick="javascript:im.addemotion(':o','{pjid}');"/>
-				</td>
-			</tr>
-			<tr>
-				<td>
-					<img src="{path}templates/default/images/smiles/5.gif" onclick="javascript:im.addemotion(':p','{pjid}');"/>
-				</td>
-				<td>
-					<img src="{path}templates/default/images/smiles/6.gif" onclick="javascript:im.addemotion('(h)','{pjid}');"/>
-				</td>
-				<td>
-					<img src="{path}templates/default/images/smiles/7.gif" onclick="javascript:im.addemotion(':@','{pjid}');"/>
-				</td>
-				<td>
-					<img src="{path}templates/default/images/smiles/8.gif" onclick="javascript:im.addemotion(':$','{pjid}');"/>
-				</td>
-			</tr>
-			<tr>
-				<td>
-					<img src="{path}templates/default/images/smiles/9.gif" onclick="javascript:im.addemotion(':s','{pjid}');"/>
-				</td>
-				<td>
-					<img src="{path}templates/default/images/smiles/10.gif" onclick="javascript:im.addemotion(':(','{pjid}');"/>
-				</td>
-				<td>
-					<img src="{path}templates/default/images/smiles/11.gif" onclick="javascript:im.addemotion(':\'(','{pjid}');"/>
-				</td>
-				<td>
-					<img src="{path}templates/default/images/smiles/12.gif" onclick="javascript:im.addemotion(':|','{pjid}');"/>
-				</td>
-			</tr>
-		</table>
-	</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/vcard_user.xsl
===================================================================
--- /trunk/instant_messenger/xsl/vcard_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,94 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/vcard_user">
-		<div class="vcard_contact">
-			<table border="0" cellpadding="1" cellspacing="0" class="vcard_contact">
-				<tr>
-					<td><xsl:value-of select="lang1" /></td>
-					<td> .: 
-						<xsl:choose>
-							<xsl:when test="div/@fn">
-								<input id="im_fn" type="text" size="40" maxlength="40" value="{div/@fn}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>
-							</xsl:when>								
-							<xsl:otherwise>
-								<input id="im_fn" type="text" size="40" maxlength="40" value="{div/@FN}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>							
-							</xsl:otherwise>
-						</xsl:choose>					
-					</td>
-				</tr>
-				<tr>
-					<td><xsl:value-of select="lang2" /></td>
-					<td> .: 
-						<xsl:choose>
-							<xsl:when test="div/@nickname">
-								<input id="im_nickname" type="text" size="20" maxlength="20" value="{div/@nickname}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>
-							</xsl:when>
-							<xsl:otherwise>			
-								<input id="im_nickname" type="text" size="20" maxlength="20" value="{div/@NICKNAME}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>							
-							</xsl:otherwise>
-						</xsl:choose>
-					</td>						
-				</tr>
-				<tr>
-					<td><xsl:value-of select="lang3" /></td>
-					<td> .: 
-						<xsl:choose>	
-							<xsl:when test="div/@orgname">
-								<input id="im_orgname" type="text" size="17" maxlength="17" value="{div/@orgname}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>
-							</xsl:when>
-							<xsl:otherwise>
-								<input id="im_orgname" type="text" size="17" maxlength="17" value="{div/@ORGNAME}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>
-							</xsl:otherwise>
-						</xsl:choose>
-					</td>
-				</tr>
-				<tr>
-					<td><xsl:value-of select="lang4" /></td>
-					<td> .: 
-						<xsl:choose>
-							<xsl:when test="div/@org">
-								<input id="im_orgunit" type="text" size="10" maxlength="10" value="{div/@org}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>
-							</xsl:when>
-							<xsl:otherwise>
-								<input id="im_orgunit" type="text" size="10" maxlength="10" value="{div/@ORG}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>						
-							</xsl:otherwise>
-						</xsl:choose>
-					</td>
-				</tr>
-				<tr>
-					<td><xsl:value-of select="lang5" /></td>
-					<td> .: 
-						<xsl:choose>
-							<xsl:when test="div/@role">
-								<input id="im_role" type="text" size="25" maxlength="25" value="{div/@role}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>
-							</xsl:when>
-							<xsl:otherwise>
-								<input id="im_role" type="text" size="25" maxlength="25" value="{div/@ROLE}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>							
-							</xsl:otherwise>
-						</xsl:choose>
-					</td>
-				</tr>
-				<tr>
-					<td><xsl:value-of select="lang6" /></td>
-					<td> .: 
-						<xsl:choose>
-							<xsl:when test="div/@bday">	
-								<input id="im_bday" type="text" size="10" maxlength="10" value="{div/@bday}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>
-							</xsl:when>
-							<xsl:otherwise>
-								<input id="im_bday" type="text" size="10" maxlength="10" value="{div/@BDAY}" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/>							
-							</xsl:otherwise>								
-						</xsl:choose>							
-					</td>
-				</tr>
-			</table>
-			<div style="margin:10px 0px">
-				<input type="button" value="{lang7}" onclick="javascript:im.save_vcard();"/>
-				<input type="button" value="{lang8}" onclick="javascript:im_window.window_close('{id}');"/>
-			</div>
-		</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/vcard_contacts.xsl
===================================================================
--- /trunk/instant_messenger/xsl/vcard_contacts.xsl	(revision 151)
+++ 	(revision )
@@ -1,80 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/vcard_contact">
-		<div class="vcard_contact">
-			<div style="margin:3px">
-				<label style="font-weight:bold;"><xsl:value-of select="lang1" /> .: </label>
-				<xsl:choose>
-					<xsl:when test="div/@fn">
-						<xsl:value-of select="div/@fn" />
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:value-of select="div/@FN" />
-					</xsl:otherwise>
-				</xsl:choose>
-			</div>
-			<div style="margin:3px">
-				<label style="font-weight:bold;"><xsl:value-of select="lang2" /> .: </label>
-				<xsl:choose>
-					<xsl:when test="div/@nickname">
-						<xsl:value-of select="div/@nickname" />
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:value-of select="div/@NICKNAME" />						
-					</xsl:otherwise>						
-		        </xsl:choose>				
-			</div>
-			<div style="margin:3px">
-				<label style="font-weight:bold;"><xsl:value-of select="lang3" /> .: </label>
-				<xsl:choose>	
-					<xsl:when test="div/@orgname">
-						<xsl:value-of select="div/@orgname" />
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:value-of select="div/@ORGNAME" />
-					</xsl:otherwise>
-				</xsl:choose>
-			</div>
-			<div style="margin:3px">
-				<label style="font-weight:bold;"><xsl:value-of select="lang4" /> .: </label>
-				<xsl:choose>
-					<xsl:when test="div/@org">
-						<xsl:value-of select="div/@org" />
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:value-of select="div/@ORG" />
-					</xsl:otherwise>
-				</xsl:choose>					
-			</div>
-			<div style="margin:3px">
-				<label style="font-weight:bold;"><xsl:value-of select="lang5" /> .: </label>
-				<xsl:choose>
-					<xsl:when test="div/@role">
-						<xsl:value-of select="div/@role" />
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:value-of select="div/@ROLE" />
-					</xsl:otherwise>
-				</xsl:choose>
-			</div>
-			<div style="margin:3px">	
-				<label style="font-weight:bold;"><xsl:value-of select="lang6" /> .: </label>
-				<xsl:choose>
-					<xsl:when test="div/@bday">
-						<xsl:value-of select="div/@bday" />
-					</xsl:when>
-					<xsl:otherwise>
-						<xsl:value-of select="div/@BDAY" />
-					</xsl:otherwise>
-				</xsl:choose>
-			</div>
-			<div style="margin:5px 0px">
-				<input type="button" value="{lang7}" onclick="javascript:im_window.window_close('{id}');" />
-			</div>
-		</div>
-		
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/message_new.xsl
===================================================================
--- /trunk/instant_messenger/xsl/message_new.xsl	(revision 151)
+++ 	(revision )
@@ -1,12 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="message">
-	<b> :</b><br/>	
-	<xsl:value-of select="body"/>
-	<br/>
-	<br/>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/vcard.xsl
===================================================================
--- /trunk/instant_messenger/xsl/vcard.xsl	(revision 151)
+++ 	(revision )
@@ -1,9 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="vCard">
-	<div FN="{FN}" NICKNAME="{NICKNAME}" ROLE="{ROLE}" ORGNAME="{ORG/ORGNAME}" ORG="{ORG/ORGUNIT}" BDAY="{BDAY}" />
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/preferences.xsl
===================================================================
--- /trunk/instant_messenger/xsl/preferences.xsl	(revision 151)
+++ 	(revision )
@@ -1,14 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="preferences">
-	<dl style="margin:5px">
-		<dt><a href="javascript:void(0);" onclick="javascript:{function1};"><img src="{path}templates/default/images/menu.gif"/><xsl:value-of select="lang1"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="javascript:{function2};"><img src="{path}templates/default/images/menu.gif"/><xsl:value-of select="lang2"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="javascript:{function3};"><img src="{path}templates/default/images/menu.gif"/><xsl:value-of select="lang3"/></a></dt>
-		<dt><a href="javascript:void(0);" onclick="javascript:{function4};"><img src="{path}templates/default/images/menu.gif"/><xsl:value-of select="lang4"/></a></dt>
-	</dl>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/colors.xsl
===================================================================
--- /trunk/instant_messenger/xsl/colors.xsl	(revision 151)
+++ 	(revision )
@@ -1,40 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="colors">
-	<div style="background: #b4cfe5;margin:1px;">
-		<table border="0" cellpadding="0" cellspacing="2">
-			<tr>
-				<td>
-					<div style="width:15px ;height: 15px;background: #000000; cursor: pointer;" onclick="javascript:im.button_color('{name}','#000000');"/>
-				</td>
-				<td>
-					<div style="width:15px ;height: 15px;background: #c0c0c0; cursor: pointer;" onclick="javascript:im.button_color('{name}','#c0c0c0');"/>
-				</td>
-				<td>
-					<div style="width:15px ;height: 15px;background: #ffff00; cursor: pointer;" onclick="javascript:im.button_color('{name}','#ffff00');"/>
-				</td>
-				<td>
-					<div style="width:15px ;height: 15px;background: #ff0000; cursor: pointer;" onclick="javascript:im.button_color('{name}','#ff0000');"/>
-				</td>
-			</tr>
-			<tr>
-				<td>
-					<div style="width:15px ;height: 15px;background: #ff00ff; cursor: pointer;" onclick="javascript:im.button_color('{name}','#ff00ff');"/>
-				</td>
-				<td>
-					<div style="width:15px ;height: 15px;background: #00ff00; cursor: pointer;" onclick="javascript:im.button_color('{name}','#00ff00');"/>
-				</td>
-				<td>
-					<div style="width:15px ;height: 15px;background: #1111ff; cursor: pointer;" onclick="javascript:im.button_color('{name}','#1111ff');"/>
-				</td>
-				<td>
-					<div style="width:15px ;height: 15px;background: #800080; cursor: pointer;" onclick="javascript:im.button_color('{name}','#800080');"/>
-				</td>
-			</tr>
-		</table>
-	</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/disconnected.xsl
===================================================================
--- /trunk/instant_messenger/xsl/disconnected.xsl	(revision 164)
+++ 	(revision )
@@ -1,32 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/disconnected">
-	<div class="disconnected">
-		<img src="{path}templates/default/images/logo.png" align="bottom" style="margin:2px"/>
-		<font style="font-weight:bold;margin:5px">Expresso Messenger</font>
-		<br/>
-		<br/>
-		<font style="font-weight:bold;margin:5px"> Aviso : </font>
-		<br/>
-		<br/>
-		<div style="margin:5px"> 
-			Sua conexão com o 
-			<br/>
-			Servidor parou.
-			<br/>
-			Tente novamente 
-			<br/>
-			ou entre em contato
-			<br/>
-			com o Administrador.
-		</div>
-		<br/>
-		<br/>
-		<img src="{path}templates/default/images/available.gif" />
-		<a href="javascript:disconnected = false; client();"><font style="font-size:7pt;margin:2px">Reconectar ...</font></a>
-	</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/mysettings.xsl
===================================================================
--- /trunk/instant_messenger/xsl/mysettings.xsl	(revision 151)
+++ 	(revision )
@@ -1,26 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="settings">
-	  <div id="im_preferences" style="margin:5px">
-		  <fieldset><legend> <xsl:value-of select="lang1"/> :</legend>
-			  <input id="ch_offline" type="checkbox" /> <xsl:value-of select="lang2"/>
-		  </fieldset>
-		  <br />
-		  <fieldset><legend> <xsl:value-of select="lang3" /> : </legend>	
-  			  <xsl:value-of select="lang4"/><input id="time_xa_im" type="input" size="2" maxlength="2" style="margin:0px 3px" onclick="javascript:im.focus_select(this,event);" onmousedown="javascript:im.focus_select(this,event);"/><xsl:value-of select="lang5"/>
-		  </fieldset>		
-		  <br />	
-  		  <fieldset>
-  		  	  <legend> <xsl:value-of select="lang6" /> :</legend>
-	    	  <input id="rd_nm" type="radio" name="rd_aviso" /> <xsl:value-of select="lang7" /> <br />
-			  <input id="rd_ch" type="radio" name="rd_aviso" /> <xsl:value-of select="lang8" />
-  		  </fieldset>
-		  	<br/>
-		  	<input type="button" value="{lang9}" onclick="javascript:im.set_preferences();"/>
-			<input type="button" value="{lang10}" onclick="javascript:im_window.window_close('my_settings_im');"/>
-	  </div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/window.xsl
===================================================================
--- /trunk/instant_messenger/xsl/window.xsl	(revision 164)
+++ 	(revision )
@@ -1,34 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/window">
-	<div id="{name}_window_master" style="width:{width};" class="window" onmousedown="javascript:drag_drop.drag(event,this); javascript:im_window.window_focus(this);" dragdrop="true">
-		<b class="corner blackcorner">
-			<b class="corner1 blackcorner1"><b></b></b>
-			<b class="corner2 blackcorner2"><b></b></b>
-			<b class="corner3 blackcorner3"></b>
-			<b class="corner4 blackcorner4"></b>
-			<b class="corner5 blackcorner5"></b>
-		</b>
-		<div class="titulo" dragdrop="true">
-			<span id="{name}_window_title" style="float:left;" dragdrop="true">
-				<xsl:value-of select="title" />
-			</span>
-			<div id="{name}_window_title_buttons" style="float:right;">
-				<div id="{name}_button_minimize" style="display: {pButMin};" class="button_minimize" onclick="javascript:im_window.window_minimize('{name}');"></div>
-				<div id="{name}_button_maximize" style="display: {pButMax};" class="button_maximize1" onclick="javascript:im_window.window_maximize('{name}');"></div>
-				<div id="{name}_button_close" style="display: {pButClose};" class="button_close" onclick="javascript:im_window.window_close('{name}');"></div>
-			</div>
-		</div>
-		<div id="{name}_window_body" class="body">
-			<div id="{name}_window_body_content" class="content" style="overflow:auto;">
-				<xsl:copy-of select="content" />
-			</div>
-		</div>
-		<div id="{name}_window_bottom" class="rodape" dragdrop="false"></div>
-		<div id="im_sub_menu"></div>
-	</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/xsl/list_ldap_contacts.xsl
===================================================================
--- /trunk/instant_messenger/xsl/list_ldap_contacts.xsl	(revision 151)
+++ 	(revision )
@@ -1,12 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="uids">
-	<xsl:for-each select="data">
-		<xsl:sort select="cn" case-order="upper-first" />
-		<option value="{mail};{uid}"><xsl:value-of select="cn" /> ( <xsl:value-of select="mail" /> ) </option>
-	</xsl:for-each>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/inc/Socket.abstract.php
===================================================================
--- /trunk/instant_messenger/inc/Socket.abstract.php	(revision 151)
+++ 	(revision )
@@ -1,87 +1,0 @@
-<?php
-/*
-+-------------------------------------------------------------------------+
-|                                                                         |
-| @FILE_NAME:   Socket.abstract.php                                       |
-| @CLASS_NAME:  (abstract) Jabber                                         |
-|                                                                         |
-| @DATE:        Wed May,16 2007 07:58:59                                  |
-| @LAST_CHANGE: Wed May,16 2007 08:03:28                                  |
-|                                                                         |
-| @AUTHOR:      [NUTS] Rodrigo Souza - rodsouza@celepar.pr.gov.br         |
-|                                                                         |
-| @BRIEF:       Abstract class for connect with a socket                  |
-|                                                                         |
-+-------------------------------------------------------------------------+
-*/
-
-abstract class Socket
-{
-	protected final function open( $pSocket = false, $pTimeOut = 1, $pBlockingMode = 0 )
-	{
-		if ( !$pSocket )
-			return false;
-
-		if ( $socket = @stream_socket_client($pSocket, $errno, $errstr) )
-		{
-			#stream_set_blocking($socket, $pBlockingMode);
-			#stream_set_timeout($socket, $pTimeOut);
-			stream_set_blocking($socket, 1);
-			stream_set_timeout($socket, 1);
-		}
-		return $socket;
-	}
-
-	protected final function blocking($pSocket = false, $pBlockingMode = 1)
-	{
-		if ( !$pSocket || !is_resource($pSocket) )
-			return false;
-
-		stream_set_blocking($pSocket, $pBlockingMode);
-	}
-
-
-	protected function read( $pSocket = false, $pLength = 4096 )
-	{
-		ini_set( 'track_errors', '1' );
-		$php_errormsg = '';
-
-		if ( !$pSocket || !is_resource($pSocket) )
-			return false;
-
-		set_magic_quotes_runtime(0);
-		$return = @fread($pSocket, $pLength);
-		set_magic_quotes_runtime(get_magic_quotes_gpc());
-
-
-		if ( $php_errormsg )
-			return false;
-
-		return $return;
-	}
-
-	protected function write( $pSocket = false, $pData = false )
-	{
-		ini_set( 'track_errors', '1' );
-		$php_errormsg = '';
-
-		if ( (!$pSocket || !is_resource($pSocket)) || !$pData )
-			return false;
-
-		$return = @fwrite($pSocket, $pData);
-
-		if ( $php_errormsg )
-			return false;
-
-		return $return;
-	}
-
-	protected final function close( $pSocket = false )
-	{
-		if ( !$pSocket || !is_resource($pSocket) )
-			return false;
-
-		return fclose($pSocket);
-	}
-}
-?>
Index: unk/instant_messenger/inc/im_acl.inc.php
===================================================================
--- /trunk/instant_messenger/inc/im_acl.inc.php	(revision 227)
+++ 	(revision )
@@ -1,53 +1,0 @@
-<?php
-$size_of_ACL = sizeof($GLOBALS['phpgw_info']['user']['acl']);
-
-for ( $i = 0; $i < $size_of_ACL && $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] == 'instant_messenger'; $i++ );
-
-$webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
-$webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
-
-if ( strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url)-1) )
-	$webserver_url .= '/';
-
-$webserver_url = $webserver_url . 'instant_messenger/';
-
-session_start();
-require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/im_sessions.inc.php';
-require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/load_lang.php';
-$_user     = $_SESSION['phpgw_info']['instant_messenger']['user'];
-$_pass     = $_SESSION['phpgw_info']['instant_messenger']['passwd'];
-$_server   = $_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-$_port     = $_SESSION['phpgw_info']['instant_messenger']['port_jabber'];
-$_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber'];
-session_write_close();
-
-$DOCUMENT_ROOT = PHPGW_SERVER_ROOT .'/instant_messenger/';
-
-$js = array(
-	'js/connector.js',
-	'js/xtools.js',
-	'js/jabber.js',
-	'js/client.js',
-	'js/images.js',
-	'js/dragdrop.js',
-	'js/build_win.js',
-	'js/templates.js',
-	'js/fcommon.js',
-	'js/menu_action.js',
-	'js/functions.js',
-	'js/images.js',
-	'js/cookies_im.js',
-	'js/load.js',
-);
-
-print '<script type="text/javascript">var path_im = "'.$webserver_url.'";</script>';
-
-foreach ( $js as $key => $val )
-	print '<script src="' . $webserver_url . $val . '?' . filemtime($DOCUMENT_ROOT . $val) . '"></script>';
-
-print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/window.css">';
-print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/chat.css">';
-print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/common.css">';
-
-print '<script type="text/javascript">setTimeout("client()",2000);</script>';
-?>
Index: unk/instant_messenger/inc/Jabberd2.abstract.php
===================================================================
--- /trunk/instant_messenger/inc/Jabberd2.abstract.php	(revision 227)
+++ 	(revision )
@@ -1,192 +1,0 @@
-<?php
-
-ini_set('include_path', $_SERVER['DOCUMENT_ROOT'] . '/instant_messenger/inc/');
-
-require_once 'Jabber.abstract.php';
-
-class Jabberd2 extends Jabber
-{
-	final function connect($pUser = false, $pPassword = false, $pConnectionType = false)
-	{
-		try
-		{
-			if ( $pUser && $pPassword && $pConnectionType )
-				if ( $_connect = parent::connect($pUser, $pPassword, $pConnectionType) )
-					return $_connect;
-
-			return false;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	function closeSocket()
-	{
-		$this->close($this->_socket);
-	}
-
-	function disconnect()
-	{
-		$this->_disconnect();
-	}
-
-	final function readSocket()
-	{
-		return $this->read();
-	}
-
-	final function writeSocket($pData)
-	{
-		return $this->write($pData);
-	}
-
-	/*
-	 * Jabber - Functions
-	 */
-
-	final function addContacts($pContact)
-	{
-		$jid = explode("@",$pContact['email']);
-		$jid = $jid[0]."@".$this->_server;
-		$name = $pContact['name'];
-		$group = $pContact['group'];
-
-		if(trim($jid[0]) != trim($this->_user))
-		{
-			if ( $jid )
-			{
-				$newcontact  = "<item jid='".$jid."'";
-				$newcontact .= " name='" . $name . "'";
-				$newcontact .= "><group>" . $group . "</group></item>";
-			}
-		}
-		$addid = "adduser_" . time();
-		if ( !$this->connected )
-			echo "disconnected";
-		else
-		{
-			if ( $this->writeSocket($this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $newcontact)) )
-				$this->getContacts();
-				echo "OK";
-		}
-	}
-
-	final function getContacts()
-	{
-		if ( !$this->isConnected() )
-			return "disconnected";
-
-		$this->iq('get', 'contacts', NULL, NULL, 'jabber:iq:roster');
-	}
-
-	final function getVcard($pJid)
-	{
-		if ( is_array($pJid) )
-		{
-			$jid = ( trim($pJid['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pJid['jid'];
-			$vcard = (trim($pJid['jid']) == "this") ? 'vCard_user' : 'vCard';
-			
-			if ( !$this->connected )
-			{
-				echo "disconnected";
-			}
-			else
-			{
-				$this->writeSocket($this->iq('get', $vcard, $jid, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>"));
-			}
-		}
-		else
-		{
-			$this->iq('get', 'vCard', $pJid, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>");
-		}
-	}
-
-	final function newVcard($NewVcard)
-	{
-		$id = $this->_user;
-
-		if ( !$this->connected )
-			echo "disconnected";
-		else
-		{
-			$this->writeSocket($this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard['vcard']."</vCard>"));
-			echo "OK";
-		}
-	}
-
-	final function removeContact($pContact)
-	{
-		$delid  = 'deluser_' . time();
-		if ( !$this->isConnected() )
-			return "disconnected";
-			
-		if ( $this->writeSocket($this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact['jid']."' subscription='remove'/>")) )
-			if ( $this->subscription($pContact['jid'],"unsubscribed") )
-				echo "OK";
-	}
-
-	final function subscription($pTo, $pType = false)
-	{
-		$jid = (is_array($pTo)) ? $pTo['jid'] : $pTo ;
-		$type = (is_array($pTo)) ? $pTo['type'] : $pType ;
-
-		if ( !$this->connected )
-			return false;
-		else
-		{
-			$this->writeSocket("<presence xmlns='jabber:client' from='".$this->_user."@".$this->_server."' type='".$type."' to='".$jid."'/>");
-			return true;
-		}
-	}
-
-	final function setPresence($pPresence = false)
-	{
-		if ( !$this->isConnected() )
-			return "disconnected";
-
-		if ( !$pPresence )
-			$this->presence();
-
-		$type = ( isset($pPresence['type']) ) ? $pPresence['type'] : NULL;
-		$to = ( isset($pPresence['to']) ) ? $pPresence['to'] : NULL;
-		$show = ( isset($pPresence['show']) ) ? $pPresence['show'] : NULL;
-		$status = ( isset($pPresence['status']) ) ? $pPresence['status'] : NULL;
-		$priority = ( isset($pPresence['priority']) ) ? $pPresence['priority'] : NULL;
-
-		$this->presence($type, $to, $show, $status, $priority);
-	}
-
-	final function setStatus()
-	{
-		$this->setPresence(array("type" => "unavailable"));
-		$this->setPresence(array("type" => "available"));	
-	}
-
-	final function updateContact($pContact)
-	{
-		$jid   = $pContact['jid'];
-		$name  = $pContact['name'];
-		$group = $pContact['group'];
-
-		if ( $jid )
-		{
-			$updatecontact  = "<item jid='$jid'";
-			$updatecontact .= " name='" . $name . "'";
-			$updatecontact .= "><group>" . $group . "</group></item>";
-		}
-
-		$upid = 'updateuser_' . time();
-		if ( !$this->connected )
-			echo "disconnected";
-		else
-		{
-			$this->writeSocket($this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact));
-			$this->getContacts();
-			echo "OK";
-		}
-	}
-}
-?>
Index: unk/instant_messenger/inc/class.contacts_im.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.contacts_im.inc.php	(revision 151)
+++ 	(revision )
@@ -1,120 +1,0 @@
-<?php
-
-require_once "class.ldap_im.inc.php";
-require_once "class.db_im.inc.php"; 
-
-class contacts_im
-{
-	private $ldap;
-	private $db_user;
-	
-	function __construct()
-	{
-		$this->ldap = new ldap_im();
-		$this->db_user = new db_im();		
-	}
-
-	private function users_auth_im()
-	{
-		$db_acls = $this->db_user->get_accounts_acl();
-		
-		$search_uids = "|";
-		if(count($db_acls) > 0)
-			foreach($db_acls as $tmp)
-				$search_uids .= "(uidNumber=".$tmp['acl_account'].")";
-
-		// Busca Usuarios
-		$uids = $this->ldap->list_users_ldap($search_uids);
-		
-		$search_groups = "|";
-		if(count($db_acls) > 0)
-			foreach($db_acls as $tmp)
-				$search_groups .= "(gidNumber=".$tmp['acl_account'].")";
- 
-		// Busca Grupos
-		$groups = $this->ldap->list_groups_ldap($search_groups);
-	
-		$search_uids = "|";
-		if($groups)
-		{
-			foreach($groups as $tmp)
-			{
-				$members = $tmp['members'];	
-				foreach($members as $mb)		
-					$search_uids .= "(uid=".$mb.")";			
-			}
-		}
-		
-		if($uids)
-		{
-			foreach($uids as $tmp)	
-				$search_uids .= "(uid=".$tmp['uid'].")";
-		}
-		$uids_members = $this->ldap->list_users_ldap($search_uids);	
-		
-		if(count($uids_members) > 0)
-			return $uids_members;
-		else
-			return 0; 
-	}
-		
-	function list_contacts($param)
-	{
-		$users	= $this->users_auth_im();
-		$order	= array();
-		$return	= "<uids>";
-		
-		foreach($users as $tmp)
-			$order[] = $tmp['cn'].";".$tmp['mail'].";".$tmp['uid'].";".$tmp['dn'];
-					
-		natsort($order);
-		$uid_unique = @array_values(@array_unique($order));
-		
-		foreach($uid_unique as $tmp)
-		{	
-			$result = explode(";",$tmp);
-			if(strtolower($result[3]) == strtolower($param['ou']))
-			{
-				$return .= "<data>";
-				$return .= "<cn>" . $result[0] . "</cn>";
-				$return .= "<mail>" . $result[1] . "</mail>";				
-				$return .= "<uid>" . $result[2] . "</uid>";
-				$return .= "</data>";
-			}
-			unset($result);
-		}			
-		
-		$return .= "</uids>";
-		return $return;
-	}
-	
-	function UserPermission($param)
-	{
-		$db_acls = $this->db_user->get_accounts_acl();
-		$members = array();		
-		$search_uid 	= "";
-		$search_groups = "|";
-		
-		$search_uid = $this->ldap->list_users_ldap("uid=".$param['uid']);
-
-		foreach($db_acls as $tmp)
-			if($tmp['acl_account'] == $search_uid[0]['uidnumber'])
-				return 1;
-			else
-				$search_groups .= "(gidNumber=".$tmp['acl_account'].")";
-
-		$groups = $this->ldap->list_groups_ldap($search_groups);
-
-		if($groups)
-		foreach($groups as $tmp){
-			$members = $tmp['members'];	
-			foreach($members as $mb){		
-				if(trim($mb) == trim($search_uid[0]['uid']))
-					return 1;
-			}			
-		}
-		
-		return 0;
-	}
-}
-?>
Index: unk/instant_messenger/inc/hook_admin.inc.php
===================================================================
--- /trunk/instant_messenger/inc/hook_admin.inc.php	(revision 20)
+++ 	(revision )
@@ -1,22 +1,0 @@
-<?php
-	/**************************************************************************\
-	* eGroupWare                                                               *
-	* http://www.egroupware.org                                                *
-	* Written by Joseph Engo <jengo@phpgroupware.org>                          *
-	* --------------------------------------------                             *
-	*  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.                                              *
-	\**************************************************************************/
-
-// Only Modify the $file and $title variables.....
-	$title = 'instant_messenger';
-	$file = array(
-		'Site Configuration'	=> $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)
-	);
-	
-//Do not modify below this line
-	display_section($appname,$title,$file);
-
-?>
Index: unk/instant_messenger/inc/load_lang.php
===================================================================
--- /trunk/instant_messenger/inc/load_lang.php	(revision 151)
+++ 	(revision )
@@ -1,26 +1,0 @@
-<?
-if ( !isset($_SESSION['phpgw_info']['instant_messenger']['lang']) || !is_array($_SESSION['phpgw_info']['instant_messenger']['lang']) )
-   if ( file_exists(($fn = dirname(__FILE__) . '/../setup/phpgw_pt-br.lang')) )
-      if ( ($fp = fopen($fn,'r')) )
-      {
-         while ($data = fgets($fp,16000))
-         {
-            list($message_id, $app_name, $null, $content) = explode("\t",substr($data,0,-1));
-            $_SESSION['phpgw_info']['instant_messenger']['lang'][$message_id] = $content;
-         }
-         fclose($fp);
-      }
-
-$script  = '<script>';
-$script .= 'var lang_im = [];';
-
-foreach ( $_SESSION['phpgw_info']['instant_messenger']['lang'] as $key => $value )
-   $script .= "lang_im['" . strtolower(addslashes($key)) . "'] = '" . addslashes($value) . "';";
-
-   #$_key = str_replace("'","\'",strtolower($key));
-   #$_val = str_replace("'","\'",$value);
-
-$script .= '</script>';
-
-echo $script;
-?>
Index: unk/instant_messenger/inc/class.ldap_im.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.ldap_im.inc.php	(revision 151)
+++ 	(revision )
@@ -1,191 +1,0 @@
-<?php
-class ldap_im
-{
-	private $ldap_host;
-	private $ldap_context;
-	private $conn;
-	private $user;
-	private $jid;
-	private $password;
-	
-	function __construct()
-	{
-		session_start();
-		$this->ldap_host 		= $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber'];
-		$this->ldap_context 	= $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber'];
-		$this->user 			= $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber'];
-		$this->password 		= $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'];
-		$this->jid				= $_SESSION['phpgw_info']['instant_messenger']['user'];
-		$this->connect_ldap(false);
-		session_write_close();
-	}
-	
-	function __destruct()
-	{
-		ldap_close($this->conn);
-	}
-	
-	function connect_ldap($refer)
-	{
-		$this->conn = ldap_connect($this->ldap_host);
-		ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3);
-		ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $refer);
-		if(trim($this->user) != "")
-			@ldap_bind($this->conn,$this->user,$this->password);
-		else		
-			@ldap_bind($this->conn);
-	}
-	
-	function get_photo_ldap($pUser,$getPhoto)
-	{
-		$user = ( $pUser == "im_avatar" ) ? $this->jid : $pUser ;
-		
-		if ($this->conn) 
-		{
-			$filter="(&(uid=".$user.")(phpgwAccountType=u))";		
-			$justthese = array("jpegphoto");
-			$search = @ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = @ldap_first_entry($this->conn, $search);
-			$jpeg_data = @ldap_get_values_len($this->conn, $entry, "jpegphoto");
-			
-			if( count($jpeg_data) > 1)
-			{
-				$photo = imagecreatefromstring($jpeg_data[0]);
-				if($photo)
-				{
-					if($getPhoto)
-					{
-						header("Content-Type: image/jpeg");
-						$width = imagesx($photo);
-						$height = imagesy($photo);
-						$twidth = 49;
-						$theight = 65;
-						$small_photo = imagecreatetruecolor ($twidth, $theight);
-						imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
-						imagejpeg($small_photo,'',100);
-						return;		
-					}else{
-						return "true";
-					}				
-				}else{
-					return "false";
-				}
-			}else{
-				return "false";
-			}
-		}
-	}
-	
-	function photo_ldap($user)
-	{
-		$uid = ( $user['uid'] == "im_avatar" ) ? $this->jid : $user['uid'] ;
-		return $this->get_photo_ldap($uid,false);
-	}
-	
-	function list_users_ldap($search)
-	{
-
-		if($this->conn){
-			$filter = "(&(".$search.")(phpgwAccountType=u))";
-			$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn");
-			$search = ldap_search($this->conn,$this->ldap_context,$filter,$justthese);
-			$entry = ldap_get_entries($this->conn,$search);
-		}
-		
-		if( $entry['count'] > 0){
-			$i = 0;
-			$result_user = array();
-			foreach($entry as $tmp)
-			{
-				if($tmp['uidnumber'][0] != "" && $tmp['phpgwaccountvisible'][0] != "-1"){
-					$result_user[$i]['uidnumber'] = $tmp['uidnumber'][0];			
-					$result_user[$i]['mail'] = $tmp['mail'][0];
-					$result_user[$i]['uid'] = $tmp['uid'][0];
-					$result_user[$i]['cn'] = $tmp['cn'][0];
-					$ou = explode("dc=",$tmp['dn']);
-					$ou = explode("ou=",$ou[0]);
-					$ou = array_pop($ou);
-					$result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1));					
-					$i++;
-				}				
-			}
-			return $result_user;
-		}
-		return 0;
-	}
-	
-	function list_groups_ldap($search)
-	{
-	
-		if( $this->conn ){
-			$filter = "(&(".$search.")(objectClass=posixGroup))";
-			$justthese = array("gidnumber","cn","memberuid");			
-			$search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = ldap_get_entries($this->conn,$search);
-		}
-
-		if($entry['count'] > 0){
-			$i = 0;
-			$result_groups = array();
-			foreach($entry as $tmpg){
-				if($tmpg['gidnumber'] != ""){
-					if(array_key_exists("memberuid", $tmpg)){
-						$result_groups[$i]['gidnumber'] = $tmpg['gidnumber'][0];						
-						@array_shift($tmpg['memberuid']);
-						foreach($tmpg['memberuid'] as $tmp)
-							$result_groups[$i]['members'][] = $tmp;					
-						$i++;
-					}
-				}
-			}	
-		}
-		
-		if(count($result_groups) > 0 ){
-			return $result_groups;
-		}else{
-			return 0;
-		}
-	}
-	
-	function list_organizations_ldap()
-	{
-		$result_org = "<organizations><ou></ou>";
-
-		if ($this->conn) 
-		{
-			$filter="ou=*";		
-			$justthese = array("ou");
-			$search = ldap_list($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = ldap_get_entries($this->conn, $search);
-		}
-		
-		foreach($entry as $tmp)
-			if($tmp['ou'][0] != "")
-				$result_org .= "<ou>" . $tmp['ou'][0] . "</ou>";  
-
-		$result_org .= "</organizations>";
-		
-		return $result_org;
-	}
-	
-	function info_user($user)
-	{
-		$uid = "uid=".$user['uid'];
-		$i= 0;
-		
-		$entry = $this->list_users_ldap($uid);
-		
-		if( count($entry) > 0 )
-			return $entry;
-		else
-			return false;	
-	}
-}
-
-if(trim($_REQUEST['user']) != "")
-{
-	$obj_img = new ldap_im();
-	$obj_img->get_photo_ldap($_REQUEST['user'],true);
-}
-
-?>
Index: unk/instant_messenger/inc/class.download.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.download.inc.php	(revision 20)
+++ 	(revision )
@@ -1,155 +1,0 @@
-<?php
-
-class download
-{
-	
-	function Decode_String($string)
-	{
-		$base64 = $string;	
-		$base64_de = base64_decode($base64);
-		$array_info = unserialize($base64_de);
-	
-		if($array_info['server'] == $_SERVER['SERVER_ADDR']){
-			$this->down_file($array_info['fileUp']);
-		}else{
-			$url = "http://".$array_info['server'].$array_info['path'].$array_info['filePhp'].$base64;
-			header("Location:" . $url);
-		}
-	}
-
-	function down_file($file)
-	{   
-		 
-		ini_set("session.save_path","/php_sessions");
-		$size = filesize(ini_get("session.save_path").'/'. $file);
-		$NameFile = explode("_IM_SendFile_",$file);
-	
-		 if (!empty($file))
-	     {
-		        if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
-		           $UserBrowser = "Opera";
-		        elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
-		            $UserBrowser = "IE";
-	            else
-		            $UserBrowser = '';
-
-				$strFileType = strrev(substr(strrev($NameFile),0,4));
-				$ContentType = "application/octet-stream";
-
-			   	if ($strFileType == ".asf") 
-			   		$ContentType = "video/x-ms-asf";
-			   	if ($strFileType == ".avi")
-			   		$ContentType = "video/avi";
-			   	if ($strFileType == ".doc")
-			   		$ContentType = "application/msword";
-			   	if ($strFileType == ".zip")
-			   		$ContentType = "application/zip";
-			   	if ($strFileType == ".xls")
-			   		$ContentType = "application/vnd.ms-excel";
-			   	if ($strFileType == ".gif")
-			   		$ContentType = "image/gif";
-			   	if ($strFileType == ".jpg" || $strFileType == "jpeg")
-			   		$ContentType = "image/jpeg";
-			   	if ($strFileType == ".wav")
-			   		$ContentType = "audio/wav";
-			   	if ($strFileType == ".mp3")
-			   		$ContentType = "audio/mpeg3";
-			   	if ($strFileType == ".mpg" || $strFileType == "mpeg")
-			   		$ContentType = "video/mpeg";
-			   	if ($strFileType == ".rtf")
-			   		$ContentType = "application/rtf";
-			   	if ($strFileType == ".htm" || $strFileType == "html")
-			   		$ContentType = "text/html";
-			   	if ($strFileType == ".xml") 
-			   		$ContentType = "text/xml";
-			   	if ($strFileType == ".xsl") 
-			   		$ContentType = "text/xsl";
-			   	if ($strFileType == ".css") 
-			   		$ContentType = "text/css";
-			   	if ($strFileType == ".php") 
-			   		$ContentType = "text/php";
-			   	if ($strFileType == ".asp") 
-			   		$ContentType = "text/asp";
-			   	if ($strFileType == ".pdf")
-			   		$ContentType = "application/pdf";
-			   	if ($strFileType == ".txt")
-			   		$ContentType = "text/plain";
-			   	if ($strFileType == ".log")
-			   		$ContentType = "text/plain";
-			   	if ($strFileType == ".wmv")
-			   		$ContentType = "video/x-ms-wmv";
-				if ($strFileType == ".sxc")
-					$ContentType = "application/vnd.sun.xml.calc";
-				if ($strFileType == ".odt")
-					$ContentType = "application/vnd.oasis.opendocument.text";
-				if ($strFileType == ".stc")
-					$ContentType = "application/vnd.sun.xml.calc.template";
-				if ($strFileType == ".sxd")
-					$ContentType = "application/vnd.sun.xml.draw";
-				if ($strFileType == ".std")
-					$ContentType = "application/vnd.sun.xml.draw.template";
-				if ($strFileType == ".sxi")
-					$ContentType = "application/vnd.sun.xml.impress";
-				if ($strFileType == ".sti")
-					$ContentType = "application/vnd.sun.xml.impress.template";
-				if ($strFileType == ".sxm")
-					$ContentType = "application/vnd.sun.xml.math";
-				if ($strFileType == ".sxw")
-					$ContentType = "application/vnd.sun.xml.writer";
-				if ($strFileType == ".sxq")
-					$ContentType = "application/vnd.sun.xml.writer.global";
-				if ($strFileType == ".stw")
-					$ContentType = "application/vnd.sun.xml.writer.template";
-				if ($strFileType == ".ps")
-					$ContentType = "application/postscript";
-				if ($strFileType == ".pps")
-					$ContentType = "application/vnd.ms-powerpoint";
-				if ($strFileType == ".odt")
-					$ContentType = "application/vnd.oasis.opendocument.text";
-				if ($strFileType == ".ott")
-					$ContentType = "application/vnd.oasis.opendocument.text-template";
-				if ($strFileType == ".oth")
-					$ContentType = "application/vnd.oasis.opendocument.text-web";
-				if ($strFileType == ".odm")
-					$ContentType = "application/vnd.oasis.opendocument.text-master";
-				if ($strFileType == ".odg")
-					$ContentType = "application/vnd.oasis.opendocument.graphics";
-				if ($strFileType == ".otg")
-					$ContentType = "application/vnd.oasis.opendocument.graphics-template";
-				if ($strFileType == ".odp")
-					$ContentType = "application/vnd.oasis.opendocument.presentation";
-				if ($strFileType == ".otp")
-					$ContentType = "application/vnd.oasis.opendocument.presentation-template";
-				if ($strFileType == ".ods")
-					$ContentType = "application/vnd.oasis.opendocument.spreadsheet";
-				if ($strFileType == ".ots")
-					$ContentType = "application/vnd.oasis.opendocument.spreadsheet-template";
-				if ($strFileType == ".odc")
-					$ContentType = "application/vnd.oasis.opendocument.chart";
-				if ($strFileType == ".odf")
-					$ContentType = "application/vnd.oasis.opendocument.formula";
-				if ($strFileType == ".odi")
-					$ContentType = "application/vnd.oasis.opendocument.image";
-				if ($strFileType == ".ndl")
-					$ContentType = "application/vnd.lotus-notes";
-								
-		        $mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream';
-	
-		        header("Content-Type: $ContentType");
-		        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
-		        header("Pragma: public");
-		        header("Expires: 0");
-		        header("Content-Disposition: attachment; filename=\"" . $NameFile[1] . "\"");
-				header("Content-length: " . $size);
-				readfile(ini_get("session.save_path") . "/" . $file); 
-				die();
-	    }
-	}
-}
-
-if(isset ($_REQUEST['file'])){
-	$obj_down = new download();
-	$obj_down->Decode_String($_REQUEST['file']);
-}
-
-?>
Index: unk/instant_messenger/inc/im_sessions.inc.php
===================================================================
--- /trunk/instant_messenger/inc/im_sessions.inc.php	(revision 164)
+++ 	(revision )
@@ -1,22 +1,0 @@
-<?php
-
-		$_SESSION['phpgw_info']['instant_messenger']['user']             = $GLOBALS['phpgw_info']['user']['account_lid'];
-		$_SESSION['phpgw_info']['instant_messenger']['user_id']			 = $GLOBALS['phpgw_info']['user']['account_id'];		
-		$_SESSION['phpgw_info']['instant_messenger']['passwd']           = $GLOBALS['phpgw_info']['user']['passwd'];
-		$_SESSION['phpgw_info']['instant_messenger']['name_jabber']      = $GLOBALS['phpgw_info']['server']['name_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['port_jabber']      = $GLOBALS['phpgw_info']['server']['port_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['resource_jabber']  = $GLOBALS['phpgw_info']['server']['resource_jabber'];
-		
-		$_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']   = $GLOBALS['phpgw_info']['server']['server_ldap_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']  = $GLOBALS['phpgw_info']['server']['context_ldap_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']     = $GLOBALS['phpgw_info']['server']['user_ldap_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['password_ldap_jabber'];
-		
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type'];
-
-?>
Index: unk/instant_messenger/inc/class.Ujabber.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.Ujabber.inc.php	(revision 236)
+++ 	(revision )
@@ -1,146 +1,0 @@
-<?php
-
-require_once 'Jabberd2.abstract.php';
-
-class Ujabber extends Jabberd2
-{
-	public final function __construct()
-	{
-		session_start();
-
-		$this->_user     = $_SESSION['phpgw_info']['instant_messenger']['user'];
-		$this->_pass     = $_SESSION['phpgw_info']['instant_messenger']['passwd'];
-		$this->_server   = $_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-		$this->_port     = $_SESSION['phpgw_info']['instant_messenger']['port_jabber'];
-		$this->_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber'];
-
-		session_write_close();
-
-		if ( $this->connect($this->_user . '@' . $this->_server . '/' . $this->_resource . ':' . $this->_port, $this->_pass, 'read/write') )
-			$this->connected = true;
-		else
-			$this->connected = false;
-	}
-
-	public final function __destruct()
-	{
-		$this->closeSocket();
-		ob_end_flush();
-		flush();
-	}
-	
-	public final function isConnected()
-	{
-		return $this->connected;
-	}
-	
-	public final function listen()
-	{
-		if ( !$this->isConnected() )
-			return "disconnected";
-
-		if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') )
-		{
-			sleep(1);
-			$xml = $this->readSocket();
-			printf("%s", $xml);
-		}
-		else
-		{
-			ob_end_clean();
-			ignore_user_abort(true);
-			ob_start();
-
-			$init = time();
-
-			while ( ( connection_aborted() === 0 ) && time() - $init < 50 )
-			{
-				# read from server and write in the client
-				$xml = $this->readSocket();
-				//var_dump($xml);
-				$xml = ( strlen($xml) ) ? $xml : ' ';
-				printf("%s", $xml);
-				ob_flush();
-				flush();
-				usleep(6000);
-			}
-		}
-	}
-
-	public final function SendMessage($pSendMessage)
-	{
-		if ( !$this->isConnected() )
-			return "disconnected";
-
-		$pSendMessage['body'] = stripslashes($pSendMessage['body']);
-
-		$patterns = array('/&nbsp;| +/i', '/<br[^>]*>/i');
-		$replace = array(' ', '<br />');
-		$pSendMessage['body'] = preg_replace($patterns, $replace, $pSendMessage['body']);
-
-		$_emotions  = '/<img emotion="(\S+)?"[^>]+>/';
-		$_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions);
-
-		foreach ( $emotions[0] as $key => $val )
-			$emotions[0][$key] = '/' . addcslashes($val, './()[]{}^$*&?') . '/i';
-
-		$pSendMessage['body'] = preg_replace($emotions[0], $emotions[1], $pSendMessage['body']);
-
-		$to = $pSendMessage['to'];
-		$type = "chat";
-		$id = "";
-		$content = array(
-			"subject" => $pSendMessage['subject'] ? $pSendMessage['subject'] : "",
-			"thread"  => $pSendMessage['thread'] ? $pSendMessage['thread'] : "",
-			"body"    => $pSendMessage['body'] ? $pSendMessage['body'] : ""
-		);
-
-		$payload = "";
-
-		if ($to && is_array($content))
-		{
-			if (!$id)
-			{
-				$id = $type . "_" . time();
-			}
-
-			$xml = "<message to='$to' type='$type' id='$id'>";
-
-			if ($content['subject'])
-			{
-				$xml .= "<subject>" . $content['subject'] . "</subject>";
-			}
-
-			if ($content['thread'])
-			{
-				$xml .= "<thread>" . $content['thread'] . "</thread>";
-			}
-
-			//Linha abaixo dentro do padrão xmpp, entretanto clientes como
-			//o PSI não seguem o padrão assim ocorre problemas de comunicação
-			//descomentar e retirar a seguinte para voltar ao padrÃ£o assim
-			//que possí­vel
-			//24/10/2007 - problema verificado por usuários do SERPRO na
-			//plataforma Windows ocorrendo também no cliente Linux
-			//por Alexandre e Rodrigo
-
-			//$xml .= "<html><body>" . $content['body'] . "</body></html>";
-
-			//retirar a linha abaixo para voltar ao padrÃ£o conforme acima
-			$xml .= "<body>" . $content['body'] . "</body>";
-			$xml .= $payload;
-			$xml .= "</message>";
-			unset($id);
-
-			echo $xml;
-			$this->writeSocket($xml);
-			$this->close();
-		}
-		else
-		{
-			//$this->writeLog("ERROR: SendMessage() #2");
-			return false;
-		}
-	}
-}
-?>
Index: unk/instant_messenger/inc/class.db_im.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.db_im.inc.php	(revision 164)
+++ 	(revision )
@@ -1,105 +1,0 @@
-<?php
-define('PHPGW_INCLUDE_ROOT','../');	
-define('PHPGW_API_INC','../phpgwapi/inc');
-require_once(PHPGW_API_INC.'/class.db.inc.php');
-	
-class db_im
-{	
-	
-	var $db;
-	var $db_name;
-	var $db_host;
-	var $db_port;
-	var $db_user;
-	var $db_pass;
-	var $db_type;
-	var $user_id;
-	var $teste;
-	
-	function db_im()
-	{
-		
-		session_start();		
-		$this->db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'];
-		$this->db_host = $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'];
-		$this->db_port = $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'];
-		$this->db_user = $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'];
-		$this->db_pass = $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'];
-		$this->db_type = $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'];
-		$this->user_id = $_SESSION['phpgw_info']['instant_messenger']['user_id'];
-		session_write_close();
-
-		$this->db = new db();
-		$this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type);		
-	}
-
-	function get_accounts_acl()
-	{
-		$result = array();
-		$query = "select acl_appname, acl_account from phpgw_acl where acl_appname = 'instant_messenger' order by acl_account";	
- 		
- 		if (!$this->db->query($query))
-        	return null;
-		
-		while($this->db->next_record())
-			$result[] = $this->db->row();
-
-		return $result;
-	}
-	
-	function query_db($pQuery)
-	{
-		if (!$this->db->query($pQuery))
-        	return false;
-		else
-			return true;
-	}
-	
-	function set_preferences($param)
-	{
-		$preferences = $param['preferences'];
-		$user_id  = $this->user_id;
-		$app_name = $this->name_app();
-		
-		$query = "insert into phpgw_preferences values('".$user_id."','".$app_name."','".serialize($preferences)."')";
-		
-		if($this->query_db($query))
-		{ 
-			return "true";
-		}
-		else
-		{
-			$query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='".$app_name."' and preference_owner='".$user_id."'";
-			if($this->query_db($query))
-				return "true";
-			else
-				return "false";			
-		}		
-	}
-	
-	function get_preferences()
-	{
-		$result = array();
-		$user_id  = $this->user_id;
-		$app_name = $this->name_app();
-		
-		$query = "select * from phpgw_preferences where preference_owner = '".$user_id."' and preference_app = '".$app_name."'";
-		
- 		if (!$this->db->query($query))
-        	return NULL;
-		
-		while($this->db->next_record())
-			$result[] = $this->db->row();
-
-		if(count($result) > 0)
-			return unserialize($result[0]['preference_value']);
-		else
-			return "ch_offline:true;time_xa_im:1;rd_nm:true;rd_ch:false";
-	}		
-	
-	function name_app()
-	{
-		return "instant_messenger";
-	}
-}
-?>
Index: unk/instant_messenger/inc/Jabber.abstract.php
===================================================================
--- /trunk/instant_messenger/inc/Jabber.abstract.php	(revision 239)
+++ 	(revision )
@@ -1,335 +1,0 @@
-<?php
-/*
-+---------------------------------------------------------------------------------+
-|                                                                                 |
-| @FILE:        Jabber.abstract.php                                               |
-| @ABSTRACT:    Jabber                                                            |
-| @EXTENDS:     Socket (Socket.class.php)                                         |
-|                                                                                 |
-| @DATE:        Wed May,16 2007 08:18:59                                          |
-| @LAST_CHANGE: Wed May,16 2007 09:03:28                                          |
-|                                                                                 |
-| @AUTHOR:      [NUTS] Rodrigo Souza - rodrigosouzadossantos [at] gmail [dot] com |
-|                                                                                 |
-| @BRIEF:       Abstract class for connect with any Jabber server                 |
-|                                                                                 |
-+---------------------------------------------------------------------------------+
-*/
-
-require_once 'Socket.abstract.php';
-
-abstract class Jabber extends Socket
-{
-	const J_FILE    = 'Jabber.log';
-	const J_ALL     = false;
-	const J_ERROR   = true;
-	const J_WARNING = true;
-	const J_NOTICE  = true;
-
-	const ALL     = 'ALL';
-	const ERROR   = 'ERROR';
-	const WARNING = 'WARNING';
-	const NOTICE  = 'NOTICE';
-
-	private final function _connect( $pUser = false, $pPassword = false, $pConnectionType = false )
-	{
-		try
-		{
-			if ( !preg_match('/^(.+)@(.+)\/(.+):(\d+)$/',$pUser, $matches) )
-				throw new Exception('[connect] #1 ' . $pUser . ' must be [USER]@[DOMAIN]/[RESOURCE]:[PORT] and [PORT] is integer. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			list($subject, $USER, $SERVER, $RESOURCE, $PORT) = $matches;
-
-			if ( !($socket = $this->open('tcp://' . $SERVER . ':' . $PORT, 1, 1)) )
-				throw new Exception('[connect] #2 can\'t access tcp://' . $SERVER . ':' . $PORT . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			$this->_socket = $socket;
-
-			fwrite($socket, "{$USER}@{$SERVER}##{$pPassword}##{$pConnectionType}");
-
-			$return = fread($socket, 3);
-
-			if ( $return == "new" )
-			{
-				$xml  = "<?xml version='1.0' ?>";
-				$xml .= "<stream:stream to='" . $SERVER . "' xmlns='jabber:client' ";
-				$xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>";
-
-				if ( $this->write($xml) === false )
-					throw new Exception('[connect] #4 it isn\'t possible connect in the server because exists a client connected with same user. File: ' . __FILE__ . '  ::  ' . __LINE__);
-			}
-
-			$this->_server = $SERVER;
-			$this->_username = $USER;
-			$this->_password = $pPassword;
-			$this->_resource = $RESOURCE;
-
-			return $return;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	protected function connect($pUser = false, $pPassword = false, $pConnectionType = false)
-	{
-		try
-		{
-			$_connect = $this->_connect($pUser, $pPassword, $pConnectionType);
-
-			if ( !$_connect )
-				throw new Exception('[connect] #0. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			if ( $_connect == "new" )
-			{
-				if ( ($xml = $this->read()) === false )
-					throw new Exception('[connect] #1 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-
-				if ( preg_match('/(<starttls .*<required\/><\/starttls>)/', $xml, $matches) )
-				{
-					if ( !$this->starttls() )
-						throw new Exception('[connect] #2 it isn\'t possible start tls. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-					# $this->writeLog('NOTICE', 'Connected TLS');
-				}
-				else
-				{
-					if ( !$this->_plain() )
-						throw new Exception('[connect] #3 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-				}
-			}
-
-			return $_connect;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			$this->_disconnect();
-			return false;
-		}
-	}
-
-	protected final function _disconnect()
-	{
-		try
-		{
-			$xml = "</stream:stream>";
-
-			#if ( $this->write($xml) === false )
-			#	throw new Exception('[disconnect] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			#if ( ($xml = $this->read()) === false )
-			#	throw new Exception('[disconnect] #2 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	private final function starttls()
-	{
-		try
-		{
-			$xml = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>";
-			if ( $this->write($xml) === false )
-				throw new Exception('[starttls] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			usleep(50000);
-			fread($this->_socket, 4096);
-
-			stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
-
-			$xml  = "<?xml version='1.0' encoding='UTF-8'?>";
-			$xml .= "<stream:stream to='" . $this->_server . "' xmlns='jabber:client' ";
-			$xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>";
-
-			if ( $this->write($xml) === false )
-				throw new Exception('[starttls] #2 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			usleep(50000);
-
-			fread($this->_socket, 4096);
-
-			usleep(50000);
-			
-			fread($this->_socket, 4096);
-			
-			if ( !$this->_plain() )
-				throw new Exception('[starttls] #3 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			return true;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	private final function _plain()
-	{
-		try
-		{
-			$this->blocking($this->_socket, 0);
-
-			if ( ($xml = $this->read()) === false )
-				throw new Exception('[_plain] #1 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			$xml  = "<username>" . $this->_username . "</username>";
-			$xml .= "<password>" . $this->_password . "</password>";
-			$xml .= "<resource>" . $this->_resource . "</resource>";
-
-			unset($this->_password);
-
-			if ( !$this->iq('set', 'auth_1', NULL, NULL, "jabber:iq:auth", $xml) )
-				throw new Exception('[_plain] #2 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			while ( !preg_match("/<iq xmlns='jabber:client' id='auth_1' type='(result|error)'/", ($readSocket = $this->read()), $matches) )
-				usleep(10000);
-
-			if($matches[1] == "error")
-				return false;
-
-			if ( ($xml = $this->read()) === false )
-				throw new Exception('[_plain] #3 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			return true;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	private final function _iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false )
-	{
-		$xml  = "<iq type='" . $pType . "' id='" . $pId . "'";
-		$xml .= ( $pTo ) ? " to='" . $pTo . "'" : "";
-		$xml .= ( $pFrom ) ? " from='" . $pFrom . "'" : "";
-
-		if ( $pXmlns == "vcard-temp" )
-		{
-			$xml .= ">";
-			$xml .= $pLoad;
-		}
-		else
-		{
-			$xml .= "><query xmlns='" . $pXmlns . "'";
-			$xml .= ( $pLoad ) ? ">" . $pLoad . "</query>" : "/>";
-		}
-
-		$xml .= "</iq>";
-
-		return $xml;
-	}
-
-	protected final function iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false)
-	{
-		try
-		{
-			if ( !preg_match("/^(get|set|result|error)$/i", $pType, $matches) )
-				throw new Exception('[iq] #1 type must be GET, SET, RESULT or ERROR. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			if ( $this->write($this->_iq($pType, $pId, $pTo, $pFrom, $pXmlns, $pLoad)) === false )
-				throw new Exception('[iq] #2 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-			else
-				return true;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	protected final function presence($pType = false, $pTo = false, $pShow = false, $pStatus = false, $pPriority = false)
-	{
-		try
-		{
-			$xml  = "<presence";
-			$xml .= ($pTo)   ? " to='{$pTo}'" : '';
-			$xml .= ($pType) ? " type='{$pType}'" : '';
-
-			if ( !($pStatus || $pShow || $pPriority) )
-				$xml .= "/>";
-			else
-			{
-				$xml .= ">";
-				$xml .= ($pStatus) ? "<status>" . $pStatus . "</status>" : '';
-				$xml .= ($pShow) ? "<show>" . $pShow . "</show>" : '';
-				$xml .= ($pPriority) ? "<priority>" . $pPriority . "</priority>" : '';
-				$xml .= ($pStatus || $pShow || $pPriority) ? "</presence>" : '';
-			}
-
-			if ( $this->write($xml) === false )
-				throw new Exception('[presence] #1 it isn\'t possible send presence for ' . $this->_server . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			return true;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	protected final function read()
-	{
-		$return = NULL;
-		do
-		{
-			$line = NULL;
-			$line = utf8_decode(parent::read($this->_socket, 4096));
-
-			if ( $line === false )
-			{
-				$return = false;
-				break;
-			}
-
-			if ( $line != NULL )
-				$return .= $line;// . "\n";
-		}
-		while ( $line != NULL );
-
-		return $return;
-	}
-
-	protected final function write($pData = false)
-	{
-		if ( !$pData )
-			return false;
-
-		return parent::write($this->_socket, utf8_encode($pData));
-	}
-
-	function __destruct()
-	{
-		$this->close($this->_socket);
-	}
-
-	protected final function writeLog($pType = false, $pLog = false)
-	{
-		if ( !defined('self::'.$pType) && !$pLog )
-			return false;
-
-		if ( !(bool)constant('self::J_'.$pType) && !(bool)constant('self::J_ALL') )
-			return false;
-
-		$log  = date('m/d/Y H:i:s');
-		$log .= ' [' . constant('self::'.$pType) . '] :: ';
-		$log .= $pLog . "\n";
-		if ( $fp = fopen (self::J_FILE, "a+") )
-		{
-			fwrite($fp, $log);
-			fclose($fp);
-		}
-	}
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/setup/phpgw_pt-br.lang
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/setup/phpgw_pt-br.lang	(revision 151)
+++ 	(revision )
@@ -1,78 +1,0 @@
-Add	instant_messenger	pt-br	Adicionar
-Add Contatct	instant_messenger	pt-br	Adicionar Contato
-add contact	instant_messenger	pt-br	Adicionar Contato
-add new contact	instant_messenger	pt-br	Adicionar Novo Contato
-add user	instant_messenger	pt-br	Adicionar Usuário
-Added information!	instant_messenger	pt-br	Informações Adicionadas!
-Authorization	instant_messenger	pt-br	Autorização
-away	instant_messenger	pt-br	Ausente
-Birthday	instant_messenger	pt-br	Aniversário
-busy	instant_messenger	pt-br	Ocupado
-change your Status	instant_messenger	pt-br	Mude seu estado
-Choice Contact	instant_messenger	pt-br	Escolha Contato
-Close	instant_messenger	pt-br	Fechar
-Close this menu	instant_messenger	pt-br	Fechar Menu
-Color	instant_messenger	pt-br	Cor
-Contact	instant_messenger	pt-br	Contato
-Contact Add	instant_messenger	pt-br	Contato Adicionado
-Custom message...	instant_messenger	pt-br	Mensagem ...
-Delete	instant_messenger	pt-br	Remover
-Description	instant_messenger	pt-br	Descrição
-Error in the message!	instant_messenger	pt-br	Erro na mensagem!
-E-mail	instant_messenger	pt-br	E-mail
-Font	instant_messenger	pt-br	Fonte
-Full Name	instant_messenger	pt-br	Nome Completo
-Group	instant_messenger	pt-br	Grupo
-instant_messenger	common	pt-br	Mensageiro Instantâneo
-instant_messenger_t	instant_messenger	pt-br	Mensageiro Instantâneo
-Information	instant_messenger	pt-br	Informações Adicionais
-Information User	instant_messenger	pt-br	Informações Pessoais
-Jid Contact	instant_messenger	pt-br	Email Expresso
-List of Contacts	instant_messenger	pt-br	Lista de Contatos
-Loading...	instant_messenger	pt-br	Carregando...
-Maximize/Restore	instant_messenger	pt-br	Maximizar/Restaurar Janela
-Minimize	instant_messenger	pt-br	Minimizar Janela
-Name	instant_messenger	pt-br	Nome
-Name full	instant_messenger	pt-br	Nome Completo
-Name Organization	instant_messenger	pt-br	Nome Organização
-New Message!	instant_messenger	pt-br	Nova Mensagem!
-Nick	instant_messenger	pt-br	Apelido
-Nickname	instant_messenger	pt-br	Apelido
-Not Auth	instant_messenger	pt-br	Não Autorizado
-Orgname	instant_messenger	pt-br	Organização
-Orgunit	instant_messenger	pt-br	Setor
-online	instant_messenger	pt-br	Online
-offline	instant_messenger	pt-br	Offline
-Options	instant_messenger	pt-br	Opções
-Photo	instant_messenger	pt-br	Foto
-Problems in its register \n	instant_messenger	pt-br	Problemas em seu registro
-preferences	instant_messenger	pt-br	Preferências
-Quick Contacts	instant_messenger	pt-br	Contatos Rápidos
-Re-connect Expresso Messenger ?	instant_messenger	pt-br	Reconectar Expresso Messenger ?
-Remove	instant_messenger	pt-br	Remover
-Remove Contact	instant_messenger	pt-br	Remover Contato
-Resize	instant_messenger	pt-br	Redimensionar
-Role	instant_messenger	pt-br	Função
-save	instant_messenger	pt-br	Salvar
-Search	instant_messenger	pt-br	Pesquisar
-Search, add, or invite	instant_messenger	pt-br	Procure, adicione ou convide
-See Info	instant_messenger	pt-br	Ver Info
-Send	instant_messenger	pt-br	Enviar
-Send File	instant_messenger	pt-br	Enviar Arquivo
-Size	instant_messenger	pt-br	Tamanho
-speak	instant_messenger	pt-br	fala
-Successfully effected register!	instant_messenger	pt-br	Registro efetuado com sucesso!
-Status	instant_messenger	pt-br	Status
-Status of the Transference	instant_messenger	pt-br	Status da Transferência
-Style	instant_messenger	pt-br	Estilo
-Telephone	instant_messenger	pt-br	Telefone
-to see preferences	instant_messenger	pt-br	Ver Preferências
-To define user information	instant_messenger	pt-br	Definir informações do usuário
-Update	instant_messenger	pt-br	Atualizar
-Vcard	instant_messenger	pt-br	Vcard
-You desire to register in service IM?	instant_messenger	pt-br	Você deseja registrar no serviço IM?
-your status	instant_messenger	pt-br	Seu status
-Wait a moment !!	pt-br	instant_messenger	Aguarde um momento !!
-waiting	instant_messenger	pt-br	Aguardando
-without_group	instant_messenger	pt-br	Sem Grupo
-Workgroup	instant_messenger	pt-br	Setor
Index: unk/instant_messenger/bkp/instant_messenger_64/setup/tables_current.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/setup/tables_current.inc.php	(revision 151)
+++ 	(revision )
@@ -1,24 +1,0 @@
-<?php
-	/***************************************************************************\
-	* Mensageiro Instantâneo												    *
-	* Alexandre Correia / Rodrigo Souza										    *
-	* ------------------------------------------------------------------------- *
-	*  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.                                               *
-	\***************************************************************************/
-  
-	$phpgw_baseline = array(
-		'phpgw_im_auth_user' => array(
-			'fd' => array(
-				'im_from' => array( 'type' => 'varchar', 'precision' => 150, 'nullable' => false ),
-				'im_to' => array( 'type' => 'varchar', 'precision' => 150, 'nullable' => false )
-			),
-			'pk' => array(),
-			'fk' => array(),
-			'ix' => array(),
-			'uc' => array()
-		),
-	);
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/setup/setup.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/setup/setup.inc.php	(revision 151)
+++ 	(revision )
@@ -1,32 +1,0 @@
-<?php
-	/****************************************************\
-	 * Im - Instant Messenger							*
-	 * Alexandre Correia								*
-	 * Rodrigo Souza									*
-	\****************************************************/
-	
-	$setup_info['instant_messenger']['name']      	= 'instant_messenger';
-	$setup_info['instant_messenger']['title']     	= 'Mensageiro Instantâneo';
-	$setup_info['instant_messenger']['version']   	= '0.2';
-	$setup_info['instant_messenger']['app_order'] 	= 9;
-	$setup_info['instant_messenger']['enable']    	= 1;
-	
-	/* Conf Table */
-	$setup_info['instant_messenger']['tables'][] = 'phpgw_im_auth_user';
-
-	$setup_info['instant_messenger']['author'] 			= '<b>Coordenadores do Projeto</b> : <br> - Joao Alfredo Knopik Junior (jakjr@celepar.pr.gov.br)<br> - Nilton Emilio Buhrer Neto (niltonneto@celepar.pr.gov.br)<br> <b>Desenvolvedores</b> <br> - Alexandre Correia (alexandrecorreia@celepar.pr.gov.br)<br>- Rodrigo Souza Santos (rodsouza@celepar.pr.gov.br)';
-	$setup_info['instant_messenger']['maintainer']	 	=  'Os mesmos';
-	$setup_info['instant_messenger']['maintainer_email']= '';
-
-	$setup_info['instant_messenger']['license']  	= 'GPL';
-	$setup_info['instant_messenger']['description'] = 'Módulo de IM com protocolo Jabber';
-
-	/* The hooks this app includes, needed for hooks registration */
-	$setup_info['instant_messenger']['hooks'][] = 'admin';
-		
-	/* Dependencies for this app to work */
-	$setup_info['instant_messenger']['depends'][] = array(
-		'appname' => 'phpgwapi',
-		'versions' => Array('0.9.14','0.9.15','1.0.0')
-	);
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/vcard_contacts.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/vcard_contacts.xsl	(revision 151)
+++ 	(revision )
@@ -1,29 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/retorno/vcard">
-   <html>
-   <head>
-   </head>
-   <body>
-      <div id="_im_vcard_contacts_childs">
-         <xsl:apply-templates select="div" />
-      </div>
-   </body>
-   </html>
-</xsl:template>
-
-<xsl:template match="div">
-   <div id="{@id}">
-      <FN><xsl:value-of select="FN" /></FN>
-      <NICKNAME><xsl:value-of select="NICKNAME" /></NICKNAME>      
-      <ROLE><xsl:value-of select="ROLE" /></ROLE>
-      <ORGNAME><xsl:value-of select="ORG/ORGNAME" /></ORGNAME>
-      <ORGUNIT><xsl:value-of select="ORG/ORGUNIT" /></ORGUNIT>
-      <BDAY><xsl:value-of select="BDAY" /></BDAY>
-      <DESC><xsl:value-of select="DESC" /></DESC>
-   </div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/contacts.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/contacts.xsl	(revision 151)
+++ 	(revision )
@@ -1,31 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/retorno/contacts">
-   <html>
-   <head>
-   </head>
-   <body>
-      <div id="all_groups">
-         <xsl:apply-templates select="group" />
-      </div>
-   </body>
-   </html>
-</xsl:template>
-
-<xsl:template match="group">
-   <div style="margin-left:16px;overflow:hidden;" id="{@name}">
-      <b><xsl:value-of select="@name" /></b>
-      <br />
-      <xsl:apply-templates select="item" />
-   </div>
-</xsl:template>
-
-<xsl:template match="item">
-   <div style="cursor:pointer;margin-left:8px;width:2000px" onmouseover="this.className='contato_hover'" onmouseout="this.className=''" onmousedown="javascript:IM.action_button(event, '{@jid}');" id="{@jid}">
-      <xsl:value-of select="@name" />
-   </div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/user_not_auth.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/user_not_auth.xsl	(revision 151)
+++ 	(revision )
@@ -1,41 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/jids">
-   <html>
-   <head>
-   </head>
-   <body>
-		<div style="margin-left:5px;margin-top:20px">
-			<b>
-			O(s) contato(s) abaixo aguarda(m) sua autorização.
-		    Para adicionar este(s) novo(s) contato(s) ou remover
-		    o(s) clique nas opções "Sim / Não". Para ver detalhes
-		    sobre o novo contato clique em "?".
-			<p />
-			Contato(s) :
-			</b>
-			<p />
-			<xsl:apply-templates select="item" />
-		</div>				
-   </body>
-   </html>
-</xsl:template>
-
-<xsl:template match="item">
-	 <div id="{@id}">
-        <span alt="Contato">
-        	<xsl:value-of select="@jid" />
-        </span>
-	    <span style="margin-left:20px" >
-	   		<a href="javascript:void(0);" onclick="IM_Preferences.Info_Contact('{@jid}');"> ? </a>
-	   	</span>
-		<span style="margin-left:10px">
-			<a href="javascript:void(0);" onclick="IM_Preferences.AcceptRequestUser('{@jid}');"> Sim </a>/<a href="javascript:void(0)" onclick="IM_Preferences.DenyRequestUser('{@jid}');" > Não </a>
-			<span id="_span_not_{@jid}"></span>
-		</span>
-	</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/preferences.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/preferences.xsl	(revision 151)
+++ 	(revision )
@@ -1,32 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/preferences">
-   <html>
-   <head>
-   </head>
-   <body>
-	  <div id="im_preferences" style="margin-left:5px;margin-top:5px">
-		  <fieldset><legend> Opções :</legend>
-			  <input id="ch_offline" type="checkbox" /> Exibir amigos desconectados
-		  </fieldset>
-		  <br />
-		  <fieldset><legend> Ausente : </legend>	
-  			  Ficar ausente depois de <input id="in_time" type="input" size="2" maxlength="2"/> minutos :
-		  </fieldset>		
-		  <br />	
-  		  <fieldset>
-  		  	  <legend> Ativar aviso de mensagens recebidas :</legend>
-	    	  <input id="rd_nm" type="radio" name="rd_aviso" /> Normal <br />
-			  <input id="rd_ch" type="radio" name="rd_aviso" /> Treme Tela
-  		  </fieldset>
-		  	<br/>
-		  	<input type="button" value="Salvar" onclick="javascript:IM_Preferences.SetYourPreferences();" />
-			<input type="button" value="Fechar" onclick="javascript:im_win.windowClose('divYourPreferences_im');"/>
-	  </div>
-   </body>
-   </html>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/del_user.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/del_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,23 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/deluser/body">
-	<html>
-		<head>
-		</head>
-		<body>	
-			<div style="margin-left:20px;margin-top:20px">
-				<span><b><xsl:value-of select="@lang1"/> .: </b></span> 
-				<div style="margin-top:3px">
-					<select id="sel_contact"></select>
-					<span style="margin-left:7px">
-						<input type="button" value="{@lang2}" onclick="javascript:IM_Preferences.RemoveContact()" />
-						<input type="button" value="{@lang3}" onclick="javascript:im_win.windowClose('divDelUser_im');"/>														
-					</span>
-				</div>
-			</div>
-		</body>
-	</html>
-</xsl:template>
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/information_user.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/information_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,102 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/info_user">
-	<html>
-		<head>
-		</head>
-		<body>
-			<table border="0" cellpadding="1" cellspacing="2" width="90%" style="margin-top:10px">
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/FN"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/fn">
-						<td><input id="FN" type="text" size="40" maxlength="40" value="{vcard/fn}"/></td>			          
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="FN" type="text" size="40" maxlength="40" value="{vcard/FN}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/NICKNAME"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/nickname">
-						<td><input id="NICKNAME" type="text" size="20" maxlength="20" value="{vcard/nickname}" /></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="NICKNAME" type="text" size="20" maxlength="20" value="{vcard/NICKNAME}" /></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/ORGNAME"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/orgname">
-						<td><input id="ORGNAME" type="text" size="17" maxlength="17" value="{vcard/orgname}"/></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="ORGNAME" type="text" size="17" maxlength="17" value="{vcard/ORGNAME}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/ORGUNIT"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/orgunit">
-						<td><input id="ORGUNIT" type="text" size="10" maxlength="10" value="{vcard/orgunit}"/></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="ORGUNIT" type="text" size="10" maxlength="10" value="{vcard/ORGUNIT}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/ROLE"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/role">
-						<td><input id="ROLE" type="text" size="25" maxlength="25" value="{vcard/role}"/></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="ROLE" type="text" size="25" maxlength="25" value="{vcard/ROLE}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/BDAY"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/bday">
-						<td><input id="BDAY" type="text" size="10" maxlength="10" value="{vcard/bday}"/></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="BDAY" type="text" size="10" maxlength="10" value="{vcard/BDAY}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/DESC"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/desc">
-						<td><input id="DESC" type="text" size="40" maxlength="40" value="{vcard/desc}"/></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="DESC" type="text" size="40" maxlength="40" value="{vcard/DESC}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-			</table>
-
-			<table border="0" cellpading="1" cellspacing="2" width="100%">
-				<tr>
-					<td>
-						<input type="button" value="{getlang/SAVE}" onclick="javascript:IM_Preferences.vCardAdd();" />
-						<input type="button" value="{getlang/CLOSE}" onclick="javascript:im_win.windowClose('divInfoUser_im');"/>									
-					</td>
-				</tr>
-			</table>
-		</body>
-	</html>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/message.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/message.xsl	(revision 151)
+++ 	(revision )
@@ -1,15 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/">
-   <html>
-   <head>
-   </head>
-   <body>
-      <xsl:copy-of select="." />
-   </body>
-   </html>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/menu_preferences.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/menu_preferences.xsl	(revision 151)
+++ 	(revision )
@@ -1,18 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/">
- <html>
-  <body>
-   <dl id="dl_im_menu_preferences">
-   <xsl:for-each select="menu/item">
-      <dt><a href="javascript:void(0);" onclick="javascript:{@function}">
-      	  <xsl:value-of select="@lang"/></a>
-      </dt>
-   </xsl:for-each>
-   </dl>
- </body>
- </html>
-</xsl:template>
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/add_user.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/add_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,52 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/adduser">
- <html>
-  <head>
-  </head>
-  <body>
-	<div style="margin-left:5px;margin-top:5px">
-		<xsl:apply-templates select="top" />
-	</div>
-	<table border="0" cellpadding="1" cellspacing="2" style="margin-left:5px;margin-top:5px">
-	     <xsl:apply-templates select="bottom" />
-   	</table>
- </body>
- </html>
-</xsl:template>
-
-<xsl:template match="top">
-	<b><xsl:value-of select="@lang1"/> .: </b>
-	<select id="ImSelOrg" name="ImSelOrg" onchange="IM_Preferences.SearchContacts();"></select>
-	<span id="_span_load_im" style="background-color:#cc4444;color:white;display:none;position:absolute;right:0px;top:0px">Carregando .....</span>	
-	<select size="10" id="ImSelAddContact" name="ImSelAddContact" class="add_user" onclick="IM_Preferences.preenche();"></select>
-</xsl:template>
-
-<xsl:template match="bottom">
-	<tr>
-		<td><b><xsl:value-of select="@lang1"/>.:</b></td>
-		<td><input id="text0" type="text" size="40" maxlength="40" readonly="true" /></td>		
-	</tr>
-	<tr>
-		<td><b><xsl:value-of select="@lang2"/>.:</b></td>
-		<td><input id="text1" type="text" size="20" maxlength="20" /></td>		
-	</tr>
-	<tr>
-		<td><b><xsl:value-of select="@lang3"/>.:</b></td>
-		<td><input id="text2" type="text" size="20" maxlength="20" /></td>		
-	</tr>
-	<tr>
-		<td><input id="text3" type="hidden" size="30" maxlength="30" /></td>
-	</tr>							
-	<tr>
-		<td colspan="2">
-			<input type="button" value="{@lang4}" onclick="javascript:IM_Preferences.Add_user('divAddUser_im');" />
-			<input type="button" value="Fechar" onclick="javascript:im_win.windowClose('divAddUser_im');"/>
-			<span id="im_status_add" style="color:#f00;font-weight:bold;margin-left:10px;"></span>			
-		</td>
-	</tr>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/info_contact.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/info_contact.xsl	(revision 151)
+++ 	(revision )
@@ -1,61 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="no"/>
-
-<xsl:template match="/info_contact">
-	<html>
-		<head>
-		</head>
-		<body>
-			<table border="0" cellpading="1" cellspacing="2" width="90%" style="margin-top:10px">
-				<tr>
-					<td width="30%" align="right">
-						<xsl:value-of select="getlang/FN" /> :
-					</td>
-					<td width="70%" align="left">
-						<xsl:value-of select="vcard/FN" />
-						<xsl:value-of select="vcard/fn" />						
-					</td>
-				</tr>
-				<tr>
-					<td width="30%" align="right">
-						<xsl:value-of select="getlang/NICKNAME" /> :
-					</td>
-					<td width="70%" align="left">
-						<xsl:value-of select="vcard/NICKNAME" />
-						<xsl:value-of select="vcard/nickname" />						
-					</td>
-				</tr>
-				<tr>
-					<td width="30%" align="right">
-						<xsl:value-of select="getlang/ORGUNIT" /> :
-					</td>
-					<td width="70%" align="left">
-						<xsl:value-of select="vcard/ORGUNIT" />
-						<xsl:value-of select="vcard/orgunit" />						
-					</td>
-				</tr>
-				<tr>
-					<td width="30%" align="right">
-						<xsl:value-of select="getlang/ROLE" /> :
-					</td>
-					<td width="70%" align="left">
-						<xsl:value-of select="vcard/ROLE" />
-						<xsl:value-of select="vcard/role" />						
-					</td>
-				</tr>
-				<tr>
-					<td width="30%" align="right">
-						<xsl:value-of select="getlang/BDAY" /> :
-					</td>
-					<td width="70%" align="left">
-						<xsl:value-of select="vcard/BDAY" />
-						<xsl:value-of select="vcard/bday" />
-					</td>
-				</tr>
-			</table>
-		</body>
-	</html>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/info_contact_ldap.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/info_contact_ldap.xsl	(revision 151)
+++ 	(revision )
@@ -1,40 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/info_user">
- <html>
-  <head>
-  </head>
-  <body>
-	<table style="background-color:#cbdae4;width:100%;border:1px solid #809aa9">
-		<tr>
-		   <td style="vertical-align:top;width:80%">
-				<xsl:apply-templates select="item" />
-		   </td>
-		   <td style="vertical-align:top">
-		   		<span id="im_span_avatar"></span>
-	   	   </td>
-   	    </tr>
-	</table>	
- </body>
- </html>
-</xsl:template>
-
-<xsl:template match="item">
-	<div style="padding-bottom"> 
-	   <span>
-	   		<b><label><xsl:value-of select='@lang_name' /></label></b>
-	   		<br/><xsl:value-of select='@name' />
-	   </span>
-	   		<br/>
-	   		<br/>
-	   <span>
-	   		<b><label><xsl:value-of select='@lang_email' /></label></b>
-	   		<br/><xsl:value-of select='@email' />
-	   </span>
-	   		<br/>
-   </div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/upd_user.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/upd_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,40 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/updUser">
- <html>
-  <head>
-  </head>
-  <body>
-		<table border='0' cellpadding='1' cellspacing='2' align='center' width='90%'>
-			<xsl:apply-templates select="body" />
-		</table>
- </body>
- </html>
-</xsl:template>
-
-<xsl:template match="body">
-		<tr>
-			<td>
-				<input id="text0" type="hidden" size="40" maxlength="40" />
-			</td>
-		</tr>
-		<tr>
-			<td><b>Contato .:</b></td>
-			<td><span id="span0"></span></td>
-		</tr>
-		<tr>
-			<td><b><xsl:value-of select="@lang1" />.:</b></td>
-			<td><input id="text1" type="text" size="20" maxlength="20" /></td>
-		</tr>
-		<tr>
-			<td><b><xsl:value-of select="@lang2" />.:</b></td>
-			<td><input id="text2" type="text" size="20" maxlength="20" /></td>
-		</tr>
-		<tr>
-			<td colspan="2"><input type="button" value="{@lang3}" onclick="IM_Preferences.Add_user('divUpdateUser_im')" /></td>
-		</tr>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/xsl/window.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/xsl/window.xsl	(revision 151)
+++ 	(revision )
@@ -1,57 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/window">
-   <html>
-   <head>
-   </head>
-   <body>
-      <div id="{@id}_im_window_master" class="master" style="top:{@top};left:{@left};height:{(@height + 48)};width:{(@width + 12)};{@style};">
-        <div id="{@id}_im_window" class="pai" style="height:{(@height + 40)};">
-         	<div id="{@id}_im_window_icon" class="im_window_icon" />
-            <div class="tit"><xsl:value-of select="@title" /></div>
-            <xsl:apply-templates select="/" mode='buttons' />
-            <div class="filho" id="{@id}_im_window_body_inner" style="width:{@width};height:{@height};" />
-         </div>      
-      </div>
-
-      <div class="im-windowfantom-des" id="{@id}_im_window_fantom" />
-      <div class="im-windowfantom-des" id="{@id}_im_window_movable" />
-      <div class="im-window-resizehandle" id="{@id}_im_window_resize" style="visibility:hidden;" />
-   </body>
-   </html>
-</xsl:template>
-
-<xsl:template match="/window" mode="buttons">
-   <xsl:if test='@close and @close="true"'>
-      <div class="im-window-button im-window-closebutton" style="z-index:6000;right:4px" onclick="im_win.windowClose(this.parentNode.id);" />
-   </xsl:if>
-
-   <xsl:if test='@maximize and @maximize="true"'>
-      <xsl:choose>
-         <xsl:when test='@close and @close="true"'>
-            <div class="im-window-button im-window-maximizerestorebutton" style="z-index:6000;right:20px" onclick="im_win.windowMaximizeRestore(this.parentNode.id);" />
-         </xsl:when>
-         <xsl:otherwise>
-            <div class="im-window-button im-window-maximizerestorebutton" style="z-index:6000;right:4px" onclick="im_win.windowMaximizeRestore(this.parentNode.id);" />
-         </xsl:otherwise>
-      </xsl:choose>
-   </xsl:if>
-
-   <xsl:if test='@minimize and @minimize="true"'>
-      <xsl:choose>
-         <xsl:when test='@close and @close="true" and @maximize and @maximize="true"'>
-            <div class="im-window-button im-window-minimizebutton" style="z-index:6000;right:36px" onclick="im_win.windowMinimize(this.parentNode.id);" />
-         </xsl:when>
-         <xsl:when test='(@close and @close="true" or @maximize and @maximize="true") and not (@close and @close="true" and @maximize and @maximize="true")'>
-            <div class="im-window-button im-window-minimizebutton" style="z-index:6000;right:20px" onclick="im_win.windowMinimize(this.parentNode.id);" />
-         </xsl:when>
-         <xsl:otherwise>
-            <div class="im-window-button im-window-minimizebutton" style="z-index:6000;right:4px" onclick="im_win.windowMinimize(this.parentNode.id);" />
-         </xsl:otherwise>
-      </xsl:choose>
-   </xsl:if>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_64/docs/change_log.txt
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/docs/change_log.txt	(revision 151)
+++ 	(revision )
@@ -1,23 +1,0 @@
-Esse arquivo descreve todas as correções, alterações e novas implementações do 
-módulo instant_messenger, e a partir da versão 27/04/2007 [0.001]
-Alexandre Luiz Correia
-Rodrigo Souza dos Santos.
-
-27/04/2007 [0.001]
-- Vcard, corrigido para a visualização de caracteres e acentos. 
-
-14/08/2007
-- Criado script IMManager.php, para conexão com o servidor Jabberd.
-- Mudança de status, offline, online, ausente,...etc, conforme documentação do xmpp
-- Novo layout para a troca de mensagens.
-
-16/08/2007
-- Permanência de estado ( online, offline, ausente, invisível), quando é feito o refresh
-de página no expresso.
-
-21/08/2007
-- Corrigido a mudança de status automática
-- Layout do adicionar contato não gera mais scrolls
-
-23/08/2007
-- Arrumado o tipo de cursor no IE na mudança de Status
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/Socket.abstract.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/Socket.abstract.php	(revision 151)
+++ 	(revision )
@@ -1,85 +1,0 @@
-<?php
-/*
-+-------------------------------------------------------------------------+
-|                                                                         |
-| @FILE_NAME:   Socket.abstract.php                                       |
-| @CLASS_NAME:  (abstract) Jabber                                         |
-|                                                                         |
-| @DATE:        Wed May,16 2007 07:58:59                                  |
-| @LAST_CHANGE: Wed May,16 2007 08:03:28                                  |
-|                                                                         |
-| @AUTHOR:      [NUTS] Rodrigo Souza - rodsouza@celepar.pr.gov.br         |
-|                                                                         |
-| @BRIEF:       Abstract class for connect with a socket                  |
-|                                                                         |
-+-------------------------------------------------------------------------+
-*/
-
-abstract class Socket
-{
-	protected final function open( $pSocket = false, $pTimeOut = 1, $pBlockingMode = 0 )
-	{
-      if ( !$pSocket )
-         return false;
-
-		$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
-
-      $pSocket = substr($pSocket, 6);
-      if ( $socket = socket_connect($sock, substr($pSocket, 0, strpos($pSocket, ":")), substr($pSocket, strpos($pSocket, ":") + 1)) )
-      {
-         socket_set_block($sock);
-      }
-
-      return $sock;
-	}
-
-   protected final function blocking($pSocket = false, $pBlockingMode = 1)
-   {
-      if ( !$pSocket || !is_resource($pSocket) )
-         return false;
-
-      if ( $pBlockingMode == 1 )
-      	socket_set_block($pSocket);
-		else
-			socket_set_nonblock($pSocket);
-   }
-
-	protected function read( $pSocket = false, $pLength = 4096 )
-	{
-      ini_set( 'track_errors', '1' );
-
-      if ( !$pSocket || !is_resource($pSocket) )
-         return false;
-
-      $return = socket_read($pSocket, $pLength);
-
-      if ( $php_errormsg )
-         return false;
-
-      return $return;
-	}
-
-	protected function write( $pSocket = false, $pData = false )
-	{
-      ini_set( 'track_errors', '1' );
-      
-      if ( (!$pSocket || !is_resource($pSocket)) || !$pData )
-         return false;
-
-		$return = @socket_write($pSocket, $pData);
-      
-      if ( $php_errormsg )
-         return false;
-
-      return $return;
-	}
-
-	protected final function close( $pSocket = false )
-	{
-      if ( !$pSocket || !is_resource($pSocket) )
-         return false;
-
-		return socket_close($pSocket);
-	}
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/im_acl.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/im_acl.inc.php	(revision 151)
+++ 	(revision )
@@ -1,77 +1,0 @@
-<?php
-   for ( $i = 0; $i < sizeof($GLOBALS['phpgw_info']['user']['acl']); $i++ )
-   {
-      if ( $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] == 'instant_messenger')
-      {
-			require_once("im_sessions.inc.php");
-         
-         $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
-         $wz_dragdrop = $webserver_url."/phpgwapi/js/wz_dragdrop/";
-         $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
-
-         if ( strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url)-1) )
-            $webserver_url .= '/';
-
-         $webserver_url = $webserver_url . 'instant_messenger/';
-
-         require_once("IMConfigure.php");
-
-         $_transport = TRANSPORT_NON_SECURITY;
-         $_port = PORT_NON_SECURITY;
-
-			$SERVER = "127.0.0.1";
-
-			$fp  = "";
-			@$fp = stream_socket_client($_transport . "://" . $SERVER . ":" . $_port, $errno, $errstr, 10);
-
-         if ( $fp )
-         {
-
-            fwrite($fp, "GET /" . CONNECT . ";" . session_id() . " HTTP/1.1\r\nHost: " . $SERVER . ":" . $_port . "\r\nAccept: */*\r\n\r\n");
-
-            $js = array(
-                        $webserver_url . 'js/XMLTools.js',
-                        $webserver_url . 'js/im_functions.js',
-                        $webserver_url . 'js/im_fcommon.js',
-                        $webserver_url . 'js/im_var_globals.js',
-                        $webserver_url . 'js/im_images.js',
-                        $webserver_url . 'js/im_smiles.js',
-                        $webserver_url . 'js/im_templates.js',
-                        $webserver_url . 'js/im_win.js',
-                        $webserver_url . 'js/im_menu_action.js',
-                        $webserver_url . 'js/im_conf_font.js',
-                        $webserver_url . 'js/im_preferences.js',
-                        $webserver_url . 'js/im_init.js',
-						      $webserver_url . 'js/im_subscription.js',
-                       );
-
-            require_once('load_lang.php');
-
-         	print '
-               <link rel="stylesheet" href="' . $webserver_url . 'templates/default/css.css" />
-               <link rel="stylesheet" href="' . $webserver_url . 'templates/default/messenger.css" />
-               <script>
-                  var im_path="' . $webserver_url . '";
-                  var ini_wzdd = false;
-                  if ( !window.dd )
-                  {
-                     ini_wzdd = true;
-                     document.write(\'\<script src="' . $wz_dragdrop . 'wz_dragdrop.js"\>\<\/script\>\');
-                     var im_path="' . $webserver_url . '";
-                  }
-               </script>';
-         
-          print '
-               <script>
-                  if ( ini_wzdd )
-                     SET_DHTML("backFantom"+NO_DRAG);
-               </script>';
-
-          foreach ( $js as $key => $val )
-             print '<script src="' . $val . '?' . filemtime($_SERVER['DOCUMENT_ROOT'] . '/' . $val) . '"></script>';
-          
-         }
-         break;
-      }
-   }
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/Jabberd2.abstract.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/Jabberd2.abstract.php	(revision 151)
+++ 	(revision )
@@ -1,117 +1,0 @@
-<?php
-
-ini_set('include_path', $_SERVER['DOCUMENT_ROOT'] . '/instant_messenger/inc/');
-
-require_once 'Jabber.abstract.php';
-
-class Jabberd2 extends Jabber
-{
-   final function connect($pUser = false, $pPassword = false)
-   {
-      try
-      {
-         if ( parent::connect($pUser, $pPassword) )
-            if ( $this->presence() )
-               return true;
-
-         return false;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-   function disconnect()
-   {
-      $this->_disconnect();
-   }
-
-   final function readSocket()
-   {
-      return $this->read();
-   }
-
-   final function writeSocket($pData)
-   {
-      return $this->write($pData);
-   }
-	
-	final function setPresence($pPresence)
-	{
-		$type = ( isset($pPresence['type']) ) ? $pPresence['type'] : NULL;
-		$to = ( isset($pPresence['to']) ) ? $pPresence['to'] : NULL;
-		$show = ( isset($pPresence['show']) ) ? $pPresence['show'] : NULL;
-		$status = ( isset($pPresence['status']) ) ? $pPresence['status'] : NULL;
-		$priority = ( isset($pPresence['priority']) ) ? $pPresence['priority'] : NULL;
-		
-		$this->presence($type, $to, $show, $status, $priority);
-	}
-	/*
-	 * Vcard
-	 */
-
-   final function getVcard($pVcard)
-   {
-		$this->iq('get', $pVcard, $pVcard, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>");
-   }
-
-   final function newVcard($NewVcard)
-   {
-   	$id = $_SESSION['phpgw_info']['instant_messenger']['user'];
-   	$this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard."</vCard>");	
-   }
-	
-	/*
-	 *  Contacts
-	 */
-
-   final function getContacts()
-   {
-		$this->iq('get', 'contacts', NULL, NULL, 'jabber:iq:roster');
-   }
-   
-   final function addContacts($pContact)
-   {
-   	$addid = "adduser_" . time();
-   	$this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $pContact);
-   }
-   
-   final function removeContact($pContact)
-   {
-   	$delid  = 'deluser_' . time();
-   	$this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact."' subscription='remove'/>");
-   }
-   
-   final function updateContact($pContact)
-   {
-   	$upid = 'updateuser_' . time();
-   	$this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $pContact);
-   }
-   
-   /*
-    * Presence 
-    */
-   
-   final function SubscriptionAcceptRequest($to = NULL)
-	{
-		$this->presence("subscribed", $to);
-	}
-
-	final function SubscriptionDenyRequest($to = NULL)
-	{
-		$this->presence("unsubscribed", $to);
-	}
-
-	final function Subscribe($to = NULL)
-	{
-		$this->presence("subscribe", $to);
-	}
-
-	final function Unsubscribe($to = NULL)
-	{
-		$this->presence("unsubscribe", $to);
-	}
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/class.contacts_im.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/class.contacts_im.inc.php	(revision 151)
+++ 	(revision )
@@ -1,120 +1,0 @@
-<?php
-
-require_once "class.ldap_im.inc.php";
-require_once "class.db_im.inc.php"; 
-
-class contacts_im
-{
-	private $ldap;
-	private $db_user;
-	
-	function __construct()
-	{
-		$this->ldap = new ldap_im();
-		$this->db_user = new db_im();		
-	}
-
-	private function users_auth_im()
-	{
-		$db_acls = $this->db_user->get_accounts_acl();
-		
-		$search_uids = "|";
-		foreach($db_acls as $tmp)
-			$search_uids .= "(uidNumber=".$tmp['acl_account'].")";
-
-		// Busca Usuarios
-		$uids = $this->ldap->list_users_ldap($search_uids);
-		
-		$search_groups = "|";
-		foreach($db_acls as $tmp)
-			$search_groups .= "(gidNumber=".$tmp['acl_account'].")";
- 
-		// Busca Grupos
-		$groups = $this->ldap->list_groups_ldap($search_groups);
-				
-		$search_uids = "|";
-		if($groups)
-		{
-			foreach($groups as $tmp)
-			{
-				$members = $tmp['members'];	
-				foreach($members as $mb)		
-					$search_uids .= "(uid=".$mb.")";			
-			}
-		}
-		
-		if($uids)
-		{
-			foreach($uids as $tmp)	
-				$search_uids .= "(uid=".$tmp['uid'].")";
-		}
-		$uids_members = $this->ldap->list_users_ldap($search_uids);	
-					
-		if(count($uids_members) > 0)
-			return $uids_members;
-		else
-			return 0; 
-	}
-		
-	function list_contacts($param)
-	{
-		$users = $this->users_auth_im();
-		$ordenar = array();
-		$return = array();
-		$i = 0;
-		
-		foreach($users as $tmp)
-			$ordenar[] = $tmp['cn'].";".$tmp['mail'].";".$tmp['uid'].";".$tmp['dn'];
-					
-		natsort($ordenar);
-		$uid_unique = @array_values(@array_unique($ordenar));
-		
-		foreach($uid_unique as $tmp)
-		{	
-			$result = explode(";",$tmp);
-			if(strtolower($result[3]) == strtolower($param['ou']))
-			{
-				$return[$i]['cn']   = $result[0];
-				$return[$i]['mail'] = $result[1];
-				$return[$i]['uid']  = $result[2];
-				$i++;
-			}
-			unset($result);
-		}			
-	
-		if(count($return) > 0)
-			return $return;
-		else
-			return 0;
-	}
-	
-	function UserPermission($param)
-	{
-		$db_acls = $this->db_user->get_accounts_acl();
-		$members = array();		
-		$search_uid 	= "";
-		$search_groups = "|";
-		
-		$search_uid = $this->ldap->list_users_ldap("uid=".$param['uid']);
-
-		foreach($db_acls as $tmp)
-			if($tmp['acl_account'] == $search_uid[0]['uidnumber'])
-				return 1;
-			else
-				$search_groups .= "(gidNumber=".$tmp['acl_account'].")";
-
-		$groups = $this->ldap->list_groups_ldap($search_groups);
-
-		if($groups)
-		foreach($groups as $tmp){
-			$members = $tmp['members'];	
-			foreach($members as $mb){		
-				if(trim($mb) == trim($search_uid[0]['uid']))
-					return 1;
-			}			
-		}
-		
-		return 0;
-	}
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/hook_admin.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/hook_admin.inc.php	(revision 151)
+++ 	(revision )
@@ -1,22 +1,0 @@
-<?php
-	/**************************************************************************\
-	* eGroupWare                                                               *
-	* http://www.egroupware.org                                                *
-	* Written by Joseph Engo <jengo@phpgroupware.org>                          *
-	* --------------------------------------------                             *
-	*  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.                                              *
-	\**************************************************************************/
-
-// Only Modify the $file and $title variables.....
-	$title = 'instant_messenger';
-	$file = array(
-		'Site Configuration'	=> $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)
-	);
-	
-//Do not modify below this line
-	display_section($appname,$title,$file);
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/load_lang.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/load_lang.php	(revision 151)
+++ 	(revision )
@@ -1,26 +1,0 @@
-<?
-if ( !isset($_SESSION['phpgw_info']['instant_messenger']['lang']) || !is_array($_SESSION['phpgw_info']['instant_messenger']['lang']) )
-   if ( file_exists(($fn = dirname(__FILE__) . '/../setup/phpgw_pt-br.lang')) )
-      if ( ($fp = fopen($fn,'r')) )
-      {
-         while ($data = fgets($fp,16000))
-         {
-            list($message_id, $app_name, $null, $content) = explode("\t",substr($data,0,-1));
-            $_SESSION['phpgw_info']['instant_messenger']['lang'][$message_id] = $content;
-         }
-         fclose($fp);
-      }
-
-$script  = '<script>';
-$script .= 'var lang_im = [];';
-
-foreach ( $_SESSION['phpgw_info']['instant_messenger']['lang'] as $key => $value )
-   $script .= "lang_im['" . strtolower(addslashes($key)) . "'] = '" . addslashes($value) . "';";
-
-   #$_key = str_replace("'","\'",strtolower($key));
-   #$_val = str_replace("'","\'",$value);
-
-$script .= '</script>';
-
-echo $script;
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/class.ldap_im.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/class.ldap_im.inc.php	(revision 151)
+++ 	(revision )
@@ -1,183 +1,0 @@
-<?php
-class ldap_im
-{
-	private $ldap_host;
-	private $ldap_context;
-	private $conn;
-	private $user;
-	private $password;
-	
-	function __construct()
-	{
-		$this->ldap_host 	= $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber'];
-		$this->ldap_context = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber'];
-		$this->user 		= $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber'];
-		$this->password 	= $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'];
-		$this->connect_ldap(false);
-	}
-	
-	function __destruct()
-	{
-		ldap_close($this->conn);
-	}
-	
-	function connect_ldap($refer)
-	{
-		$this->conn = ldap_connect($this->ldap_host);
-		ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3);
-		ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $refer);
-		if(trim($this->user) != "")
-			@ldap_bind($this->conn,$this->user,$this->password);
-		else		
-			@ldap_bind($this->conn);
-	}
-	
-	function get_photo_ldap($user,$getPhoto)
-	{
-		$user = ( $user == "user" ) ? $_SESSION['phpgw_info']['instant_messenger']['user'] : $user ;
-		
-		if ($this->conn) {
-			$filter="(&(uid=".$user.")(phpgwAccountType=u))";		
-			$justthese = array("jpegphoto");
-			$search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = ldap_first_entry($this->conn, $search);
-			$jpeg_data = @ldap_get_values_len($this->conn, $entry, "jpegphoto");
-			
-			if( count($jpeg_data) > 1){
-
-				$photo = imagecreatefromstring($jpeg_data[0]);
-				if($photo){
-					if($getPhoto){
-						header("Content-Type: image/jpeg");
-						$width = imagesx($photo);
-						$height = imagesy($photo);
-						$twidth = 49;
-						$theight = 65;
-						$small_photo = imagecreatetruecolor ($twidth, $theight);
-						imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
-						imagejpeg($small_photo,'',100);
-						return;		
-					}else{
-						return 1;
-					}				
-				}else{
-					return 0;
-				}
-			}else{
-				return 0;
-			}
-		}
-	}
-	
-	function photo_ldap($user)
-	{
-		$uid = ( $user['uid'] == "user" ) ? $_SESSION['phpgw_info']['instant_messenger']['user'] : $user['uid'] ;
-		return $this->get_photo_ldap($uid,false);
-	}
-	
-	function list_users_ldap($search)
-	{
-
-		if($this->conn){
-			$filter = "(&(".$search.")(phpgwAccountType=u))";
-			$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn");
-			$search = ldap_search($this->conn,$this->ldap_context,$filter,$justthese);
-			$entry = ldap_get_entries($this->conn,$search);
-		}
-		
-		if( $entry['count'] > 0){
-			$i = 0;
-			$result_user = array();
-			foreach($entry as $tmp)
-			{
-				if($tmp['uidnumber'][0] != "" && $tmp['phpgwaccountvisible'][0] != "-1"){
-					$result_user[$i]['uidnumber'] = $tmp['uidnumber'][0];			
-					$result_user[$i]['mail'] = $tmp['mail'][0];
-					$result_user[$i]['uid'] = $tmp['uid'][0];
-					$result_user[$i]['cn'] = $tmp['cn'][0];
-					$ou = explode("dc=",$tmp['dn']);
-					$ou = explode("ou=",$ou[0]);
-					$ou = array_pop($ou);
-					$result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1));					
-					$i++;
-				}				
-			}
-			return $result_user;
-		}
-		return 0;
-	}
-	
-	function list_groups_ldap($search)
-	{
-	
-		if( $this->conn ){
-			$filter = "(&(".$search.")(objectClass=posixGroup))";
-			$justthese = array("gidnumber","cn","memberuid");			
-			$search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = ldap_get_entries($this->conn,$search);
-		}
-
-		if($entry['count'] > 0){
-			$i = 0;
-			$result_groups = array();
-			foreach($entry as $tmpg){
-				if($tmpg['gidnumber'] != ""){
-					if(array_key_exists("memberuid", $tmpg)){
-						$result_groups[$i]['gidnumber'] = $tmpg['gidnumber'][0];						
-						@array_shift($tmpg['memberuid']);
-						foreach($tmpg['memberuid'] as $tmp)
-							$result_groups[$i]['members'][] = $tmp;					
-						$i++;
-					}
-				}
-			}	
-		}
-		
-		if(count($result_groups) > 0 ){
-			return $result_groups;
-		}else{
-			return 0;
-		}
-	}
-	
-	function list_organizations_ldap()
-	{
-		$result_org = array();
-		$i = 0;
-		if ($this->conn) {
-			$filter="ou=*";		
-			$justthese = array("ou");
-			$search = ldap_list($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = ldap_get_entries($this->conn, $search);
-		}
-		
-		foreach($entry as $tmp){
-			if($tmp['ou'][0] != ""){
-				$result_org[$i] = $tmp['ou'][0];
-				$i++;
-			}
-		}
-		sort($result_org);
-		return $result_org;
-	}
-	
-	function info_user($user)
-	{
-		$uid = "uid=".$user['uid'];
-		$i= 0;
-		
-		$entry = $this->list_users_ldap($uid);
-		
-		if( count($entry) > 0 )
-			return $entry;
-		else
-			return false;	
-	}
-}
-
-if(trim($_REQUEST['user']) != ""){
-	$obj_img = new ldap_im();
-	$obj_img->get_photo_ldap($_REQUEST['user'],true);
-}
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/class.download.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/class.download.inc.php	(revision 151)
+++ 	(revision )
@@ -1,155 +1,0 @@
-<?php
-
-class download
-{
-	
-	function Decode_String($string)
-	{
-		$base64 = $string;	
-		$base64_de = base64_decode($base64);
-		$array_info = unserialize($base64_de);
-	
-		if($array_info['server'] == $_SERVER['SERVER_ADDR']){
-			$this->down_file($array_info['fileUp']);
-		}else{
-			$url = "http://".$array_info['server'].$array_info['path'].$array_info['filePhp'].$base64;
-			header("Location:" . $url);
-		}
-	}
-
-	function down_file($file)
-	{   
-		 
-		ini_set("session.save_path","/php_sessions");
-		$size = filesize(ini_get("session.save_path").'/'. $file);
-		$NameFile = explode("_IM_SendFile_",$file);
-	
-		 if (!empty($file))
-	     {
-		        if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
-		           $UserBrowser = "Opera";
-		        elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
-		            $UserBrowser = "IE";
-	            else
-		            $UserBrowser = '';
-
-				$strFileType = strrev(substr(strrev($NameFile),0,4));
-				$ContentType = "application/octet-stream";
-
-			   	if ($strFileType == ".asf") 
-			   		$ContentType = "video/x-ms-asf";
-			   	if ($strFileType == ".avi")
-			   		$ContentType = "video/avi";
-			   	if ($strFileType == ".doc")
-			   		$ContentType = "application/msword";
-			   	if ($strFileType == ".zip")
-			   		$ContentType = "application/zip";
-			   	if ($strFileType == ".xls")
-			   		$ContentType = "application/vnd.ms-excel";
-			   	if ($strFileType == ".gif")
-			   		$ContentType = "image/gif";
-			   	if ($strFileType == ".jpg" || $strFileType == "jpeg")
-			   		$ContentType = "image/jpeg";
-			   	if ($strFileType == ".wav")
-			   		$ContentType = "audio/wav";
-			   	if ($strFileType == ".mp3")
-			   		$ContentType = "audio/mpeg3";
-			   	if ($strFileType == ".mpg" || $strFileType == "mpeg")
-			   		$ContentType = "video/mpeg";
-			   	if ($strFileType == ".rtf")
-			   		$ContentType = "application/rtf";
-			   	if ($strFileType == ".htm" || $strFileType == "html")
-			   		$ContentType = "text/html";
-			   	if ($strFileType == ".xml") 
-			   		$ContentType = "text/xml";
-			   	if ($strFileType == ".xsl") 
-			   		$ContentType = "text/xsl";
-			   	if ($strFileType == ".css") 
-			   		$ContentType = "text/css";
-			   	if ($strFileType == ".php") 
-			   		$ContentType = "text/php";
-			   	if ($strFileType == ".asp") 
-			   		$ContentType = "text/asp";
-			   	if ($strFileType == ".pdf")
-			   		$ContentType = "application/pdf";
-			   	if ($strFileType == ".txt")
-			   		$ContentType = "text/plain";
-			   	if ($strFileType == ".log")
-			   		$ContentType = "text/plain";
-			   	if ($strFileType == ".wmv")
-			   		$ContentType = "video/x-ms-wmv";
-				if ($strFileType == ".sxc")
-					$ContentType = "application/vnd.sun.xml.calc";
-				if ($strFileType == ".odt")
-					$ContentType = "application/vnd.oasis.opendocument.text";
-				if ($strFileType == ".stc")
-					$ContentType = "application/vnd.sun.xml.calc.template";
-				if ($strFileType == ".sxd")
-					$ContentType = "application/vnd.sun.xml.draw";
-				if ($strFileType == ".std")
-					$ContentType = "application/vnd.sun.xml.draw.template";
-				if ($strFileType == ".sxi")
-					$ContentType = "application/vnd.sun.xml.impress";
-				if ($strFileType == ".sti")
-					$ContentType = "application/vnd.sun.xml.impress.template";
-				if ($strFileType == ".sxm")
-					$ContentType = "application/vnd.sun.xml.math";
-				if ($strFileType == ".sxw")
-					$ContentType = "application/vnd.sun.xml.writer";
-				if ($strFileType == ".sxq")
-					$ContentType = "application/vnd.sun.xml.writer.global";
-				if ($strFileType == ".stw")
-					$ContentType = "application/vnd.sun.xml.writer.template";
-				if ($strFileType == ".ps")
-					$ContentType = "application/postscript";
-				if ($strFileType == ".pps")
-					$ContentType = "application/vnd.ms-powerpoint";
-				if ($strFileType == ".odt")
-					$ContentType = "application/vnd.oasis.opendocument.text";
-				if ($strFileType == ".ott")
-					$ContentType = "application/vnd.oasis.opendocument.text-template";
-				if ($strFileType == ".oth")
-					$ContentType = "application/vnd.oasis.opendocument.text-web";
-				if ($strFileType == ".odm")
-					$ContentType = "application/vnd.oasis.opendocument.text-master";
-				if ($strFileType == ".odg")
-					$ContentType = "application/vnd.oasis.opendocument.graphics";
-				if ($strFileType == ".otg")
-					$ContentType = "application/vnd.oasis.opendocument.graphics-template";
-				if ($strFileType == ".odp")
-					$ContentType = "application/vnd.oasis.opendocument.presentation";
-				if ($strFileType == ".otp")
-					$ContentType = "application/vnd.oasis.opendocument.presentation-template";
-				if ($strFileType == ".ods")
-					$ContentType = "application/vnd.oasis.opendocument.spreadsheet";
-				if ($strFileType == ".ots")
-					$ContentType = "application/vnd.oasis.opendocument.spreadsheet-template";
-				if ($strFileType == ".odc")
-					$ContentType = "application/vnd.oasis.opendocument.chart";
-				if ($strFileType == ".odf")
-					$ContentType = "application/vnd.oasis.opendocument.formula";
-				if ($strFileType == ".odi")
-					$ContentType = "application/vnd.oasis.opendocument.image";
-				if ($strFileType == ".ndl")
-					$ContentType = "application/vnd.lotus-notes";
-								
-		        $mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream';
-	
-		        header("Content-Type: $ContentType");
-		        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
-		        header("Pragma: public");
-		        header("Expires: 0");
-		        header("Content-Disposition: attachment; filename=\"" . $NameFile[1] . "\"");
-				header("Content-length: " . $size);
-				readfile(ini_get("session.save_path") . "/" . $file); 
-				die();
-	    }
-	}
-}
-
-if(isset ($_REQUEST['file'])){
-	$obj_down = new download();
-	$obj_down->Decode_String($_REQUEST['file']);
-}
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/im_sessions.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/im_sessions.inc.php	(revision 151)
+++ 	(revision )
@@ -1,24 +1,0 @@
-<?php
-
-	  $_SESSION['phpgw_info']['instant_messenger']['user']             = $GLOBALS['phpgw_info']['user']['account_lid'];
-	  $_SESSION['phpgw_info']['instant_messenger']['user_id']			 = $GLOBALS['phpgw_info']['user']['account_id'];         
-     $_SESSION['phpgw_info']['instant_messenger']['passwd']           = $GLOBALS['phpgw_info']['user']['passwd'];
-     $_SESSION['phpgw_info']['instant_messenger']['name_jabber']      = $GLOBALS['phpgw_info']['server']['name_jabber'];
-     $_SESSION['phpgw_info']['instant_messenger']['port_jabber']      = $GLOBALS['phpgw_info']['server']['port_jabber'];
-     $_SESSION['phpgw_info']['instant_messenger']['resource_jabber']  = $GLOBALS['phpgw_info']['server']['resource_jabber'];
-
-     # Conf. Ldap
-     $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']   = $GLOBALS['phpgw_info']['server']['server_ldap_jabber'];
-     $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']  = $GLOBALS['phpgw_info']['server']['context_ldap_jabber'];
-     $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']     = $GLOBALS['phpgw_info']['server']['user_ldap_jabber'];
-     $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['password_ldap_jabber'];
-     $_SESSION['phpgw_info']['instant_messenger']['size_file_jabber']  	= $GLOBALS['phpgw_info']['server']['size_file_jabber'];	
-
-     $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];
-     $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];
-     $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];
-     $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user'];
-     $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass'];
-     $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type'];
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/class.Ujabber.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/class.Ujabber.inc.php	(revision 151)
+++ 	(revision )
@@ -1,542 +1,0 @@
-<?php
-
-class Ujabber
-{
-   /*
-    * Listen 
-    */
-   
-   final function listen()
-   {
-      $return = null;
-		
-		if($_SESSION['phpgw_info']['instant_messenger']['IM_disconnect'])
-		{
-      	$_SESSION['phpgw_info']['instant_messenger']['IM_disconnect'] = false;
-      	return "disconnected";
-		}
-		
-	   $_SESSION['phpgw_info']['instant_messenger']['timeClient'] = time();
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = true;
-      $xml = $_SESSION['phpgw_info']['instant_messenger']['socket']['in'];
-
-      unset($_SESSION['phpgw_info']['instant_messenger']['socket']['in']);
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = false;
-
-      ### Arranjo Tecnico ### 
-      $vkrd = $xml;
-      
-      if(isset($_SESSION['phpgw_info']['instant_messenger']['contacts']))
-         unset($_SESSION['phpgw_info']['instant_messenger']['contacts']);
-
-      ### - messages - ###
-      $_messages = "/<message[^>]+from='(\S+)'[^>]*>(?(?=.*?<composing |.*?<paused ).*?<(composing|paused) )(?(?=.*?<html).*?<html[^>]*><body[^>]*>(.*?)<\/body><\/html>).*?<\/message>/s";
-      $_messages = preg_match_all($_messages, $xml, $messages);
-      if ( $_messages !== false && $_messages > 0 )
-      {
-         $xml = preg_replace("/<message.*?<\/message>/", "", $xml);         
-         $return .= $this->getMessages($messages);
-      }
-      ### - Fim messages - ###
-
-      ### - contacts - ###
-      $_contacts = "/<iq[^>]+id='contacts'[^>]*>.*?<\/iq>/";
-      $_contacts = preg_match_all($_contacts, $xml, $_xml);
-
-      $_contacts = "/<item.*?(?(?=[^>]+name)[^>]+name='(.*?)')[^>]+subscription='(.*?)'[^>]+jid='(.*?)'";
-      $_contacts .= "(?(?=[^>]*\/>)[^>]*\/>|[^>]*><group>(.*?)<\/group><\/item>)/";
-      $_contacts = preg_match_all($_contacts, $_xml[0][0], $contacts);
-      if ( $_contacts !== false && $_contacts > 0 )
-      {
-         $xml = preg_replace("/<iq[^>]+id='contacts'[^>]*>.*?<\/iq>/", "", $xml);
-         $return .= rawurldecode(urldecode($this->getContacts($contacts)));
-      }
-      ### - Fim contacts - ###
-
-      ### - presence - ###
-      $xml = $_SESSION['phpgw_info']['instant_messenger']['presences'] . $xml;
-
-      $_presence  = "/<presence(?(?=[^>]+\/>)[^>]+\/>|[^>]+>.*?<\/presence>)/";
-      $_presence = preg_match_all($_presence, $xml, $presence);
-
-      $patterns[0] = '/<priority>[^<]*<\/priority>|<(\S) (?(?=[^>]*\/>)[^>]*\/>|[^>]*>.*?<\/\1>)/';
-      $patterns[1] = '/ xmlns=\'.*?\'| to=\'.*?\'/';
-      $patterns[2] = '/> +</';
-      $replacements[0] = '';
-      $replacements[1] = '';
-      $replacements[2] = '><';
-      $_xml = preg_replace($patterns, $replacements, implode('', $presence[0]));
-
-      $_presence  = "/<presence[^>]+from='(\S+)'[^>]*type='(unavailable)'(?(?=[^>]*\/>)[^>]*\/>|[^>]*>.*?<\/presence>)|";
-      $_presence .= "<presence[^>]+from='(\S+)'(?(?=[^>]+type)[^>]+type='(\S+)')[^>]*";
-      $_presence .= "(?(?=\/>)\/>|>";
-      $_presence .= "(?(?=<s[^>]*?>)<s[^>]*?>(.*?)<\/s[^>]*?>(?(?=<s[^>]*?>)<s[^>]*?>(.*?)<\/s[^>]*?>))";
-      $_presence .= "<\/presence>)/";
-      $_presence = preg_match_all($_presence, $_xml, $presence);
-      if ( $_presence !== false && $_presence > 0 )
-      {
-         foreach ( $presence[5] as $key => $val )
-         {
-            if ( !empty($presence[1][$key]) && (strpos($presence[1][$key], '/') !== false) )
-               $presence[1][$key] = substr($presence[1][$key], 0, strpos($presence[1][$key], '/'));
-            
-            if ( !empty($presence[3][$key]) && strpos($presence[3][$key], '/') !== false )
-               $presence[3][$key] = substr($presence[3][$key], 0, strpos($presence[3][$key], '/'));
-   
-            if ( !empty($val) && !preg_match("/^(away|chat|dnd|xa)$/", $val) )
-               if ( preg_match("/^(away|chat|dnd|xa)$/", $presence[6][$key]) )
-               {
-                  $aux = $presence[5][$key];
-                  $presence[5][$key] = $presence[6][$key];
-                  $presence[6][$key] = $aux;
-               }
-               else
-               {
-                  if ( empty($presence[6][$key]) )          
-                     $presence[6][$key] = $presence[5][$key];
-                  $presence[5][$key] = '';
-               }
-         }
-         $xml = preg_replace("/<presence[^>]\/?>|<presence[^>]>.*?<\/presence>/", "", $xml);
-
-         $return .= $this->getPresence($presence);
-      }
-      ### - Fim presence - ###
-
-      
-      ### - vcard - ###
-      ### - Arranjo Tecnico - ###
-      $_xml = $vkrd;
-      $_vcard = "/<iq.*? id='(.*?)' .*?(<vCard [^>]+\/>|<vCard.*?<\/vCard>)<\/iq>/"; 
-      $_vcard = preg_match_all($_vcard, $_xml, $vcard);
-      if( $_vcard !== false && $_vcard > 0)
-      {
-         $xml = preg_replace("/<iq.*?<vCard.*?<\/iq>/", "", $xml);
-         $return .= urldecode($this->getVcard($vcard));
-      }
-      ### - Fim vcard - ###
-      ## Final do Listen;
-
-      return $return;
-   }
-   
-   function reconnect()
-   {
-      require_once("IMConfigure.php");
-
-      $_transport = TRANSPORT_NON_SECURITY;
-      $_port = PORT_NON_SECURITY;
-
-		$SERVER = "127.0.0.1";
-
-		$fp  = "";
-		@$fp = stream_socket_client($_transport . "://" . $SERVER . ":" . $_port, $errno, $errstr, 10);
-
-		if ( $fp )
-		{
-			fwrite($fp, "GET /" . CONNECT . ";" . session_id() . " HTTP/1.1\r\nHost: " . $SERVER . ":" . $_port . "\r\nAccept: */*\r\n\r\n");
-			return 'true';
-		}
-		else
-			return 'false';
-   } 
-   
-   /*
-    * Contacts
-    */
-
-   function getContacts(array $pContacts)
-   {
-      $_group = array();
-      $return = NULL;
-      $jid = array_unique($pContacts[3]);
-      
-      foreach ( $jid as $key => $val )
-      {
-         $_SESSION['phpgw_info']['instant_messenger']['contacts'][] = $val;
-
-         $item  = NULL;
-         $item .= '<item name="' . (( !empty($pContacts[1][$key]) ) ? $pContacts[1][$key] : $val);
-         $item .= '" jid="' . $val;
-         $item .= '" subscription="' . $pContacts[2][$key];
-         $item .= '" />';
-
-         $_group[utf8_decode(strtolower(!empty($pContacts[4][$key]) ? $pContacts[4][$key] : 'default'))][] = $item;
-      } 
-      
-      ksort($_group);
-
-      foreach ( $_group as $key => $val )
-         $return .= '<group name="' . $key . '">' . implode('', $val) . '</group>';
-
-      return '<contacts>' . $return . '</contacts>';
-   }
-
-   function requireContacts()
-   {
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['getContacts'] = NULL;
-   }
-   
-  /*
-   * Presence 
-   */
-
-   function setPresence($pPresence)
-   {
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['setPresence'] = $pPresence;
-      foreach($pPresence as $key=>$presence)
-      	if($key == 'show' || $key == 'type')
-      	{
-      		$_SESSION['phpgw_info']['instant_messenger']['MyPresence'] = $presence;
-      	}
-   }
-   
-   function MyPresence()
-   {
-   	if(isset($_SESSION['phpgw_info']['instant_messenger']['MyPresence']))
-	   	return $_SESSION['phpgw_info']['instant_messenger']['MyPresence'];
-   }
-   
-   function getPresence(array $pPresence)
-   {
-      $offline = array();
-      foreach ( $pPresence[1] as $key => $val )
-      {
-         if ( empty($val) )
-            continue;
-
-         $_offline = true;
-         for ( $i = $key; $i < sizeof($pPresence[1]); $i++ )
-            if ( $pPresence[1][$key] == $pPresence[3][$i] || $pPresence[1][$key] == $pPresence[5][$i] )
-               $_offline = false;
-
-         if ( $_offline )
-            $offline[$key] = $val;
-      }
-
-      $online = array();
-      foreach ( $pPresence[3] as $key => $val )
-      {
-         if ( empty($val) )
-            continue;
-
-         $_online = true;
-         for ( $i = ($key + 1); $i < sizeof($pPresence[3]); $i++ )
-            if ( in_array($val, $offline) || $pPresence[3][$key] == $pPresence[3][$i] )
-               $_online = false;
-
-         if ( $_online )
-            $online[$key] = $val;
-      }
-
-      $return = NULL;
-
-      foreach ( $offline as $key => $val )
-      {
-         $val = ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val;
-         $return .= "<presence from='" . $val . "' type='unavailable' />";
-      }
-      
-      foreach ( $online as $key => $val )
-      {
-         $val = ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val;
-
-         if ( empty($pPresence[4][$key]) )
-            $pPresence[4][$key] = ( empty($pPresence[5][$key]) ) ?
-               'available' : $pPresence[5][$key];
-
-         $return .= "<presence from='" . $val . "' type='" . $pPresence[4][$key];
-         if ( empty($pPresence[6][$key]) )
-            $return .= "' />";
-         else
-            $return .= "'>" . $pPresence[6][$key] . "</presence>";
-
-         if ( strpos($pPresence[4][$key], 'subscribe') === false )
-         {
-            $session .= "<presence from='" . $val . "'><show>" . $pPresence[4][$key] . "</show>";
-            if ( !empty($pPresence[6][$key]) )
-               $session .= "<status>" . $pPresence[6][$key] . "</status>";
-            $session .= "</presence>";
-         }
-      }
-
-      $_SESSION['phpgw_info']['instant_messenger']['presences'] = $session;
-
-      return $return;
-   }
-
-   /*
-    * GetMessage
-    */
-   
-   function getMessages(array $pMessages)
-   {
-      $_messages = array();
-      $return = NULL;
-
-      foreach ( $pMessages[1] as $key => $val )
-      {
-         trim($pMessages[3][$key]);
-         if ( !empty($pMessages[3][$key]) )
-            $_messages[$val][] = $pMessages[3][$key];
-            
-         if ( !empty($pMessages[2][$key]) )
-         {
-            $return .= '<' . $pMessages[2][$key] . ' from="';
-            $return .= ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val;
-            $return .= '" />';
-         }
-      }
-
-      foreach ( $_messages as $key => $val )
-      {
-         $return .= '<messages from="' . $key . '">';
-         foreach ( $val as $msg )
-            $return .= '<message>' . $msg . '</message>';
-         $return .= '</messages>';
-      }
-
-      return $return;
-   }
-
-   /*
-    * SendMessage
-    */
-
-   function SendMessage($pSendMessage)
-   {
-      $pSendMessage['body'] = stripslashes($pSendMessage['body']);
-      $_emotions  = '/<img emotion="(\S+)?"[^>]+>/';
-      $_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions);
-
-      foreach ( $emotions[0] as $key => $val )
-         $emotions[0][$key] = '/' . addcslashes($val, './()[]{}^$*&?') . '/i';
-
-      $pSendMessage['body'] = preg_replace($emotions[0], $emotions[1], $pSendMessage['body']);
-
-      $to = $pSendMessage['to'];
-      $type = "normal";
-      $id = "";
-      $content = array(
-         "subject" => $pSendMessage['subject'] ? $pSendMessage['subject'] : "",
-         "thread" => $pSendMessage['thread'] ? $pSendMessage['thread'] : "",
-         "body" => $pSendMessage['body'] ? $pSendMessage['body'] : ""
-      );
-
-      $payload = "";
-
-      if ($to && is_array($content))
-      {
-         if (!$id)
-         {
-            $id = $type . "_" . time();
-         }
-
-         $xml = "<message to='$to' type='$type' id='$id'>";
-
-         if ($content['subject'])
-         {
-            $xml .= "<subject>" . $content['subject'] . "</subject>";
-         }
-
-         if ($content['thread'])
-         {
-            $xml .= "<thread>" . $content['thread'] . "</thread>";
-         }
-
-         $xml .= "<html><body>" . $content['body'] . "</body></html>";
-         $xml .= $payload;
-         $xml .= "</message>";
-         unset($id);
-
-         $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] .= $xml;
-      }
-      else
-      {
-         $this->writeLog("ERROR: SendMessage() #2");
-         return FALSE;
-      }
-   }
-
-   /*
-    * Composing / Paused Message
-    */
-
-   function composingMessage($pComposing)
-   {
-
-		$xml  = "<message xmlns='jabber:client' to='".$pComposing['to']."' id='".time()."' type='chat'>";
-		$xml .= "<x xmlns='jabber:x:event'>";
-		$xml .= "<composing/>";
-		$xml .= "</x>";
-		$xml .= "<composing xmlns='http://jabber.org/protocol/chatstates'/>";
-		$xml .= "</message>";
-   	$_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] .= $xml;
-   }
-   
-   function pausedMessage($pComposing)
-   {
-		$xml  = "<message xmlns='jabber:client' to='".$pComposing['to']."' id='".time()."' type='chat'>";
-		$xml .= "<x xmlns='jabber:x:event'/>";
-		$xml .= "<paused xmlns='http://jabber.org/protocol/chatstates'/>";
-		$xml .= "</message>";
-
-		$_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] .= $xml;
-   }
-   
-   /*
-    * UpdateContact
-    */
-   
-   function updateContact($pUser)
-   {
-      $jid   = $pUser['jid'];
-      $name  = $pUser['name'];
-      $group = $pUser['group'];
-      
-      if ( $jid )
-      {
-         $updatecontact  = "<item jid='$jid'";
-         $updatecontact .= " name='" . $name . "'";
-         $updatecontact .= "><group>" . $group . "</group></item>";
-         $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['updateContact'] = $updatecontact;
-      }
-      $this->requireContacts();
-   }
-   
-   /*
-    * AddContact
-    */
-   
-   function addContacts($pUser)
-   {
-      $jid = explode("@",$pUser['email']);
-      $pJid = $jid[0]."@".$_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-      $pName = $pUser['name'];
-      $pGroup = $pUser['group'];
-
-      if(trim($jid[0]) != trim($this->username))
-      {
-         if ( $pJid )
-         {
-            $newcontact  = "<item jid='$pJid'";
-            $newcontact .= " name='" . $pName . "'";
-            $newcontact .= "><group>" . $pGroup . "</group></item>";
-            $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['addContacts'] = $newcontact;
-            $this->subscribe($pJid);
-            $this->requireContacts();           
-         }
-      }
-   }
-   
-   /*
-    * RemoveContact
-    */
-    
-    function removeContact($pUser)
-    {
-         $pJid = $pUser['jid'];
-         $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['removeContact'] = $pJid;
-         $this->unsubscribed($pJid);
-         $this->requireContacts();
-    }
-
-   /*
-    * Vcard
-    */
-
-   function newVcard($pVcardUser)
-   {
-      $pVcard = explode("_vkrd_", $pVcardUser['vcard']);
-
-      $xmlVcard  = "<FN>".$pVcard[0]."</FN>";
-      $xmlVcard .= "<NICKNAME>".$pVcard[1]."</NICKNAME>";
-      $xmlVcard .= "<ORG>";
-      $xmlVcard .= "<ORGNAME>".$pVcard[2]."</ORGNAME>";
-      $xmlVcard .= "<ORGUNIT>".$pVcard[3]."</ORGUNIT>";
-      $xmlVcard .= "</ORG>";
-      $xmlVcard .= "<ROLE>".$pVcard[4]."</ROLE>";
-      $xmlVcard .= "<BDAY>".$pVcard[5]."</BDAY>";
-      $xmlVcard .= "<DESC>".$pVcard[6]."</DESC>";
-      
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['newVcard'] = $xmlVcard;
-
-   }
-   
-   function getVcard(array $Vcard)
-   {
-      $div = "";
-      $_expr = "/<[^<vCard xmlns=\'vcard\-temp\'>].*[^<\/vCard>]>/";
-      array_shift($Vcard);
-      $div = '<vcard>';
-      $jid_user = $_SESSION['phpgw_info']['instant_messenger']['user'];
-      $jid_user .= "@" . $_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-      for($i = 0 ; $i < count($Vcard[0]) ; $i++)
-      {
-         preg_match($_expr,$Vcard[1][$i],$div_vcard);
-         $div_new[] = $div_vcard;
-
-         if ( $jid_user == $Vcard[0][$i] )
-            $_SESSION['phpgw_info']['instant_messenger']['vcard'] = $div_new[$i][0];
-         
-         $div .= '<div id="vcard_'.$Vcard[0][$i].'">'.urldecode($div_new[$i][0]).'</div>';
-      }
-      $div .= '</vcard>';
-         
-      return $div;
-   }
-   
-   function Vcard()
-   {
-      $contacts = array();
-      $contacts = $_SESSION['phpgw_info']['instant_messenger']['contacts'];
-      $jid_user = $this->getJid();
-
-      if( count($contacts) > 0 )
-      {
-         array_unshift($contacts,$jid_user);
-
-         foreach($contacts as $user)
-            $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['vcard'][] = $user;
-         return "true";
-      }else{
-         return "false";
-      }
-   }
-   
-   function VcardUser()
-   {
-   	$_SESSION['phpgw_info']['instant_messenger']['socket']['out']['vcard'][] = $this->getJid();;
-   }
-   
-   function getJid()
-   {
-      $jid = $_SESSION['phpgw_info']['instant_messenger']['user'] . "@" . $_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-      return $jid;   
-   }
-   
-   function subscribe($pJid)
-   {
-      $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ;
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['Subscribe'] = $jid;
-   }
-   
-   function subscribed($pJid)
-   {
-      $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ;
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['SubscriptionAcceptRequest'] = $jid;
-   }
-   
-   function unsubscribe($pJid)
-   {
-      $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ;
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['Unsubscribe'] = $jid;
-   }
-   
-   function unsubscribed($pJid)
-   {
-      $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ;
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['SubscriptionDenyRequest'] = $jid;   
-   }
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/class.db_im.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/class.db_im.inc.php	(revision 151)
+++ 	(revision )
@@ -1,97 +1,0 @@
-<?php
-define('PHPGW_INCLUDE_ROOT','../');	
-define('PHPGW_API_INC','../phpgwapi/inc');
-require_once(PHPGW_API_INC.'/class.db.inc.php');
-	
-class db_im
-{	
-	
-	var $db;
-	var $db_name;
-	var $db_host;
-	var $db_port;
-	var $db_user;
-	var $db_pass;
-	var $db_type;
-	var $teste;
-	
-	function db_im(){
-		$this->db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'];
-		$this->db_host = $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'];
-		$this->db_port = $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'];
-		$this->db_user = $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'];
-		$this->db_pass = $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'];
-		$this->db_type = $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'];
-		
-		$this->db = new db();		
-		$this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type);
-	}
-
-	function get_accounts_acl()
-	{
-		$result = array();
-		$query = "select acl_appname, acl_account from phpgw_acl where acl_appname = 'instant_messenger' order by acl_account";	
- 		
- 		if (!$this->db->query($query))
-        	return null;
-		
-		while($this->db->next_record())
-			$result[] = $this->db->row();
-
-		return $result;
-	}
-	
-	function query_db($pQuery)
-	{
-		if (!$this->db->query($pQuery))
-        	return false;
-		else
-			return true;
-	}
-	
-	function set_preferences($param)
-	{
-		$preferences = $param['preferences'];
-		$user_id  = $_SESSION['phpgw_info']['instant_messenger']['user_id']; 
-		$app_name = $this->name_app();
-
-		$query = "insert into phpgw_preferences values('".$user_id."','".$app_name."','".serialize($preferences)."')";
-		
-		if($this->query_db($query))	 
-			return "true";
-		else{
-			$query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='".$app_name."' and preference_owner='".$user_id."'";
-			if($this->query_db($query))
-				return "true";
-			else
-				return "false";			
-		}		
-	}
-	
-	function get_preferences()
-	{
-		$result = array();
-		$user_id  = $_SESSION['phpgw_info']['instant_messenger']['user_id'];
-		$app_name = $this->name_app();
-		
-		$query = "select * from phpgw_preferences where preference_owner = '".$user_id."' and preference_app = '".$app_name."'";
-		
- 		if (!$this->db->query($query))
-        	return NULL;
-		
-		while($this->db->next_record())
-			$result[] = $this->db->row();
-
-		if(count($result) > 0){
-			return unserialize($result[0]['preference_value']);
-		}else{
-			return "ch_offline:true;in_time:1;rd_nm:true;rd_ch:false";
-		}
-	}
-	
-	function name_app()
-	{
-		return "instant_messenger";
-	}
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/IMConfigure.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/IMConfigure.php	(revision 151)
+++ 	(revision )
@@ -1,33 +1,0 @@
-<?php
-   ###
-   # definitions of access - BEGIN
-   #
-      define('CONNECT', 'con');
-      define('CLOSE', 'close');
-      define('GET_MESSAGE', 'getMessage');
-      define('SEND_MESSAGE', 'send');
-   #
-   # definitions of access - END
-   ###
-
-   ###
-   # definitions of time - BEGIN
-   #
-      define('DISCONNECT_AFTERWARDS_OF', 20);
-      define('READ_SOCKET_AFTER_OF', 2);
-   #
-   # definitions of time - END
-   ###
-
-   ###
-   # definitions of socket - BEGIN
-   #
-      define('TRANSPORT_NON_SECURITY', 'tcp');
-      define('PORT_NON_SECURITY', '8000');
-
-      //define('TRANSPORT_SECURITY', 'sslv3');
-      //define('PORT_SECURITY', '9001');
-   #
-   # definitions of socket - END
-   ###
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/Jabber.abstract.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/Jabber.abstract.php	(revision 151)
+++ 	(revision )
@@ -1,317 +1,0 @@
-<?php
-/*
-+-------------------------------------------------------------------------+
-|                                                                         |
-| @FILE:        Jabber.abstract.php                                       |
-| @ABSTRACT:    Jabber                                                    |
-| @EXTENDS:     Socket (Socket.class.php)                                 |
-|                                                                         |
-| @DATE:        Wed May,16 2007 08:18:59                                  |
-| @LAST_CHANGE: Wed May,16 2007 09:03:28                                  |
-|                                                                         |
-| @AUTHOR:      [NUTS] Rodrigo Souza - rodsouza@celepar.pr.gov.br         |
-|                                                                         |
-| @BRIEF:       Abstract class for connect with any Jabber server         |
-|                                                                         |
-+-------------------------------------------------------------------------+
-*/
-
-require_once 'Socket.abstract.php';
-
-abstract class Jabber extends Socket
-{
-   const J_FILE    = '/var/log/expresso/Jabber.log';
-   const J_ALL     = false;
-   const J_ERROR   = true;
-   const J_WARNING = true;
-   const J_NOTICE  = true;
-
-   const ALL     = 'ALL';
-   const ERROR   = 'ERROR';
-   const WARNING = 'WARNING';
-   const NOTICE  = 'NOTICE';
-
-   private final function _connect( $pUser = false, $pPassword = false )
-   {
-      try
-      {	
-         if ( !preg_match('/^(.+)@(.+)\/(.+):(\d+)$/',$pUser, $matches) )
-            throw new Exception('[connect] #1 ' . $pUser . ' must be [USER]@[DOMAIN]/[RESOURCE]:[PORT] and [PORT] is integer. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         list($subject, $USER, $SERVER, $RESOURCE, $PORT) = $matches;
-
-         if ( !($socket = $this->open('tcp://' . $SERVER . ':' . $PORT, 1, 1)) )
-            throw new Exception('[connect] #2 can\'t access tcp://' . $SERVER . ':' . $PORT . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         $this->_socket = $socket;
-
-         $xml  = "<?xml version='1.0' encoding='UTF-8'?>";
-         $xml .= "<stream:stream to='" . $SERVER . "' xmlns='jabber:client' ";
-         $xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>";
-
-         if ( $this->write($xml) === false )
-            throw new Exception('[connect] #3 it isn\'t possible write in the socket ' . $socket . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         $this->_server = $SERVER;
-         $this->_username = $USER;
-         $this->_password = $pPassword;
-         $this->_resource = $RESOURCE;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-   protected function connect( $pUser = false, $pPassword = false )
-   {   
-      try
-      {
-         $this->_connect($pUser, $pPassword);
-         $this->blocking($this->_socket, 0);
-			
-			$xml = $this->read();
-         
-         if ( $xml === false )
-            throw new Exception('[connect] #1 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-         
-         if ( preg_match('/(<starttls .*<required\/><\/starttls>)/', $xml, $matches) )
-         {
-            if ( !$this->starttls() )
-               throw new Exception('[connect] #2 it isn\'t possible start tls. File: ' . __FILE__ . '  ::  ' . __LINE__);
-         }
-         else
-	 		{
-            if ( !$this->_plain() )
-               throw new Exception('[connect] #3 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-	 		}
-
-         return true;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         $this->_disconnect();
-         return false;
-      }
-   }
-
-   protected final function _disconnect()
-   {
-      try
-      {
-         $xml = "</stream:stream>";
-
-         if ( $this->write($xml) === false )
-            throw new Exception('[disconnect] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[disconnect] #2 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-   private final function starttls()
-   {
-      try
-      {
-         $xml = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>";
-         
-         if ( $this->write($xml) === false )
-            throw new Exception('[starttls] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[starttls] #2 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         if ( !preg_match('/<proceed.*\/>/', $xml, $matches) )
-            throw new Exception('[starttls] #3 can\'t start tls in the socket ' .$this->_socket . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-		   stream_socket_enable_crypto($this->_socket, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT);
-
-         $xml  = "<?xml version='1.0' encoding='UTF-8'?>";
-         $xml .= "<stream:stream to='" . $this->_server . "' xmlns='jabber:client' ";
-         $xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>";
-         if ( $this->write($xml) === false )
-            throw new Exception('[starttls] #4 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         usleep(90000);
-         $this->blocking($this->_socket, 0);
-
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[starttls] #5 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         if ( !$this->_plain() )
-            throw new Exception('[starttls] #6 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         return true;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-   private final function _plain()
-   {
-      try
-      {
-			//$this->blocking($this->_socket, 1);
-
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[_plain] #1 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         $xml  = "<username>" . $this->_username . "</username>";
-         $xml .= "<password>" . $this->_password . "</password>";
-         $xml .= "<resource>" . $this->_resource . "</resource>";
-
-         unset($this->_password);
-
-         if ( !$this->iq('set', 'auth_1', NULL, NULL, "jabber:iq:auth", $xml) )
-            throw new Exception('[_plain] #2 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         while ( !preg_match("/<iq xmlns='jabber:client' id='auth_1' type='(result|error)'/", ($readSocket = $this->read()), $matches) )
-         	   usleep(10000);
-
-			if($matches[1] == "error")
-				return false;
-
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[_plain] #3 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         return true;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-	private final function _iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false )
-	{
-		$xml  = "<iq type='" . $pType . "' id='" . $pId . "'";
-		$xml .= ( $pTo ) ? " to='" . $pTo . "'" : "";
-		$xml .= ( $pFrom ) ? " from='" . $pFrom . "'" : "";
-
-		if ( $pXmlns == "vcard-temp" )
-      {
-			$xml .= ">";
-			$xml .= $pLoad;
-		}
-      else
-      {
-			$xml .= "><query xmlns='" . $pXmlns . "'";
-			$xml .= ( $pLoad ) ? ">" . $pLoad . "</query>" : "/>";
-		}
-
-		$xml .= "</iq>";
-		
-		return $xml;	
-	}
-
-   protected final function iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false)
-   {
-      try
-      {
-         if ( !preg_match("/^(get|set|result|error)$/i", $pType, $matches) )
-            throw new Exception('[iq] #1 type must be GET, SET, RESULT or ERROR. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-		   if ( $this->write($this->_iq($pType, $pId, $pTo, $pFrom, $pXmlns, $pLoad)) === false )
-            throw new Exception('[iq] #2 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-         else
-            return true;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-	protected final function presence($pType = false, $pTo = false, $pShow = false, $pStatus = false, $pPriority = false)
-	{
-      try
-      {
-         $xml  = "<presence";
-         $xml .= ($pTo)   ? " to='{$pTo}'" : '';
-         $xml .= ($pType) ? " type='{$pType}'" : '';
-         
-         if ( !($pStatus || $pShow || $pPriority) )
-				$xml .= "/>";
-			else
-			{
-			 $xml .= ">";
-	         $xml .= ($pStatus) ? "<status>" . $pStatus . "</status>" : '';
-	         $xml .= ($pShow) ? "<show>" . $pShow . "</show>" : '';
-	         $xml .= ($pPriority) ? "<priority>" . $pPriority . "</priority>" : '';
-	         $xml .= ($pStatus || $pShow || $pPriority) ? "</presence>" : '';
-			}
-
-         if ( $this->write($xml) === false )
-            throw new Exception('[presence] #1 it isn\'t possible send presence for ' . $this->_server . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         return true;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-	}
-
-   protected final function read()
-   {
-      $return = NULL;
-      do
-      {
-         $line = NULL;
-         $line = utf8_decode(parent::read($this->_socket, 4096));
-
-         if ( $line === false )
-         {
-            $return = false;
-            break;
-         }
-
-         if ( $line != NULL )
-            $return .= $line ;
-      }
-      while ( $line != NULL );
-
-      return $return;
-   }
-
-	protected final function write($pData = false)
-   {
-      if ( !$pData )
-         return false;
-
-      return parent::write($this->_socket, utf8_encode($pData));
-   }
-
-   protected final function writeLog($pType = false, $pLog = false)
-   {
-      if ( !defined('self::'.$pType) && !$pLog )
-         return false;
-
-      if ( !(bool)constant('self::J_'.$pType) && !(bool)constant('self::J_ALL') )
-         return false;
-
-      $log  = date('m/d/Y H:i:s');
-      $log .= ' [' . constant('self::'.$pType) . '] :: ';
-      $log .= $pLog . "\n";
-      if ( $fp = fopen (self::J_FILE, "a+") )
-      {
-         fwrite($fp, $log);
-         fclose($fp);
-      }
-   }
-}
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/inc/Language.class.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/inc/Language.class.php	(revision 151)
+++ 	(revision )
@@ -1,41 +1,0 @@
-<?php
-
-class Language
-{
-   const _DEFAULT_LANGUAGE_ = 'ENGLISH';
-   static private $_language = NULL;
-
-   static private $_phrase = NULL;
-
-   function __construct()
-   {
-      echo 'ok';
-   }
-
-   function setLanguage( $pLanguage = false )
-   {
-      if ( !$pLanguage || !is_file($pLanguage . '_language.txt') )
-         return false;
-
-      $this->_language = $pLanguage;
-      $this->_phrase = file($this->_language . '_language.txt');
-
-      foreach($this->_phrase as $val )
-      {
-         $_phrase = explode('§§', $val);
-         if ( sizeof($_phrase) != 2 )
-            continue;
-         $this->_phrase[$_phrase[0]] = $_phrase[1];
-      }
-   }
-
-   public function phrase( $pPhrase )
-   {
-      if ( !$this->_phrase || !isset($this->_phrase[$pPhrase]) )
-         return '** ' . self::_DEFAULT_LANGUAGE_;
-      else
-         return $this->_phrase[$pPhrase];
-   }
-}
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_menu_action.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_menu_action.js	(revision 151)
+++ 	(revision )
@@ -1,67 +1,0 @@
-// Instant Messenger
-// im_menu_action.js
-
-	var im_menu_action = {
-      "delay_hide" : 500,
-      "delayhide" : false,
-
-      "menu" : function()
-      {
-         try
-         {
-            var pElement = arguments[0];
-            delete arguments[0];
-            var pMenu = ( func.isString(arguments[1]) ) ? arguments[1] : arguments;
-            if ( document.getElementById(pElement).innerHTML == "" )
-            {
-               func.confEl(pElement, 'style', 'display:block;');
-               this.layout(pMenu, pElement);
-            }
-            else
-            {
-               func.confEl(pElement, 'style', 'display:none;');
-               this.del_innerHTML(pElement);
-               this.clear_delayhide();
-            }
-         }
-         catch(e)
-         {
-         }
-      },
-
-	  "layout" : function(pHtml, pElement)
-      {
-			var _this = this;
-			var el_dest_ = ( func.isString(pElement) ) ? func.byId(pElement) : pElement;
-			var div_menu = func.newEl("div");
-         func.confEl(div_menu, 'style', 'padding:0px;border:1px solid #809aa9');
-			div_menu.onmouseover = function(){_this.clear_delayhide();};
-			div_menu.onmouseout = function(){_this.resetit(pElement);};
-			if ( func.isString(pHtml) )
-				div_menu.innerHTML = pHtml;
-         else
-            for ( i = 1; i < pHtml.length; i++ )
-               func.insEl(pHtml[i], div_menu);
-
-			func.insEl(div_menu, el_dest_);
-			this.delayhide = setTimeout("im_menu_action.del_innerHTML('"+pElement+"')", 2000);
-		},
-
-	   "del_innerHTML": function(pElement)
-       {
-           func.confEl(pElement, 'style', 'display:none;');
-		   func.byId(pElement).innerHTML = "";
-		   document.oncontextmenu = new Function("return true");
-	   },
-
-	   "resetit": function(pElement)
-       {
-			this.delayhide = setTimeout("im_menu_action.del_innerHTML('"+pElement+"')",this.delay_hide);
-	   },
-
-	   "clear_delayhide" : function()
-       {
-			if ( this.delayhide )
-				clearTimeout(this.delayhide);
-	   }
-	}
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_preferences.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_preferences.js	(revision 151)
+++ 	(revision )
@@ -1,576 +1,0 @@
-// Instant Messenger
-// im_preferences.js
-
-	function IM_Preferences()
-	{
-		this.save_vcard = "";	
-		this.jid = false;
-		this.im_timer_xa = "";
-	}
-
-   /*
-	* Add
-	*/
-	
-	IM_Preferences.prototype.Add_userLoad = function()
-	{
-		Templates.add_user();
-		this.SearchOrganizationsLdap();
-		var select_contact = document.getElementById('ImSelAddContact');
-		select_contact.innerHTML = "";
-	}
-	
-	IM_Preferences.prototype.SearchOrganizationsLdap = function()
-	{
-		var handler_organizations = function(data)
-		{
-			var data = func.interface(data);
-			var select_org = document.getElementById('ImSelOrg');
-			if(select_org.options.length > 0)
-				select_org.options.splice(0,select_org.options.length);
-			var options = new Option("--Selecione -- ", -1, false, true);
-			select_org[select_org.length] = options;
-			
-			for(var i in data){
-				var options = new Option(data[i], data[i], false, true);
-				select_org[select_org.length] = options;
-			}
-			select_org[0].selected = true;
-		}
-		XMLTools.request('$this.ldap_im.list_organizations_ldap','GET',handler_organizations);
-	}
-	
-	IM_Preferences.prototype.SearchContacts = function()
-	{
-		var select_org = document.getElementById('ImSelOrg');
-		var organization = "";
-		var span_load = document.getElementById('_span_load_im');
-			span_load.style.display = "block";
-		
-		for(var i=0; i < select_org.options.length; i++){
-			if(select_org.options[i].selected == true){
-				organization = select_org.options[i].value;
-			}
-		}
-		var handler_contacts = function(XMLdata)
-		{
-			var data = func.interface(XMLdata);
-			var select_contact = document.getElementById('ImSelAddContact');
-			var text0 = document.getElementById('text0');
-			var text1 = document.getElementById('text1');
-			var content = "";
-			select_contact.innerHTML = "";
-			text0.value = "";
-			text1.value = "";
-			if(data)
-			{
-				for(var i in data)
-				{
-					var options =  new Option(data[i].cn + " ( "+ data[i].mail + " )", data[i].mail + ";" + data[i].uid, false, false);
-					select_contact[select_contact.length] = options;
-				}
-			}
-			span_load.style.display = "none";		
-		}
-		XMLTools.request('$this.contacts_im.list_contacts','POST',handler_contacts, 'ou='+organization);
-	}
-
-	IM_Preferences.prototype.preenche = function()
-	{
-		var select = document.getElementById('ImSelAddContact');
-		if(select.options.length > 0){
-			for(var i=0; i < select.options.length; i++){
-				if(select.options[i].selected == true){
-					var email = select.options[i].value.substr(0,select.options[i].value.indexOf(';'));
-					var uid = select.options[i].value.substr((select.options[i].value.indexOf(';')+1),select.options[i].value.length);
-					document.getElementById('text0').value = email;
-					document.getElementById('text1').value = select.options[i].value.substr(0,select.options[i].value.indexOf('@'));	
-					document.getElementById('text2').focus();
-					document.getElementById('text3').value = uid; 			
-				}
-			}
-		}
-	}
-	
-	IM_Preferences.prototype.Add_user = function(pFunc)
-	{
-		var text0 = document.getElementById('text0');
-		var text1 = document.getElementById('text1');
-		var text2 = document.getElementById('text2');
-		var text3 = ( document.getElementById('text3') != null ) ? document.getElementById('text3') : false;
-
-		var _this = this;
-		var jid   = text0.value;
-		var subscription = "";
-
-		if(func.trim(text0.value) != "" && func.trim(text1.value) != "" && func.trim(text2.value) != "")
-		{
-			var handler_add_contact = function(data)
-			{
-				IM.vcards = false;
-				IM.Vcard();
-				
-				text0.value = "";
-				text1.value = "";
-				text2.value = "";	
-
-				if(pFunc != 'divAddUser_im')
-				{
-					if(document.getElementById('im_cell_' + jid))
-					{
-						var div_jid = document.getElementById('im_cell_' + jid);
-						div_jid.parentNode.removeChild(div_jid);
-				
-						for(var i in IM.UsersNot)
-							if( IM.UsersNot[i] === jid )
-								IM.UsersNot.splice(i,1);
-	
-						im_win.windowClose(pFunc);
-						Subscription.subscribed(jid);
-						IM.setStatus(statusFlag);
-						setTimeout('Subscription.subscribe("'+jid+'")',2000);
-					}
-				}
-				else
-				{
-					Templates.Status_AddUser();
-					setTimeout("Templates.Status_AddUser();",3000);
-				}				
-				if( IM.UsersNot.length == 0 )
-					im_win.windowClose('divFormAuthUser_im');
-			}
-			var name = text1.value;
-			var group = text2.value;
-			if(text3){
-				var email = text3.value + "@" + text0.value.substr((text0.value.indexOf('@')+1),text0.value.length);
-			}else{
-				var email = text0.value;
-			}
-			XMLTools.request('$this.Ujabber.addContacts','POST',handler_add_contact,"email="+email+"&name="+name+"&group="+group);
-		}else{
-			alert("Informe todos os campos!");
-		}
-	}
-	
-	IM_Preferences.prototype.AcceptRequestUser = function(pJid)
-	{
-		Templates.AcceptRequestUser();
-   		document.getElementById('text0').value = pJid;
-   		document.getElementById('text1').value = pJid.substr(0,pJid.indexOf('@'));
-   		document.getElementById('text1').focus();
-   		document.getElementById('text1').select();
-   		document.getElementById('span0').innerHTML = pJid.substr(0,pJid.indexOf('@'));
-	}
-
-   /*
-	* Remove
-	*/
-
-	IM_Preferences.prototype.RemoveContact = function(pJid)
-	{
-		var _this = this;
-		if(!pJid)
-		{
-			var sel_box = document.getElementById('sel_contact');
-			for(var i=0; i < sel_box.options.length; i++)
-			{
-				if(sel_box[i].selected && sel_box.options[i].value != 0)
-					pJid = sel_box.options[i].value;
-			}
-		}
-		if( pJid )
-		{
-			if( confirm('Deseja remover o contato : ' + pJid) )
-			{
-				IM.vcards = false;
-				IM.Vcard();
-				var div_child = document.getElementById(pJid);
-				div_child.parentNode.removeChild(div_child);
-				_this.ComboRemoveUser(_this.LoadJids());		
-				var handler_remove_contact = function(data)
-				{
-				};
-				XMLTools.request('$this.Ujabber.removeContact','POST',handler_remove_contact,"jid="+pJid);
-			}
-		}else
-			alert('Opção inválida !!');
-	}
-	
-	IM_Preferences.prototype.Remove_userLoad = function()
-	{
-		Templates.remove_user();
-		var div_allg = document.getElementById('all_groups');
-		var _this = this;
-		_this.ComboRemoveUser(_this.LoadJids());		
-	}
-
-	IM_Preferences.prototype.ComboRemoveUser = function(pJids)
-	{
-		var sel_box = document.getElementById('sel_contact');
-		
-		if( document.getElementById('sel_contact') != null )
-		{
-			if( sel_box.options.length > 0 )
-			{
-				for(var i=0; i < sel_box.options.length; i++)
-				{
-					sel_box.options[i] = null;
-					i--;
-				}
-			}
-	
-			var opt = new Option('--- Selecione ---',0,false,true);
-			sel_box[sel_box.length] = opt;		
-			for(var i in pJids)
-			{
-				var opt = new Option(pJids[i].substr(0,pJids[i].indexOf('@')), pJids[i], false, true);
-				sel_box[sel_box.length] = opt;
-			}
-			sel_box[0].selected = true;
-		}
-	}
-
-	IM_Preferences.prototype.DenyRequestUser = function(pJid)
-	{
-		if(confirm('Deseja excluir ' + pJid + '?'))
-		{
-			var div_jid = document.getElementById('im_cell_' + pJid);
-			div_jid.parentNode.removeChild(div_jid);
-			
-			for(var i in IM.UsersNot)
-				if(IM.UsersNot[i] === pJid)
-					IM.UsersNot.splice(i,1);
-
-			if( IM.UsersNot.length == 0 )
-				im_win.windowClose('divFormAuthUser_im');
-
-			var handler_denyrequest = function(data)
-			{
-			};
-			XMLTools.request('$this.Ujabber.unsubscribe','POST',handler_denyrequest,'jid='+pJid);
-		}
-	}
-
-	/*
-	 * LoadJids
-	 */
-
-	IM_Preferences.prototype.LoadJids = function()
-	{
-		var div_allg = document.getElementById('all_groups');
-		var elements = div_allg.firstChild;
-		var jids = [];
-		while ( elements )
-		{			
-			var childs = elements.firstChild;
-			while( childs )
-			{
-				if(childs.tagName == "DIV")
-					jids[jids.length] = childs.id;
-				childs = childs.nextSibling;
-			}
-			elements = elements.nextSibling;
-		}
-		jids.sort();
-		
-		return jids;	
-	}
-	
-   /*
-    * Update
-    */
-   
-   IM_Preferences.prototype.Update_ = function(pJid,pType)
-   {
-		var div_child = document.getElementById(pJid);
-		var group = div_child.parentNode.id;
-		var name  = div_child.firstChild;
-			name = name.nextSibling.nodeValue;
-
-		if(pType)
-		{
-			var action = prompt('Digite um novo apelido para : ' + pJid, " ");
-			name = (action == "Apelido") ? "" : action ;
-		}else{
-			var action = prompt('Digite um novo grupo para : ' + pJid , " ");
-			group = action ;
-		}
-		
-		if( action != "" && action != null)
-		{
-			var handler_update_contact = function(XMLdata)
-			{
-			};
-			XMLTools.request('$this.Ujabber.updateContact','POST',handler_update_contact,"jid="+pJid+"&name="+name+"&group="+group);
-		}
-   }
-
-	IM_Preferences.prototype.Update_Group = function(pJid)
-	{
-		this.Update_(pJid,false);		
-	}
-		
-	IM_Preferences.prototype.Update_NickName = function(pJid)
-	{
-		this.Update_(pJid,true);   
-	}
-   
-   /*
-	* Vcard
-	*/
-
-	IM_Preferences.prototype.vCardInit = function()
-	{
-		var _this = this;
-		var nickname = "";
-		var message  = "";
-		var vcards   = "";
-
-		var handler_getId = function(_XMLdata)
-		{
-			var jid = _XMLdata.getElementsByTagName("retorno").item(0);
-			jid = jid.firstChild.nodeValue;
-			_this.jid = jid;
-			
-			if((vcards = _this.vCardLoad(jid)))
-			{
-				nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length);
-				nickname = nickname.substr(0,nickname.indexOf('|'));
-				nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length);
-
-				message = vcards.substr(vcards.indexOf('DESC'),vcards.length);
-				message = message.substr(0,message.indexOf('|'));
-				message = message.substr(message.indexOf(':') + 1 , message.length);
-			}
-			
-			nickname = (func.trim(nickname) != "" ) ? nickname : _this.jid ;
-			message  = (func.trim(message) != "" ) ? message : "Sua Mensagem";
-			IM.custom_message = message;
-			
-			var span_nick = document.getElementById('span_nickname');
-				span_nick.innerHTML = ( nickname ) ? "<b>" + decodeURI(nickname.substring(0,15)) + "</b>" : "<b>" + IM.get_lang('Nickname') + "</b>";
-		}
-		XMLTools.request('$this.Ujabber.getJid','GET',handler_getId);
-	}
-
-	IM_Preferences.prototype.vCardLoad = function(Jid)
-	{
-		var div_jid  = document.getElementById("vcard_" + Jid);
-		var strg = div_jid.innerHTML;
-		var elements = div_jid.firstChild;
-		var exp , tag  = '';
-		
-		while ( elements )
-		{			
-			if(elements.tagName != undefined && elements.tagName.substr(0,1) != "/" )
-			{		
-				tag = elements.tagName;
-				exp = eval('/<'+tag+'>/gi');
-				strg = strg.replace(exp, tag + " : " );
-				exp = eval('/<\\/'+tag+'>/gi');
-				strg = strg.replace(exp, " | ");
-			}
-			elements = elements.nextSibling;
-		}			
-
-		return strg;
-	}
-		
-	IM_Preferences.prototype.vCard = function()
-	{
-		if(!this.jid){
-			alert('Carregando !!');
-		}else{
-			var div_jid  = document.getElementById("vcard_" + this.jid);
-			var strg = div_jid.innerHTML;
-			Templates.information_user(strg);
-		}	
-	}
-
-	IM_Preferences.prototype.vCardLoad_Contact = function(pJid)
-	{
-		if(!this.jid){
-			alert('Carregando !!');
-		}else{
-			if(document.getElementById('vcard_' + pJid) != null)
-			{
-				var vcards = document.getElementById('vcard_' + pJid);
-				Templates.information_Contact(vcards.innerHTML);
-			}else
-				alert('Vcard não carregado!');
-		}
-	}
-	
-	IM_Preferences.prototype.vCardAdd = function()
-	{
-		var Nvcard = new Array('FN','NICKNAME','ORGNAME','ORGUNIT','ROLE','BDAY','DESC');
-		var vcard = "";
-		var new_vcard = "";
-		var value = "";
-		for(var i in Nvcard)
-		{
-			if( Nvcard[i] === 'NICKNAME' )
-			{	
-				var nn = ( func.trim(document.getElementById(Nvcard[i]).value) != "") ? document.getElementById(Nvcard[i]).value : this.jid; 
-				document.getElementById('span_nickname').innerHTML = "<b>" + nn.substring(0,15) + "</b>";
-			}
-			
-			value = document.getElementById(Nvcard[i]).value;
-			new_vcard += '<'+Nvcard[i]+'>'+value+'</'+Nvcard[i]+'>';
-			value = (func.trim(value) != "") ? value : "";
-			vcard += value + "_vkrd_";
-		}
-
-		document.getElementById("vcard_" + this.jid).innerHTML = new_vcard;
-		vcard = vcard.substr(0,vcard.length - 6 );		
-
-		var handler_vcard_add = function(XMLdata)
-		{
-		};
-		XMLTools.request('$this.Ujabber.newVcard','POST',handler_vcard_add,"vcard="+escape(vcard));	
-		alert('Informações Cadastradas / Adicionadas !!!');	
-		im_win.windowClose('divInfoUser_im');
-	}
-	
-   /*
-	* IM_Preferences
-	*/
-	
-	IM_Preferences.prototype.yourPreferences = function()
-	{
-		Templates.yourPreferences();
-	}
-
-	IM_Preferences.prototype.SetYourPreferences = function()
-	{
-		var preferences = "";
-		preferences  = ( func.byId('ch_offline').checked ) ? 'ch_offline:true;' : 'ch_offline:false;';
-		if( func.byId('in_time').value )
-		{
-			var numbers = /^\d+$/;
-			if(numbers.test(func.byId('in_time').value) && func.byId('in_time').value != "0")
-				var minutes = func.byId('in_time').value;
-			else
-			{
-				alert('Informe valores válidos !');
-				func.byId('in_time').focus();
-				return false;
-			}
-		}
-
-		this.im_timer_xa = func.byId('in_time').value;
-		preferences += ( func.trim(func.byId('in_time').value )) ? 'in_time:' + func.byId('in_time').value + ";" : 'in_time:0;';
-		preferences += ( func.byId('rd_nm').checked ) ? 'rd_nm:true;' : 'rd_nm:false;';
-		preferences += ( func.byId('rd_ch').checked ) ? 'rd_ch:true' : 'rd_ch:false';
-		IM.userPrefe = preferences;
-		
-		var handler_preferences = function(XMLdata)
-		{
-			var data = XMLdata.getElementsByTagName('retorno').item(0);
-			data = eval(data.firstChild.nodeValue);
-			if(data)
-			{
-				IM.Contacts_Offline();
-				alert('Preferências salvas !');
-			}
-		};
-		XMLTools.request('$this.db_im.set_preferences','POST',handler_preferences,'preferences='+preferences);
-	}
-	
-	IM_Preferences.prototype.GetYourPreferences = function()
-	{
-		var _this = this;
-		if(!IM.userPrefe)
-		{
-			var handler_getPreferences = function(XMLdata)
-			{
-				var data = XMLdata.getElementsByTagName('retorno').item(0);
-				data = data.firstChild.nodeValue;
-				IM.userPrefe = data;
-				_this.TimerXa(_this.LoadPreferences('in_time'));
-			}
-			XMLTools.request('$this.db_im.get_preferences','GET',handler_getPreferences);
-		}
-	}
-	
-	IM_Preferences.prototype.LoadPreferences = function(pElement)
-	{
-		var preferences_im = IM.userPrefe;
-		
-		while( preferences_im !== "")
-		{
-			var values = "";
-			var value = "";
-			if(value = preferences_im.substr(0,preferences_im.indexOf(';')))
-			{
-				values = value + '\n';
-				preferences_im = preferences_im.replace(value,'');	
-			}
-			if(preferences_im.substr(0,1) == ";"){
-				preferences_im = preferences_im.substr(1,preferences_im.length);
-			}else{
-				values = preferences_im + '\n';
-				preferences_im = '';
-			}
-			
-			var ele = values.substr(0,values.indexOf(':'));
-			var val = values.substr((values.indexOf(':')+1),values.length);
-
-			if(ele == pElement)
-				return val;
-
-			if((document.getElementById(ele)!= null) && (document.getElementById(ele).type == 'text'))
-				document.getElementById(ele).value = val;
-			else
-				if(document.getElementById(ele) != null)
-					document.getElementById(ele).checked = eval(val);
-		}
-	}
-
-   /*
-    * Estado de Ausente Automático
-    */
-	
-	IM_Preferences.prototype.TimerXa = function(pTimer)
-	{
-		this.im_timer_xa = pTimer;
-		_awayTimer = setTimeout("IM.setAway()", parseInt(pTimer) * 60000 );
-	}
-
-   /*
-	*  Detalhes do Contato para Autorização
-	*/
-	
-	IM_Preferences.prototype.Info_Contact = function(pJid)
-	{
-		var element = "_span_not_" + pJid;
-		var uid = pJid.substr(0,pJid.indexOf('@'));
-		var handler_ldap =  function(data)
-		{
-			var data = func.interface(data);
-			var XMLinfoLdap = "";
-			if(data)
-			{
-				XMLinfoLdap = '<info_user>';
-				for(var i in data)			
-					XMLinfoLdap += '<item lang_name="'+IM.get_lang('Name')+'" name="'+ data[i].cn +'" lang_email="'+IM.get_lang('E-mail')+'" email="'+ data[i].mail +'" />';
-				XMLinfoLdap += '</info_user>';
-			}
-			im_menu_action.menu(element, parse_XmlXsl(XMLinfoLdap,'info_contact_ldap.xsl'));
-			if(document.getElementById('im_span_avatar') != null)
-			{
-				var span = document.getElementById('im_span_avatar');
-				var	img = func.newEl('img');
-				func.confEl(img, 'id', pJid + '_avatar');
-				func.confEl(img, 'src', img_photo.src);
-				func.confEl(img, 'style', 'height:65px;width:60px;align:right;');
-				span.appendChild(img);
-				// Foto Ldap;
-				im_win.get_photo_ldap(pJid);
-			}
-		}
-		XMLTools.request('$this.ldap_im.info_user','POST',handler_ldap,'uid='+uid);
-	}
-	
-	// Build Object	
-	var IM_Preferences = new IM_Preferences();
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_init.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_init.js	(revision 151)
+++ 	(revision )
@@ -1,15 +1,0 @@
-function init_jabber()
-{
-   try
-   {
-      if ( window.IM && window.im_win && window.func )
-         IM.load_im();
-      else
-         setTimeout('init_jabber()', 2000);
-   }
-   catch(e)
-   {
-         setTimeout('init_jabber()', 2000);
-   }
-}
-init_jabber();
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_subscription.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_subscription.js	(revision 151)
+++ 	(revision )
@@ -1,51 +1,0 @@
-// Instant Messenger
-// im_subscription.js
-
-	function Subscription()
-	{
-	}
-	
-	Subscription.prototype.subscribe = function(pJid)
-	{
-		var handler_subscribe = function(data)
-		{
-		};
-		XMLTools.request('$this.Ujabber.subscribe','POST',handler_subscribe,'jid='+pJid);
-	}		
-	
-	Subscription.prototype.subscribed = function(pJid)
-	{
-		var handler_subscribe = function(data)
-		{
-		};
-		XMLTools.request('$this.Ujabber.subscribed','POST',handler_subscribe,'jid='+pJid);
-	}
-	
-	Subscription.prototype.unsubscribe = function(pJid)
-	{
-		alert('#1 - O usuário ' + pJid + "\nnão aceitou seu convite ou o excluiu de sua lista!" );	
-	}
-	
-	Subscription.prototype.unsubscribed = function(pJid)
-	{
-		alert('#2 - O usuário ' + pJid + ' não aceitou seu convite!' );
-	}
-	
-	Subscription.prototype.RequestAutorization = function(pJid)
-	{
-		if(confirm('(Re)-requisitar Autorização para o usuário : ' + pJid))
-		{
-			var handler_requestAut = function(data)
-			{
-			};
-			XMLTools.request('$this.Ujabber.subscribe','POST',handler_requestAut,'jid='+pJid);
-		}
-	}
-
-	Subscription.prototype.complete_subscribe = function(pJid)
-	{
-		this.subscribed(pJid);
-	}
-	// Build Object;
-	
-	var Subscription = new Subscription();
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_images.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_images.js	(revision 151)
+++ 	(revision )
@@ -1,35 +1,0 @@
-// Instant Messenger
-// im_images.js
-
-		var navbar = new Image();
-		navbar.src = im_path + 'templates/default/images/navbar.png';
-		var img_group_close = new Image();
-		img_group_close.src = im_path + "templates/default/images/group_close.gif";
-		var img_group_open = new Image();
-		img_group_open.src = im_path + "templates/default/images/group_open.gif";
-		var img_available = new Image();
-		img_available.src = im_path + "templates/default/images/available.gif";
-		var img_unavailable = new Image();
-		img_unavailable.src = im_path + "templates/default/images/unavailable.gif";
-		var img_busy = new Image();
-		img_busy.src = im_path + "templates/default/images/busy.gif";
-		var img_chat = new Image();
-		img_chat.src = im_path + "templates/default/images/chat.gif";
-		var img_photo = new Image();
-		img_photo.src = im_path + "templates/default/images/photo.png";
-		var img_menu = new Image();
-		img_menu.src = im_path + "templates/default/images/menu.gif";
-		var img_chat_bubble = new Image();
-		img_chat_bubble.src = im_path + "templates/default/images/chat_bubble.gif";
-		var img_typing = new Image();
-		img_typing.src = im_path + "templates/default/images/typing.gif";
-		var img_edit = new Image();
-		img_edit.src = im_path + "templates/default/images/img/icon_edit.gif";
-		var img_xa = new Image();
-		img_xa.src = im_path + "templates/default/images/xa.gif";
-		var img_away = new Image();
-		img_away.src = im_path + "templates/default/images/away.gif";
-		var img_dnd = new Image();
-		img_dnd.src = im_path + "templates/default/images/dnd.gif";
-		var img_wait = new Image();
-		img_wait.src = im_path + "templates/default/images/wait.gif";
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_functions.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_functions.js	(revision 151)
+++ 	(revision )
@@ -1,963 +1,0 @@
-	function IM()
-	{
-	   this.vcards      = false;
-	   this.statusvcard = false;
-	   this.UsersNot	= [];
-	   this.userPrefe   = false;
-	   this.count_Vcard = 0;
-	   this._listen     = "";
-	   this.custom_message = "";
-	   this.timeout_composing = "";
-	}
-
-	IM.prototype.load_im = function()
-	{
-		this.listen();
-	    this.requireContacts();
-	    this.atalho();
-
-	    var handler_Status = function(XmlData)
-	    {
-			var data = XmlData.getElementsByTagName('retorno').item(0);
-			data = data.firstChild.nodeValue;
-			if( data )
-			{
-				if(data == 'available' || data == 'xa')
-					awayFlag = true;
-				statusFlag = data;
-				setTimeout('IM.ImgStatus("'+data+'")',4000);
-			}
-	    };
-	    XMLTools.request('$this.Ujabber.MyPresence', 'GET', handler_Status);
-	};
-
-	IM.prototype.listen = function()
-	{
-	   var _this = this;
-	   var handler = function(XMLdata)
-	   {
-	      try
-	      {
-				var data = XMLdata.documentElement;
-				if ( data.hasChildNodes() )
-				{
-					data = data.firstChild;
-					if ( data.nodeType == 3 && data.nodeValue == 'disconnected' ) 
-					{
-						document.getElementById('div_contacts').innerHTML = '<a href="javascript:void(0);" onclick="javascript:IM.reconnect();">'+_this.get_lang("Re-connect Expresso Messenger ?")+'</a>';
-						_this.ImgStatus('unavailable');
-						statusFlag = 'unavailable';
-						clearTimeout(_awayTimer);
-						return false;
-					}
-				}					
-				
-				if( !_this.userPrefe )
-				{
-					if(window.IM_Preferences)
-						IM_Preferences.GetYourPreferences();
-				}
-
-	            _this.getContacts(XMLdata);
-	            _this.getPresence(XMLdata);
-				_this.getComposing(XMLdata);
-	            _this.getMessages(XMLdata);
-				_this.getVcard(XMLdata);
-
-            	if(!_this.vcards)
-            	{
-	            	_this.Vcard();
-	            	_this.vcards = true;
-	            }
-
-	      }catch(e){}
-
-	      _this._listen = setTimeout('IM.listen()', 3000);
-	   };
-
-	   XMLTools.__RETURN_MODE__ = 'XML';
-	   XMLTools.request('$this.Ujabber.listen', 'GET', handler);
-	};
-	
-	IM.prototype.reconnect = function()
-	{
-		var _this = this;
-		var handler_reconnect = function(XMLdata)
-		{
-			if ( XMLdata.documentElement.firstChild.nodeValue == 'true' )
-			{
-				document.getElementById('div_contacts').innerHTML  = '<div><img src="' + img_wait.src + '" width="25px" heigth="25px" style="float:left;margin:3px "/>';
-				document.getElementById('div_contacts').innerHTML += '<font style="color:#0000FF;float:left;margin:9px 5px">' + _this.get_lang("Wait a moment !!") + '</font></div>';
-				setTimeout('IM.load_im()',2000);
-	           	_this.count_Vcard = 0;
-				_this.ImgStatus('available');
-				statusFlag = 'available';	   
-				_awayTimer = setTimeout("IM.setAway()", parseInt(IM_Preferences.im_timer_xa) * 60000 );				        	
-			}else{
-				document.getElementById('div_contacts').innerHTML = '<a href="javascript:void(0);" onclick="javascript:IM.reconnect();">'+_this.get_lang("Re-connect Expresso Messenger ?")+'</a>';
-				_this.ImgStatus('unavailable');
-				statusFlag = 'unavailable';				
-				return false;
-			}
-		};
-		XMLTools.__RETURN_MODE__ = 'XML';
-		XMLTools.request('$this.Ujabber.reconnect', 'GET', handler_reconnect);
- 	};
-
-   /*
-	*  Contacts
-	*/
-
-	IM.prototype.requireContacts = function()
-	{
-	   var handler = function(data)
-		{
-		};
-	   XMLTools.request('$this.Ujabber.requireContacts', 'GET', handler);
-	};
-
-	IM.prototype.getContacts = function(data)
-	{
-	   try
-	   {
-	      if ( data.getElementsByTagName('contacts').length > 0 )
-	      {
-	         var node = data.documentElement.firstChild;
-	         while ( node.nodeName != 'contacts' )
-	         	node = node.nextSibling;
-
-	         var div = document.getElementById("div_contacts");
-	         var xsl = XMLTools.load(im_path + 'xsl/contacts.xsl?' + Date.parse(new Date));
-	         var img = document.createElement('img');
-	         img.id  = 'img_all_groups';
-	         img.src = img_group_open.src;
-	         img.onclick = function(){IM.visible_group("all_groups")};
-
-	         var a = document.createElement('div');
-	         a.innerHTML = XMLTools.transform(node, xsl);
-
-	         div.innerHTML = '';
-	         div.appendChild(img);
-	         div.appendChild(document.createTextNode(this.get_lang('List of Contacts')));
-	         div.appendChild(a);
-
-			 var group = func.byId("all_groups").firstChild;
-			 while ( group )
-	         {
-					var contact = group.firstChild.nextSibling;
-					while ( contact = contact.nextSibling )
-					{
-						var img = func.newEl('img');
-						img.src = img_unavailable.src;
-
-						func.insElB(img, func.byId(contact.id).firstChild);
-					}
-
-					try
-					{
-						var img = document.createElement('img');
-						img.src = img_group_open.src;
-						img.id = "img_" + group.id;
-						var el_parent = group;
-
-						el_parent.insertBefore(img,el_parent.firstChild);
-
-					} catch(e){}
-					group = group.nextSibling;
-	         }
-	      }
-	   }catch(e){}
-
-	};
-
-   /*
-	*  Visible / Unvisible
-	*/
-
-	IM.prototype.visible_group = function(el)
-	{
-		var _this = this;
-		var divParent = document.getElementById(el);
-		divParent.style.display = "none";
-		var img = document.getElementById("img_" + el);
-		img.onclick = function(){_this.unvisible_group(el)};
-		img.src = img_group_close.src;
-	}
-
-	IM.prototype.unvisible_group = function(el)
-	{
-		var _this = this;
-		var div = document.getElementById(el);
-		div.style.display = "";
-		var img = document.getElementById("img_" + el);
-		img.onclick = function(){_this.visible_group(el)};
-		img.src = img_group_open.src;
-	}
-
-	/*
-	 * Presence
-	 */
-
-	IM.prototype.getPresence = function(data)
-	{
-	   try
-	   {
-	      var presence = data.documentElement.firstChild;
-		  var _this = this;
-	      while ( presence )
-	      {
-		      if ( presence.nodeName != 'presence' )
-		      {
-                 presence = presence.nextSibling;
-		         continue;
-		      }
-
-				var from = presence.getAttribute('from');
-				var type = presence.getAttribute('type');
-				if ( presence.hasChildNodes() )
-					var status_message = presence.firstChild.nodeValue;
-				else
-					var status_message = false;
-
-				if( from )
-				{
-			         switch ( type )
-			         {
-			         	case 'subscribe' :
-			         		if ( !func.byId(from) )
-								_this.UsersNot[_this.UsersNot.length] = from;
-							else
-							{
-								Subscription.subscribed(from);
-								this.setStatus(statusFlag);
-							}
-						break;
-			         	case 'subscribed' :
-			         		//
-			         	break;
-			         	case 'unsubscribe' :
-			         		Subscription.unsubscribe(from);
-			         		type = 'unavailable';
-			         		func.byId(from).firstChild.src = eval('img_' + type + '.src');
-			         		break;
-			         	case 'unsubscribed' :
-			         		Subscription.unsubscribed(from);
-			         		type = 'unavailable';
-			         		func.byId(from).firstChild.src = eval('img_' + type + '.src');
-			         		break;
-			         	default :
-			     			if ( func.byId(from) )
-			     			{
-			     				func.byId(from).firstChild.src = eval('img_' + type + '.src');
-			     				var status;
-
-			     				if ( (status = func.byId(from + '_im_window')) )
-			     				{
-						        	status.firstChild.style.background = 'url('+func.byId(from).firstChild.src+')';
-									status = func.byId(from + '_im_window_message');
-						        	if( status_message && status_message != "available" )
-						        		status.innerHTML = from.substr(0, from.indexOf('@')) + ' : ' + status_message;
-						        	else
-						        		status.innerHTML = '';
-						        }
-
-	     						if( document.getElementById('status_message_' + from) == null)
-	     						{
-		     						var lbl = document.createElement('label');
-		     						lbl.id = 'status_message_' + from;
-		     						if(!status_message)
-		     							lbl.innerHTML = "";
-		     						else
-		     							if( status_message != "available" )
-				     						lbl.innerHTML = "<span style='margin-left:10px'><br/> ( " + status_message + " )</span>";
-									func.byId(from).appendChild(lbl);
-		     					}else{
-									var lbl = document.getElementById('status_message_' + from);
-		     						if(!status_message)
-		     							lbl.innerHTML = "";
-		     						else
-		     							if( status_message != "available" )
-				     						lbl.innerHTML = "<span style='margin-left:10px'><br/> ( " + status_message + " )</span>";
-		     					}
-			     			}
-			         }
-				 }
-			    if( _this.UsersNot.length > 0 )
-			  		Templates.Users_Not_Auth(_this.UsersNot);
-	         presence = presence.nextSibling;
-	      }
-	      _this.Contacts_Offline();
-	   }catch(e){}
-	};
-
-	/*
-	 * Contatos - Offline
-	 */
-
-	IM.prototype.Contacts_Offline = function()
-	{
-		 var offline = true;
-		 if(IM.userPrefe)
-		 	offline = eval(IM_Preferences.LoadPreferences('ch_offline'));
-		 else
-		 	offline = eval(IM_Preferences.LoadPreferences('ch_offline'));
-
-		 var group = func.byId("all_groups").firstChild;
-		 while ( group )
-         {
-			var contact = group.firstChild;
-			while ( contact )
-			{
-				if(contact.tagName == "DIV")
-				{
-					var childF = contact.firstChild;
-					if( childF.src == img_unavailable.src && !offline)
-						func.byId(contact.id).style.display = "none";
-					else
-						func.byId(contact.id).style.display = "block";
-				}
-				contact = contact.nextSibling;
-			}
-			group = group.nextSibling;
-         }
-	}
-
-	/*
-	 * Get / Send - Messages
-	 */
-
-	IM.prototype.getMessages = function(data)
-	{
-	   try
-	   {
-	      data = data.documentElement;
-	      if ( data.childNodes.length > 0 )
-	      {
-	         var message = data.firstChild;
-	         while ( message )
-	         {
-	            if ( message.tagName == 'messages' )
-	            {
-	               var from = message.getAttribute('from');
-	               with ( from )
-	                  from = substr(0, indexOf('/'))
-
-	               if( document.getElementById('vcard_' + from) != null)
-	               {
-						var vcards = IM_Preferences.vCardLoad(from);
-						var nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length);
-						    nickname = nickname.substr(0,nickname.indexOf('|'));
-						    nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length);
-						    nickname = ( func.trim(nickname) != "" ) ? nickname : from ;
-				   }
-				   else
-				      var nickname = from;
-				  
-				   if(nickname.indexOf('@') != -1)	
-				   		nickname = nickname.substr(0,nickname.indexOf('@'));
-
-	               var win = document.getElementById(from + '_chatMessages');
-	               if ( !win )
-	               {
-	                  im_win.open_chat(from);
-	                  win = document.getElementById(from + '_chatMessages');
-	               }
-
-	               var el = message.firstChild;
-	               while ( el )
-	               {
-	                  var xsl = XMLTools.load(im_path + 'xsl/message.xsl?' + Date.parse(new Date));
-	                  var next = el.nextSibling;
-
-	                  var label = document.createElement('strong');
-	                  label.appendChild(document.createTextNode(nickname));
-
-	                  win.appendChild(label);
-	                  win.appendChild(document.createElement('br'));
-	                  var msg = XMLTools.transform(el, xsl);
-	                  win.innerHTML += this.emotions_icons(msg);
-	                  win.appendChild(document.createElement('br'));
-	                  win.appendChild(document.createElement('br'));
-	                  win.scrollTop = win.scrollHeight;
-			   		  im_win.newMessageNotification();
-
-	                  el = next;
-	               }
-	            }
-
-				if ( (composing = func.byId(from + '_composing')) )
-					if ( composing.style.display = 'block' )
-						composing.style.display = 'none';
-
-	            message = message.nextSibling;
-	         }
-	      }
-	   }catch(e){}
-	}
-
-	IM.prototype.sendMessage = function (pJID)
-	{
-	   var _this = this;
-	   var name_document = document.getElementById(pJID + '_edita');
-	   var envio = name_document.contentWindow.document.getElementsByTagName('body').item(0);
-
-	   var imgs = envio.getElementsByTagName('img');
-	   var cod;
-	   var emotion_regexp;
-
-	   for ( i = imgs.length - 1; i > -1; i--)
-	   {
-	      if ( (cod = imgs[i].getAttribute('emotion')) )
-		  {
-			 emotion_regexp = new RegExp('<img[^>]*?emotion="' + cod_emotions[cod][1] + '"[^>]*?>', "i");
-             envio.innerHTML = envio.innerHTML.replace(emotion_regexp, cod);
-          }
-	      else
-	         imgs[i].parentNode.removeChild(imgs[i]);
-	   }
-
-	   envio.innerHTML = func.trim(envio.innerHTML);
-	   envio.innerHTML = envio.innerHTML.replace(/&nbsp;| +/gi, ' ');
-	   envio.innerHTML = envio.innerHTML.replace(/<br[^>]*>/gi, '<br />');
-
-	   if ( envio.innerHTML != "" )
-	   {
-	      var message_text  = "<div style='";
-	      message_text += (envio.style.fontFamily != "") ? "font-family:"+envio.style.fontFamily+";" : "";
-	      message_text += (envio.style.fontSize != "") ? "font-size:"+envio.style.fontSize+";" : "" ;
-	      message_text += (envio.style.fontWeight != "") ? "font-weight:"+envio.style.fontWeight+";": "";
-	      message_text += (envio.style.fontStyle != "" ) ? "font-style:"+envio.style.fontStyle+";" : "";
-	      message_text += (envio.style.color != "") ? "color:"+envio.style.color+";" : "color:black";
-	      message_text += "'>";
-	      message_text += envio.innerHTML + "</div>";
-
-	   	  message_text = message_text.replace(/&nbsp;| +/gi, ' ');
-	   	  message_text = message_text.replace(/<br[^>]*>/gi, '<br />');
-
-	      envio.innerHTML = '';
-
-	      var message_element = document.getElementById(pJID + '_chatMessages');
-	      var nickname = "me ";
-		  if( IM_Preferences.jid )
-		  {
-			  var vcards = IM_Preferences.vCardLoad(IM_Preferences.jid);
-			  nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length);
-			  nickname = nickname.substr(0,nickname.indexOf('|'));
-			  nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length);
-			  nickname = (func.trim(nickname) != "") ? nickname : IM_Preferences.jid;
-			  if(nickname.indexOf('@') != -1)	
-				nickname = nickname.substr(0,nickname.indexOf('@'));
-		  }
-
-	      message_element.innerHTML += '<strong>' + nickname + ' ';
-	      message_element.innerHTML += ' ' + _this.get_lang('speak') + ':</strong><br />';
-		  message_element.innerHTML += this.emotions_icons(message_text) + '<br />';
-	      message_element.scrollTop = message_element.scrollHeight;
-
-	      var handler_sendMessage = function(data)
-	      {
-			 var data = func.interface(data);
-	         if(!data)
-	            alert(data);
-	      }
-	   	  XMLTools.request('$this.Ujabber.SendMessage','POST',handler_sendMessage,"to="+pJID+"&body="+escape(message_text));
-	   }
-	};
-    
-    /*
-     * Composing / GetComposing / Paused Message
-     */
-
-	IM.prototype.getComposing = function(data)
-	{
-		if ( data.hasChildNodes() )
-		{
-			var node = data.documentElement.firstChild;
-			while ( node )
-			{
-				var composing;
-				if ( node.nodeName == 'composing' )
-					if ( (composing = func.byId(node.getAttribute('from') + '_composing')) )
-						if ( composing.style.display = 'none' )
-							composing.style.display = 'block';
-
-				if ( node.nodeName == 'paused' )
-					if ( (composing = func.byId(node.getAttribute('from') + '_composing')) )
-						if ( composing.style.display = 'block' )
-							composing.style.display = 'none';
-
-				node = node.nextSibling;
-			}
-		}
-	};
-	
-	IM.prototype.composingMessage = function(pId)
-	{
-		if( IM.timeout_composing )
-		{	
-			clearTimeout(IM.timeout_composing);
-			IM.timeout_composing = eval('setTimeout("IM.pausedMessage(\'' + pId + '\')",2000)');
-		}
-		else
-		{
-			IM.timeout_composing = eval('setTimeout("IM.pausedMessage(\'' + pId + '\')",2000)');
-			var handler_composingMessage = function(data)
-			{
-			};
-			XMLTools.request('$this.Ujabber.composingMessage', 'POST', handler_composingMessage,"to="+pId);
-		}
-	};
-	
-	IM.prototype.pausedMessage = function(pId)
-	{
-		clearTimeout(IM.timeout_composing);
-		IM.timeout_composing = "";
-		var handler_pausedMessage = function(data)
-		{
-		};
-		XMLTools.request('$this.Ujabber.pausedMessage','POST',handler_pausedMessage,"to="+pId);
-	};
-
-	/*
-	 * Get_lang
-	 */
-
-	IM.prototype.get_lang = function(_key, _arg1, _arg2, _arg3, _arg4)
-	{
-	   var _value = "";
-
-	   if ( !lang_im[_key.toLowerCase()] )
-	      return _key + "*";
-
-	   _value = lang_im[_key.toLowerCase()];
-
-	   if ( _arg1 || _arg2 ||_arg3 || _arg4 )
-	   {
-	      for (j = 1; j <= 4; j++ )
-	         if( eval("_arg"+j) )
-	         {
-	            var regExp = new RegExp("%" + j + "");
-	            _value = _value.replace(regExp, eval("_arg"+j));
-	         }
-	   }
-
-	   return _value;
-	};
-
-	IM.prototype.getWinContactsState = function()
-	{
-	   try
-	   {
-	      var win_state = false;
-	          win_state = ( windowItems['contacts'].state == WINDOW_STATE_REGULAR ) ? true : false;
-	          win_state = ( win_state ) ? win_state : ( windowItems['contacts'].state == WINDOW_STATE_MAXIMIZED ) ? true : false;
-	      return win_state;
-
-	   }catch(e){}
-	};
-
-	IM.prototype.showContacts = function()
-	{
-	   if ( this.getWinContactsState() )
-	      im_win.windowClose('contacts_im');
-	   else
-	   {
-	      im_win.windowMaximizeRestore('contacts_im');
-	   }
-	};
-
-   /*
-	*  Smiles
-    */
-
-    IM.prototype.emotions_icons = function(pEmotion)
-    {
-	   var emotion_regexp;
-	   for ( i in cod_emotions )
-       {
-		  try
-		  {
-			 emotion_regexp = new RegExp(cod_emotions[i][1], 'gi');
-             if ( emotion_regexp.test(pEmotion) )
-             {
-                var image = eval('smile_' + cod_emotions[i][0] + '.src.substr(smile_' +cod_emotions[i][0]  + '.src.indexOf(im_path))');
-			    emotion_regexp = new RegExp(cod_emotions[i][1], 'gi');
-                pEmotion = pEmotion.replace(emotion_regexp, '<img emotion="' + i + '" src="' + image + '">');
-             }
-		  }catch(e){}
-       }
-       return pEmotion;
-    }
-
-	IM.prototype.atalho = function()
-	{
-	   if ( (local = func.byId('user_info')) && !(func.byId('myStatus')) )
-	   {
-         var aux  = new Array();
-         var _mix = func.newEl('a', 'a', 'img', 'img', 'dl');
-
-         var fast_menu_link  = _mix[0];
-         var contacts_link   = _mix[1];
-         var fast_menu_image = _mix[2];
-         var contacts_image  = _mix[3];
-         var im_fast_menu    = _mix[4];
-
-         fast_menu_link.onclick = function(){IM.showFastMenu();};
-         contacts_link.onclick  = function(){IM.showContacts();};
-
-         aux['fast_menu_image'] = new Array();
-         aux['fast_menu_image']['element'] = fast_menu_image;
-         aux['fast_menu_image']['style']   = 'width:9px;height:9px';
-         aux['fast_menu_image']['src']     = im_path + 'templates/default/images/menuarwopen.gif';
-
-         aux['im_fast_menu'] = new Array();
-         aux['im_fast_menu']['element'] = im_fast_menu;
-         aux['im_fast_menu']['id']      = 'fast_menu_im';
-         aux['im_fast_menu']['class']   = 'menu_im';
-
-         aux['contacts_image'] = new Array();
-         aux['contacts_image']['element'] = contacts_image;
-         aux['contacts_image']['id']      = 'myStatus';
-         aux['contacts_image']['src']     = eval('img_' + statusFlag + '.src');
-         aux['contacts_image']['style']   = 'width:15px;height:15px';
-         func.confEl(aux);
-
-         func.insEl(fast_menu_image, fast_menu_link);
-         func.insEl(contacts_image, contacts_link);
-         func.insElB(fast_menu_link, contacts_link, im_fast_menu, document.createTextNode(' '), local.firstChild);
-	   }
-	   else
-	      setTimeout('IM.atalho()', 5000);
-	};
-
-	/*
-	 * Vcard
-	 */
-
-	IM.prototype.Vcard = function()
-	{
-		var _this = this;
-		if( _this.count_Vcard < 4)
-		{
-			var handler_getVcard = function(_XMLdata)
-			{
-				var data = _XMLdata.getElementsByTagName('retorno').item(0);
-				data = eval(data.firstChild.nodeValue);
-				if(!data)
-					setTimeout("IM.Vcard()",2000);
-				_this.count_Vcard++;
-			};
-	   		XMLTools.request('$this.Ujabber.Vcard','GET',handler_getVcard);
-	   	}else{
-			var handler_getVcardUser = function(XMLdata)
-			{
-			};
-	   		XMLTools.request('$this.Ujabber.VcardUser','GET',handler_getVcardUser);
-	   	}
-
-	};
-
-	IM.prototype.getVcard = function(data)
-	{
-		  var _this = this;
-		  try
-		  {
-			     if ( data.getElementsByTagName('vcard').length > 0  && !_this.statusvcard )
-			     {
-			         var div = document.getElementById("im_vcard_contacts");
-			         var xsl = XMLTools.load(im_path + 'xsl/vcard_contacts.xsl?' + Date.parse(new Date));
-			         _this.statusvcard = true;
-
-			         div.innerHTML = "";
-			         div.innerHTML += XMLTools.transform(data, xsl);
-		 	         IM_Preferences.vCardInit();			         
-				 }
-
-
-		  }catch(e){}
-	};
-
-	IM.prototype.open_chat = function(pJID)
-	{
-	   im_win.open_chat(pJID);
-	};
-
-	IM.prototype.action_button = function(pEv, pJid)
-	{
-		try
-		{
-			if ( pEv.button > 1 )
-			{
-				var posx = 0;
-				var posy = 0;
-				if (pEv.pageX || pEv.pageY)
-				{
-					posx = pEv.pageX;
-					posy = pEv.pageY;
-				}
-				else if (pEv.clientX || pEv.clientY)
-				{
-					posx = pEv.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
-					posy = pEv.clientY + document.body.scrollTop + document.documentElement.scrollTop;
-				}
-				this.menu_button_right(pJid, posx, posy);
-				document.oncontextmenu = new Function("return false");
-			}
-			else
-				if ( func.byId(pJid).firstChild.src != img_unavailable.src )
-					this.open_chat(pJid);
-		}catch(e){}
-	};
-
-	IM.prototype.menu_button_right = function(pElement, pX, pY)
-	{
-	   var form_menu_button_right = '<dl style="z-index:99999">'+
-	                                '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.Update_NickName(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Nick') + '</a>'+
-	                                '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.Update_Group(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Group') + '</a>'+
-	                                '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.RemoveContact(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Delete') + '</a>'+
-									'<dt><a href="javascript:void(0);" onclick="javascript:Subscription.RequestAutorization(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('(Re)-requisitar Autorização') + '</a>' +	                                
-	                                '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.vCardLoad_Contact(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('See Info') + '</a>'+
-	                                '</dl>';
-	   im_menu_action.menu('menu_contato', form_menu_button_right);
-	   func.byId('menu_contato').style.top = pY-10;
-	   func.byId('menu_contato').style.left = pX-10;
-	   func.byId('menu_contato').style.zIndex = zValue + 10;
-	};
-
-	/*
-	 * Menu
-	 */
-
-	IM.prototype.menu_preferences = function()
-	{
-		  var posx = 0;
-		  var posy = 0;
-		  var pEv = arguments[0];
-
-		  if (pEv.pageX || pEv.pageY)
-		  {
-			  posx = pEv.pageX;
-			  posy = pEv.pageY;
-		  }
-		  else if (pEv.clientX || pEv.clientY)
-		  {
-			  posx = pEv.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
-			  posy = pEv.clientY + document.body.scrollTop + document.documentElement.scrollTop;
-		  }
-
-		  var p_element = document.getElementById(arguments[1]);
-		  var _xmlDoc = "";
-		  var _this = this;
-
-		  _xmlDoc = '<menu>' +
-						'<item function="IM_Preferences.Add_userLoad()" lang="'+IM.get_lang('Add Contact')+'"/>' +
-						'<item function="IM_Preferences.Remove_userLoad()" lang="'+IM.get_lang('Remove Contact')+'"/>' +
-						'<item function="IM_Preferences.vCard()" lang="'+IM.get_lang('Vcard')+'"/>' +
-						'<item function="IM_Preferences.yourPreferences()" lang="'+IM.get_lang('preferences')+'"/>' +
-					'</menu>';
-
-	      im_menu_action.menu(p_element.id,parse_XmlXsl(_xmlDoc,'menu_preferences.xsl'));
-	      func.byId(p_element).style.top = posy;
-	      func.byId(p_element).style.left = posx;
-	      func.byId(p_element).style.zIndex = zValue + 10;
-
-	      _this.Load_Images_menu();
-	}
-
-	IM.prototype.Load_Images_menu = function(Element)
-	{
-		try
-		{
-			var group = document.getElementById("dl_im_menu_preferences");
-			var Child =  group.childNodes;
-
-			for(var i = 0; i < Child.length; i++)
-			{
-				var img = document.createElement('img');
-				img.src = img_menu.src;
-				Child[i].firstChild.insertBefore(img, Child[i].firstChild.firstChild);
-			}
-		}catch(e){}
-	}
-
-   /*
- 	*  Função Provisória - By AlC
- 	*/
-
-	function parse_XmlXsl(_xmlDoc, form_xsl)
-	{
-		  var xslWin = false;
-
-		  if ( !xslWin ) xslWin = XMLTools.load(im_path + 'xsl/' + form_xsl + '?' + Date.parse(new Date));
-
-		  a = document.createElement('div');
-		  if (window.ActiveXObject)
-		  {
-		     var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
-		     xmlDoc.async = "false";
-		     xmlDoc.loadXML(_xmlDoc);
-		  }
-		  else
-		  {
-		     var parser = new DOMParser();
-		     var xmlDoc = parser.parseFromString(_xmlDoc, "text/xml");
-		  }
-		  a.innerHTML = XMLTools.transform(xmlDoc, xslWin);
-
-		  return a;
-
-	}
-
-   IM.prototype.showFastMenu = function()
-   {
-		 var _dt = func.newEl('dt', 'dt', 'dt', 'dt', 'dt');
-		 var _a  = func.newEl('a', 'a', 'a', 'a', 'a');
-
-		 for ( var i in _dt )
-		 {
-		    if ( typeof _dt[i] == 'function' )
-		       continue;
-		    eval('var option' + (parseInt(i)+1) + ' = _dt[' + i + '];');
-		    eval('var option' + (parseInt(i)+1) + '_link = _a[' + i + '];');
-		 }
-
-		 var _img = func.newEl('img', 'img', 'img', 'img','img');
-
-		 for ( var i in _img )
-		 {
-		    if ( typeof _dt[i] == 'function' )
-		       continue;
-		    eval('var option' + (parseInt(i)+1) + '_image = _img[' + i + '];');
-		 }
-		
-		 option1_link.onclick = function(){statusFlag = 'available'; IM.setStatus('available');};
-		 option2_link.onclick = function(){statusFlag = 'xa'; awayFlag = false; IM.setStatus('xa');};
-		 option3_link.onclick = function(){statusFlag = 'dnd'; IM.setStatus('dnd');};
-		 option4_link.onclick = function(){statusFlag = 'unavailable'; IM.setStatus('unavailable');};
-		 option5_link.onclick = function(){IM.setStatus('custom')};
-
-		 func.confEl(option1_image, 'src', img_available.src);
-		 func.confEl(option1_image, 'style', 'width:16px;height:16px;cursor:pointer;');
-		 func.confEl(option2_image, 'src', img_xa.src);
-		 func.confEl(option2_image, 'style', 'width:16px;height:16px;cursor:pointer;');
-		 func.confEl(option3_image, 'src', img_dnd.src);
-		 func.confEl(option3_image, 'style', 'width:16px;height:16px;cursor:pointer;');
-		 func.confEl(option4_image, 'src', img_unavailable.src);
-		 func.confEl(option4_image, 'style', 'width:16px;height:16px;cursor:pointer;');
-		 func.confEl(option5_image, 'src', img_edit.src);
-		 func.confEl(option5_image, 'style', 'width:16px;height:16px;cursor:pointer;');
-
-		 func.insEl(option1_image, IM.get_lang('online'), option1_link);
-		 func.confEl(option1_link, 'style','cursor:pointer;');
-		 func.insEl(option1_link, option1);
-
-		 func.insEl(option2_image, IM.get_lang('away'), option2_link);
-		 func.confEl(option2_link, 'style','cursor:pointer;');
-		 func.insEl(option2_link, option2);
-
-		 func.insEl(option3_image, IM.get_lang('busy'), option3_link);
-		 func.confEl(option3_link, 'style','cursor:pointer;');
-		 func.insEl(option3_link, option3);
-
-		 func.insEl(option4_image, IM.get_lang('offline'), option4_link);
-		 func.confEl(option4_link, 'style','cursor:pointer;');
-		 func.insEl(option4_link, option4);
-
-		 func.insEl(option5_image, IM.get_lang('Custom message...'), option5_link);
-		 func.confEl(option5_link, 'style','cursor:pointer;');
-		 func.insEl(option5_link, option5);
-
-		 im_menu_action.menu('fast_menu_im', option1, option2, option3, option4, option5);
-   };
-
-	IM.prototype.setStatus = function(pStatus)
-	{
-		try
-		{
-			var handler = function()
-			{
-			};
-
-			if ( func.byId('fast_menu_im').style.display == 'block' )
-				im_menu_action.menu('fast_menu_im', null);
-			
-			if ( pStatus == 'custom' )
-			{
-				pStatus = prompt('Personalize seu Status : ', this.custom_message);
-				pStatus = 'show=' + statusFlag + '&status=' + pStatus;
-			}
-			else
-			{
-				if ( pStatus == 'unavailable' )
-				{
-					this.ImgStatus(pStatus);
-					pStatus = 'type=' + pStatus;
-				}
-				else
-				{
-					try
-					{
-						this.ImgStatus(pStatus);
-						pStatus = 'show=' + pStatus;
-					}catch(e){}
-				}
-			}
-			XMLTools.request('$this.Ujabber.setPresence', 'POST', handler, pStatus);
-		}catch(e){}
-	};
-
-   IM.prototype.ImgStatus = function(pStatus)
-   {
-		var myStatus;
-		if ( (myStatus = func.byId('myStatus')) )
-			myStatus.src = eval('img_' + pStatus + '.src');
-   };
-
-   IM.prototype.setAway = function()
-   {
-      if(statusFlag != 'dnd' && statusFlag != 'unavailable')
-      {
-		  if ( awayFlag )
-	      {
-		     this.setStatus('available');
-		     statusFlag = 'available';
-	         awayFlag = false;
-	      }
-	      else
-	      {
-	         this.setStatus('xa');
-	   	     statusFlag = 'xa';
-	       	 awayFlag = true;
-	      }		
-      }
-   };
-
-	IM.prototype.infoContact = function(pUid)
-	{
-		try
-		{
-			var info = false;
-			var div_allg = document.getElementById('all_groups');
-			var elements = div_allg.firstChild;
-			while ( elements )
-			{
-				var childs = elements.firstChild;
-				while( childs )
-				{
-					if(childs.tagName == "DIV" && childs.id.indexOf(pUid) === 0 )
-					{
-						info = {'jid':childs.id, 'src':childs.firstChild.src};
-						break;
-					}
-					childs = childs.nextSibling;
-				}
-				if ( !info )
-					elements = elements.nextSibling;
-				else
-					break;
-			}
-			return info;
-		}catch(e){return false;}
-	};
-
-var IM = new IM();
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_conf_font.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_conf_font.js	(revision 151)
+++ 	(revision )
@@ -1,55 +1,0 @@
-var im_conf_font = {
-    
-    content   : null,
-	
-	"get_element" : function()
-	{
-		var _document = document.getElementById(im_win.chat_pJid + '_edita');
-		this.content = _document.contentWindow.document.getElementsByTagName('body').item(0);
-
-	},
-
-	"changeFont" : function(nameFont)
-	{
-  	    this.get_element();
-	    this.content.style.fontFamily = nameFont;
-	    this.content.innerHTML = this.content.innerHTML;
-	    im_win.hideFontNameSelection();
-	},
-	
-	"changeSizeFont" : function(SizeFont)
-	{
-		this.get_element();
-		this.content.style.fontSize = SizeFont;
-		this.content.innerHTML = this.content.innerHTML;
-		im_win.hideFontSizeSelection();
-	},
-	
-	"changeFontColor" : function(ColorFont)
-	{
-		this.get_element();
-		this.content.style.color = ColorFont;
-		this.content.innerHTML = this.content.innerHTML;
-		im_win.hideFontColorSelection();
-	},
-	
-	"changeFontStyle" : function(StyleFont)
-	{
-		this.get_element();
-		if(StyleFont == "bold")
-			this.content.style.fontWeight = "bold";
-		else{
-			this.content.style.fontWeight = "normal";
-			this.content.style.fontStyle = StyleFont;
-		}
-		this.content.innerHTML = this.content.innerHTML;
-		im_win.hideFontStyleSelection();
-	},
-	
-	"defaultOptions" : function()
-	{
-		this.content.style.fontStyle = "normal"	;
-		this.content.style.color = "000000";
-		this.content.style.fontStyle = "10pt";
-	}
-}
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_var_globals.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_var_globals.js	(revision 151)
+++ 	(revision )
@@ -1,96 +1,0 @@
-/**
-* @AUTHOR: [NUTS] Rodrigo Souza
-* @DATE: 2006/10/23 11:37:30
-* @LAST CHANGE: Qui 14 Dez 2006 14:28:12 BRST::
-**/
-
-var focusFlag = true;
-
-window.document.onblur = windowBlur;
-window.document.onfocus = windowFocus;
-window.document.onclick = windowFocus;
-window.document.onmouseover = awayTimer;
-
-var window_title = document.title;
-
-var statusFlag = 'available';
-var awayFlag = false;
-var _awayTimer = null;
-
-function awayTimer()
-{
-	if( awayFlag )
-		IM.setAway();
-	
-	if(window.IM_Preferences)
-	{
-		if( _awayTimer )
-			clearTimeout(_awayTimer);
-		_awayTimer = setTimeout("IM.setAway()", parseInt(IM_Preferences.im_timer_xa) * 60000 );
-	}
-}
-
-awayTimer();
-
-function windowBlur() 
-{
-	try{
-		focusFlag = false; 
-		document.title = window_title;
-	}catch(e){}
-}
-function windowFocus()
-{
-	try{
-		focusFlag = true; 
-		document.title = window_title;
-	}catch(e){}
-}
-
-var WINDOW_STATE_REGULAR = "regular";
-var WINDOW_STATE_MINIMIZED = "minimized";
-var WINDOW_STATE_MAXIMIZED = "maximized";
-var WINDOW_STATE_CLOSED = "closed";
-
-var TASKBAR_STATE_SELECTED = "selected";
-var TASKBAR_STATE_UNSELECTED = "unselected";
-var TASKBAR_STATE_MINIMIZED = "minimized";
-var TASKBAR_STATE_FLASH = "flash";
-
-var windowState = WINDOW_STATE_REGULAR;
-var taskbarItems = new Object();
-var windowItems = new Object();
-
-var zValue = 1000;
-
-var TASKBAR_HEIGHT=27;
-
-var ACTIVE_OBJECTID = "contacts";
-	
-var isEmotionSelectionVisible = false;
-var isFontNameSelectionVisible = false;
-var isFontSizeSelectionVisible = false;
-var isFontColorSelectionVisible = false;
-var isFontStyleSelectionVisible = false;
-var activeChatWindowId = "";
-
-var newMessageTimer;
-var messages_timeout = false;
-var contacts_timeout = false;
-
-var im_busy = false;
-
-var cod_emotions = {
-	":)" : [1,"\\\:\\\)"],
-	":d" : [2,"\\\:d"],
-	";)" : [3,"\\\;\\\)"],
-	":o" : [4,"\\\:o"],
-	":p" : [5,"\\\:p"],
-	"(h)" : [6,"\\\(h\\\)"],
-	":@" : [7,"\\\:\\\@"],
-	":$" : [8,"\\\:\\\$"],
-	":s" : [9,"\\\:s"],
-	":(" : [10,"\\\:\\\("],
-	":'(" : [11,"\\\:\\\'\\\("],
-	":|" : [12,"\\\:\\\|"]
-};
Index: unk/instant_messenger/bkp/instant_messenger_64/js/XMLTools.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/XMLTools.js	(revision 151)
+++ 	(revision )
@@ -1,177 +1,0 @@
-var XMLTools = {
-   "__DEBUG__" : false,
-   "__DEFAULT_URI__" : im_path + 'controller.php?action=',
-   "__HTTP__" : null,
-   "__MODE__" : 'X',
-   "__RETURN_MODE_DEFAULT__" : 'JSON',
-   "__RETURN_MODE__" : false,
-   "__THREADS__" : [],
-   "http" : function()
-   {
-      try
-      {
-         this.__HTTP__ = new XMLHttpRequest();
-         this.__HTTP__.overrideMimeType('text/xml');
-      }
-      catch (e)
-      {
-         try
-         {
-            this.__HTTP__ = new ActiveXObject('Msxml2.XMLHTTP');
-         }
-         catch (e1)
-         {
-            try
-            {
-               this.__HTTP__ = new ActiveXObject('Microsoft.XMLHTTP');
-            }
-            catch (e2)
-            {
-               this.__HTTP__ = null;
-            }
-         }
-      }
-   },
-   "load" : function(pFile)
-   {
-      var data = null;
-      if ( document.implementation.createDocument )
-	     data = document.implementation.createDocument("", "", null);
-      else
-         data = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
-
-      data.async = false;
-      data.load(pFile);
-      return data;
-   },
-   "request" : function(pTarget, pMethod, pHandler, pData)
-   {
-      if ( typeof pHandler != 'function' || this.__THREADS__[pTarget] )
-         return false;
-
-      var __this = this;
-      var __pTarget = pTarget
-      this.http();
-      var __HTTP__ = this.__HTTP__;
-      this.__THREADS__[pTarget] = pHandler;
-
-      var __handler = function ()
-      {
-         try
-         {
-            if ( __HTTP__.readyState == 4 )
-            {
-               switch ( __HTTP__.status )
-               {
-                  case 200:
-                        var data = ( __this.__MODE__ == 'X' ) ?
-                                    __HTTP__.responseXML :
-                                    __HTTP__.responseText;
-
-                        var handler = __this.__THREADS__[__pTarget];
-                        delete __this.__THREADS__[__pTarget];
-                        handler(data, __pTarget);
-                  break; /* [case : status 200] */
-                  case 404:
-                        alert('Page Not Found!');
-                  break; /* [case : status 404] */
-                  default:
-               }
-            }
-         }
-         catch(e)
-         {
-            if ( __this.__DEBUG__ ) alert("request : #2\n\n" + e)
-         }
-      }
-
-      try
-      {
-         var target = this.__DEFAULT_URI__ + pTarget;
-         if ( this.__RETURN_MODE__ )
-         {
-            target += '&returnMode=' + this.__RETURN_MODE__;
-            this.__RETURN_MODE__ = false;
-         }
-         else
-            target += '&returnMode=' + this.__RETURN_MODE_DEFAULT__;
-
-         if ( pMethod == 'POST' )
-         {
-            __HTTP__.open("POST", target, true);
-            __HTTP__.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
-            __HTTP__.setRequestHeader('Cache-Control',  'no-store, no-cache, must-revalidate');
-            __HTTP__.setRequestHeader('Cache-Control', 'post-check=0, pre-check=0');
-            __HTTP__.setRequestHeader('Pragma', 'no-cache');
-            __HTTP__.onreadystatechange = __handler;
-            pData = ( pData ) ? pData : null ;
-         }
-         else
-         {
-            __HTTP__.open("GET", target, true);
-            __HTTP__.onreadystatechange = __handler;
-            pData = null;
-         }
-         __HTTP__.send(pData);
-      }
-      catch(e)
-      {
-         if ( this.__DEBUG__ ) alert("request : #1\n\n" + e)
-      }
-      return true;
-   },
-   "transform" : function(pXML, pXSL)
-   {
-		try
-		{
-			var fragment = null;
-			if ( window.XSLTProcessor )
-			{
-				var xslProc = new XSLTProcessor();
-				xslProc.importStylesheet(pXSL);
-				fragment = xslProc.transformToFragment(pXML, document);
-
-				// para retornar valor igual ao ie.
-				var aux = document.createElement("div");
-				aux.appendChild(fragment);
-				fragment = aux.innerHTML;
-			}
-			else
-			{
-				var xslTemplate = new ActiveXObject("MSXML2.XSLTemplate");
-				xslTemplate.stylesheet = pXSL;
-
-				var myXslProc = xslTemplate.createProcessor();
-				myXslProc.input = pXML;
-
-				myXslProc.transform();
-				fragment = myXslProc.output;
-			}
-			return fragment;
-		}
-		catch(e)
-		{
-			alert("transform\n\n" + e + "\n\n" + e.description);
-		}
-   },
-	"create" : function()
-	{
-		try
-		{
-			var a = false;
-			if ( document.implementation.createDocument )
-				a = document.implementation.createDocument("", "", null);
-			else if ( ActiveXObject )
-				a = new ActiveXObject("Msxml2.DOMDocument");
-
-			with ( a )
-				appendChild(createProcessingInstruction("xml", "version='1.0'"));
-
-			return a;
-		}
-		catch(e)
-		{
-			alert("create\n\n" + e + "\n\n" + e.description);
-		}
-	}
-}
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_smiles.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_smiles.js	(revision 151)
+++ 	(revision )
@@ -1,27 +1,0 @@
-// Instant Messenger
-// im_smiles.js
-
-	   var smile_1 = new Image();
-	   smile_1.src = im_path + "templates/default/images/img/smiles/1.gif"
-	   var smile_2 = new Image();
-	   smile_2.src = im_path + "templates/default/images/img/smiles/2.gif"
-	   var smile_3 = new Image();
-	   smile_3.src = im_path + "templates/default/images/img/smiles/3.gif"
-	   var smile_4 = new Image();
-	   smile_4.src = im_path + "templates/default/images/img/smiles/4.gif"
-	   var smile_5 = new Image();
-	   smile_5.src = im_path + "templates/default/images/img/smiles/5.gif"
-	   var smile_6 = new Image();
-	   smile_6.src = im_path + "templates/default/images/img/smiles/6.gif"
-	   var smile_7 = new Image();
-	   smile_7.src = im_path + "templates/default/images/img/smiles/7.gif"
-	   var smile_8 = new Image();
-	   smile_8.src = im_path + "templates/default/images/img/smiles/8.gif"
-	   var smile_9 = new Image();
-	   smile_9.src = im_path + "templates/default/images/img/smiles/9.gif"
-	   var smile_10 = new Image();
-	   smile_10.src = im_path + "templates/default/images/img/smiles/10.gif"
-	   var smile_11 = new Image();
-	   smile_11.src = im_path + "templates/default/images/img/smiles/11.gif"
-	   var smile_12 = new Image();
-	   smile_12.src = im_path + "templates/default/images/img/smiles/12.gif"
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_win.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_win.js	(revision 151)
+++ 	(revision )
@@ -1,1114 +1,0 @@
-var im_win = {
-
-   chat_pJid : null,
-   _imWindowTemplate : null,
-   xslWin : false,
-   photo  : false,
-	
-   "load" : function()
-   {
-      try
-      {
-			var backFantom = func.newEl('div');
-			func.confEl(backFantom, 'id', 'backFantom');
-			func.confEl(backFantom, 'style', 'position:absolute;top:0px;left:0px;width:100%;height:100%;z-Index:-1;');
-
-			var menu_contato = func.newEl('div');
-			func.confEl(menu_contato, 'id', 'menu_contato');
-			func.confEl(menu_contato, 'class', 'menu_im');
-			func.confEl(menu_contato, 'style', 'position:absolute;z-index:99999');
-
-			var emotions = func.newEl('div');
-			func.confEl(emotions, 'id', 'shared_emotions');
-			func.confEl(emotions, 'class', 'emotionFrame');
-			func.confEl(emotions, 'style', 'position:absolute;padding:1px;left:350px;visibility:hidden;top:0px');
-
-			var font_name = func.newEl('div');
-			func.confEl(font_name, 'id', 'shared_fontName');
-			func.confEl(font_name, 'class', 'statusMenu');
-			func.confEl(font_name, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
-
-			var font_size = func.newEl('div');
-			func.confEl(font_size, 'id', 'shared_fontSize');
-			func.confEl(font_size, 'class', 'statusMenu');
-			func.confEl(font_size, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
-
-			var font_color = func.newEl('div');
-			func.confEl(font_color, 'id', 'shared_fontColor');
-			func.confEl(font_color, 'class', 'statusMenu');
-			func.confEl(font_color, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
-
-			var font_style = func.newEl('div');
-			func.confEl(font_style, 'id', 'shared_fontStyle');
-			func.confEl(font_style, 'class', 'statusMenu');
-			func.confEl(font_style, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
-
-			func.insEl(backFantom, menu_contato, emotions, font_name, font_size, font_color, font_style, false);
-
-			emotions.innerHTML = Templates.emotions();
-			font_name.innerHTML = Templates.font_name();
-			font_size.innerHTML = Templates.font_size();
-			font_color.innerHTML = Templates.font_color();
-			/*font_style.innerHTML = Templates.font_style();*/
-
-			var pId = 'contacts';
-
-			var main_menu_all = func.newEl('div');
-			func.confEl(main_menu_all, 'style', 'margin: 3px;');
-
-			var main_menu_head = func.newEl('div');
-			func.confEl(main_menu_head, 'id', pId + '_im_window_body_inner_head');
-			func.confEl(main_menu_head, 'style', 'margin: 0px 0px 3px 0px; border: 1px solid #809aa9; display: block;');
-
-			var main_menu_vcard = func.newEl('div');
-			func.confEl(main_menu_vcard, 'id', 'im_vcard_contacts');
-			func.confEl(main_menu_vcard, 'style', 'display: none;');
-
-			var main_menu_body = func.newEl('div');
-			func.confEl(main_menu_body, 'id', 'div_contacts');
-			func.confEl(main_menu_body, 'style', 'border: 1px solid #809aa9;');
-			main_menu_body.innerHTML = '<b>Nenhum Contato</b>';
-
-			func.insEl(main_menu_head, main_menu_vcard, main_menu_body, main_menu_all);
-
-			var main_menu_head_picture = func.newEl('img');
-			func.confEl(main_menu_head_picture, 'id', pId + '_avatar');
-			func.confEl(main_menu_head_picture, 'src', img_photo.src);
-			func.confEl(main_menu_head_picture, 'style', 'float: left; height: 65px; margin: 2px; width: 49px;');
-
-			var main_menu_head_name_lable = func.newEl('span');
-			func.confEl(main_menu_head_name_lable,'style','margin: 3px;');
-			main_menu_head_name_lable.innerHTML = IM.get_lang('Nickname');
-
-			var br1 = func.newEl('br');
-						
-			var main_menu_head_name = func.newEl('span');
-			func.confEl(main_menu_head_name, 'id', 'span_nickname');
-			func.confEl(main_menu_head_name, 'style', 'margin-left: 5px;');
-			var main_menu_head_name_txt = document.createTextNode("your nickname");
-			func.insEl(main_menu_head_name_txt, main_menu_head_name);
-
-			var br2 = func.newEl('br');
-			var br3 = func.newEl('br');
-
-			func.insEl(main_menu_head_picture, main_menu_head_name_lable, br1, main_menu_head_name, br2, br3, main_menu_head);
-
-			var main_menu_head_div = func.newEl("div");
-			func.confEl(main_menu_head_div,'id','menu_preferences');
-			func.confEl(main_menu_head_div,'class','menu_im');
-			func.confEl(main_menu_head_div,'style','float: left;cursor:pointer');
-
-			func.insEl(main_menu_head_div, false);
-
-		    var params = [];
-			params['body']       = main_menu_all;
-			params['close']      = true;
-			params['height']     = 270;
-			params['left']       = 10;
-			params['id']         = pId;
-			params['maximize']   = true;
-			params['style']      = 'visibility:hidden';
-			params['title']      = 'Expresso Messenger';
-			params['top']        = 10;
-			params['width']      = 210;
-			this.build(params);
-
-			this.config(pId);
-
-			this.windowMinimize(pId + '_im');
-
-			main_menu_head.innerHTML += '<span id="span_menu_pref" style="float: left;cursor: pointer;" onmousedown="IM.menu_preferences(event ,\'menu_preferences\'); document.oncontextmenu = new Function(\'return false\');"></span>';
-
-			var br3 = func.newEl('br');
-			func.confEl(br3, 'style', 'clear: both');
-
-			var div_ie = func.newEl('div');
-
-			func.insEl(br3, div_ie, main_menu_head);
-
-			main_menu_head_pref_img = func.newEl('img');
-			func.confEl(main_menu_head_pref_img, 'src', img_group_close.src);
-			func.confEl(main_menu_head_pref_img, 'id', 'img_pref');
-
-			main_menu_head_pref_txt = document.createTextNode(IM.get_lang('Options'));
-
-			func.insEl(main_menu_head_pref_img, main_menu_head_pref_txt, 'span_menu_pref');
-      }
-      catch(e)
-      {
-         alert("load\n\n" + e + "\n\n" + e.description)
-      }
-   },
-
-   "config" : function(pId)
-   {
-      try
-      {
-         ADD_DHTML("backFantom"+NO_DRAG);
-         ADD_DHTML("shared_fontStyle"+NO_DRAG);
-         ADD_DHTML("shared_fontColor"+NO_DRAG);
-         ADD_DHTML("shared_fontSize"+NO_DRAG);
-         ADD_DHTML("shared_fontName"+NO_DRAG);
-         ADD_DHTML("shared_emotions"+NO_DRAG);
-         ADD_DHTML(pId+"_im_window_body_inner"+NO_DRAG);
-         ADD_DHTML(pId+"_im_window"+NO_DRAG);
-         ADD_DHTML(pId+"_im_window_master"+NO_DRAG);
-         ADD_DHTML(pId+"_im_window_fantom"+NO_DRAG);
-         ADD_DHTML(pId+"_im_window_movable"+CURSOR_MOVE);
-         ADD_DHTML(pId+"_im_window_resize"+CURSOR_NW_RESIZE);
-
-
-         dd.elements.backFantom.setOpacity(0);
-         document.getElementById("backFantom").style.zIndex = -1;
-
-
-         dd.elements.contacts_im_window_resize.moveTo(dd.elements.contacts_im_window.x+dd.elements.contacts_im_window.w-dd.elements.contacts_im_window_resize.w-2, dd.elements.contacts_im_window.y+dd.elements.contacts_im_window.h-dd.elements.contacts_im_window_resize.h-2);
-         dd.elements.contacts_im_window_movable.moveTo(dd.elements.contacts_im_window.x, dd.elements.contacts_im_window.y);
-         dd.elements.contacts_im_window_movable.setOpacity(0);
-
-         dd.elements.contacts_im_window_resize.setOpacity(1);
-         dd.elements.contacts_im_window_resize.moveTo(dd.elements.contacts_im_window_fantom.x+dd.elements.contacts_im_window_fantom.w-dd.elements.contacts_im_window_resize.w-2, dd.elements.contacts_im_window_fantom.y+dd.elements.contacts_im_window_fantom.h-dd.elements.contacts_im_window_resize.h-2);
-
-         var contacts_im_window = new Object();
-         contacts_im_window.x = dd.elements.contacts_im_window_master.x;
-         contacts_im_window.y = dd.elements.contacts_im_window_master.y;
-         contacts_im_window.w = dd.elements.contacts_im_window_master.w;
-         contacts_im_window.h = dd.elements.contacts_im_window_master.h;
-         contacts_im_window.state = WINDOW_STATE_REGULAR;
-         windowItems[pId] = contacts_im_window;
-      }
-      catch(e)
-      {
-         alert("config\n\n" + e + "\n\n" + e.description)
-      }
-   },
-
-   "build" : function()
-   {
-      var pBody       = '';
-      var pClose      = true;
-      var pHeight     = 360;
-      var pId         = false;
-      var pLeft       = NaN;
-      var pMaximize   = true;
-      var pMinimize   = true;
-      var pStyle      = '';
-      var pTitle      = '';
-      var pTop        = NaN;
-      var pWidth      = 250;
-
-      for ( var i = 0; i < arguments.length; i++ )
-      {
-            for ( var n in arguments[i] )
-               if ( !func.isUndefined(arguments[i][n]) )
-                  switch ( n )
-                  {
-                     case 'body'    : pBody     = arguments[i][n]; break;
-                     case 'close'   : pClose    = arguments[i][n]; break;
-                     case 'height'  : pHeight   = arguments[i][n]; break;
-                     case 'id'      : pId       = arguments[i][n]; break;
-                     case 'left'    : pLeft     = arguments[i][n]; break;
-                     case 'maximize': pMaximize = arguments[i][n]; break;
-                     case 'minimize': pMinimize = arguments[i][n]; break;
-                     case 'style'   : pStyle    = arguments[i][n]; break;
-                     case 'title'   : pTitle    = arguments[i][n]; break;
-                     case 'top'     : pTop      = arguments[i][n]; break;
-                     case 'width'   : pWidth    = arguments[i][n]; break;
-                  }
-      }
-
-      if ( !pId || pHeight < 60 || pWidth < 100 )
-         return false;
-
-      if ( isNaN(pLeft) )
-         if ( windowItems[pId] )
-            pLeft = windowItems[pId].x;
-         else
-            pLeft = Math.floor(Math.random()*(dd.getWndH()-100));
-
-      if ( isNaN(pTop) )
-         if ( windowItems[pId] )
-            pTop = windowItems[pId].y;
-         else
-            pTop = Math.floor(Math.random()*(dd.getWndW()-pHeight-480))
-
-      if ( windowItems[pId] )
-      {
-         pHeight = dd.elements[pId + "_im_window_body_inner"].h;
-         pWidth = dd.elements[pId + "_im_window_body_inner"].w;
-      }
-
-      if ( !this.xslWin ) this.xslWin = XMLTools.load(im_path + 'xsl/window.xsl?' + Date.parse(new Date));
-      _xmlDoc = '<window id="' + pId + '" title="' + pTitle + '" height="' + pHeight + '" width="' + pWidth + '" left="' + pLeft + '" top="' + pTop + '" minimize="' + pMinimize + '" maximize="' + pMaximize  + '" close="' + pClose + '" style="position:absolute;' + pStyle + '" />';
-
-      a = document.createElement('div');
-
-      if (window.ActiveXObject)
-      {
-         var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
-         xmlDoc.async = "false";
-         xmlDoc.loadXML(_xmlDoc);
-      }
-      else
-      {
-         var parser = new DOMParser();
-         var xmlDoc = parser.parseFromString(_xmlDoc, "text/xml");
-      }
-      a.innerHTML = XMLTools.transform(xmlDoc, this.xslWin);
-      document.getElementsByTagName('body').item(0).appendChild(a);
-
-      switch ( typeof pBody )
-      {
-         case 'object' :
-                        func.insEl(pBody, pId + '_im_window_body_inner');
-         break;
-         case 'string' :
-                        func.byId(pId + '_im_window_body_inner').innerHTML = pBody;
-
-      }
-
-      RoundedTop('div#' + pId + '_im_window_master', '', '#cbdae4');
-      this.windowMaximizeZ(pId);
-
-   },
-
-   "hideAllChatSelections" : function()
-   {
-      this.hideEmotionSelection();
-      this.hideFontNameSelection();
-      this.hideFontSizeSelection();
-      this.hideFontColorSelection();
-      this.hideFontStyleSelection();
-   },
-
-   "hideWindowItem" : function(pId)
-   {
-      try
-      {
-         dd.elements[pId + "_im_window"].hide();
-         dd.elements[pId + "_im_window_master"].hide();
-         dd.elements[pId + "_im_window_fantom"].hide();
-         dd.elements[pId + "_im_window_resize"].hide();
-         dd.elements[pId + "_im_window_movable"].hide();
-         if ( (name_document = document.getElementById(pId + '_divEdita')) )
-         {
-            name_document.innerHTML = '';
-            var contact = func.byId(pId);
-            var _status = IM.vcard_contacts[contact.getAttribute('nuncontact')].online
-            contact.firstChild.src = ( _status == parseInt(1) ) ? img_online.src : img_offline.src;
-         }
-      }
-      catch(e)
-      {}
-   },
-
-   "incZ" : function()
-   {
-      zValue += 5;
-      return zValue;
-   },
-
-   "drag" : function()
-   {
-      try
-      {
-         var objName = dd.obj.name;
-         i = objName.indexOf("_");
-         objName = objName.substr(0,i);
-
-         this.incZ();
-         document.getElementById(objName + "_im_window_fantom").style.zIndex = zValue;
-         dd.elements[objName + "_im_window_fantom"].setOpacity(0.5);
-
-         document.getElementById(objName + "_im_window_fantom").className = "im_window_fantom";
-
-         var posX = dd.obj.x;
-         var posY = dd.obj.y;
-         if ( posX < 0 )
-            posX = 0;
-         if ( posY < 0 )
-            posY = 0;
-
-         dd.elements[objName + "_im_window_resize"].setOpacity(0);
-
-         if ( dd.obj.name == (objName + "_im_window_resize") )
-         {
-            windowState = WINDOW_STATE_REGULAR;
-
-            // check if the re-size goes out of the screen
-            if ( posX > ( dd.getWndW() - 15 ) )
-               posX = dd.getWndW()-15;
-            if ( posY > ( dd.getWndH() - 13 ) )
-               posY = dd.getWndH()-13;
-
-            // everything is fine, let's change the size of all required objects
-            var newW = posX-dd.elements[objName + "_im_window_fantom"].x+15;
-            var newH = posY-dd.elements[objName + "_im_window_fantom"].y+15;
-            if ( newW < 100) newW = 100;
-            if ( newH < 100) newH = 100;
-            dd.elements[objName + "_im_window_fantom"].resizeTo(newW, newH);
-
-    		if( document.getElementById(objName + "_chatMessages"))
-    		{
-				func.confEl(document.getElementById(objName + "_chatMessages"),"style","width:" + (newW - 105) +";height:" + (newH - 150) +";margin: 2px 0px 2px 2px; overflow:auto;");
-				func.confEl(document.getElementById(objName + '_edita'),"style","width:" + (newW - 105) + ";height: 50px;margin: 3px 1px 0px 2px;float: left;");
-			}
-
-            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
-            var windowItem = windowItems[objName];
-            windowItem.state = WINDOW_STATE_REGULAR;
-         }
-         else
-         {
-            if ( posX > ( dd.getWndW() - dd.elements[objName + "_im_window_master"].w ) )
-               posX = dd.getWndW() - dd.elements[objName + "_im_window_master"].w;
-
-            if ( posY > ( dd.getWndH() - dd.elements[objName + "_im_window_master"].h ) )
-               posY = dd.getWndH() - dd.elements[objName + "_im_window_master"].h;
-
-            dd.elements[objName + "_im_window_fantom"].moveTo(posX, posY);
-         }
-      }
-      catch(e)
-      {
-      }
-   },
-
-   "drop" : function()
-   {
-      try
-      {
-         document.getElementById("backFantom").style.zIndex = -1;
-
-         var objName = dd.obj.name;
-         i = objName.indexOf("_");
-         objName = objName.substr(0,i);
-
-         var posX = dd.obj.x;
-         var posY = dd.obj.y;
-         if ( posX < 0 )
-            posX = 0;
-         if ( posY < 0 )
-            posY = 0;
-         if ( posX > ( dd.getWndW() - dd.elements[objName + "_im_window_master"].w ) )
-            posX = dd.getWndW() - dd.elements[objName + "_im_window_master"].w;
-         if ( posY > ( dd.getWndH() - dd.elements[objName + "_im_window_master"].h ) )
-            posY = dd.getWndH() - dd.elements[objName + "_im_window_master"].h;
-
-         dd.elements[objName + "_im_window_resize"].setOpacity(1);
-
-         if ( dd.obj.name == (objName + "_im_window_resize") )
-         {
-            var newW = dd.obj.x-dd.elements[objName + "_im_window_fantom"].x+17;
-            var newH = dd.obj.y-dd.elements[objName + "_im_window_fantom"].y+17;
-
-            if ( newW < 100) newW = 100;
-            if ( newH < 100) newH = 100;
-
-            var winW = dd.elements[objName + "_im_window_master"].w - dd.elements[objName + "_im_window"].w;
-            var winH = dd.elements[objName + "_im_window_master"].h - dd.elements[objName + "_im_window"].h;
-
-            dd.elements[objName + "_im_window_fantom"].resizeTo(newW, newH);
-            dd.elements[objName + "_im_window_master"].resizeTo(newW, newH);
-
-            var bodyW = dd.elements[objName + "_im_window"].w - dd.elements[objName + "_im_window_body_inner"].w;
-            var bodyH = dd.elements[objName + "_im_window"].h - dd.elements[objName + "_im_window_body_inner"].h;
-
-            dd.elements[objName + "_im_window"].resizeTo(newW - winW, newH - winH);
-
-            bodyW = dd.elements[objName + "_im_window"].w - bodyW;
-            bodyH = dd.elements[objName + "_im_window"].h - bodyH;
-
-            dd.elements[objName + "_im_window_body_inner"].resizeTo(bodyW, bodyH);
-
-            dd.elements[objName + "_im_window_movable"].resizeTo(newW-55, 25);
-            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
-         }
-         else
-         {
-            dd.elements[objName + "_im_window_fantom"].moveTo(posX, posY);
-            dd.elements[objName + "_im_window_master"].moveTo(posX, posY);
-            dd.elements[objName + "_im_window"].moveTo(posX, (posY+4));
-            dd.elements[objName + "_im_window_movable"].moveTo(posX, posY);
-            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-3, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-3);
-         }
-
-         this.windowMaximizeZ(objName);
-
-         dd.elements[objName + "_im_window_fantom"].setOpacity(0);
-         var windowItem = windowItems[objName];
-
-         if ( windowItem != null )
-         {
-            windowItem.x = dd.elements[objName + "_im_window_master"].x;
-            windowItem.y = dd.elements[objName + "_im_window_master"].y;
-            windowItem.w = dd.elements[objName + "_im_window_master"].w;
-            windowItem.h = dd.elements[objName + "_im_window_master"].h;
-         }
-      }catch(e){}
-   },
-
-   "pick" : function()
-   {
-      document.getElementById("backFantom").style.zIndex = zValue;
-      this.hideAllChatSelections();
-      var objName = dd.obj.name;
-      i = objName.indexOf("_im");
-      objName = objName.substr(0,i);
-      ACTIVE_OBJECTID = objName;
-   },
-
-   "showWindowItem" : function(pId)
-   {
-      /*
-       * Não tire esta linha
-       * Isso deve estar aqui para a janela 'oculta'
-       * não 'piscar' na tela no momento que é criada.
-       */
-      func.byId(pId + '_im_window_body_inner').style.overflow = 'auto';
-
-      if ( (name_document = document.getElementById(pId + '_divEdita')) )
-      {
-         name_document.innerHTML = '<iframe name="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '_edita" class="edit_message" id="' + pId + '_edita" frameborder="0" style="border:margin: 3px 1px 0px 2px; width:220px; height:50px; float:left;"></iframe>';
-
-         name_document = document.getElementById(pId + '_edita');
-         name_document.contentWindow.document.write('<html><body id="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '" style="margin:0px;padding:0px"></body></html>');
-         name_document.contentWindow.document.close();
-         name_document.contentWindow.document.designMode = "On";
-
-         func.attachEvent(name_document.contentWindow.document, 'keypress', im_win.getText);
-         func.attachEvent(name_document.contentWindow.document, 'keyup', im_win.clearText);
-
-         name_document.contentWindow.focus();
-      }
-
-      dd.elements[pId + "_im_window_master"].show();
-      dd.elements[pId + "_im_window"].show();
-      dd.elements[pId + "_im_window_fantom"].show();
-      dd.elements[pId + "_im_window_resize"].show();
-      dd.elements[pId + "_im_window_movable"].show();
-      
-   },
-
-   "windowMaximizeZ" : function(objName)
-   {
-      try
-      {
-         this.incZ();
-         document.getElementById(objName + "_im_window_fantom").style.zIndex = zValue-3;
-         document.getElementById(objName + "_im_window_master").style.zIndex = zValue-2;
-         document.getElementById(objName + "_im_window").style.zIndex = zValue-1;
-         document.getElementById(objName + "_im_window_body_inner").style.zIndex = zValue-1;
-         document.getElementById(objName + "_im_window_resize").style.zIndex = zValue;
-         document.getElementById(objName + "_im_window_movable").style.zIndex = zValue;
-         if ( dd.elements[objName + "_im_window_movable"] )
-            dd.elements[objName + "_im_window_movable"].z = zValue+1;
-      }catch(e){}
-   },
-
-   "windowMinimize" : function(objName)
-   {
-      with(objName)
-         objName = substr(0, indexOf('_im'));
-
-      this.hideWindowItem(objName);
-      windowItem = windowItems[objName];
-      if ( windowItem != null )
-      {
-         windowItem.state = WINDOW_STATE_MINIMIZED;
-      }
-
-   },
-
-   "windowMaximizeRestore" : function(objName)
-   { 
-      with(objName)
-         objName = substr(0, indexOf('_im'));
-
-      this.hideAllChatSelections();
-
-      windowItem = windowItems[objName];
-
-      if ( windowItem != null )
-      {
-         var bodyW = dd.elements[objName + "_im_window"].w - dd.elements[objName + "_im_window_body_inner"].w;
-         var bodyH = dd.elements[objName + "_im_window"].h - dd.elements[objName + "_im_window_body_inner"].h;
-
-         if ( windowItem.state==WINDOW_STATE_REGULAR )
-         {
-            windowItem.x = dd.elements[objName + "_im_window_master"].x;
-            windowItem.y = dd.elements[objName + "_im_window_master"].y;
-            windowItem.w = dd.elements[objName + "_im_window_master"].w;
-            windowItem.h = dd.elements[objName + "_im_window_master"].h;
-
-            var bodyX = dd.elements[objName + "_im_window_body_inner"].x + dd.elements[objName + "_im_window"].x;
-            var bodyY = dd.elements[objName + "_im_window_body_inner"].y + dd.elements[objName + "_im_window"].y;
-
-            dd.elements[objName + "_im_window_fantom"].moveTo(0, 0);
-            dd.elements[objName + "_im_window_master"].moveTo(0, 0);
-            dd.elements[objName + "_im_window"].moveTo(0, 4);
-
-            dd.elements[objName + "_im_window_fantom"].resizeTo(dd.getWndW(), dd.getWndH());
-            dd.elements[objName + "_im_window_master"].resizeTo(dd.getWndW(), dd.getWndH());
-            dd.elements[objName + "_im_window"].resizeTo(dd.getWndW(), dd.getWndH() - 5);
-            dd.elements[objName + "_im_window_body_inner"].resizeTo(dd.getWndW() - bodyW, dd.getWndH() - bodyH - 5);
-
-            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
-            windowItem.state = WINDOW_STATE_MAXIMIZED;
-
-            window.status = objName + "'s Z: " + document.getElementById(objName+"_im_window").style.zIndex;
-
-         }
-         else
-         {
-            dd.elements[objName + "_im_window_fantom"].resizeTo(windowItem.w, windowItem.h);
-            dd.elements[objName + "_im_window_master"].resizeTo(windowItem.w, windowItem.h);
-            dd.elements[objName + "_im_window"].resizeTo(windowItem.w, windowItem.h - 5);
-            dd.elements[objName + "_im_window_body_inner"].resizeTo(windowItem.w - bodyW, windowItem.h - bodyH - 5);
-
-            dd.elements[objName + "_im_window_fantom"].moveTo(windowItem.x, windowItem.y);
-            dd.elements[objName + "_im_window_master"].moveTo(windowItem.x, windowItem.y);
-            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
-            windowItem.state = WINDOW_STATE_REGULAR;
-         }
-
-      dd.elements[objName + "_im_window_movable"].moveTo(dd.elements[objName + "_im_window"].x, dd.elements[objName + "_im_window"].y);
-      dd.elements[objName + "_im_window_movable"].resizeTo(dd.elements[objName + "_im_window"].w-55, 25);
-
-      this.showWindowItem(objName);
-      this.windowMaximizeZ(objName);
-      }
-      
-  	  if( !this.photo )
-  	  {
-		setTimeout('im_win.get_photo_ldap(\"user@user\")',1000 );
-		this.photo = true;
-	  }
-   },
-
-   "create_window" : function()
-   {
-      pId = arguments[0]['id'];
-
-      if ( document.getElementById(pId + '_im_window'))
-      {
-         this.windowMaximizeZ(pId);
-      	 this.showWindowItem(pId);
-      }
-      else
-      {
-         this.build(arguments[0]);
-
-         ADD_DHTML(pId + "_im_window_body_inner"+NO_DRAG);
-         ADD_DHTML(pId + "_im_window"+NO_DRAG);
-         ADD_DHTML(pId + "_im_window_master"+NO_DRAG);
-         ADD_DHTML(pId + "_im_window_fantom"+NO_DRAG);
-         ADD_DHTML(pId + "_im_window_movable"+CURSOR_MOVE);
-         ADD_DHTML(pId + "_im_window_resize"+CURSOR_NW_RESIZE);
-
-         dd.elements[pId + "_im_window_movable"].moveTo(dd.elements[pId + "_im_window"].x, dd.elements[pId + "_im_window"].y);
-         dd.elements[pId + "_im_window_movable"].resizeTo(dd.elements[pId + "_im_window"].w-20, 25);
-         dd.elements[pId + "_im_window_movable"].setOpacity(0);
-
-         dd.elements[pId + "_im_window_resize"].setOpacity(1);
-
-         dd.elements[pId + "_im_window_resize"].moveTo(dd.elements[pId + "_im_window"].x+dd.elements[pId + "_im_window"].w-dd.elements[pId + "_im_window_resize"].w-2, dd.elements[pId + "_im_window"].y+dd.elements[pId + "_im_window"].h-dd.elements[pId + "_im_window_resize"].h-2);
-         dd.elements[pId + "_im_window_resize"].moveTo(dd.elements[pId + "_im_window_fantom"].x+dd.elements[pId + "_im_window_fantom"].w-dd.elements[pId + "_im_window_resize"].w-2, dd.elements[pId + "_im_window_fantom"].y+dd.elements[pId + "_im_window_fantom"].h-dd.elements[pId + "_im_window_resize"].h-2);
-
-         var windowItem = new Object();
-         windowItem.x = dd.elements[pId + "_im_window_master"].x;
-         windowItem.y = dd.elements[pId + "_im_window_master"].y;
-         windowItem.w = dd.elements[pId + "_im_window_master"].w;
-         windowItem.h = dd.elements[pId + "_im_window_master"].h;
-         windowItem.state = WINDOW_STATE_MINIMIZED;
-         windowItems[pId] = windowItem;
-
-         title = (arguments[0]['title']) ? arguments[0]['title'] : arguments[0]['id'];
-         this.windowMinimize(pId + '_im');
-         this.windowMaximizeRestore(pId + '_im');
-      }
-   },
-
-   "open_chat" : function(pId)
-   {
-      if ( !func.byId(pId + '_im_window') )
-      {
-         text = '';
-         text += '<div class="border" id="' + pId + '_chatMessages" style="width:220px; height:130px; margin: 2px 0px 2px 2px; overflow:auto;"></div>';
-         text += '<div style="float: left; position: relative; height:130px;">';
-         text += '   <div class="myAvatar">';
-         text += '      <img id="' + pId + '_avatar" alt="Display Picture" title="Display Picture" src="' + im_path + 'templates/default/images/photo.png" width="49" height="65" border="0" />';
-         text += '   </div>';
-         text += '   <div id="' + pId + '_composing" class="composing"><img src="' + img_typing.src + '" /></div>';
-         text += '</div>';
-         text += '<br style="clear:both;"/>';
-         text += '<dl>';
-         text += '   <dd class="small">';
-         text += '      &nbsp;<span id="selectEmotionsDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showEmotionSelection(\'' + pId + '\');" title="Select Imotions here!"><img src="' + im_path + 'templates/default/images/img/1.gif" width="15" height="15" alt="Select Imotions here!" style="vertical-align:	text-top;" /></span>';
-         text += '   </dd>';
-         text += '   <dd class="small">|</dd>';
-         text += '   <dd class="small">';
-         text += '      <span id="selectFontNameDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontNameSelection(\'' + pId + '\');" title="Select Font Name here!" style="height:19px;">'+IM.get_lang('Font')+'</span>';
-         text += '   </dd>';
-         text += '   <dd class="small">|</dd>';
-         text += '   <dd class="small">';
-         text += '      <span id="selectFontSizeDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontSizeSelection(\'' + pId + '\')" title="Select Font Size here!" style="height:19px;">'+IM.get_lang('Size')+'</span>';
-         text += '   </dd>';
-         text += '   <dd class="small">|</dd>';
-         text += '   <dd class="small">';
-         text += '      <span id="selectFontColorDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontColorSelection(\'' + pId + '\')" title="Select Font Color here!" style="height:19px;">'+IM.get_lang('Color')+'</span>';
-         text += '   </dd>';
-         text += '   <dd class="small">|</dd>';
-         text += '   <dd class="small">';
-         text += '      <span id="selectFontStyleDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontStyleSelection(\'' + pId + '\')" title="Select Font Color here!" style="height:19px;">'+IM.get_lang('Style')+'</span>';
-         text += '   </dd>';
-         text += '</dl>';
-         text += '<div id="' + pId + '_divEdita" style="margin: 0px 2px"><iframe name="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '_edita" class="edit_message" id="' + pId + '_edita" frameborder="0" style="margin: 3px 1px 0px 2px; width:220px; height:50px; float:left;"></iframe></div>';
-         text += '<br/><a onclick="javascript:IM.sendMessage(\'' + pId + '\')" title="Send a message" style="float:left;margin: 0px 2px;"><img src="' + im_path + 'templates/default/images/send.gif" width="50" height="25" border=0 style="margin-top:3px"></a>';
-         text += '<br style="clear:both" /><span id="' + pId + '_im_window_message" style="margin-left: 2px" />';
-
-         var params = [];
-         params['body']     = text;
-         params['height']   = 225;
-         params['id']       = pId;
-         params['maximize'] = false;
-         params['minimize'] = false;
-         params['title']    = pId;
-         params['width']    = 320;
-         this.create_window(params);
-
-         // Photo Ldap;
-         this.get_photo_ldap(pId);
-		
-         name_document = document.getElementById(pId + '_edita');
-         name_document.contentWindow.document.write('<html><body id="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '" style="margin:0px;padding:0px"></body></html>');
-         name_document.contentWindow.document.close();
-         name_document.contentWindow.document.designMode = "On";
-
-         func.attachEvent(name_document.contentWindow.document, 'keypress', im_win.getText);
-         func.attachEvent(name_document.contentWindow.document, 'keyup', im_win.clearText);
-
-         name_document.contentWindow.focus();
-         
-         var status = func.byId(pId + '_im_window');
-         status.firstChild.style.background = 'url('+func.byId(pId).firstChild.src+')';
-      }
-      else
-      {
-         this.showWindowItem(pId);
-      }
-   },
-
-   "get_photo_ldap" : function(IdLdap)
-   {
-		var uid_ldap = IdLdap.substr(0,IdLdap.indexOf('@'));
-		var handler_photo_ldap = function(_XMLdata)
-		{
-			var data = _XMLdata.getElementsByTagName('retorno').item(0);
-			data = eval(data.firstChild.nodeValue);
-			if(data)
-			{
-				IdLdap = ( IdLdap == 'user@user' ) ? 'contacts' : IdLdap;
-				if( document.getElementById(IdLdap + "_avatar") != null ){
-					var ph_img = document.getElementById(IdLdap + "_avatar");
-					ph_img.src = (im_path + "inc/class.ldap_im.inc.php?user="+uid_ldap) ? im_path + "inc/class.ldap_im.inc.php?user="+uid_ldap : img_photo.src ;
-				}
-			}
-		}
-
-	    XMLTools.__RETURN_MODE__ = 'XML';
-		XMLTools.request('$this.ldap_im.photo_ldap','POST',handler_photo_ldap,'uid='+uid_ldap);
-   },
-
-   "windowClose" : function(objName)
-   {
-      with(objName)
-         objName = substr(0, indexOf('_im'));
-
-      this.hideWindowItem(objName);
-      this.hideAllChatSelections();
-
-      var windowItem = windowItems[objName];
-      if ( windowItem != null )
-         windowItem.state = WINDOW_STATE_CLOSED;
-
-      if ( objName != 'contacts' )
-      {
-         var win = document.getElementById(objName + '_im_window_master');
-         var resize = document.getElementById(objName + '_im_window_resize');
-         var fantom = document.getElementById(objName + '_im_window_fantom');
-         var movable = document.getElementById(objName + '_im_window_movable');
-
-         win.parentNode.removeChild(win);
-         resize.parentNode.removeChild(resize);
-         fantom.parentNode.removeChild(fantom);
-         movable.parentNode.removeChild(movable);
-
-         //delete windowItem;
-      }
-   },
-
-   "hideEmotionSelection" : function()
-   {
-      emotionsDiv = document.getElementById("shared_emotions");
-      if ( isEmotionSelectionVisible )
-      {
-         emotionsDiv.style.visibility = "hidden";
-         isEmotionSelectionVisible = false;
-      }
-   },
-
-   "highlightie5" : function (e)
-   {
-      if ( e.className == "emotionItem" )
-         e.className = "emotionItem-sel";
-      else if ( e.className == "menuitems" )
-         e.className = "menuitems-sel";
-
-   },
-
-   "lowlightie5" : function(e)
-   {
-      if ( e.className == "emotionItem-sel" )
-         e.className = "emotionItem";
-      else if ( e.className == "menuitems-sel" )
-         e.className = "menuitems";
-   },
-
-   "addEmotion" : function(emotion)
-   {
-      var n_document = document.getElementById(this.chat_pJid + '_edita');
-      var edita = n_document.contentWindow.document.getElementsByTagName('body').item(0);
-      edita.innerHTML += IM.emotions_icons(emotion);
-
-      this.hideEmotionSelection();
-   },
-
-   "showEmotionSelection" : function(objName)
-   {
-      this.chat_pJid = objName;
-      activeChatWindowId = objName;
-      var emotionsDiv = document.getElementById("shared_emotions");
-      if(!isEmotionSelectionVisible)
-      {
-         this.hideAllChatSelections();
-         chatObj = dd.elements[objName + "_im_window"];
-         x = chatObj.x + 6;
-         y = chatObj.y + chatObj.h - 200;
-         dd.elements.shared_emotions.moveTo(x,y);
-         this.incZ();
-         document.getElementById("shared_emotions").style.zIndex = zValue;
-         emotionsDiv.style.visibility = "visible";
-         isEmotionSelectionVisible = true;
-      }
-      else
-      {
-         this.hideAllChatSelections();
-      }
-   },
-
-   "showFontNameSelection" : function(objName)
-   {
-      this.chat_pJid = objName;
-      activeChatWindowId = objName;
-      var objDiv = document.getElementById("shared_fontName");
-      if(!isFontNameSelectionVisible)
-      {
-         this.hideAllChatSelections();
-         chatObj = dd.elements[objName + "_im_window"];
-         x = chatObj.x + 85;
-         y = chatObj.y + chatObj.h - 185;
-         dd.elements.shared_fontName.moveTo(x,y);
-         this.incZ();
-         document.getElementById("shared_fontName").style.zIndex = zValue;
-         objDiv.style.visibility = "visible";
-         isFontNameSelectionVisible = true;
-      }
-      else
-      {
-         this.hideAllChatSelections();
-      }
-   },
-
-   "hideFontNameSelection" : function()
-   {
-      var objDiv = document.getElementById("shared_fontName");
-      if ( isFontNameSelectionVisible )
-      {
-         objDiv.style.visibility = "hidden";
-         isFontNameSelectionVisible = false;
-      }
-   },
-
-   "showFontSizeSelection" : function(objName)
-   {
-
-      this.chat_pJid = objName;
-      activeChatWindowId = objName;
-      var objDiv = document.getElementById("shared_fontSize");
-      if ( !isFontSizeSelectionVisible )
-      {
-         this.hideAllChatSelections();
-         chatObj = dd.elements[objName + "_im_window"];
-         x = chatObj.x + 154;
-         y = chatObj.y + chatObj.h - 200;
-         dd.elements.shared_fontSize.moveTo(x,y);
-         this.incZ();
-         document.getElementById("shared_fontSize").style.zIndex = zValue;
-         objDiv.style.visibility = "visible";
-         isFontSizeSelectionVisible = true;
-      }
-      else
-      {
-         this.hideAllChatSelections();
-      }
-   },
-
-   "hideFontSizeSelection" : function()
-   {
-      var objDiv = document.getElementById("shared_fontSize");
-      if ( isFontSizeSelectionVisible )
-      {
-         objDiv.style.visibility = "hidden";
-         isFontSizeSelectionVisible = false;
-      }
-   },
-
-   "showFontColorSelection" : function(objName)
-   {
-      this.chat_pJid = objName;
-      activeChatWindowId = objName;
-      var objDiv = document.getElementById("shared_fontColor");
-      if ( !isFontColorSelectionVisible )
-      {
-         this.hideAllChatSelections();
-         chatObj = dd.elements[objName + "_im_window"];
-         x = chatObj.x + 191;
-         y = chatObj.y + chatObj.h - 200;
-         dd.elements.shared_fontColor.moveTo(x,y);
-         this.incZ();
-         document.getElementById("shared_fontColor").style.zIndex = zValue;
-         objDiv.style.visibility = "visible";
-         isFontColorSelectionVisible = true;
-      }
-      else
-      {
-         this.hideAllChatSelections();
-      }
-   },
-
-   "showFontStyleSelection" : function(objName)
-   {
-      this.chat_pJid = objName;
-      activeChatWindowId = objName;
-      var objDiv = document.getElementById("shared_fontStyle");
-      if ( !isFontStyleSelectionVisible )
-      {
-         this.hideAllChatSelections();
-         chatObj = dd.elements[objName + "_im_window"];
-         x = chatObj.x + 234;
-         y = chatObj.y + chatObj.h - 181;
-         dd.elements.shared_fontStyle.moveTo(x,y);
-         this.incZ();
-         document.getElementById("shared_fontStyle").style.zIndex = zValue;
-         objDiv.style.visibility = "visible";
-         isFontStyleSelectionVisible = true;
-      }
-      else
-      {
-         this.hideAllChatSelections();
-      }
-   },
-
-   "hideFontColorSelection" : function()
-   {
-      var objDiv = document.getElementById("shared_fontColor");
-      if ( isFontColorSelectionVisible )
-      {
-         objDiv.style.visibility = "hidden";
-         isFontColorSelectionVisible = false;
-      }
-   },
-
-   "hideFontStyleSelection" : function()
-   {
-      var objDiv = document.getElementById("shared_fontStyle");
-      if ( isFontStyleSelectionVisible )
-      {
-         objDiv.style.visibility = "hidden";
-         isFontStyleSelectionVisible = false;
-      }
-   },
-
-   "newMessageNotification" : function()
-   {
-      if ( !focusFlag )
-      {
-         if ( document.title=="......................" )
-            document.title = IM.get_lang("New Message!");
-         else
-            document.title = "......................";
-         
-         this.Mod_Notification();
-
-         if ( newMessageTimer )
-            clearTimeout(newMessageTimer);
-         newMessageTimer = setTimeout("im_win.newMessageNotification()", 1000);
-      }
-      else
-      {
-         if ( newMessageTimer ) clearTimeout(newMessageTimer);
-      }
-      
-   },
-
-   "Mod_Notification" : function()
-   {
-		// Aviso Normal
-		if(eval(IM_Preferences.LoadPreferences('rd_nm')))
-		{
-		}
-		// Aviso Chato		 
-	 	if(eval(IM_Preferences.LoadPreferences('rd_ch')))
-	 	{
-			if(self.moveBy)
-			{
-				for(i=10;i>0;i--)
-			 	{
-				  self.moveBy(i,0);
-			 	  self.moveBy(-i,0);
-			 	}
-			}
-		}
-   },
-
-   "getText" : function(e)
-   {
-
-      if ( !focusFlag ) windowFocus();
-      evt = e.keyCode;
-      pId = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0).id;
-      pId = pId.replace('_at_', '@').replace(/_dot_/g, '.')
-	  IM.composingMessage(pId);	
-      switch ( evt )
-      {
-         case 13 :
-                  if ( !e.shiftKey )
-                     IM.sendMessage(pId);
-                  return false;
-         break;
-         case 27 :
-                  im_win.windowClose(pId + '_im');
-         break;
-      }
-   },
-
-   "clearText" : function(e)
-   {
-      if ( !focusFlag ) windowFocus();
-      evt = e.keyCode;
-      _text = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0);
-
-      switch ( evt )
-      {
-         case 13 :
-                  //if ( !e.shiftKey )
-                     _text.innerHTML = '';
-                     return false;
-         break;
-      }
-   }
-}
-
-function my_DragFunc()
-{
-   im_win.drag();
-}
-function my_DropFunc()
-{
-   im_win.drop();
-}
-function my_PickFunc()
-{
-   im_win.pick();
-}
-function selectDiv(obj) {
-  obj.className = "sel-small";
-}
-function unselectDiv(obj) {
-  obj.className = "des-small";
-}
-function getElementsBySelector(selector)
-{
-   var i;
-   var s=[];
-   var selid="";
-   var selclass="";
-   var tag=selector;
-   var objlist=[];
-   if ( selector.indexOf(" ") > 0 )
-   {//descendant selector like "tag#id tag"
-      s=selector.split(" ");
-      var fs=s[0].split("#");
-      if ( fs.length == 1 )
-         return(objlist);
-      return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
-   }
-   if ( selector.indexOf("#") > 0 )
-   {//id selector like "tag#id"
-      s=selector.split("#");
-      tag=s[0];
-      selid=s[1];
-   }
-   if ( selid != "" )
-   {
-      objlist.push(document.getElementById(selid));
-      return(objlist);
-   }
-   if ( selector.indexOf(".") > 0 )
-   {//class selector like "tag.class"
-      s=selector.split(".");
-      tag=s[0];
-      selclass=s[1];
-   }
-   var v = document.getElementsByTagName(tag);  // tag selector like "tag"
-   if ( selclass == "" )
-      return(v);
-
-   for ( i = 0; i < v.length; i++ )
-      if ( v[i].className ==selclass )
-         objlist.push(v[i]);
-
-   return(objlist);
-}
-function AddTop(el,bk,color,size)
-{
-   try
-   {
-      var i;
-      var d=document.createElement("b");
-      var cn="_r";
-      var lim=4;
-      if(size && size=="small"){ cn="_rs"; lim=2}
-      d.className="_rtop";
-      d.style.backgroundColor=bk;
-      for(i=1;i<=lim;i++)
-      {
-         var x=document.createElement("b");
-         x.className=cn + i;
-         x.style.backgroundColor=color;
-         d.appendChild(x);
-      }
-      el.insertBefore(d,el.firstChild);
-   }
-   catch(e)
-   {}
-}
-function RoundedTop(selector,bk,color,size){
-   var i;
-   var v=getElementsBySelector(selector);
-   for(i=0;i<v.length;i++)
-          AddTop(v[i],bk,color,size);
-}
-
-im_win.load();
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_fcommon.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_fcommon.js	(revision 151)
+++ 	(revision )
@@ -1,391 +1,0 @@
-/*
-+------------------------------------------------+
-| @FILE:    functions.js                         |
-| @AUTHOR:  [NUTS] Rodrigo Souza                 |
-| @DATE:    Sex 27 Out 2006 12:38:22 BRST        |
-| @LAST CHANGE: Seg 27 Nov 2006 12:35:22 BRST::  |
-+------------------------------------------------+
-*/
-
-/*
- * @DESC The method has one optional boolean argument
- *          deep which when set recursively creates a
- *          deep copy, otherwise (when deep is false
- *          or not defined) a shallow copy is created.
- */
-/*Object.prototype.clone = function(deep)
-{
-   objectClone = new this.constructor();
-   for (var property in this)
-   {
-      if (!deep)
-         objectClone[property] = this[property];
-      else if (typeof this[property] == 'object')
-         objectClone[property] = this[property].clone(deep);
-      else
-         objectClone[property] = this[property];
-   }
-
-      return objectClone;
-}*/
-
-/*
- *
- */
-var func = {
-   "json" : false,
-   "attachEvent" : function(obj, eventName, eventHandler) 
-   {
-      if ( obj )
-      {
-         if ( eventName.substring(0, 2) == 'on' )
-         {
-            eventName = eventName.substring(2,eventName.length);
-         }
-         if ( obj.addEventListener )
-         {
-            obj.addEventListener(eventName, eventHandler, false);
-         }
-         else if ( obj.attachEvent )
-         {
-            obj.attachEvent('on'+eventName, eventHandler);
-         }
-      }
-   },
-
-   "byId" : function()
-   {
-      var elements = new Array();
-      for ( var i = 0; i < arguments.length; i++ )
-      {
-         element = arguments[i];
-         if ( this.isString(element) )
-            element = document.getElementById(element);
-
-         if (arguments.length == 1)
-            return element;
-
-         elements.push(element);
-      }
-      return elements;
-   },
-
-   "byTag" : function()
-   {
-      var elements = new Array();
-      for ( var i = 0; i < arguments.length; i++ )
-      {
-         element = arguments[i];
-         if ( this.isString(element) )
-            element = document.getElementsByTagName(element);
-
-         if ( arguments.length == 1 )
-            return element;
-
-         elements.push(element);
-      }
-      return elements;
-   },
-
-   "client_height" : function()
-   {
-      if( typeof( window.innerWidth ) == 'number' )
-      {
-         //Non-IE
-         return window.innerHeight;
-      }
-      else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
-      {
-         //IE 6+ in 'standards compliant mode'
-         return document.documentElement.clientHeight;
-      }
-      else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
-      {
-         //IE 4 compatible
-         return document.body.clientHeight;
-      }
-   },
-
-   "client_width" : function()
-   {
-         if( typeof( window.innerWidth ) == 'number' )
-         {
-            //Non-IE
-            return window.innerWidth;
-         }
-         else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
-         {
-            //IE 6+ in 'standards compliant mode'
-            return document.documentElement.clientWidth;
-         }
-         else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
-         {
-            //IE 4 compatible
-            return document.body.clientWidth;
-         }
-   },
-
-   "_confEl" : function(pElement, pAttribute, pValue)
-   {
-      if ( !func.isString(pValue) )
-         return false;
-
-      if ( this.isString(pElement) )
-      {
-         pElement = document.getElementById(pElement);
-      }
-
-      switch ( pAttribute )
-      {
-         /*
-          * No IE a propriedade style nÃo funciona se adicionada via setAttribute()
-          */
-         case 'style' :
-                        pElement.style.cssText = pValue;
-         break;
-         case 'class' :
-                        pElement.setAttribute(pAttribute, pValue);
-                        pElement.setAttribute(pAttribute+'Name', pValue); // IE
-         break;
-         default :
-                        pElement.setAttribute(pAttribute, pValue);
-      } /* switch */
-   },
-
-   "confEl" : function()
-   {
-      switch ( arguments.length )
-      {
-         case 1 :
-                  matriz = arguments[0];
-                  if ( !this.isArray(matriz) )
-                     return false;
-
-                  for ( var i in matriz )
-                  {
-                     pElement = matriz[i]['element'];
-                     delete matriz[i]['element'];
-
-                     for ( var j in matriz[i] )
-                     {
-                        this._confEl(pElement, j, matriz[i][j]);
-                     }
-                  }
-         break;
-         case 2 :
-                  var pElement = arguments[0];
-
-                  if ( !this.isArray(arguments[1]) )
-                     return false;
-
-                  for ( var i in arguments[1] )
-                  {
-                     this._confEl(pElement, i, arguments[1][i]);
-                  }
-         break;
-         case 3 :
-                  var pElement = arguments[0];
-
-                  this._confEl(pElement, arguments[1], arguments[2]);
-         break;
-      }
-   },
-
-   "elH" : function(pEl)
-   {
-      // no IE a funcao scrollHeight nÃ£o retorna o valor correto
-      return document.getElementById(pEl).offsetHeight;
-   },
-
-   "elHW" : function(pEl)
-   {
-      aux = {
-               h:this.elH(pEl),
-               w:this.elW(pEl)
-            };
-      return aux;
-   },
-
-   "elW" : function(pEl)
-   {
-      return document.getElementById(pEl).offsetWidth;
-   },
-
-   "interface" : function(_XmlDoc)	
-   {
-	   var data = _XmlDoc.getElementsByTagName('retorno').item(0);
-	   if ( data.childNodes.length == 1 )
-	      data = data.firstChild.nodeValue;
-
-	   if ( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(data) )
-	   {
-	      eval('data = ' + data);
-	      if ( this.json ){
-	         this.json = false;
-	      }else{
-	         data = this.json2array(data);
-	      }
-	   }
-
-	   return data;
-  
-   },
-
-   "insEl" : function()
-   {
-      try
-      {
-         if ( arguments.length == 1 )
-         {
-            var body = document.getElementsByTagName('body');
-            body[0].appendChild(arguments[0]);
-         }
-         else
-         {
-            var parentEl;
-            switch ( typeof arguments[arguments.length-1] )
-            {
-               case 'object' :
-                              parentEl = arguments[arguments.length-1];
-               break;
-               case 'string' :
-                              parentEl = document.getElementById(arguments[arguments.length-1]);
-               break;
-               case 'boolean' : parentEl = document.getElementsByTagName('body').item(0);
-            }
-
-            for ( var i = 0; i < arguments.length-1; i++ )
-            {
-                  if ( this.isString(arguments[i]) )
-                     arguments[i] = document.createTextNode(arguments[i]);
-
-                  parentEl.appendChild(arguments[i]);
-            }
-         } /* else */
-         return true;
-      }
-      catch(e)
-      {}
-   },
-
-   "insElB" : function()
-   {
-      try
-      {
-         if ( arguments.length < 2 )
-         {
-            return false;
-         }
-         else
-         {
-            var referenceEl;
-            var parentEl;
-            switch ( typeof arguments[arguments.length-1] )
-            {
-               case 'object' :
-                              parentEl    = arguments[arguments.length-1].parentNode;
-                              referenceEl = arguments[arguments.length-1];
-               break;
-               case 'string' :
-                              referenceEl = document.getElementById(arguments[arguments.length-1]);
-                              parentEl    = referenceEl.parentNode;
-            }
-
-            for ( var i = 0; i < arguments.length-1; i++ )
-            {
-                  parentEl.insertBefore(arguments[i], referenceEl);
-            }
-         } /* else */
-         return true;
-      }
-      catch(e)
-      {}
-   },
-
-   "isArray" : function(a)
-   {
-      return this.isObject(a) && a.constructor == Array;
-   },
-
-   "isFunction" : function(a)
-   {
-      return typeof a == 'function';
-   },
-
-   "isNumber" : function(a)
-   {
-      return typeof a == 'number' && isFinite(a);
-   },
-
-   "isNull" : function(a)
-   {
-      return a === null;
-   },
-
-   "isObject" : function(a)
-   {
-      return (a && typeof a == 'object') || this.isFunction(a);
-   },
-
-   "isString" : function(a)
-   {
-      return typeof a == 'string';
-   },
-
-   "isUndefined" : function(a)
-   {
-      return typeof a == 'undefined';
-   },
-
-   "json2array" : function(pObject)
-   {
-	   var retorno = [];
-	   for( var i in pObject )
-	      if( pObject[i].constructor == Object )
-	      {
-	         retorno[i] = [];
-	         retorno[i] = this.json2array(pObject[i]);
-	      }
-	      else
-	         retorno[i] = pObject[i];
-	   return retorno;
-   },
-
-   "newEl" : function(pElement)
-   {
-      if ( arguments.length == 1 )
-      {
-         switch ( typeof pElement)
-         {
-            case 'string' :
-                           return document.createElement(pElement);
-            break;
-            case 'object' :
-                           var retorno = new Array();
-                           if (this.isArray(pElement))
-                           {
-                              for (var i in pElement)
-                              {
-                                 retorno[i] = document.createElement(pElement[i]);
-                              }
-                              return retorno;
-                           }
-            break;
-         } /* switch */
-      } /* if */
-      else
-      {
-         var retorno = new Array();
-         for ( var i = 0; i < arguments.length; i++ )
-         {
-            retorno[i] = document.createElement(arguments[i]);
-         }
-         return retorno;
-      }
-   },
-
-   "trim" : function(pString)
-   {
-      return pString.replace(/^( )*|( )*$/g, '');
-   }
-}
Index: unk/instant_messenger/bkp/instant_messenger_64/js/im_templates.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/js/im_templates.js	(revision 151)
+++ 	(revision )
@@ -1,244 +1,0 @@
-/**
-* @AUTHOR: Alexandre Correia / Rodrigo Souza
-* @DATE: 2006/10/24 17:03:00
-* @LAST CHANGE: Seg 11 Dez 2006 10:21:34 BRST::
-* Instant Messenger
-* im_templates.js
-**/
-
-	function Templates(){
-
-		this.element 	= document.getElementById("im_expresso");
-		this.form 		= "";
-		this.time_set 	= "";
-		this.transfer	= 0;
-		this.arquivo 	= "";
-	}
-
-   /*
-	* Conf forms
-	*/
-
-	Templates.prototype.conf_form = function(pName,pWidth,pHeight,pHTML,pTitle)
-	{
-	     var params = new Array();
-    	 params['body'] = pHTML;
-      	 params['height'] = pHeight;
-     	 params['id'] = pName;
-     	 params['maximize'] = false;
-     	 params['minimize'] = false;
-     	 params['title'] = pTitle;
-     	 params['width'] = pWidth;
-		 im_win.create_window(params);
-	}
-
-   /*
-	* Add Usuario
-	*/
-
-	Templates.prototype.add_user = function()
-	{
-		var _this = this;
-		var _XmlAddUser = '<adduser>' +	
-							'<top lang1="'+IM.get_lang('Selecione uma Organização')+'" />' +
-							'<bottom lang1="'+IM.get_lang('Jid Contact')+'" lang2="'+IM.get_lang('Nickname')+'" lang3="'+IM.get_lang('Group')+'" lang4="'+IM.get_lang('Add')+'"/>' +
-  					  	  '</adduser>';
-		
-		_this.conf_form("divAddUser",525,295,parse_XmlXsl(_XmlAddUser,'add_user.xsl'),":: " + IM.get_lang('Add New Contact') + " - Expresso ::");
-	}
-	
-	Templates.prototype.AcceptRequestUser = function()
-	{
-		var _this = this;
-		var _XmlupdUser = '<updUser>' +
-							'<body lang1="'+IM.get_lang('Nickname')+'" lang2="'+IM.get_lang('Group')+'" lang3="'+IM.get_lang('Update')+'" />' +		
-						  '</updUser>';	
-						  
-		_this.conf_form("divUpdateUser",300,110,parse_XmlXsl(_XmlupdUser,'upd_user.xsl'),":: " + IM.get_lang('Add New Contact') + " - Expresso ::");
-	}
-	
-	Templates.prototype.Status_AddUser = function()
-	{
-		if( document.getElementById('im_status_add') != null )
-			if( document.getElementById('im_status_add').innerHTML != "" )
-				document.getElementById('im_status_add').innerHTML = "";
-			else
-				document.getElementById('im_status_add').innerHTML = IM.get_lang('Contact Add') + ' ... !!!';
-	}
-
-   /*
-	* Del Usuario
-	*/
-
-	Templates.prototype.remove_user = function()
-	{
-		var _this = this;
-		var _XmlDelUser = '<deluser>' +
-							'<body lang1="'+IM.get_lang('Contact')+'" lang2="'+IM.get_lang('Remove')+'" lang3="'+IM.get_lang('close')+'"/>' +
-						  '</deluser>';
-
-		_this.conf_form("divDelUser",300,110,parse_XmlXsl(_XmlDelUser,'del_user.xsl'),":: " + IM.get_lang('Remove Contact') + " - Expresso ::");
-	}
-
-   /*
-	* Update Usuario
-	*/
-
-	Templates.prototype.Users_Not_Auth = function (jids)
-	{
-		var _this = this;
-		var _XmlUserNAuth = '<jids>';	
-		for(var i in jids)
-		{		
-			_XmlUserNAuth += '<item id="im_cell_'+jids[i]+'" jid="'+jids[i]+'" />';
-		}
-		_XmlUserNAuth += '</jids>';
-		if(document.getElementById('divFormAuthUser_im') == null){
-			_this.conf_form("divFormAuthUser",360,250,parse_XmlXsl(_XmlUserNAuth,'user_not_auth.xsl'), ":: Contatos sem Cadastro - Expresso ::");
-		}else{
-			document.getElementById('divFormAuthUser_im').innerHTML = '';
-			document.getElementById('divFormAuthUser_im').innerHTML = parse_XmlXsl(_XmlUserNAuth,'user_not_auth.xsl');
-		}
-	}
-
-   /*
-	* Vcard Usuario
-	*/
-
-	Templates.prototype.information_user = function(pVcardUser)
-	{
-		var _this = this;
-		var _XmlInfoUser = '<info_user>' +
-								'<vcard>' +
-									pVcardUser +	
-								'</vcard>' +
-							    '<getlang>' +
-									'<FN>' + IM.get_lang('Full Name') + '</FN>'+
-									'<NICKNAME>' + IM.get_lang('NickName') + '</NICKNAME>' +
-									'<ORGNAME>' + IM.get_lang('Orgname') + '</ORGNAME>' +
-									'<ORGUNIT>' + IM.get_lang('Orgunit') + '</ORGUNIT>' +
-									'<ROLE>' + IM.get_lang('Role') + '</ROLE>' +
-									'<BDAY>' + IM.get_lang('Birthday') + '</BDAY>' +
-									'<DESC>' + IM.get_lang('Status') + '</DESC>' +
-									'<SAVE>' +IM.get_lang('save') + '</SAVE>' +
-									'<CLOSE>' +IM.get_lang('close') + '</CLOSE>' +									
-								'</getlang>' +
-						   '</info_user>';	
-		_this.conf_form("divInfoUser",400,220,parse_XmlXsl(_XmlInfoUser,'information_user.xsl'), ":: " + IM.get_lang('Information User') + " - Expresso ::");
-	}
-
-	Templates.prototype.information_Contact = function(pVcardContact)
-	{
-		var _this = this;
-		var _XmlInfoContact = '<info_contact>' + 
-								 '<vcard> ' +
-								 	pVcardContact +
-								 '</vcard> ' +		
-								 '<getlang>'+
-								  	'<FN>' + IM.get_lang('Full Name') + '</FN>' +
-								  	'<NICKNAME>' + IM.get_lang('NickName') + '</NICKNAME>' +	
-								  	'<ORGUNIT>' + IM.get_lang('Orgunit') + '</ORGUNIT>' +	
-								  	'<ROLE>' + IM.get_lang('Role') + '</ROLE>' +	
-								  	'<BDAY>' + IM.get_lang('Birthday') + '</BDAY>' +	
-		 				 	     '</getlang>' +
-		 				 	  '</info_contact>';
-		_this.conf_form("divInfoContact",430,110,parse_XmlXsl(_XmlInfoContact,'info_contact.xsl'),":: Informações do Contato - Expresso ::");
-
-	}
-
-   Templates.prototype.emotions = function()
-   {
-	  var smiles = new Array("\':)\'#smile_1.src","\':d\'#smile_2.src","\';)\'#smile_3.src","\':o\'#smile_4.src","\':p\'#smile_5.src","\'(h)\'#smile_6.src","\':@\'#smile_7.src","\':$\'#smile_8.src","\':s\'#smile_9.src","\':(\'#smile_10.src","\':\\\'\(\'#smile_11.src","\':|\'#smile_12.src");
-	  var grid = '';
-	      grid += '<table cellpadding="0" cellspacing="0" border="0">';
-	      grid += '<tr>';
-	   	  for(var i = 0 ; i < 4; i++)	
-		      grid += '<td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion('+smiles[i].substr(0,smiles[i].indexOf('#'))+')" id="sendMessageMenuId"><img width="19" height="19" src="'+eval(smiles[i].substr(smiles[i].indexOf('#') + 1))+'" /></div></td>';
-		  grid += '</tr>';	
-	      grid += '<tr>';
-	   	  for(var i = 4 ; i < 8; i++)	
-		      grid += '<td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion('+smiles[i].substr(0,smiles[i].indexOf('#'))+')" id="sendMessageMenuId"><img width="19" height="19" src="'+eval(smiles[i].substr(smiles[i].indexOf('#') + 1))+'" /></div></td>';
-		  grid += '</tr>';	
-	      grid += '<tr>';
-	   	  for(var i = 8 ; i < 12; i++)	
-		      grid += '<td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion('+smiles[i].substr(0,smiles[i].indexOf('#'))+')" id="sendMessageMenuId"><img width="19" height="19" src="'+eval(smiles[i].substr(smiles[i].indexOf('#') + 1))+'" /></div></td>';
-		  grid += '</tr>';	
-	      grid += '<tr>';
-	      grid += '<td colspan="18"><hr style="background:#cccccc;margin:1px:size:1px;"/></td>';
-	      grid += '</tr>';
-	      grid += '<tr>';
-	      grid += '<td colspan="18"><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideEmotionSelection()" id="closeEmotionSelectionDiv">Close This Menu</div></td>';
-	      grid += '</tr>';
-	      grid += '</table>';
-      return grid;
-   }
-
-   Templates.prototype.font_name = function()
-   {
-	  var fonts_n = new Array("Arial:Arial","Courier:Courier","Times:Times New Roman");
-	  var grid = '';
-
-	  for( var i = 0 ; i < fonts_n.length; i++ )
-    	  grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFont(\'' + fonts_n[i].substr(0,fonts_n[i].indexOf(':') + 1 )+'\')" id="fontStyle1" style="width:120px;font-family:'+fonts_n[i].substr(fonts_n[i].indexOf(':') + 1 )+'">' + fonts_n[i].substr(fonts_n[i].indexOf(':') + 1 ) + '</div>';	  
-
-      grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
-  	  grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontNameSelection()" id="fontStyle1" style="width:120px">Close This Menu</div>';
-
-      return grid;
-   }
-
-   Templates.prototype.font_size = function()
-   {
-      var fonts_s = new Array("9pt:9","10pt:10","11pt:11","12pt:12","14pt:14","16pt:16","18pt:18");
-      var grid = '';
-
-	  for( var i = 0 ; i < fonts_s.length ; i++ )
-	      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeSizeFont(\'' + fonts_s[i].substr(0,fonts_s[i].indexOf(':')) + '\');" id="fontStyle1" style="width:100px">' + fonts_s[i].substr(fonts_s[i].indexOf(':') + 1 ) + '</div>';
-
-      grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
-      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontSizeSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
-
-      return grid;
-   }
-
-   Templates.prototype.font_color = function()
-   {
-      var fonts_c = new Array("#000000:Black","#c0c0c0:Silver","#ffff00:Yellow","#ff0000:Red","#ff00ff:Pink","#00ff00:Green","#1111ff:Blue","#800080:Magenta");
-	  var grid = '';		 
-	  
-	  for( var i = 0; i < fonts_c.length ; i++ )	
-	      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'' + fonts_c[i].substr(0,fonts_c[i].indexOf(':')) + '\')" id="fontStyle1" style="width:100px">' + fonts_c[i].substr(fonts_c[i].indexOf(':') + 1 )  + '</div>';
-
-      grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
-      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontColorSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
-	  	      
-      return grid;
-   }
-
-   Templates.prototype.font_style = function()
-   {
-     var fonts_st = new Array("normal:Regular","italic:Italic","bold:Bold");
-     var grid = '';
-     
-     for( var i = 0 ; i < fonts_st.length; i++ )
-     	grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontStyle(\'' + fonts_st[i].substr(0,fonts_st.indexOf(':')) + '\')" id="fontStyle1" style="width:100px">' + fonts_st[i].substr( fonts_st[i].indexOf(':') + 1 ) + '</div>';
-     grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
-     grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontStyleSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
-	 
-     return grid;
-   }
-
-  /*
-   * Preferências do usuário
-   */
-   
-   Templates.prototype.yourPreferences = function()
-   {
-		var _this = this;
-		var _XmlPreferences = '<preferences />';
-		_this.conf_form("divYourPreferences",345,222,parse_XmlXsl(_XmlPreferences,'preferences.xsl'),":: Informações do Contato - Expresso ::");
-		IM_Preferences.LoadPreferences(null);
-   }
-
-   //Templates
-   var Templates = new Templates();
Index: unk/instant_messenger/bkp/instant_messenger_64/templates/default/css.css
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/templates/default/css.css	(revision 151)
+++ 	(revision )
@@ -1,405 +1,0 @@
-b.rnd
-{
-   background:	#fff;
-   display:	block;
-   font-size:	1px;
-}
-b.rnd b
-{
-   display:	block;
-   height:		1px;
-   overflow:	hidden;
-}
-b.rnd1
-{
-   border-color:     #809aa9;
-   border-width:     1px 1px 0px 1px;
-   border-style:     solid;
-   background:						#cbdae4;
-   margin:							0px 2px;
-}
-b.rnd2
-{
-      border-color:     #809aa9;
-      border-width:     0px 1px 0px 1px;
-      border-style:     solid;
-      background:					   #cbdae4;
-	  margin:							0px 1px;
-}
-
-/* IM:WINDOW - ADD USER */
-
-select.add_user
-{
-   font-family:   Tahoma, Verdana, sans-serif;
-   font-size:     8pt;
-   font-weight:   normal;
-   border-color:  #809aa9;
-   border-width:  1px 1px;
-   border-style:  solid;
-   margin:        2px 2px 2px 2px;
-   width:    	  493px;
-
-
-}
-
-/* IM:WINDOW */
-
-.im_window_fantom
-{
-	position: absolute;
-	padding: 0px;
-	border-style: dashed;
-	border-width: 1px 1px 1px 1px;
-	border-color: #000000;
-	background-color: #ffffff;
-	overflow: hidden;
-}
-
-.im-windowfantom-des
-{
-	position: absolute;
-	padding: 0px;
-	overflow: hidden;
-}
-
-.im-window
-{
-    background: transparent;
-	position:   absolute;
-}
-
-.im-window-resizehandle
-{
-	position: relative;
-	overflow: auto;
-	width: 15px;
-	height: 15px;
-    background-image: url(images/img/winresize2.gif);
-}
-
-.im-window-sel {
-	z-index: 100;
-}
-
-.im-window-des {
-	z-index: 50;
-}
-
-/* IM:WINDOWHEAD */
-
-.im_window_head
-{
-   background:    #cbdae4;
-   border-color:  #809aa9;
-   border-width:  0px 1px;
-   border-style:  solid;
-   height:        24px;
-	margin:        0px;
-	overflow:      hidden;
-	width:         258px;
-}
-
-.im-window-sel .im-windowhead {
-	background-position: 0 0;
-}
-
-.im-window-des .im-windowhead {
-	background-position: 0 -25px;
-}
-
-.im-window-flash .im-windowhead {
-	background-position: 0 0px;
-        background-image: url(images/img/flash_win_top_left2.gif);
-}
-
-.im-windowhead-right{
-	padding-right: 5px;
-	margin: 0;
-	background: 100% 0 transparent no-repeat;
-        background-image: url(images/img/win_top_right.gif);
-	overflow: hidden;
-}
-
-.im-window-sel .im-windowhead-right{
-	background-position: 100% 0;
-}
-
-.im-window-des .im-windowhead-right{
-	background-position: 100% -25px;
-}
-
-.im-window-flash .im-windowhead-right{
-	background-position: 100% 0;
-        background-image: url(images/img/flash_win_top_right2.gif);
-}
-
-.im-windowhead-mid {
-	position: relative;
-	background-position: 0 0;
-        background-image: url(images/img/win_top_mid.gif);
-	background-repeat: repeat-x;
-	overflow: hidden;
-	line-height: 25px;
-	height: 25px;
-	cursor: auto;
-	font-weight: bold;
-	padding-left: 24px;
-}
-
-.im-window-sel .im-windowhead-mid {
-	background-position: 0 0;
-	color: #000000;
-}
-
-.im-window-des .im-windowhead-mid {
-	background-position: 0 -25px;
-	color: #aaaaaa;
-}
-
-.im-window-flash .im-windowhead-mid {
-	background-position: 0 0;
-        background-image: url(images/img/flash_win_top_mid2.gif);
-	color: #aaaaaa;
-}
-
-.im_window_title
-{
-   cursor:        move;
-   float:         left;
-   font-weight:   bolder;
-   height:        16px;
-   left:          8px;
-   overflow:      hidden;
-   position:   	  relative;
-   top:           3px;
-   width:         166px;
-}
-
-.im_window_icon
-{
-   float: left;
-   height: 16px;
-   margin: 0px 5px;
-   width: 16px;
-}
-
-
-/* IM:WINDOWBODY */
-
-
-.im_window_body
-{
-	background-color: #cbdae4;
-	border-color:     #809aa9;
-	border-style:     solid;
-	border-width:     0px 1px 1px 1px;
-}
-
-.im_window_body_inner
-{
-	background: #fff;
-    border:     1px solid #809aa9;
-    margin:  0px 3px;
-	overflow: auto;
-}
-
-.im-window-des .im-windowbody {
-	border-color: #d0dfe5;
-	background-color: #f0f5f8;
-
-}
-
-.im-window-flash .im-windowbody {
-	border-color: #d0dfe5;
-	background-color: #f0f5f8;
-    background-image: url(images/img/flash_window_background.gif);
-}
-
-.im-window-des .im-windowbody-inner {
-	border-color: #b9cfd8;
-}
-
-.edit_message
-{
-	background-color: #fff;
-   border:           2px solid #c9d9e8;
-	color:            #000;
-	font-family:      Tahoma, Verdana, sans-serif;
-	font-size:        10pt;
-	font-weight:      normal;
-   padding:          0px;
-}
-
-/* WINDOWBUTTONS */
-
-.im_window_head_buttons
-{
-    display:       block;
-    float:         left;
-	height:        15px;
-    padding-top:   6px;
-	position:      relative;
-	right:         0px;
-	width:         53px;
-}
-
-.im-window-sel .im-windowbutton-container {
-	background-position: 0 0;
-}
-
-.im-window-des .im-windowbutton-container {
-	background-position: 0 -25px;
-}
-
-.im-window-button {
-	margin: 1px 0px 0 2px;
-	/*float: left;*/
-   /*float: right;*/
-   /*clear: both;*/
-	height: 13px;
-	width: 13px;
-   position: absolute;
-	cursor: pointer;
-   top: 3px;
-   /*left: 20px;
-   /*right: 10px;*/
-}
-
-.im-window-sel .im-window-button {
-	background-position: 0 0;
-}
-
-.im-window-sel .im-window-button-hov {
-	background-position: 0 -13px;
-}
-
-.im-window-sel .im-window-button-pres {
-	background-position: 0 -26px;
-}
-
-.im-window-des .im-window-button {
-	background-position: 0 -39px;
-}
-
-.im-window-des .im-window-button-hov {
-	background-position: 0 -52px;
-}
-
-.im-window-des .im-window-button-pres {
-	background-position: 0 -65px;
-}
-
-.im-window-closebutton {
-   background-image: url(images/img/close.gif);
-}
-
-.im-window-maximizerestorebutton {
-   background-image: url(images/img/max.gif);
-}
-
-.im-window-minimizebutton {
-   background-image: url(images/img/min.gif);
-}
-
-/* IM:TASKBAR */
-
-.im-taskbar
-{
-	position: absolute;
-	width: 100%;
-	height: 27px;
-	z-index: 101; 
-	background-position: 0 0;
-	background-repeat: repeat;
-    overflow: hidden;
-}
-
-/* IM:TASKBARITEM */
-
-.im-taskbaritem-des {
-	position: absolute;
-	top: 0;
-	right: 0;
-	width: 150px;
-	height: 22px;
-    border-style: solid;
-	border-width: 1px 1px 1px 1px;
-	border-color: #B9CFD8;
-    background-position: 0 -4px;
-    background-image: url(images/img/win_top_mid.gif);
-    padding: 3px 10px;
-    color: #555555;
-    -moz-box-sizing: border-box;
-    cursor:pointer ;
-}
-
-.im-taskbaritem-flash {
-	position: absolute;
-	top: 0;
-	right: 0;
-	width: 150px;
-	height: 22px;
-        border-style: solid;
-        border-color: #B9CFD8;
-	border-width: 1px 1px 1px 1px;
-        background-position: 0 0;
-        background-image: url(images/img/flash_window_background.gif);
-        background-repeat: repeat;
-        padding: 3px 10px;
-        color: #555555;
-        -moz-box-sizing: border-box;
-        cursor:pointer ;
-}
-
-.im-taskbaritem {
-    position: absolute;
-	top: 0;
-	right: 0;
-	width: 150px;
-	height: 22px;
-    border-style: solid;
-	border-width: 1px 1px 1px 1px;
-	border-color: #B9CFD8;
-        background-position: 0 -26px;
-        background-image: url(images/img/win_top_mid.gif);
-        padding: 3px 10px;
-        color: #999999;
-        -moz-box-sizing: border-box;
-        cursor:pointer;
-}
-
-.menu_im
-{
-   /*border-bottom: 1px solid #ccc;*/
-   display:       none;
-   /*float:         left;*/
-   list-style:    none;
-   margin:        0px;
-   padding:       0px;
-   position:      absolute;
-   width:         150px; /* Width of Menu Items */
-	z-index:       1000;
-}
-
-.menu_im dt a
-{
-   background:      #cbdae4;
-   border:          1px solid #b9cfd8;
-   border-bottom:   0px;
-   color:           #000;
-   display:         block;
-   padding:         2px;
-   text-decoration: none;
-}
-
-.menu_im dt a:hover
-{
-   color:      #e2144a;
-   background: #f9f9f9;
-}
-
-.contato_hover
-{
-   background-color: #cbdae4;
-}
Index: unk/instant_messenger/bkp/instant_messenger_64/templates/default/messenger.css
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/templates/default/messenger.css	(revision 151)
+++ 	(revision )
@@ -1,361 +1,0 @@
-div.border
-{
-   margin-top: 0px;
-   border: 2px solid #C9D9E8;
-   padding: 0px;
-   float: left;
-}
-
-div.popupChecker
-{
-   position : absolute;
-   left : 15px;
-   top : 100px;
-   background : #FFFFFF;
-   width : 200px;
-   height : 100px;
-   text-align : center;
-   visibility : hidden;
-}
-
-div.deleteContact
-{
-    position : absolute;
-    left : 20px;
-    top : 100px;
-    background : #FFFFFF;
-    width : 250px;
-    height : 150px;
-    text-align : center;
-    visibility : hidden;
-}
-
-div.flyMenu
-{
-    position : absolute;
-    left : 75px;
-    top : 100px;
-    border: 2px solid #C9D9E8;
-    background : #DFEFFE;
-    width : 150px;
-    height : 60px;
-    text-align : left;
-    visibility : hidden;
-}
-
-div.statusMenu
-{
-    position : absolute;
-    border: 1px solid #C9D9E8;
-    background : #DFEFFE;
-    text-align : left;
-    visibility : hidden;
-}
-
-.flyMenuClass
-{
-    position:absolute;
-    width:150px;
-    border:2px solid #C9D9E8;
-    background-color:#DFEFFE;
-    line-height:20px;
-    cursor:default;
-    font-size:11px;
-    z-index:100;
-    visibility:hidden;
-}
-
-.menuitems
-{
-    padding-left:10px;
-    padding-right:10px;
-    font-size:11px;
-    border: 1px solid #DFEFFE;
-    cursor:pointer ;
-}
-
-.padding
-{
-    padding-left:10px;
-    padding-right:10px;
-    font-size:11px;
-}
-
-.contactItem
-{
-    font-size:11px;
-}
-
-table.border
-{
-    margin-top: 0px;
-    border: 2px solid #C9D9E8;
-    padding: 0px;
-    float: left;
-}
-
-p.small
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-
-}
-
-span.small
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-}
-
-p.small-red
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-    color: #FF0000;
-}
-
-font.small
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-}
-
-font.small-grey
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-}
-
-font.large
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 12pt;
-}
-
-table.window
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 10pt;
-	border : 1px solid Black;
-}
-
-table.excel
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-	border : 0px dashed Black;
-}
-
-div.sel
-{
-  	position: absolute;
-  	padding: 0px 4px 2px;
-  	border: solid 1px;
-  	border-color: #C9D9E8;
-  	background: #ffffff;
-}
-
-div.des
-{
-  	position: absolute;
-  	border: 0px;
-  	padding: 1px 5px 3px;
-}
-
-div.sel-small
-{
-  	position: relative;
-  	padding: 1px 6px 1px 6px;
-  	border: solid 1px;
-  	border-color: #C9D9E8;
-  	background: #DFEFFF;
-  	cursor:pointer;
-  	-moz-box-sizing: border-box;
-}
-
-div.des-small
-{
-  	position: relative;
-  	border: 0px;
-  	padding: 2px 7px 2px 7px;
-  	cursor:pointer ;
-  	-moz-box-sizing: border-box;
-}
-
-span.sel-small
-{
-  	position: relative;
-  	padding: 0px 2px;
-  	border: solid 1px;
-  	border-color: #C9D9E8;
-  	background: #DFEFFF;
-  	cursor:pointer;
-  	-moz-box-sizing: border-box;
-}
-
-span.des-small
-{
-  	position: relative;
-  	border: 0px;
-  	padding: 1px 3px;
-  	cursor:pointer ;
-  	-moz-box-sizing: border-box;
-}
-
-div.menuitems
-{
-    padding: 2px;
-    padding-left:10px;
-    padding-right:10px;
-    font-size:11px;
-    border: 1px solid #DFEFFE;
-    background : #DFEFFE;
-    cursor:pointer ;
-}
-
-div.menuitems-sel
-{
-    padding: 2px;
-    padding-left:10px;
-    padding-right:10px;
-    font-size:11px;
-    border: 1px solid #C9D9E8;
-    background: #ffffff;
-    cursor:pointer ;
-}
-
-div.emotionFrame 
-{
-    position: absolute;
-    border: 1px solid #A9B9C8;
-    background: #DFEFFE;
-}
-
-div.emotionItem
-{
-    padding: 2px;
-    font-size:11px;
-    background: #ffffff;
-    border: 1px solid #DFEFFE;
-    cursor:pointer ;
-}
-
-div.emotionItem-sel
-{
-    padding: 1px;
-    font-size:11px;
-    background: #FFFFFF;
-    border: 2px solid #99a9b8;
-    cursor: pointer;
-}
-
-div.myAvatar
-{
-    background: #fff;
-    border: 2px solid #C9D9E8;
-    height:     65px;
-	margin:     2px;
-    padding:    2px;
-    width:      49px;
-}
-
-div.composing
-{
-    background: #fff;
-	bottom:     0px;
-	display:    none;
-    height:     14px;
-	position:   absolute;
-    width:      14px;
-}
-
-div.avatarSelection
-{
-    position: relative;
-    border-style: solid;
-	border-width: 1px 1px 1px 1px;
-	border-color: #B9CFD8;
-    background-color: #ffffff;
-    padding: 2px;
-    cursor:pointer ;
-    -moz-box-sizing: border-box;
-}
-
-dl
-{
-    margin: 0px;
-    padding: 0px;
-}
-dd
-{
-    margin: 0px;
-    padding: 0px;
-   display: inline;   
-}
-
-   .master
-   {
-      height:     250px;
-      margin:     0px;
-      padding:    0px;
-	   position:   absolute;
-      overflow:   hidden;
-      width:      350px;
-      z-index:    1;
-   }
-   .pai
-   {
-	  background: #cbdae4 4px 2px no-repeat;
-      border:     1px solid #809aa9;
-      border-top: 0px;
-      height:     242px;
-      margin:     0px 0px 0px 0px;
-      padding:    3px 2px 0px 0px;
-	  position:   relative;
-      z-index:    1;
-   }
-   .filho
-   {
-      background: #fff;
-      border:     1px solid #809aa9;
-      height:     208px;
-      left:       4px;
-      margin:     0px 0px 15px 0px;
-      position:   absolute;
-      top: 23px;
-      width:      338px;
-      z-index:    2;
-   }
-   .header
-   {
-      margin:     0px 0px 3px 3px;
-      padding:    0px 0px 0px 20px;
-      height:     20px;
-   }
-   .but
-   {
-      border:  1px solid #809aa9;
-      height:  13px;
-      width:   13px;
-      margin:  3px 58px 3px -3px;
-      padding: 0px;
-   }
-   .tit
-   {
-      float:   left;
-      height: 13px;
-      margin:  0px;
-      padding: 0px;
-      overflow: hidden;
-   }
-._rtop{display:block;}
-._rtop *{display:block;height: 1px;overflow: hidden}
-._r1{margin: 0 4px;height: 0px}
-._r2{margin: 0 3px}
-._r3{margin: 0 2px}
-._r4{margin: 0 1px}
-
-._rs1{margin: 0 2px}
-._rs2{margin: 0 1px}
-._rtop *{border-width: 0px 1px;border-style: solid; border-color: #809aa9}
-._rtop ._r1{border-top: 1px solid #809aa9;}
Index: unk/instant_messenger/bkp/instant_messenger_64/templates/default/stop_script.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/templates/default/stop_script.php	(revision 151)
+++ 	(revision )
@@ -1,6 +1,0 @@
-#!/usr/bin/php5 -q
-<?php
-
-	exec("killall php >/dev/null &");
-	set_time_limit(1);
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/templates/default/config.tpl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/templates/default/config.tpl	(revision 151)
+++ 	(revision )
@@ -1,78 +1,0 @@
-<!-- BEGIN header -->
-<form method="POST" action="{action_url}">
-<table border="0" align="center">
-   <tr bgcolor="{th_bg}">
-    <td colspan="2"><font color="{th_text}">&nbsp;<b>{title} - Jabber</b></font></td>
-   </tr>
-<!-- END header -->
-
-<!-- BEGIN body -->
-   <tr bgcolor="{row_on}">
-    <td colspan="2">&nbsp;</td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td colspan="2">&nbsp;<b>Configuração do Servidor Jabber</b></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Digite o nome da máquina Servidor Jabber:</td>
-    <td><input id="IM_name_jabber" name="newsettings[name_jabber]" value="{value_name_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td>Digite Nome da Conexão:</td>
-    <td><input id="IM_resource_jabber" name="newsettings[resource_jabber]" value="{value_resource_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Digite a porta do Servidor Jabber:</td>
-    <td><input id="IM_port_jabber" name="newsettings[port_jabber]" value="{value_port_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td>Servidor Ldap:</td>
-    <td><input id="IM_server_ldap_jabber" name="newsettings[server_ldap_jabber]" value="{value_server_ldap_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Contexto:</td>
-    <td><input id="IM_context_ldap_jabber" name="newsettings[context_ldap_jabber]" value="{value_context_ldap_jabber}" size="30"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td>Usuário Ldap:</td>
-    <td><input id="IM_user_ldap_jabber" name="newsettings[user_ldap_jabber]" value="{value_user_ldap_jabber}" size="30"></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Password:</td>
-    <td><input type="password" name="newsettings[password_ldap_jabber]" value="{value_password_ldap_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td colspan="2"> Gerenciamento IMManager</td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-	<td colspan="2">
-		<iframe src ="instant_messenger/templates/default/script_load.php?user={value_user_ldap_jabber}" frameborder="0" height="60px" scrolling="no"></iframe>
-	</td>
-   </tr>
-<!-- END body -->
-
-<!-- BEGIN footer -->
-  <tr bgcolor="{th_bg}">
-    <td colspan="2">
-&nbsp;
-    </td>
-  </tr>
-  <tr>
-    <td colspan="2" align="center">
-      <input type="submit" name="submit" value="{lang_submit}">
-      <input type="submit" name="cancel" value="{lang_cancel}">
-    </td>
-  </tr>
-</table>
-</form>
-<!-- END footer -->
Index: unk/instant_messenger/bkp/instant_messenger_64/templates/default/index.tpl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/templates/default/index.tpl	(revision 151)
+++ 	(revision )
@@ -1,164 +1,0 @@
-<!-- BEGIN index -->
-    <h1>Como Utilizar o Expresso Messenger</h1>
-    <h2><a name="toc">Conteúdo</a></h2>
-    <ol>
-      <li><a href="#intro">Introdução</a>
-      <li><a href="#acesso_primeiro">Acessando o Expresso Messenger pela Primeira Vez</a>
-      <li><a href="#supported">Browsers Suportados</a>
-	  <li><a href="#prefe">Menu Opções</a>
-      <li><a href="#contact_list">Lista de Contatos</a>
-        <ol>
-          <li><a href="#status">Indicador de Status</a>
-          <li><a href="#useradd">Adicionando um novo contato</a>
-          <li><a href="#userdel">Removendo um contato</a>          
-        </ol>
-      <li><a href="#menu_right">Preferências Avançadas</a>
-      <li><a href="#info_ad">Vcard - Informações Adicionais</a>
-      <li><a href="#info_prefe">Preferências</a>      
-	  <li><a href="#troca_mens">Troca de Mensagens</a>
-	  <li><a href="#troca_status">Troca de Status</a>      
-    </ol>
-
-    <h2><a name="intro">1. Introdução</a></h2>
-    
-    O Expresso Messenger é uma aplicação que permite o envio e recebimento de mensagens instantaneamente. Através da sua lista de contatos, você pode trocar mensagens e arquivos com seus contatos. Através da lista também é possível saber se seus contatos estão Online ou Offline. Para a troca de mensagens basta clicar em cima do nome do seu contato, se o mesmo estiver online ( verifique a sessão <a href="#status">Indicador de Status</a> ) abrirá uma janela onde você poderá enviar/receber as mensagens. O Expresso Messenger está associado
-    a um serviço de mensagens instantâneas Jabber, este serviço é responsável pelo armazenamento dos seus contatos, preferências e mensagens.
-	
-	<br clear="all">
-	<br>
-	( figura 1 )
-    <img src="templates/default/images/lista_contatos.png" width="242" height="381" alt="Im Screenshot" align="left" style="padding-right:4px;"> 
-	
-    <br clear="all">
-
-	<h2><a name="acesso_primeiro">2. Acessando o Expresso Messenger pela Primeira Vez</a></h2>
-	
-	Para o acessar o Expresso Messenger, basta clicar em cima da figura <img src="templates/default/images/available.gif">("bolinha verde"), abrirá uma uma janela igual a figura 2. A lista de contatos aparecerá com a seguinte frase : "Nenhum Contato", até que sejam cadastrados novos contatos. 
-
-	<br clear="all">
-	<br>
-	( figura 2 )
-    <img src="templates/default/images/lista_contatos_primeira.png" width="222" height="337" alt="Im Screenshot" align="left" style="padding-right:4px;"> 
-    
-    <br clear="all">
-
-    <h2><a name="supported">3. Browsers Suportados</a></h2>
-
-    <p>
-      <b>Windows XP/2000/ME/98/95:</b>
-	  <ul>
-	    <li>MS Internet Explorer desde a versão 6.0</li>
-	    <li>Mozilla Firefox desde a versão 1.5</li>
-	  </ul>
-	  
-    <p>
-      <b>Linux:</b>
-      <ul>
-	    <li>Mozilla Firefox desde a versão 1.5</li>
-      </ul>
-    </p>
-
-    <h2><a name="prefe">4. Menu Opções</a></h2>
-	( figura 3 )
-    <img src="templates/default/images/menu_preferencias.png" width="272" height="173" alt="Menu Preferências" align="left">
-    <br clear="all">
-    <br>
-
-	Para acessar o menu "Opções" ( conforme figura 3 ), basta dar um clique com o mouse e abrirá um menu com as opções de Adicionar Contato ( <b>veja <a href="#useradd">Adicionando um novo contato</a></b> ), Remover Contato ( <b>veja <a href="#userdel">Removendo um contato</a></b> ), 
-	Vcard - Informações Adicionais ( <b>veja <a href="#info_ad">Vcard - Informações Adicionais</a></b> ) e Preferências ( <b>veja <a href="#info_prefe">Preferências</a></b> ).
-    
-    <h2><a name="contact_list">5. Lista de Contatos</a></h2>
-	( figura 4 )
-    <img src="templates/default/images/lista_contatos1.png" width="236" height="242" alt="Lista de Contatos" align="left">
-    <br clear="all">
-    <br>
-    
-    Na lista de contato ( conforme figura 4 ), você visualizará seus contatos. 
-    <h3><a name="status">1. Status dos Usuários</a></h3>
-    
-    <img src="templates/default/images/available.gif" align="top"> - Contato Online<br>
-    <img src="templates/default/images/away.gif" align="top"> - Contato Ausente<br>
-    <img src="templates/default/images/dnd.gif" align="top"> - Contato Ocupado<br>
-    <img src="templates/default/images/unavailable.gif" align="top"> - Contato Offline<br>    
-
-    <h3><a name="useradd">2. Adicionando um novo contato </a></h3>
-	( figura 4.1 )
-	<br/>
-    <img src="templates/default/images/adicionar_contato.png" width="536" height="342" alt="Adicionar Contato" align="left">
-    <br clear="all">
-    <br>
-
-	Para adicionar um novo contato ( conforme figura 4.1 ), selecione uma organização e automaticamente carregará os usuários que tem permissão para usar o Mensageiro Instantâneo Expresso. Para escolher
-	seu novo contato basta apenas dar um clique em cima do nome desejado. Logo abaixo, três campos são necessários para adicionar o novo contato, sendo que o campo "Email Expresso" e
-	"Nickname" são preenchidos no momento da escolha do novo contato e o campo grupo terá que ser definido. Tendo os três campos preenchidos basta clicar no Botão Adicionar ( <input type="button" value="Adicionar"> ) .
-
-	<h3><a name="userdel">3. Removendo um contato </a></h3>
-	( figura 4.2 )
-	<br/>	
-    <img src="templates/default/images/remover_contato.png" width="314" height="157" alt="Remover Contato" align="left">
-    <br clear="all">
-    <br>
-
-	Para remover um contato da sua lista ( conforme figura 4.2 ), selecione na lista e clique no botao Botão Remover ( <input type="button" value="Remover"> ) .
-    
-    <h2><a name="menu_right">6. Preferências Avançadas</a></h2>
-	( figura 4.3 )
-	<br/>
-    <img src="templates/default/images/menu_right.png" width="151" height="108" alt="Preferências Avançadas" align="left">
-    <br clear="all"/>
-    <br/>
-
-    Clicando com o botão direito do mouse, você tera acesso a um menu ( conforme figura 3.3 ), com as seguintes funcionalidades :
-
-    <ul>
-      <li>Apelido: Renomeia o Apelido ( Nickname ) do seu contato
-      <li>Grupo: Muda seu contato para um novo grupo
-      <li>Remover: Exclui o contato
-      <li>(Re)-requisitar Autorização: Requisitar autorização
-      <li>Ver Info: Visualize as informações dos seus contatos
-    </ul>
-
-    <h2><a name="info_ad">7. Vcard - Informações Adicionais</a></h2>
-	( figura 5 )
-    <img src="templates/default/images/info_adicionais.png" width="410" height="267" alt="Informações Adicionais" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Efetuando o cadastro ( conforme figura 5 ) com seus dados, os contatos que você adicionou em sua lista poderão ver essas informações. Cada contato cadastrado em sua lista
-	também possui esta opção ( <b>veja <a href="#menu_right">Preferências Avançadas</a></b>, opção Ver Info).
-
-    <h2><a name="info_prefe">8. Preferências</a></h2>
-	( figura 6 )
-    <img src="templates/default/images/preferencias.png" width="356" height="270" alt="Preferências" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Personalize seu tempo para ficar ausente, se em sua lista de contato aparecerá seus contatos offline e um tipo de aviso para uma nova mensagem. 
-
-    <h2><a name="troca_mens">9. Troca de Mensagens</a></h2>
-	( figura 7 )
-    <img src="templates/default/images/troca_mensagem.png" width="332" height="272" alt="Troca de Mensagens" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Clicando com o mouse em cima do nome do contato escolhido, abrirá uma janela ( conforme figura 7 ), para a troca de mensagens. Nessa mesma janela existe um menu, o qual é possível
-	configurar o formato da : Fonte, Tamanho, Cor e o Estilo. Você também pode enviar os Smiles, clicando nessa figura <img src="templates/default/images/img/1.gif">.
-
-    <h2><a name="troca_status">10. Troca de Status</a></h2>
-	( figura 8 )
-    <img src="templates/default/images/troca_status.png" width="449" height="313" alt="Troca de Status" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Para mudar o seu status basta dar um click em cima do status desejado.
-
-	<br/><br/>
-
-    <img src="templates/default/images/available.gif" align="top"> - Online <br/>
-    <img src="templates/default/images/away.gif" align="top"> - Ausente <br/>
-    <img src="templates/default/images/dnd.gif" align="top"> - Ocupado <br/>
-    <img src="templates/default/images/unavailable.gif" align="top"> - Offline - Não recebe mensagem <br/>    
-    <img src="templates/default/images/img/icon_edit.gif" align="top"> - Mensagem - Personalize sua mensagem <br/>        
-
-    <hr noshade>
-<!-- END index -->
Index: unk/instant_messenger/bkp/instant_messenger_64/templates/default/start_script.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/templates/default/start_script.php	(revision 151)
+++ 	(revision )
@@ -1,6 +1,0 @@
-#!/usr/bin/php5 -q
-<?php
-	
-	exec("php -q /var/www/expresso/instant_messenger/IMManager.php &>/dev/null &");
-	set_time_limit(1);
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/templates/default/script_load.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/templates/default/script_load.php	(revision 151)
+++ 	(revision )
@@ -1,107 +1,0 @@
-<html>
-<head>
-<script type="text/javascript">
-	var number_process = "";
-
-	function init()
-	{
-		info_process_id();
-		if(!validate_form() || number_process != "")
-			document.im_script_load.start_script.disabled = true;
-		
-	}
-	function info_process_id()
-	{
-		var element = document.getElementById('span_process_id');
-		if(number_process)		
-			element.innerHTML = number_process;
-		else
-			element.innerHTML = "<font color='red'>Serviço parado</font>";	
-	}
-	function validate_form()
-	{
-		if(trim(parent.document.getElementById('IM_name_jabber').value) == "")
-			return false;
-		if(trim(parent.document.getElementById('IM_resource_jabber').value) == "")
-			return false;
-		if(trim(parent.document.getElementById('IM_port_jabber').value) == "")
-			return false;
-		if(trim(parent.document.getElementById('IM_server_ldap_jabber').value) == "")
-			return false;
-		if(trim(parent.document.getElementById('IM_context_ldap_jabber').value) == "")
-			return false;
-		if(trim(parent.document.getElementById('IM_user_ldap_jabber').value) == "")
-			return false;
-
-		return true;
-	}
-	
-	function trim(pString)
-   {
-      return pString.replace(/^( )*|( )*$/g, '');
-   }
-   
-</script>
-<?php
-	
-	if( isset($_SESSION['phpgw_info']['instant_messenger']['user']) )
-	{
-		if($_REQUEST['user'] || $_SESSION['phpgw_info']['instant_messenger']['user'] == "rodsouza" || $_SESSION['phpgw_info']['instant_messenger']['user'] == "alexandrecorreia")
-		{
-			if($_POST['start_script'])
-			{
-				exec("php -q start_script.php");		
-				unset($_POST['start_script']);
-			}
-			
-			if($_POST['stop_script'])
-			{
-				exec("php -q stop_script.php");		
-				unset($_POST['stop_script']);
-			}
-			
-			$process = shell_exec("ps aux | grep IMManager.php$ | cut -c10-14");
-			$process = preg_replace("/\\n/","",$process);
-			echo "<script>number_process='".$process."'</script>";
-			
-		}else
-			exit;
-	}else
-		exit;
-
-?>
-<style>
-div
-{
-	font-weight : bold;
-	font-size: 11px !important; 
-	color: #006699 !important; 
-	font-family: Arial, Helvetica, sans-serif !important;
-}
-input,button
-{
-	font-size: 11px !important; 
-	color: #006699 !important; 
-	font-family: Arial, Helvetica, sans-serif !important;
-	border: 1px #bbbbbb solid !important;
-}
-
-input[type=submit],input[type=button],button
-{
-	margin:1px !important;
-	padding:1px !important;
-	cursor: pointer !important; 
-	cursor: hand !important;
-}
-</style>
-</head>
-<body onload="javascript:init();">
-	<div>Número do Processo : <span id="span_process_id"></span></div>
-	<br />
-	<form name="im_script_load" method="POST" action="script_load.php">
-		<input type="submit" value="Start Script" name="start_script" />
-		<input type="submit" value="Stop Script" name="stop_script" />
- 		<input type="hidden" name="user" value="user" />		
-	</form>
-</body>
-</html>
Index: unk/instant_messenger/bkp/instant_messenger_64/IMManager.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/IMManager.php	(revision 151)
+++ 	(revision )
@@ -1,272 +1,0 @@
-#!/usr/bin/php -Cq
-<?php
-
-   require_once('inc/IMConfigure.php');
-	require_once('inc/Jabberd2.abstract.php');
-
-	## limit to indefinite execution
-	set_time_limit (0);
-   
-   ###
-   # definitions of socket - BEGIN
-   #
-      define('URI', '0.0.0.0');
-      define('TARGET_NON_SECURITY', TRANSPORT_NON_SECURITY . '://' . URI  . ':' . PORT_NON_SECURITY);
-      define('SOCKET_NON_SECURITY', socket_create(AF_INET, SOCK_STREAM, SOL_TCP));
-   #
-   # definitions of socket - END
-   ###
-      // create a streaming socket, of type TCP/IP
-      // set the option to reuse the port
-      socket_set_option(SOCKET_NON_SECURITY, SOL_SOCKET, SO_REUSEADDR, 1);
-
-      // "bind" the socket to the address to "localhost", on port $port
-      // so this means that all connections on this port are now our resposibility to send/recv data, disconnect, etc..
-      socket_bind(SOCKET_NON_SECURITY, 0, 8000);
-
-      // start listen for connections
-      socket_listen(SOCKET_NON_SECURITY);
-
-   if ( !SOCKET_NON_SECURITY )
-   {
-      printf("NON SECURITY:\n(%d) %s", $errno_non_security, $errstr_non_security);
-      exit(0);
-   }
-
-   $master = array(SOCKET_NON_SECURITY);
-   $users = array();
-   $send = false;
-
-   while ( true )
-   {
-      $read = $master;
-      $_w = NULL;
-      $_e = NULL;
-      //$mod_fd = @stream_select($read, $_w , $_e , READ_SOCKET_AFTER_OF );
-      $mod_fd = socket_select($read, $_w = NULL, $_e = NULL, READ_SOCKET_AFTER_OF);
-
-      if ( $mod_fd === FALSE )
-      {
-         break;
-      }
-
-      for ( $i = 0; $i < $mod_fd; ++$i )
-      {
-         if ( $read[$i] === SOCKET_NON_SECURITY )
-         {
-            $conn_non_security = socket_accept(SOCKET_NON_SECURITY);
-            $master[] = &$conn_non_security;
-         }
-         else
-         {
-	    $sock_data = socket_read($read[$i], 1024);
-            if ( strlen($sock_data) === 0 )
-            {
-               $key_to_del = array_search($read[$i], $master, TRUE);
-               socket_close($read[$i]);
-               unset($master[$key_to_del]);
-            }
-            else if ( $sock_data === FALSE )
-            {
-               $key_to_del = array_search($read[$i], $master, TRUE);
-               unset($master[$key_to_del]);
-            }
-            else
-            {
-               $headers = (split("\n", $sock_data));
-
-               preg_match('/^(GET|POST) \/(.+) HTTP\/1\.\d/U', $headers[0], $request);
-               preg_match('/^Host: \w*:(.+)/', $headers[1], $host);
-
-               $conn = &$conn_non_security;
-
-               $request = explode(';', $request[2]);
-
-               if ( $request[0] == CONNECT && isset($request[1]) && !isset($users[$request[1]]) )
-               {
-                  connect($users, $request[1]);
-               }
-
-               if ( $request[0] == CLOSE && isset($request[1]) && isset($users[$request[1]]) )
-               {   
-               	close($request[1]);
-               }
-
-               socket_close($read[$i]);
-               unset($master[array_search($read[$i], $master)]);
-            }
-         }
-      }	
-      
-      foreach ( $users as $key => $val )
-      {
-   		$time_now = time();
-   		if ( ( $time_now - $users[$key]['timeClient'] ) < DISCONNECT_AFTERWARDS_OF )         
-         {
-         	readSocket($users, $key);
-         }
-         else
-         {
-				if((($time_now - $users[$key]['timeClient']) / DISCONNECT_AFTERWARDS_OF) > 2 )
-				{
-     				$users[$key]['jabber']->disconnect();
-     				unset($users[$key]);     				
-				}
-				else
-				{
-					readSocket($users, $key);
-				}         	
-         }
-      }
-   }
-	
-   exit(0);
-
-   function connect(&$pUsers, $pSession)
-   {
-	global $users;
-		      
-      $sessionpath = explode(';', session_save_path());
-      foreach ( $sessionpath as $path )
-      {
-         $path = ( strrpos($path, '/') == strlen($path) - 1 ) ? $path : $path . '/';
-
-         if ( file_exists($path . 'sess_' . $pSession) )
-         {
-            session_id($pSession);
-
-            ob_start();
-            session_start();
-            ob_clean();
-            ob_end_flush();
-
-            $is_user = isset($_SESSION['phpgw_info']['instant_messenger']['user']) and isset($_SESSION['phpgw_info']['instant_messenger']['passwd']);
-            if ( $is_user )
-            {
-               $_user     = $_SESSION['phpgw_info']['instant_messenger']['user'];
-               $_pass     = $_SESSION['phpgw_info']['instant_messenger']['passwd'];
-               $_server   = $_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-               $_port     = $_SESSION['phpgw_info']['instant_messenger']['port_jabber'];
-               $_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber'];
-               $_time     = time();
-               $_SESSION['phpgw_info']['instant_messenger']['timeClient'] = $_time;
-					$_SESSION['phpgw_info']['instant_messenger']['timeServer'] = $_time;               
-               $_SESSION['phpgw_info']['instant_messenger']['socket'] = NULL;
-               $_SESSION['phpgw_info']['instant_messenger']['socket']['in'] = NULL;
-               $_SESSION['phpgw_info']['instant_messenger']['socket']['out'] = array();
-               $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] = NULL;
-               $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = false;
-
-               session_write_close();
-
-               $a = new Jabberd2;
-               if ( ($a->connect($_user . '@' . $_server . '/' . $_resource . ':' . $_port, $_pass)) )
-               {
-                  $pUsers[$pSession] = array();
-                  $pUsers[$pSession]['jabber'] = $a;
-                  $pUsers[$pSession]['timeClient'] = $_time;
-               }
-               else
-               {
-                  unset($a);
-               }
-               break;
-            }
-            session_write_close();
-         }
-      }
-   }
-
-   function close($pUser)
-   {
-      global $users;
-      $users[$pUser]['jabber']->disconnect();
-      unset($users[$pUser]);
-   }
-
-   function readSocket(&$pUsers, $pSession)
-   {
-      global $send;
-      $sessionpath = explode(';', session_save_path());
-      foreach ( $sessionpath as $path )
-      {
-         $path = ( strrpos($path, '/') == strlen($path) - 1 ) ? $path : $path . '/';
-
-         if ( file_exists($path . 'sess_' . $pSession) )
-         {
-            session_id($pSession);
-
-            ob_start();
-            session_start();
-            ob_clean();
-            ob_end_flush();
-
-            $is_user = isset($_SESSION['phpgw_info']['instant_messenger']['user']) and isset($_SESSION['phpgw_info']['instant_messenger']['passwd']);
-            if ( $is_user )
-            {
-               $pUsers[$pSession]['timeClient'] = $_SESSION['phpgw_info']['instant_messenger']['timeClient'];
-               $_SESSION['phpgw_info']['instant_messenger']['timeServer'] = time();
-               
-					$readSocket = @$pUsers[$pSession]['jabber']->readSocket();
-               
-               $connection_close_timeout = strpos($readSocket, "<stream:error");
-               $connection_close_server = strpos($readSocket,"</stream:stream>");
-               
-               if ( ($readSocket !== false) && ($connection_close_timeout === false ) && ($connection_close_server === false ))
-               {
-                  $_SESSION['phpgw_info']['instant_messenger']['IM_disconnect'] = false;
-                  if ( !empty($readSocket) )
-                  {
-                     $_SESSION['phpgw_info']['instant_messenger']['socket']['in'] .= $readSocket;
-                  }
-
-						if ( $_SESSION['phpgw_info']['instant_messenger']['socket']['out'] )
-							foreach ( $_SESSION['phpgw_info']['instant_messenger']['socket']['out'] as $action => $value )
-							{
-								if ( $action === 'message' )
-								{
-									if ( !is_null($value) )
-									{
-										$pUsers[$pSession]['jabber']->writeSocket($value);
-										$_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] = NULL;
-									}
-								}
-								else if ( $action === 'vcard' )
-								{
-									if ( !empty($value) )
-									{
-										foreach ( $value as $key => $val )
-										{
-											$pUsers[$pSession]['jabber']->getVcard($val);
-											unset($_SESSION['phpgw_info']['instant_messenger']['socket']['out']['vcard'][$key]);
-										}
-									}
-								}
-								else
-								{
-									if ( method_exists($pUsers[$pSession]['jabber'], $action) )
-										if ( $value )
-											$pUsers[$pSession]['jabber']->$action($value);
-										else
-											$pUsers[$pSession]['jabber']->$action();
-									unset($_SESSION['phpgw_info']['instant_messenger']['socket']['out'][$action]);
-								}
-							}
-               }
-               else
-               {
-               	$_SESSION['phpgw_info']['instant_messenger']['IM_disconnect'] = true;
-               	close($pSession);               	
-               }
-               break;
-            }
-            else
-            {
-               close($pSession);
-            }
-            break;
-         }
-      }
-      session_write_close();
-   }
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/controller.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/controller.php	(revision 151)
+++ 	(revision )
@@ -1,103 +1,0 @@
-<?php
-	//	Explode action from cExecuteForm function
-	$cExecuteFormReturn = false;
-   $returnMode = $_REQUEST['returnMode'];
- 	if($_POST['_action']) {
- 		if($_FILES) {
- 			$count_files = $_POST['countFiles'];
-			$array_files = array();
- 			for($idx = 1; $idx <= $count_files; $idx++) {
- 				if($_FILES['file_'.$idx] && !$_FILES['file_'.$idx]['error'])
- 					$array_files[] = $_FILES['file_'.$idx];
- 			}
- 			$_POST['FILES'] = $array_files;
- 		}
- 		list($app,$class,$method) = explode('.',@$_POST['_action']);
- 		$cExecuteFormReturn = true;
- 	}
- 	//	Explode action from cExecute function
- 	else if($_GET['action'])
-   {
-      unset($_GET['returnMode']);
-		list($app,$class,$method) = explode('.',@$_GET['action']);
-   }
-	// NO ACTION
-	else
-		return $_SESSION['response'] = 'false';
-
-	// Load dinamically class file.
-	if($app == '$this')
-		$filename = 'inc/class.'.$class.'.inc.php';
-	else
-		$filename = '../'.$app.'/inc/class.'.$class.'.inc.php';
-
-	include_once($filename);
-
-	// Create new Object  (class loaded).
-	$obj = new $class;
-
-	// Prepare parameters for execution.
-	$params = array();
-
-	// If array $_POST is not null , the submit method is POST.
-	if($_POST) {
-		$params = $_POST;
-	}
-	// If array $_POST is null , and the array $_GET > 1, the submit method is GET.
-	else if(count($_GET) > 1)	{
-		array_shift($_GET);
-		$params = $_GET;
-	}
-
-	$result = array();
-
-
-	// if params is not empty, then class method with parameters.
-	if($params)
-		$result = $obj -> $method($params);
-	else
-		$result = $obj -> $method();
-
-	// Return result json string into xml object.
-	if(!$cExecuteFormReturn)
-   {
-      $dom = new DOMDocument;//('1.0', 'UTF-8');
-
-      if ( $returnMode == 'JSON')
-      {
-         $root = $dom->appendChild(new DOMElement('retorno'));
-         encode($result, 'encode');
-         $result = ( !is_object($result) && !is_array($result) ) ? $result : json_encode($result);
-
-         $root->appendChild($dom->createCDATASection($result));
-      }
-      else
-		{
-			$_SESSION['phpgw_info']['instant_messenger']['debug2'] = $result;
-			$dom->loadXML('<retorno>' . utf8_encode($result) . '</retorno>');
-		}
-
-      $dom->normalizeDocument();
-		$retorno = $dom->saveXML();
-      header('Pragma: anytextexeptno-cache', true);
-      header('Content-type: text/xml, charset=UTF-8');
-		print $retorno;
-   }
-	else
-		$_SESSION['response'] = $result;
-
-   function encode(&$item, $val = 'encode')
-   {
-      switch( gettype($item) )
-      {
-         case 'object' :
-                     $item = get_object_vars($item);
-                     encode($item);
-         break;
-         case 'array' :
-                     array_walk_recursive($item, 'encode');
-         break;
-         default : $item = utf8_encode($item);
-      }
-   }
-?>
Index: unk/instant_messenger/bkp/instant_messenger_64/index.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_64/index.php	(revision 151)
+++ 	(revision )
@@ -1,45 +1,0 @@
-<?php
-	/****************************************************\
-	 *													*
-	 * 	 			Im - Instant Messenger				*
-	 *													*
-	\****************************************************/
-	
-	$GLOBALS['phpgw_info']['flags'] = array(
-		'currentapp' => 'instant_messenger',
-		'im_version'	=> '0.2'
-	);
-	
-	include("../header.inc.php");
-    $im_version = $GLOBALS['phpgw_info']['flags']['im_version'];
-
-	// Template  
-	$template_1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
-	$template_1->set_file(Array('instant_messenger' => 'index.tpl'));
-	$template_1->set_block('instant_messenger','index');
-	$template_1->pfp('out','index');
-	
-	// Session
-	$_SESSION['phpgw_info']['instant_messenger']['user'] 			      	= $GLOBALS['phpgw_info']['user']['account_lid'];
-	$_SESSION['phpgw_info']['instant_messenger']['passwd'] 			      = $GLOBALS['phpgw_info']['user']['passwd'];
-	$_SESSION['phpgw_info']['instant_messenger']['name_jabber'] 	      = $GLOBALS['phpgw_info']['server']['name_jabber'];
-	$_SESSION['phpgw_info']['instant_messenger']['port_jabber'] 	      = $GLOBALS['phpgw_info']['server']['port_jabber'];
-	$_SESSION['phpgw_info']['instant_messenger']['resource_jabber']       = $GLOBALS['phpgw_info']['server']['resource_jabber'];
-
-	// Conf. Ldap
-	$_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']    = $GLOBALS['phpgw_info']['server']['server_ldap_jabber'];
-	$_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']   = $GLOBALS['phpgw_info']['server']['context_ldap_jabber'];
-	$_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']      = $GLOBALS['phpgw_info']['server']['user_ldap_jabber'];
-	$_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']  = $GLOBALS['phpgw_info']['server']['password_ldap_jabber'];	
-	$_SESSION['phpgw_info']['instant_messenger']['size_file_jabber']  	  = $GLOBALS['phpgw_info']['server']['size_file_jabber'];	
-	
-	$_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];
-	$_SESSION['phpgw_info']['instant_messenger']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];
-	$_SESSION['phpgw_info']['instant_messenger']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];
-	$_SESSION['phpgw_info']['instant_messenger']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user'];
-	$_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass'];	
-	$_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type'];
-
-	// Footer
-	$GLOBALS['phpgw']->common->phpgw_footer();
-?>
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BOOK/client.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BOOK/client.c	(revision 216)
+++ 	(revision )
@@ -1,22 +1,0 @@
-#include "unp.h"
-
-int main(int argc, char ** argv)
-{
-	int sockfd;
-	struct sockaddr_in servaddr;
-
-	if ( argc != 2 )
-		err_quit("you need use <IPaddress>");
-
-	sockfd = Socket(AF_INET, SOCK_STREAM, 0);
-
-	bzero(&servaddr, sizeof(servaddr));
-	servaddr.sin_family = AF_INET;
-	servaddr.sin_port = htons(SERV_PORT);
-	inet_pton(AF_INET, argv[1], &(servaddr.sin_addr));
-
-	connect(sockfd, (SA *) &(servaddr), sizeof(servaddr));
-
-	str_cli(stdin, sockfd);
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BOOK/server.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BOOK/server.c	(revision 216)
+++ 	(revision )
@@ -1,82 +1,0 @@
-#include "unp.h"
-
-int main(int argc, char ** argv)
-{
-	int maxfdp1,
-		listenfd,
-		connfd,
-		nready,
-		udpfd;
-	char mesg[MAXLINE];
-	pid_t childpid;
-	fd_set rset;
-	ssize_t n;
-	socklen_t clilen,
-			  len;
-	const int on = 1;
-	struct sockaddr_in cliaddr,
-					   servaddr;
-	void sig_chld(int);
-
-	listenfd = Socket(AF_INET, SOCK_STREAM, 0); /* create listening TCP socket */
-
-	bzero(&servaddr, sizeof(servaddr));
-	servaddr.sin_family = AF_INET;
-	servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
-	servaddr.sin_port = htons(SERV_PORT);
-
-	setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &(on), sizeof(on));
-	bind(listenfd, (SA *)&servaddr, sizeof(servaddr));
-
-	Listen(listenfd, LISTENQ);
-
-	udpfd = Socket(AF_INET, SOCK_DGRAM, 0); /* create UDP socket */
-
-	bzero(&servaddr, sizeof(servaddr));
-	servaddr.sin_family = AF_INET;
-	servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
-	servaddr.sin_port = htons(SERV_PORT);
-
-	bind(udpfd, (SA *)&servaddr, sizeof(servaddr));
-
-	signal(SIGCHLD, sig_chld);	/* must call waitpid() */
-
-	FD_ZERO(&(rset));
-	maxfdp1 = max(listenfd, udpfd) + 1;
-
-	for ( ; ; )
-	{
-		FD_SET(listenfd,&(rset));
-		FD_SET(udpfd,&(rset));
-
-		if ( (nready = select(maxfdp1, &(rset), NULL, NULL, NULL)) < 0 )
-		{
-			if ( errno == EINTR )
-				continue;	/* back to for() */
-			else
-				err_sys("select error");
-		}
-		if ( FD_ISSET(listenfd, &(rset)) )
-		{
-			len = sizeof(cliaddr);
-			connfd = accept(listenfd, (SA *) &(cliaddr), &(len));
-
-			if ( childpid = fork() == 0 )	/* child process */
-			{
-				close(listenfd);			/* close listening socket */
-				str_echo(connfd);			/* process request */
-				exit(0);
-			}
-			close(connfd);					/* parent closes connected socket */
-		}
-		if ( FD_ISSET(udpfd, &(rset)) )
-		{
-			len = sizeof(cliaddr);
-			n = recvfrom(udpfd, mesg, MAXLINE, 0, (SA *) &(cliaddr), &(len));
-			sendto(udpfd, mesg, n, 0, (SA *) &(cliaddr), len);
-		}
-
-	}
-
-	return 0;
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BOOK/unp.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BOOK/unp.h	(revision 216)
+++ 	(revision )
@@ -1,567 +1,0 @@
-#include "config.h"
-
-#include <sys/types.h>		/* basic system data type */
-#include <sys/socket.h>		/* basic socket definitions */
-#include <sys/time.h>		/* timeval{} for select() */
-#include <time.h>			/* timespec{} for pselect() */
-#include <netinet/in.h>		/* sockaddr_in{} and other Internet defns */
-#include <arpa/inet.h>		/* inet(3) functions */
-#include <errno.h>
-#include <fcntl.h>			/* for nonblocking */
-#include <netdb.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>		/* for S_xxx file mode constants */
-#include <sys/uio.h>		/* for iovec{} and readv/writev */
-#include <unistd.h>
-#include <sys/wait.h>
-#include <sys/un.h>			/* for Unix domain sockets */
-
-#ifdef	HAVE_SYS_SELECT_H
-	#include <sys/select.h>	/* for convenience */
-#endif
-
-#ifdef	HAVE_POLL_H
-	#include <poll.h>	/* for convenience */
-#endif
-
-#ifdef	HAVE_STRINGS_H
-	#include <strings.h>	/* for convenience */
-#endif
-
-/* Three headers are normally needed for socket/file ioctl's:
- * <sys/ioctl.h>, <sys/filio.h> and <sys/sockio.h>.
- */
-#ifdef HAVE_SYS_IOCTL_H
-	#include <sys/ioctl.h>
-#endif
-
-#ifdef HAVE_SYS_FILIO_H
-	#include <sys/filio.h>
-#endif
-
-#ifdef HAVE_SYS_SOCKIO_H
-	#include <sys/sockio.h>
-#endif
-
-#ifdef HAVE_PTHREAD_H
-	#include <pthread.h>
-#endif
-
-/* OSF/1 actually disable recv() and send() in <sys/socket.h> */
-#ifdef __osf__
-	#undef recv
-	#undef send
-	#define recv(a,b,c,d)	recvfrom(a,b,c,d,0,0)
-	#define send(a,b,c,d)	sendto(a,b,c,d,0,0)
-#endif
-
-#ifndef INADDR_NOME
-	#define INADDR_NOME 0xffffffff	/* should have been in <netinet/in.h> */
-#endif
-
-#ifndef SHUT_RD				/* these three Posix.1g names are quite now */
-	#define SHUT_RD		0	/* shutdown for reading */
-	#define SHUT_WR		1	/* shutdown for writing */
-	#define SHUT_RDWR	2	/* shutdown for reading and writing */
-#endif
-
-#ifndef INET_ADDRSTRLEN
-	#define INETADDRSTRLEN 16	/* "ddd.ddd.ddd.ddd\0" 1234567890123456 */
-#endif
-
-/* Define following even if IPv6 not supported, so we can always allocate
- * an adequately-sized buffer, without #ifdefs in the code.
- */
-#ifndef	INET6_ADDRSTRLEN
-	#define INET6_ADDRSTRLEN 46	/* max size of IPv6 address string:
-								 * "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx" or
-								 * "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:ddd.ddd.ddd.ddd\0"
-								 * 1234567890123456789012345678901234567890123456
-								 */
-#endif
-
-/* Define bzero() as a macro if it's not standard C libary. */
-#ifndef HAVE_BZERO
-	#define bzero(ptr,n)	memset(ptr,0,n)
-#endif
-
-/* Older resolvers do not have gethostbyname2() */
-#ifndef HAVE_GETHOSTBYNAME2
-	#define gethostbyname2(host,family)		gethostbyname((host))
-#endif
-
-/* The structure returned by recvfrom_frags() */
-//struct in_pktinfo
-//{
-//	struct in_addr ipi_addr;	/* dst IPv4 address */
-//	int ipi_ifindex;			/* received interface index */
-//}
-
-/* We need the newer CMSG_LEN() and CMSG_SPACE() macros, but few
- * implementions support them today. These two macros really need
- * an ALIGN() macro, but each implementation does this differently. */
-#ifndef CMSG_LEN
-	#define CMSG_LEN(size)		(sizeof(struct cmsghdr) + (size))
-#endif
-#ifndef CMSG_SPACE
-	#define CMSG_SPACE(size)	(sizeof(struct cmsghdr) + (size))
-#endif
-
-/* Posix.1g requires the SUN_LEN() macro but not all implementations
- * define it (yet). Note that this 4.4BSD macro works regardless
- * whether there is a length field or not
- */
-#ifndef SUN_LEN
-	#define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
-#endif
-
-/* Posix.1g remanes "Unix domain" as "local IPC". But
- * not all systems define AF_LOCAL and PF_LOCAL (yet).
- */
-#ifndef AF_LOCAL
-	#define AF_LOCAL	AF_UNIX
-#endif
-#ifndef PF_LOCAL
-	#define PF_LOCAL	PF_UNIX
-#endif
-
-/* Posix.1g require that an include of <poll.h> define INFTIM, but
- * many systems still define it in <sys/stropts.h>. We don't want
- * to include all the streams stuff if it's not needed, so we just
- * define INFTIM here. This is the standard value, but there's no
- * guarantee it is -1.
- */
-#ifndef INFTIM
-	#define INFTIM (-1)			/* infinite poll timeout */
-	#ifdef HAVE_POLL_H
-		#define INFTIM_UNPH		/* tell unpxti.h we defined it */
-	#endif
-#endif
-
-/* Following could be derived from SOMAXCONN in <sys/socket.h>, but many
- * kernels still #define it as 5, while actually supporting many more
- */
-#define LISTENQ		1024	/* 2nd argument to listen() */
-
-/* Miscellaneous constants */
-#define MAXLINE		4096	/* max text line length */
-#define MAXSOCKADDR	128		/* max socket address struct size */
-#define BUFFSIZE	8192	/* buffer size for reads and writes */
-
-/* Define some port number that can be used for client-servers */
-#define SERV_PORT		9877			/* TCP and UDP client-servers */
-#define SERV_PORT_STR	"9877"			/* TCP and UDP client-servers */
-#define UNIXSTR_PATH	"/tmp/unix.str"	/* Unix domain stream cli-serv */
-#define UNIXDG_PATH	"/tmp/unix.dg"	/* Unix domain datagram cli-serv */
-
-/* Following shortens all the type casts of point arguments */
-#define SA struct sockaddr
-#define FILE_MODE	(S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)		/* default file access permissions for new files */
-#define DIR_MODE	(FILE_MODE | S_IXUSR | S_IXGRP | S_IXOTH)	/* default permissions for new directories */
-
-typedef void Sigfunc(int);	/* for signal handlers */
-
-#define min(a,b)	((a) < (b) ? (a) : (b))
-#define max(a,b)	((a) > (b) ? (a) : (b))
-
-#include <stdarg.h>		/* ANSI C hearder file */
-#include <syslog.h>		/* for syslog() */
-
-int daemon_proc;
-
-static void err_doit(int, int, const char *, va_list);
-
-void err_ret(const char * fmt, ...)
-{
-	va_list ap;
-	va_start(ap, fmt);
-	err_doit(1, LOG_INFO, fmt, ap);
-	va_end(ap);
-	return;
-}
-
-int err_sys(const char * fmt, ...)
-{
-	va_list ap;
-	va_start(ap, fmt);
-	err_doit(1, LOG_INFO, fmt, ap);
-	va_end(ap);
-	exit(1);
-}
-
-void err_dump(const char * fmt, ...)
-{
-	va_list ap;
-	va_start(ap, fmt);
-	err_doit(1, LOG_INFO, fmt, ap);
-	va_end(ap);
-	abort();
-	exit(1);
-}
-
-void err_msg(const char * fmt, ...)
-{
-	va_list ap;
-	va_start(ap, fmt);
-	err_doit(1, LOG_INFO, fmt, ap);
-	va_end(ap);
-	return;
-}
-
-void err_quit(const char * fmt, ...)
-{
-	va_list ap;
-	va_start(ap, fmt);
-	err_doit(1, LOG_INFO, fmt, ap);
-	va_end(ap);
-	exit(1);
-}
-
-static void err_doit(int errnoflag, int level, const char * fmt, va_list ap)
-{
-	int errno_save,
-		n;
-	char buf[MAXLINE + 1];
-
-	errno_save = errno;
-	#ifdef HAVE_VSNPRINTF
-		vsnprintf(buf, MAXLINE, fmt, ap);
-	#else
-		vsprintf(buf, fmt, ap);
-	#endif
-	n = strlen(buf);
-	if ( errnoflag )
-		snprintf(buf + n, MAXLINE - n, ": %s", strerror(errno_save));
-	else
-	{
-		fflush(stdout);
-		fputs(buf, stderr);
-		fflush(stderr);
-	}
-	return;
-}
-
-int Socket(int family, int type, int protocol)
-{
-	int n;
-	if ( (n = socket(family, type, protocol)) < 0 )
-		err_sys("socket error");
-	return(n);
-}
-
-void Listen(int fd, int backlog)
-{
-	char * ptr;
-	/* can override 2nd argument with environment variable */
-	if ( (ptr = getenv("LISTENQ")) != NULL )
-		backlog = atoi(ptr);
-	if ( listen(fd, backlog) < 0 )
-		err_sys("listen error");
-}
-
-/* Read 'n' bytes from a descriptor. */
-ssize_t readn(int fd, void * vptr, size_t n)
-{
-	size_t	nleft;
-	ssize_t	nread;
-	char	* ptr;
-
-	ptr = vptr;
-	nleft = n;
-	while ( nleft > 0 )
-	{
-		if ( (nleft = read(fd, ptr, nleft)) < 0 )
-		{
-			if ( errno == EINTR )
-				nread = 0; /* and call read() again */
-			else
-				return (-1);
-		}
-		else if ( nread == 0 )
-			break; /* EOF */
-
-		nleft -= nread;
-		ptr += nread;
-	}
-	return (n - nleft); /* return >= 0 */
-}
-
-/* Write 'n' bytes to a descriptor. */
-ssize_t writen(int fd, const void *(vptr), size_t n)
-{
-	size_t	nleft;
-	ssize_t	nwritten;
-	const char * ptr;
-
-	ptr = vptr;
-	nleft = n;
-	while ( nleft > 0 )
-	{
-		if ( (nwritten = write(fd, ptr, nleft)) <= 0 )
-		{
-			if ( errno == EINTR )
-				nwritten = 0; /*and call write() again */
-			else
-				return (-1); /* error */
-		}
-
-		nleft -= nwritten;
-		ptr += nwritten;
-	}
-	return (n);
-}
-
-ssize_t readline(int fd, void *(vptr), size_t maxlen)
-{
-	size_t  n,
-			rc;
-	char c,
-		 * ptr;
-
-	ptr = vptr;
-	for ( n = 1; n < maxlen; n++ )
-	{
-		again:
-			if ( (rc = read(fd, &(c), 1)) == 1 )
-			{
-				*(ptr)++ = c;
-				if ( c == '\n' )
-					break; /* newline is stored, like fgets() */
-			}
-			else if ( rc == 0 )
-			{
-				if ( n == 1 )
-					return(0); /* EOF, no data read */
-				else
-					break; /* EOF, some data read */
-			}
-			else
-			{
-				if ( errno == EINTR )
-					goto again;
-				return(-1); /* error, errno set by read() */
-			}
-	}
-
-	*(ptr) = 0; /* null terminate like fgets() */
-	return(n);
-}
-
-char * gf_time(void)
-{
-	struct timeval tv;
-	static char str[30];
-	char * ptr;
-
-	if ( gettimeofday(&tv, NULL) < 0 )
-		err_sys("gettimeofday error");
-
-	ptr = ctime(&tv.tv_sec);
-	strcpy(str, &ptr[11]);
-	snprintf(str + 8, sizeof(str) - 8, ".%06d", tv.tv_usec);
-	return(str);
-}
-
-void str_echo(int sockfd)
-{
-	long arg1,
-		 arg2;
-	ssize_t n;
-	char line[MAXLINE];
-
-	for ( ; ; )
-	{
-		if ( (n = readline(sockfd, line, MAXLINE)) == 0 )
-			return; /* connection closed by other end */
-
-		/*if ( sscanf(line, "%ld%ld", &(arg1), &(arg2)) == 2 )
-			snprintf(line, sizeof(line), "%ld\n", arg1 + arg2);
-		else
-			snprintf(line, sizeof(line), "input error\n");
-
-		n = strlen(line);*/
-		writen(sockfd, line, n);
-	}
-}
-
-void str_cli(FILE * fp, int sockfd)
-{
-	int maxfdp1, stdineof, val;
-	ssize_t n, nwritten;
-	fd_set rset, wset;
-	char sendline[MAXLINE],
-		 recvline[MAXLINE];
-	char to[MAXLINE],
-		 fr[MAXLINE];
-	char * toiptr,
-		 * tooptr,
-		 * friptr,
-		 * froptr;
-
-	val = fcntl(sockfd, F_GETFL, 0);
-	fcntl(sockfd, F_SETFL, val| O_NONBLOCK);
-
-	val = fcntl(STDIN_FILENO, F_GETFL, 0);
-	fcntl(STDIN_FILENO, F_SETFL, val| O_NONBLOCK);
-
-	val = fcntl(STDOUT_FILENO, F_GETFL, 0);
-	fcntl(STDOUT_FILENO, F_SETFL, val| O_NONBLOCK);
-
-	toiptr = tooptr = to;
-	friptr = froptr = fr;
-	stdineof = 0;
-
-	maxfdp1 = max(max(STDIN_FILENO, STDOUT_FILENO), sockfd) + 1;
-	for ( ; ; )
-	{
-		FD_ZERO(&(rset));
-		FD_ZERO(&(wset));
-		if ( stdineof == 0 && toiptr < &to[MAXLINE] )
-			FD_SET(STDIN_FILENO, &(rset));	/* read from stdin */
-		if ( friptr < &fr[MAXLINE] )
-			FD_SET(sockfd, &(rset));		/* read from socket */
-		if ( tooptr != toiptr )
-			FD_SET(sockfd, &(wset));		/* data to wrtite to socket */
-		if ( froptr != friptr )
-			FD_SET(STDOUT_FILENO, &(wset));	/* data to wrtite to stdout */
-
-		select(maxfdp1, &(rset), &(wset), NULL, NULL);
-
-		if ( FD_ISSET(STDIN_FILENO, &(rset)) )
-		{
-			if ( (n = readline(STDIN_FILENO, toiptr, &to[MAXLINE] - toiptr)) < 0 )
-			{
-				if ( errno != EWOULDBLOCK )
-					err_sys("read error on stdin");
-			}
-			else if ( n == 0 )
-			{
-				fprintf(stderr, "%s: EOF on stdin\n", gf_time());
-				stdineof = 1;	/* all done with stdin */
-				if ( tooptr == toiptr )
-					shutdown(sockfd, SHUT_WR);	/* send FIN */
-			}
-			else
-			{
-				fprintf(stderr, "%s: read %d bytes from socket\n", gf_time(), n);
-				toiptr += n;	/* # just read */
-				FD_SET(sockfd, &(wset));	/* try and write below */
-			}
-		}
-
-		if ( FD_ISSET(sockfd, &(rset)) )
-		{
-			if ( (n = readline(sockfd, friptr, &fr[MAXLINE] - friptr)) < 0 )
-			{
-				if ( errno != EWOULDBLOCK )
-					err_sys("read error on socket");
-			}
-			else if ( n == 0 )
-			{
-				fprintf(stderr, "%s: EOF on socket\n", gf_time());
-				if ( stdineof )
-					return;	/* normal termination */
-				else
-					err_quit("server terminated prematurely");
-			}
-			else
-			{
-				fprintf(stderr, "%s: read %d bytes from socket\n", gf_time(), n);
-				friptr += n;	/* # just read */
-				FD_SET(STDOUT_FILENO, &(wset));	/* try and write below */
-			}
-		}
-
-		if ( FD_ISSET(STDOUT_FILENO, &(wset)) && ((n = friptr - froptr) < 0) )
-		{
-			if ( (nwritten = write(STDOUT_FILENO, froptr, n)) < 0 )
-			{
-				if ( errno != EWOULDBLOCK )
-					err_sys("write error to stdout");
-			}
-			else
-			{
-				fprintf(stderr, "%s: wrote %d bytes to stdout\n", gf_time(), nwritten);
-				froptr += nwritten;	/* # just written */
-				if ( froptr == friptr )
-					froptr = friptr = fr;	/* back to beginning of buffer */
-			}
-		}
-
-		if ( FD_ISSET(sockfd, &(wset)) && ((n = toiptr - tooptr) < 0) )
-		{
-			if ( (nwritten = write(sockfd, tooptr, n)) < 0 )
-			{
-				if ( errno != EWOULDBLOCK )
-					err_sys("write error to socket");
-			}
-			else
-			{
-				fprintf(stderr, "%s: wrote %d bytes to socket\n", gf_time(), nwritten);
-				tooptr += nwritten;	/* # just written */
-				if ( tooptr == toiptr )
-				{
-					tooptr = toiptr = to;	/* back to beginning of buffer */
-					if ( stdineof )
-						shutdown(sockfd, SHUT_WR);	/* send FIN */
-				}
-			}
-		}
-
-
-
-
-
-		/*
-		if ( FD_ISSET(fileno(fp), &(rset)) ) // input is readable
-		{
-			if ( fgets(sendline, MAXLINE, fp) == NULL )
-			{
-				stdineof == 1;
-				shutdown(sockfd, SHUT_WR); // send FIN
-				FD_CLR(fileno(fp), &(rset));
-				continue;
-			}
-			writen(sockfd, sendline, strlen(sendline));
-		}
-		*/
-	}
-}
-
-Sigfunc * signal(int signo, Sigfunc * func)
-{
-	struct sigaction act,
-					 oact;
-
-	act.sa_handler = func;
-	sigemptyset(&(act.sa_mask));
-	act.sa_flags = 0;
-	if ( signo == SIGALRM )
-	{
-		#ifdef SA_INTERRUPT
-			act.sa_flags |= SA_INTERRUPT;	/* SunOS 4.x */
-		#endif
-	}
-	else
-	{
-		#ifdef SA_RESTART
-			act.sa_flags |= SA_RESTART;		/* SVR4, 4.4BSD */
-		#endif
-	}
-	if ( sigaction(signo, &(act), &(oact)) < 0 )
-		return SIG_ERR;
-	return oact.sa_handler;
-}
-
-void sig_chld(int signo)
-{
-	pid_t pid;
-	int stat;
-
-	while ( (pid = waitpid(-1, &(stat), WNOHANG)) > 0 )
-		printf("child %d terminated\n", pid);
-	return;
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BOOK/config.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BOOK/config.h	(revision 216)
+++ 	(revision )
@@ -1,52 +1,0 @@
-#define HAVE_PTHREAD_H		1		/* <pthread.h> */
-#define HAVE_STRINGS_H		1		/* <strings.h> */
-
-//#define HAVE_SYS_FILIO_H	1		/* <sys/filio.h> */
-#define HAVE_SYS_IOCTL_H	1		/* <sys/ioctl.h> */
-#define HAVE_SYS_SELECT_H	1		/* <sys/select.h> */
-//#define HAVE_SYS_SOCKIO_H	1		/* <sys/sockio.h> */
-#define HAVE_SYS_SYSCTL_H	1		/* <sys/sysctl.h> */
-#define HAVE_SYS_TIME_H		1		/* <sys/time.h> */
-
-/* Define if we can include <time.h> with <sys/time.h> */
-#define TIME_WITH_SYS_TIME	1
-
-/* Define the following if the function is provided */
-#define HAVE_BZERO			1
-#define HAVE_GETHOSTBYNAME	1
-#define HAVE_VSNPRINTF		1
-
-/* Define the following if the function prototype is in a header */
-#define HAVE_GETHOSTNAME_PROTO	1	/* <unistd.h> */
-#define HAVE_GETRUSAGE_PROTO	1	/* <sys/resource.h> */
-#define HAVE_HSTRERROR_PROTO	1	/* <netdb.h> */
-#define HAVE_INET_ATON_PROTO	1	/* <arpa/inet.h> */
-#define HAVE_INET_PTON_PROTO	1	/* <arpa/inet.h> */
-#define HAVE_SNPRINTF_PROTO		1	/* <stdio.h> */
-
-/* Define the following if the strutured is defined */
-#define HAVE_SOCKADDR_DL_STRUCT	1	/* <.h> */
-#define HAVE_TIMESPEC_STRUCT	1	/* <.h> */
-
-/* Define the following if the feature is defined */
-#define HAVE_SOCKADDR_SA_LEN	1	/* sockadr{} has sa_len */
-#define HAVE_MSGHDR_MSG_CONTROL	1	/* msghdr{} has msg_control member */
-
-/* Define the following to the appropriate datatype, if necessary */
-//#define uint8_t	unsigned char		/* <sys/type.h> */
-//#define uint16_t	unsigned short		/* <sys/type.h> */
-//#define uint32_t	unsigned int		/* <sys/type.h> */
-
-/* socklen_t should be typedef'd as uint32_t, but configure defines
- * it to be an unsigned int, as it is needed early in the compile
- * process, sometimes before some implementations define uint32_t. */
-//#define socklen_t	unsigned int	/* <sys/socket.h> */
-//#define sa_family_t	SA_FAMILY_T		/* <sys/socket.h> */
-//#define SA_FAMILY_T	uint8_t
-
-/* Define the following, if system suports the feature */
-#define IPV4		1	/* IPv4, uppercase V name */
-#define IPv4		1	/* IPv4, lowercase V name */
-#define UNIXDOMAIN	1	/* Unix domain sockets */
-#define UNIXdomain	1	/* Unix domain sockets */
-#define MCAST		1	/* multicasting support */
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_27092007.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_27092007.c	(revision 216)
+++ 	(revision )
@@ -1,256 +1,0 @@
-#include "server.h"
-
-int main(int argc, char ** argv)
-{
-	/* variables to parse arguments */
-	extern int optind,
-			   optopt;
-	extern char * optarg;
-	char * log_file;
-	int c		= (int)NULL,
-		errflg	= (int)NULL,
-		verbose	= (int)NULL;
-
-	/* fd -> file descriptor */
-	int socket_server_fd	= (int)NULL,
-		socket_server_port	= (int)NULL,
-		socket_accept_fd	= (int)NULL,
-		sockaddr_in_size	= sizeof(struct sockaddr_in),
-		err					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	struct client * clients = (struct client *) NULL,
-				  * current = (struct client *) NULL;
-
-	pthread_t threads;
-
-	/* clear screen */
-	system(__CLEAR_SCREEN__);
-
-	while ( (c = getopt(argc, argv, ":vp:")) != -1 )
-	{
-		switch ( c )
-		{
-			case 'p':
-				if ( socket_server_port = strtol(optarg, 0, 10) == 0 )
-				{
-					fprintf(stderr, "Option -%c requires a valid port and '%s' isn't valid\n", optopt, optarg);
-					++errflg;
-				}
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			case ':':
-				/* -f or -o without operand */
-				fprintf(stderr, "Option -%c requires an operand\n", optopt);
-				++errflg;
-				break;
-			case '?':
-				fprintf(stderr, "Unrecognized option: -%c\n", optopt);
-				++errflg;
-		}
-	}
-	if ( errflg )
-	{
-		fprintf(stderr, "usage: . . . \n\n");
-		exit(2);
-	}
-	//exit(0);
-
-	/*if ( argc != 2 || (socket_server_port = strtol(argv[1], 0, 10)) == 0 )
-		usage();*/
-
-	/* make a socket */
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	if ( !socket_server_port )
-		socket_server_port = __DEFAULT_OPEN_PORT__;
-
-	/* fill address struct */
-	server_addr.sin_addr.s_addr	= INADDR_ANY;
-	server_addr.sin_port		= htons(socket_server_port);
-	server_addr.sin_family		= AF_INET;
-	bzero(&(server_addr.sin_zero), 8);
-
-	if ( __DEBUG__  || verbose )
-		printf("\nBinding to port %d...\n", socket_server_port);
-
-	/* bind to a port */
-	if ( bind(socket_server_fd, (struct sockaddr *)&(server_addr), sizeof(server_addr)) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not connect to host\n");
-		exit(1);
-	}
-
-	/* get port number */
-	getsockname(socket_server_fd, (struct sockaddr *)&(server_addr), (socklen_t *) &(sockaddr_in_size));
-	if ( __DEBUG__  || verbose )
-	{
-		printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-		printf("Server\n\
-				sin_family        = %d\n\
-				sin_addr.s_addr   = %d\n\
-				sin_port          = %d\n"
-				, server_addr.sin_family
-				, server_addr.sin_addr.s_addr
-				, ntohs(server_addr.sin_port)
-			  );
-		printf("\nMaking a listen queue of %d elements", __QUEUE_SIZE__);
-	}
-
-	/* establish listen queue */
-	if ( listen(socket_server_fd, __QUEUE_SIZE__) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		if ( __DEBUG__  || verbose )
-			puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &(accept_addr), (socklen_t *) &(sockaddr_in_size));
-		fcntl(socket_accept_fd, F_SETFL, fcntl(socket_accept_fd, F_GETFL, 0) | O_NDELAY);
-
-		if ( socket_accept_fd > -1 )
-		{
-			if ( clients == (struct client *) NULL )
-				current = clients;
-			else
-				while ( (current = clients->next) != (struct client *) NULL );
-
-			current				= (struct client *) malloc(sizeof(struct client));
-			current->next		= (struct client *) NULL;
-			current->fd			= socket_accept_fd;
-			current->sockaddr	= accept_addr;
-			current->last		= time(NULL);
-
-			pthread_create(&(threads), NULL, handler, (void *) current);
-		}
-		puts("jah era #5");
-	}
-	pthread_exit(NULL);
-}
-
-void * handler(void * pClient)
-{
-    char pBuffer[__BUFFER_SIZE__];
-    struct client * client = (struct client *) pClient;
-    int i = 0, err;
-	time_t last;
-
-	char ip[46];
-	unsigned short port;
-	inet_ntop(AF_INET, &(client->sockaddr.sin_addr), ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-	//fcntl( client->fd, F_SETFL, fcntl( client->fd, F_GETFL ) & ~O_NONBLOCK );
-	//printf(":::client %d\n\n\n", fcntl( client->fd, F_GETFL, 0));
-	//printf(":::client %d\n\n\n", fcntl( client->fd, F_SETFL, fcntl( client->fd, F_GETFL ) & ~O_NONBLOCK ));
-	/*---------------------------------------------------*/
-
-	int jabber_fd		= (int)NULL,
-		jabber_port		= (int)NULL,
-		jabber_error	= (int)NULL;
-
-	struct sockaddr_in jabber_addr;
-
-	jabber_port = __DEFAULT_JABBER_PORT__;
-	//jabber_port = strtol(__DEFAULT_JABBER_PORT__, 0, 10);
-	jabber_fd = socket(AF_INET, SOCK_STREAM, 0);
-	fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | O_NDELAY);
-
-	jabber_addr.sin_family = AF_INET;
-	inet_aton(__DEFAULT_JABBER_IP__, &jabber_addr.sin_addr);
-	jabber_addr.sin_port = htons(jabber_port);
-
-	jabber_error = connect(jabber_fd, (struct sockaddr *) &(jabber_addr), sizeof(jabber_addr));
-
-	last = time(NULL);
-	//while ( (time(NULL) - last) < 60 )
-	//{
-		/* read from client */
-	//	read(client->fd, pBuffer, __BUFFER_SIZE__);
-	//	printf("\n\n--------\n\nread from client:\n%s\n\n------------\n\n", pBuffer);
-		/* write in the jabber service */
-	//	write(jabber_fd, pBuffer, strlen(pBuffer));
-	//	sleep(1);
-		/* read from jabber service */
-	//	read(jabber_fd, pBuffer, __BUFFER_SIZE__);
-	//	printf("\n\n--------\n\nread from jabber:\n%s\n\n------------\n\n", pBuffer);
-		/* write in the client */
-	//	write(client->fd, pBuffer, strlen(pBuffer));
-	//}
-
-	int optval = 1;
-	socklen_t optlen = sizeof(optval);
-	if ( setsockopt(client->fd, SOL_SOCKET, SO_KEEPALIVE, &(optval), optlen ) )
-	{
-		puts("asdgsdfgsdfg");
-		exit(1);
-	}
-
-	int retval, ttlval, rbuf, len;
-	while ( (time(NULL) - last) < 20 )
-	{
-		printf("\n\n#################\n%d\n", getsockopt(client->fd, SOL_SOCKET, SO_KEEPALIVE, &optval, NULL));
-		printf("%d\n#######################\n\n", optval );
-		bzero(pBuffer, __BUFFER_SIZE__);
-		/* read from client */
-		printf("\n\n--------\nread from client...\n");
-		printf("error: %d\n", read(client->fd, pBuffer, __BUFFER_SIZE__));
-		printf("read from client:\n%s\n\n------------\n\n", pBuffer);
-
-		/* write in the jabber service */
-		printf("write in the jabber...\n");
-		//write(jabber_fd, pBuffer, strlen(pBuffer));
-		printf("send to jabber %d", sendto(jabber_fd, pBuffer, strlen(pBuffer), MSG_CONFIRM, 0,0));
-
-		//while ( (time(NULL) - last) < 5 );
-
-		bzero(pBuffer, __BUFFER_SIZE__);
-		/* read from jabber service */
-		printf("\n\n--------\nread from jabber...\n");
-		printf("error: %d\n", read(jabber_fd, pBuffer, __BUFFER_SIZE__));
-		printf("read from jabber:\n%s\n\n------------\n\n", pBuffer);
-
-		/* write in the client */
-		printf("write in the client...\n");
-		write(client->fd, pBuffer, strlen(pBuffer));
-
-		//printf("buffer limpo: %s\n\n----------------\n\n", pBuffer);
-		sleep(1);
-	}
-
-    if ( close(jabber_fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close jabber socket\n");
-        return 0;
-    }
-	/*---------------------------------------------------*/
-    if ( close(client->fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/client2.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/client2.c	(revision 216)
+++ 	(revision )
@@ -1,55 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <unistd.h>
-#include <fcntl.h> 
-
-int main()
-{
-  register int s;
-  register int bytes;
-  struct sockaddr_in sa;
-  //char buffer[BUFSIZ+1];
-  int status = 1;
-  char * buffer = malloc(BUFSIZ),//(char)NULL;
-		 * xml_connect = {"<?xml version='1.0' encoding='UTF-8'?><stream:stream to='localhost' xmlns='jabber:client'xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"};
-  
-  //fcntl(O_NONBLOCK, F_SETFL, 0);
-  //fcntl(O_ASYNC, F_SETFL, 1);
-  if ( (s = socket(PF_INET, SOCK_STREAM, 0)) < 0 )
-  {
-    perror("socket");
-    return 1;
-  }
-
-  bzero(&sa, sizeof sa);
-
-  sa.sin_family = AF_INET;
-  sa.sin_port = htons(5222);
-  sa.sin_addr.s_addr = htonl((((((127 << 8) | 0) << 8) | 0) << 8) | 1);
-
-  //fcntl(O_NONBLOCK, F_SETFL, 0);
-  //fcntl(O_ASYNC, F_SETFL, 1);
-  if ( connect(s, (struct sockaddr *)&sa, sizeof sa) < 0 )
-  {
-    perror("connect");
-    close(s);
-    return 2;
-  }
-  
-  printf("::: %d\n\n\n", fcntl( s, F_SETFL, fcntl( s, F_GETFL ) & ~O_NONBLOCK ));
-
-  write(s, xml_connect, sizeof(xml_connect)-1);
-
-  while ((bytes = read(s, buffer, 4096)) > 0)
-  //bytes = read(s, buffer, 1);//BUFSIZ);
-  printf("%s", buffer);
-
-  close(s);
-  return 0;
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/client_tls.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/client_tls.c	(revision 216)
+++ 	(revision )
@@ -1,240 +1,0 @@
-/*#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-*/
-/* define HOME to be dir for key and certificate files... */
-//#define HOME "/usr/local/ssl/"
-/* Make these what you want for certificate & key files */
-//#define CERT_FILE "mycert.pem"
-//#define KEY_FILE  "mycert.pem"
-
-/*Cipher list to be used*/
-//#define CIPHER_LIST "RC4-MD5"
-
-/*Trusted CAs location*/
-//#define CA_FILE CERT_FILE
-//#define CA_DIR  NULL
-
-/*Password for the key file*/
-//#define KEY_PASSWD ""
-
-//#define IP "im.celepar.parana"
-
-//#define PORT "5222"
-
-#include "server.h"
-
-
-int main(void)
-{
-int socketfd, nHostPort;
-   int err;
-   char buff[32];
-struct sockaddr_in socketaddr;
-
-/*SSL PART*/
-SSL_METHOD *meth;
-SSL_CTX  *ctx;
-SSL  *myssl;
-/*SSL PART*/
-
-   /* if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-    {
-       printf("\n<port>\n\n");
-       printf("\ncould not make a socket\n");
-       return 0;
-    }*/
-
-   socketfd=socket(AF_INET,SOCK_STREAM,0);
-
-socketaddr.sin_family=AF_INET;
-inet_aton("127.0.0.1", &socketaddr.sin_addr);
-socketaddr.sin_port=htons(8888);
-
-/* Connect to the server, TCP/IP layer,*/
-   err=connect(socketfd,(struct sockaddr*)&socketaddr,sizeof(socketaddr));
-   if(err<0){
-      printf("Socket returned error #%d,program terminated\n", err);
-      exit(0);
-   }
-
-   /* SSL Part*/
-	OpenSSL_add_all_algorithms();
-SSL_library_init();
-SSL_load_error_strings();
-
-
-   meth=TLSv1_client_method();
-  
-   ctx=SSL_CTX_new(meth);
-   if (!ctx) {
-    printf("Error creating the context.\n");
-    exit(0);
-}
-
-/*
-   if (SSL_CTX_set_cipher_list(ctx,CIPHER_LIST) <= 0) {
-printf("Error setting the cipher list.\n");
-exit(0);
-}
-*/
-   /*Indicate the certificate file to be used*/
-  /* if (SSL_CTX_use_certificate_file(ctx,CERT_FILE, SSL_FILETYPE_PEM) <= 0) {
-   printf("Error setting the certificate file.\n");
-   exit(0);
-}*/
-
-
-
-/*Load the password for the Private Key*/
-   //SSL_CTX_set_default_passwd_cb_userdata(ctx,KEY_PASSWD);
-
-
-/*Indicate the key file to be used*/
-/*if (SSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM) <= 0) {
-printf("Error setting the key file.\n");
-exit(0);
-}*/
-
-/*Make sure the key and certificate file match*/
-/*if (!SSL_CTX_check_private_key(ctx)) {
-    printf("Private key does not match the certificate public key\n");
-    exit(0);
-}*/
-
-/* Set the list of trusted CAs based on the file and/or directory provided*/
-/*   if(SSL_CTX_load_verify_locations(ctx,CA_FILE,CA_DIR)<1){
-            printf("Error setting verify location\n");
-            exit(0);
-   }*/
-
-/* Set for server verification*/
-//   SSL_CTX_set_verify(ctx,SSL_VERIFY_PEER,NULL);
-   SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-
-/*Create new ssl object*/
-myssl=SSL_new(ctx);
-
-   if(!myssl){
-      printf("Error creating SSL structure.\n");
-      exit(0);
-   }
-
-/*Bind the socket to the SSL structure*/
-SSL_set_fd(myssl,socketfd);
-
-/*Connect to the server, SSL layer.*/
-err=SSL_connect(myssl);
-      printf("SSL error #%d in accept,program terminated\n",err);
-   /*Check for error in connect.*/
-if (err<1) {
-
-      err=SSL_get_error(myssl,err);
-      printf("SSL error #%d in accept,program terminated\n",err);
-
-      if(err==5){printf("sockerrno is:\n");}
-
-      close(socketfd);
-      SSL_CTX_free(ctx);
-      exit(0);
-   }
-
-/*Print out connection details*/
-   printf("SSL connection on socket %x,Version: %s, Cipher: %s\n",
-      socketfd,
-   SSL_get_version(myssl),
-SSL_get_cipher(myssl));
-
-puts("_________OK_______________");
-exit(0);
-/*Send message to the server.*/
-   err=SSL_write(myssl,"Hello there!!!!",sizeof("Hello there!!!!")+1);
-   /*Check for error in write.*/
-   if(err<1){
-      err=SSL_get_error(myssl,err);
-      printf("Error #%d in write,program terminated\n",err);
-      /********************************/
-      /* If err=6 it means the client */
-      /* issued an SSL_shutdown. You  */
-      /* must respond with a shutdown */
-      /* to complete a graceful       */
-      /* shutdown                     */
-      /********************************/
-      if(err==6){
-         SSL_shutdown(myssl);
-      }
-      SSL_free(myssl);
-      close(socketfd);
-      SSL_CTX_free(ctx);
-      exit(0);
-   }
-
-/*Read servers response.*/
-   err = SSL_read (myssl, buff, sizeof(buff));
-   /*Check for error in read.*/
-   if(err<1){
-      err=SSL_get_error(myssl,err);
-      printf("Error #%d in read,program terminated\n",err);
-      /********************************/
-      /* If err=6 it means the client */
-      /* issued an SSL_shutdown. You  */
-      /* must respond with a shutdown */
-      /* to complete a graceful       */
-      /* shutdown                     */
-      /********************************/
-      if(err==6){
-         SSL_shutdown(myssl);
-      }
-      SSL_free(myssl);
-      close(socketfd);
-      SSL_CTX_free(ctx);
-      exit(0);
-   }
-   printf("Server said: %s\n",buff);
-   err=SSL_shutdown(myssl);
-	buff[0] = '\0';
-   SSL_read (myssl, buff, sizeof(buff));
-   /*********************************/
-   /* If err is equal to 0 you are  */
-   /* issuing the shutdown first.   */
-   /* If its 1 then you are         */
-   /* responding to a previously    */
-   /* issued shutdown message       */
-   /*********************************/
-   if(err==0)
-	{
-      err=SSL_shutdown(myssl);
-		buff[0] = '\0';
-	   SSL_read (myssl, buff, sizeof(buff));
-      if(err<1){
-         printf("#1 Error in shutdown\n");
-      }else if(err==1){
-         printf("Client exited gracefully\n");
-      }
-   }else if(err<0){
-         printf("Error in shutdown\n");
-
-   }else if(err==1){
-      printf("Client exited gracefully\n");
-   }
-   close(socketfd);
-SSL_free(myssl);
-SSL_CTX_free(ctx);
-   exit(0);
-
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_24092007.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_24092007.h	(revision 216)
+++ 	(revision )
@@ -1,66 +1,0 @@
-#include <fcntl.h>
-
-#include <netdb.h>
-#include <netinet/in.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-
-#include <pthread.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <unistd.h>
-
-#ifndef __CLIENTS__
-   #define __CLIENTS__ 10
-#endif
-
-#define SOCKET_ERROR        -1
-#define BUFFER_SIZE         4096
-#define MESSAGE             "This is the message I'm sending back and forth"
-#define QUEUE_SIZE          5
-
-/* Make these what you want for certificate & key files */
-#define CERT_FILE "mycert.pem"
-#define KEY_FILE  "mycert.pem"
-
-/*Cipher list to be used*/
-#define CIPHER_LIST "RC4-MD5"
-
-/*Trusted CAs location*/
-#define CA_FILE CERT_FILE
-#define CA_DIR NULL
-
-/*Password for the key file*/
-#define KEY_PASSWD ""
-
-#ifndef __CLEAR_SCREEN__
-	#define __CLEAR_SCREEN__ "clear"
-#endif
-
-struct client
-{
-	int fd;
-	struct sockaddr_in sockaddr;
-	pthread_t thread;
-	SSL * myssl;
-	time_t last;
-	struct client * next;
-};
-
-void * handler(void *);
-
-void usage (void)
-{
-	puts("usage: ./server <PORT>\n\n");
-	exit (-1);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/mycert.pem
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/mycert.pem	(revision 216)
+++ 	(revision )
@@ -1,34 +1,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXAIBAAKBgQDY8Tao9bylsCI6LVR8yWWO7HgfnQQCwh2cqigKHaSnuo5n67R5
-Cp7dAbYkVf1V7BZ+V3nn7eVQ2FXcb8BooBQY51J9j7Q75IT5AZRar1ket5pRnVJH
-THGpm8trQsP54gV14lRToI36zXFzxakR08B1iKRyyLUVwp8RvAUxS+kKHwIDAQAB
-AoGAFIbWTixaOi8tPeX2HYyM0HYtc4hOzdgCJ0WuXi6p2rj7KngR7nYDzBOSYWPF
-gbDB/BhYz4oh7YFatm3Yfc3PuNLbuTxaMuuevDl9Qy+0cVI3FL7ban5jgEXMZVB8
-rgIfxmem8Kj7Eu/WtF/UJiz+epJQgrndlNtWJTWSDHoLRqkCQQD3lf4kRwiJJrAS
-Hj48/FVaR+0nvcEia7YsF44is8Yd++BG1tKNZZaKpdhssVA/9Pd+8hC9Sqzji+Mc
-ZXdbAoh1AkEA4FCeoH/ZfWZ3KfCyGfK6T2SEf3tJB/bleFg1mdmv9INuk6HSKMKW
-62mhxAk4DjcYcoM8QSeAE4FN7aOwB3OVwwJAeL/7qf/G5vUqbDu5yQ6cJiLsRDSk
-rD/yIkD+vmgFWPxOHt6I5BNGv6oxCpnT9M1po801Ysy302aXRnMqKgXrPQJBAMYG
-ZgNK2rXZv1lHI/PEVLXCBzaDn/VoASw8sxUfGDbD0NqEAQP6xUEN/8EQYmwqN2rg
-cFEUjfyqKiGgX8Y0RAECQGTEkKvhDzgyyphx5JkYem7sAUI7gFGKZxJaVU+KkN5e
-pU4pgNiFUT0uTbfFzzOYQKeyVlBqGiv7rVn3BO3pfV4=
------END RSA PRIVATE KEY-----
------BEGIN CERTIFICATE-----
-MIIDKzCCApSgAwIBAgIJAOkSDgQDK1oGMA0GCSqGSIb3DQEBBQUAMG0xCzAJBgNV
-BAYTAkJSMQswCQYDVQQIEwJQUjEMMAoGA1UEBxMDQ1dCMQ0wCwYDVQQKEwRTQ0tU
-MQ0wCwYDVQQLEwRzY2t0MSUwIwYDVQQDExxlY2VsZXBhcjkxMTM3LmNlbGVwYXIu
-cGFyYW5hMB4XDTA3MDgwOTE2Mzg0MVoXDTA4MDgwODE2Mzg0MVowbTELMAkGA1UE
-BhMCQlIxCzAJBgNVBAgTAlBSMQwwCgYDVQQHEwNDV0IxDTALBgNVBAoTBFNDS1Qx
-DTALBgNVBAsTBHNja3QxJTAjBgNVBAMTHGVjZWxlcGFyOTExMzcuY2VsZXBhci5w
-YXJhbmEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANjxNqj1vKWwIjotVHzJ
-ZY7seB+dBALCHZyqKAodpKe6jmfrtHkKnt0BtiRV/VXsFn5Xeeft5VDYVdxvwGig
-FBjnUn2PtDvkhPkBlFqvWR63mlGdUkdMcamby2tCw/niBXXiVFOgjfrNcXPFqRHT
-wHWIpHLItRXCnxG8BTFL6QofAgMBAAGjgdIwgc8wHQYDVR0OBBYEFDqDGL/fTaKt
-NtkTuuzBet9mgcSOMIGfBgNVHSMEgZcwgZSAFDqDGL/fTaKtNtkTuuzBet9mgcSO
-oXGkbzBtMQswCQYDVQQGEwJCUjELMAkGA1UECBMCUFIxDDAKBgNVBAcTA0NXQjEN
-MAsGA1UEChMEU0NLVDENMAsGA1UECxMEc2NrdDElMCMGA1UEAxMcZWNlbGVwYXI5
-MTEzNy5jZWxlcGFyLnBhcmFuYYIJAOkSDgQDK1oGMAwGA1UdEwQFMAMBAf8wDQYJ
-KoZIhvcNAQEFBQADgYEAVHm/1+iybB3u48nP0NDIocPIhUC55e8iL9h0GOmvJalp
-IpCeIuefCTPCkrJHNMSVNqz6q3UfJLNXe91UdaAYvXEqWLP0mYUz5DWnzUYIIb/y
-W1BZ2WqcX8KZeJJgF/Gu0BJj5oGaf8LMVQoS58TiWgQABg1UTFHnHoXJhABQ1Qo=
------END CERTIFICATE-----
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_27092007.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_27092007.h	(revision 216)
+++ 	(revision )
@@ -1,102 +1,0 @@
-#include <fcntl.h>
-
-#include <linux/tcp.h>
-
-#include <netdb.h>
-#include <netinet/in.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-
-#include <pthread.h>
-
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <unistd.h>
-
-/* define max clients per child */
-#ifndef __CLIENTS__
-   #define __CLIENTS__ 100
-#endif
-
-/* define max clients waiting in the queue for connect */
-#ifndef __QUEUE_SIZE__
-	#define __QUEUE_SIZE__ 10
-#endif
-
-/* __SOCKET_ERROR__ must be -1, don't change this */
-#ifndef __SOCKET_ERROR__
-	#define __SOCKET_ERROR__ -1
-#endif
-
-/* open port when this server is activated */
-#ifndef __DEFAULT_OPEN_PORT__
-	#define __DEFAULT_OPEN_PORT__ 8888
-#endif
-
-/* ip of jabber service */
-#ifndef __DEFAULT_JABBER_PORT__
-	#define __DEFAULT_JABBER_PORT__ 5222
-#endif
-
-/* port to connect on jabber service */
-#ifndef __DEFAULT_JABBER_IP__
-	#define __DEFAULT_JABBER_IP__ "10.15.20.202"
-#endif
-
-/* the jabber's documentation recommends read the packages of socket with size of 4096 (2^12) KB */
-#ifndef __BUFFER_SIZE__
-	#define __BUFFER_SIZE__ 4096
-#endif
-
-#define MESSAGE			"This is the message I'm sending back and forth"
-
-/* Make these what you want for certificate & key files */
-#define CERT_FILE "mycert.pem"
-#define KEY_FILE  "mycert.pem"
-
-/*Cipher list to be used*/
-#define CIPHER_LIST "RC4-MD5"
-
-/*Trusted CAs location*/
-#define CA_FILE CERT_FILE
-#define CA_DIR NULL
-
-/*Password for the key file*/
-#define KEY_PASSWD ""
-
-#ifndef __CLEAR_SCREEN__
-	#define __CLEAR_SCREEN__ "clear"
-#endif
-
-/* 0 -> false; 1 -> true */
-#ifndef __DEBUG__
-	#define __DEBUG__ 0
-#endif
-
-struct client
-{
-	int fd;
-	struct sockaddr_in sockaddr;
-	pthread_t thread;
-	SSL * myssl;
-	time_t last;
-	struct client * next;
-};
-
-void * handler(void *);
-
-void usage (void)
-{
-	puts("usage: ./server <PORT>\n\n");
-	exit (-1);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/keepalive.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/keepalive.c	(revision 216)
+++ 	(revision )
@@ -1,51 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-int main(void);
-
-int main()
-{
-	int s;
-	int optval;
-	socklen_t optlen = sizeof(optval);
-
-	/* Create the socket */
-	if((s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
-		perror("socket()");
-		exit(EXIT_FAILURE);
-	}
-
-	/* Check the status for the keepalive option */
-	if(getsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen) < 0) {
-		perror("getsockopt()");
-		close(s);
-		exit(EXIT_FAILURE);
-	}
-	printf("SO_KEEPALIVE is %s\n", (optval ? "ON" : "OFF"));
-
-	/* Set the option active */
-	optval = 1;
-	optlen = sizeof(optval);
-	if(setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) {
-		perror("setsockopt()");
-		close(s);
-		exit(EXIT_FAILURE);
-	}
-	printf("SO_KEEPALIVE set on socket\n");
-
-	/* Check the status again */
-	if(getsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen) < 0) {
-		perror("getsockopt()");
-		close(s);
-		exit(EXIT_FAILURE);
-	}
-	printf("SO_KEEPALIVE is %s\n", (optval ? "ON" : "OFF"));
-
-	close(s);
-
-	exit(EXIT_SUCCESS);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server.c	(revision 216)
+++ 	(revision )
@@ -1,173 +1,0 @@
-#include "server.h"
-
-int main(int argc, char* argv[])
-{
-	/* handle to socket */
-	int hSocket = (int)NULL,
-		hServerSocket = (int)NULL;
-
-	int nAddressSize = sizeof(struct sockaddr_in);
-	int nHostPort = (int)NULL;
-	int err;
-
-	/* holds info about a machine */
-	struct hostent * pHostInfo = (struct hostent *)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in Address;
-
-	struct client * clients = (struct client *)NULL;
-	pthread_t threads;
-	//pthread_t clients;
-
-	system(__CLEAR_SCREEN__);
-
-	char * end = {"2"};
-	if ( argc != 2 || (nHostPort = strtol(argv[1], (char **)NULL, 10)) == 0 )
-	{
-		printf("\nCould not make a socket\n");
-		usage();
-	}
-
-	puts("\nStarting server");
-	puts("Making socket");
-
-	/* make a socket */
-	hServerSocket = socket(AF_INET, SOCK_STREAM, 0);
-	if ( hServerSocket == SOCKET_ERROR )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	/* fill address struct */
-	Address.sin_addr.s_addr = INADDR_ANY;
-	Address.sin_port = htons(nHostPort);
-	Address.sin_family = AF_INET;
-
-	printf("\nBinding to port %d...\n", nHostPort);
-
-	/* bind to a port */
-	if ( bind(hServerSocket, (struct sockaddr*)&Address, sizeof(Address)) == SOCKET_ERROR )
-	{
-		printf("\nCould not connect to host\n");
-		return 0;
-	}
-
-	/* get port number */
-	getsockname( hServerSocket, (struct sockaddr *) &Address,(socklen_t *)&nAddressSize);
-	printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", hServerSocket, ntohs(Address.sin_port));
-
-	printf("Server\n\
-			sin_family        = %d\n\
-			sin_addr.s_addr   = %d\n\
-			sin_port          = %d\n"
-			, Address.sin_family
-			, Address.sin_addr.s_addr
-			, ntohs(Address.sin_port)
-			);
-	printf("\nMaking a listen queue of %d elements", QUEUE_SIZE);
-
-	/* establish listen queue */
-	if ( listen(hServerSocket, QUEUE_SIZE) == SOCKET_ERROR )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		hSocket = accept(hServerSocket, (struct sockaddr*)&Address, (socklen_t *)&nAddressSize);
-
-		printf("%d\n\n", hSocket);
-
-		clients = (struct client *) malloc(sizeof(struct client));
-		clients->hSocket = hSocket;
-		clients->last = time(NULL);
-
-		pthread_create(&threads, NULL, handler, (void *)clients);
-		clients = (struct client *)NULL;
-		puts("jah era #5");
-	}
-	pthread_exit(NULL);
-}
-
-void * handler(void * pClient)
-{
-    char pBuffer[BUFFER_SIZE];
-    struct client * client = (struct client *)pClient;
-    int i = 0, err;
-	time_t last;
-
-    if ( close(client->hSocket) == SOCKET_ERROR )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-	printf("%d", client->hSocket);
-	//sin_addr.s_addr
-
-    fflush(stdin);
-    fflush(stdout);
-    pthread_exit(NULL);
-    /*
-	printf("\nGot a connection");
-
-	last = time(NULL);
-	while ( time(NULL) - client->last < 10 )
-	{
-		printf("%s\n\n", "teste");
-		sleep(1);
-	}
-
-	client->last = time(NULL);
-	*/
-
-    /**
-	 * number returned by read() and write() is the number of bytes
-     * read or written, with -1 being that an error occured
-     * write what we received back to the server
-	 **/
-
-    /*
-	strcpy(pBuffer, MESSAGE);
-    printf("\nSending \"%s\" to client\n",pBuffer);
-    write(client->hSocket, pBuffer, strlen(pBuffer)+1);
-	*/
-
-	/* read from socket into buffer */
-	/*read(client->hSocket, pBuffer, sizeof(pBuffer));
-
-	printf("Received from client: %s\n", pBuffer);
-
-    if ( strcmp(pBuffer, MESSAGE) == 0 )
-        printf("The messages match\n");
-    else
-        printf("Something was changed in the message\n");
-	*/
-
-    /*while (i < 10)
-    {
-		 printf("%d\n", i);
-		 usleep(1000000);
-		 i++;
-    }*/
-
-    /* close socket */
-    /*printf("\nClosing the socket");
-    if ( close(client->hSocket) == SOCKET_ERROR )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-	*/
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server.h	(revision 216)
+++ 	(revision )
@@ -1,101 +1,0 @@
-#include <fcntl.h>
-
-#include <netdb.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-
-#include <pthread.h>
-
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <unistd.h>
-
-/* define max clients per child */
-#ifndef __CLIENTS__
-   #define __CLIENTS__ 100
-#endif
-
-/* define max clients waiting in the queue for connect */
-#ifndef __QUEUE_SIZE__
-	#define __QUEUE_SIZE__ 10
-#endif
-
-/* __SOCKET_ERROR__ must be -1, don't change this */
-#ifndef __SOCKET_ERROR__
-	#define __SOCKET_ERROR__ -1
-#endif
-
-/* open port when this server is activated */
-#ifndef __DEFAULT_OPEN_PORT__
-	#define __DEFAULT_OPEN_PORT__ 8888
-#endif
-
-/* ip of jabber service */
-#ifndef __DEFAULT_JABBER_PORT__
-	#define __DEFAULT_JABBER_PORT__ 5222
-#endif
-
-/* port to connect on jabber service */
-#ifndef __DEFAULT_JABBER_IP__
-	#define __DEFAULT_JABBER_IP__ "10.15.20.219"
-#endif
-
-/* the jabber's documentation recommends read the packages of socket with size of 4096 (2^12) KB */
-#ifndef __BUFFER_SIZE__
-	#define __BUFFER_SIZE__ 4096
-#endif
-
-#define MESSAGE			"This is the message I'm sending back and forth"
-
-/* Make these what you want for certificate & key files */
-#define CERT_FILE "mycert.pem"
-#define KEY_FILE  "mycert.pem"
-
-/*Cipher list to be used*/
-#define CIPHER_LIST "RC4-MD5"
-
-/*Trusted CAs location*/
-#define CA_FILE CERT_FILE
-#define CA_DIR NULL
-
-/*Password for the key file*/
-#define KEY_PASSWD ""
-
-#ifndef __CLEAR_SCREEN__
-	#define __CLEAR_SCREEN__ "clear"
-#endif
-
-/* 0 -> false; 1 -> true */
-#ifndef __DEBUG__
-	#define __DEBUG__ 0
-#endif
-
-struct client
-{
-	int fd;
-	struct sockaddr_in sockaddr;
-	pthread_t thread;
-	SSL * myssl;
-	time_t last;
-	struct client * next;
-};
-
-void * handler(void *);
-
-void usage (void)
-{
-	puts("usage: ./server <PORT>\n\n");
-	exit (-1);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/signal.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/signal.c	(revision 216)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/* This flag controls termination of the main loop.  */
-volatile sig_atomic_t keep_going = 1;
-
-/* The signal handler just clears the flag and re-enables itself.  */
-	void 
-catch_alarm (int sig)
-{
-	keep_going = 0;
-	puts("ALARM");
-	signal (sig, catch_alarm);
-}
-
-	void 
-do_stuff (void)
-{
-	puts ("Doing stuff while waiting for alarm....");
-}
-
-	int
-main (void)
-{
-	/* Establish a handler for SIGALRM signals.  */
-	signal (SIGALRM, catch_alarm);
-
-	/* Set an alarm to go off in a little while.  */
-	alarm (2);
-
-	/* Check the flag once in a while to see when to quit.  */
-	while (keep_going)
-		do_stuff ();
-
-	return EXIT_SUCCESS;
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/client.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/client.c	(revision 216)
+++ 	(revision )
@@ -1,63 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#define IP "localhost"
-
-#define PORT "8888"
-
-int main(void)
-{
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-	int err,
-		i,
-		unit;
-	char buff[4096];
-	char * _xml = (char)NULL,
-		 * xml_connect = {"<?xml version='1.0' encoding='UTF-8'?><stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"};
-
-	_xml = (char *)malloc(sizeof(xml_connect));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	socketaddr.sin_addr.s_addr = INADDR_ANY;//inet_addr(IP);
-	socketaddr.sin_port = htons(nHostPort);
-
-	//printf("::: %d\n\n\n", fcntl( socketfd, F_SETFL, fcntl( socketfd, F_GETFL ) & ~O_NONBLOCK ));
-	//printf("::: %d\n\n\n", fcntl( socketfd, F_SETFL, fcntl( socketfd, F_GETFL ) & O_NONBLOCK ));
-
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	sprintf(_xml, xml_connect, "localhost");
-
-	write(socketfd, _xml, strlen(_xml));
-
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/client_tls.c_bkp2
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/client_tls.c_bkp2	(revision 216)
+++ 	(revision )
@@ -1,64 +1,0 @@
-/*#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-*/
-/* define HOME to be dir for key and certificate files... */
-//#define HOME "/usr/local/ssl/"
-/* Make these what you want for certificate & key files */
-//#define CERT_FILE "mycert.pem"
-//#define KEY_FILE  "mycert.pem"
-
-/*Cipher list to be used*/
-//#define CIPHER_LIST "RC4-MD5"
-
-/*Trusted CAs location*/
-//#define CA_FILE CERT_FILE
-//#define CA_DIR  NULL
-
-/*Password for the key file*/
-//#define KEY_PASSWD ""
-
-//#define IP "im.celepar.parana"
-
-//#define PORT "5222"
-
-#include "server.h"
-
-
-int main(void)
-{
-	int jabber_fd       = (int)NULL,
-		jabber_port     = (int)NULL,
-		jabber_error    = (int)NULL;
-
-	struct sockaddr_in jabber_addr;
-
-	jabber_port = __DEFAULT_JABBER_PORT__;
-	jabber_fd = socket(AF_INET, SOCK_STREAM, 0);
-
-	printf("Socket %d\n", jabber_fd);
-
-	jabber_addr.sin_family = AF_INET;
-	inet_aton(__DEFAULT_JABBER_IP__, &jabber_addr.sin_addr);
-	jabber_addr.sin_port = htons(jabber_port);
-
-	jabber_error = connect(jabber_fd, (struct sockaddr *) &(jabber_addr), sizeof(jabber_addr));
-	printf("Socket returned error #%d, ip = %s and port = %d, program terminated\n", jabber_error, __DEFAULT_JABBER_IP__, __DEFAULT_JABBER_PORT__);
-
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/proxy.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/proxy.c	(revision 216)
+++ 	(revision )
@@ -1,588 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <stdarg.h>
-#include <syslog.h>
-
-/* Buffer size, in bytes, used for copying in the Cat() function. */
-const size_t BUF_SIZE = 10240;
-
-/* Typedef for a signal handler function. */
-typedef void (*signal_handler_t) (int);
-
-/* Prototypes for functions in this file. */
-void ParseArgs (int argc, char *argv[], struct in_addr *ra,
-		unsigned short *rp, struct in_addr *la, unsigned short *lp);
-void Initialise (void);
-void sig_child (int signo);
-int CreateServerSocket (struct in_addr addr, unsigned short port);
-void Daemonise (void);
-void MainLoop (int listen_fd, struct in_addr rem_addr,
-		unsigned short rem_port);
-void Proxy (int server_fd, int client_fd);
-int AcceptClientConnection (int listen_fd);
-int ConnectToServer (struct in_addr addr, unsigned short port);
-void Cat (int in_fd, int out_fd);
-int NameToAddr (const char *name, struct in_addr *p_inaddr);
-int NameToPort (const char *name, unsigned short *port, const char *proto);
-#ifdef __GNUC__
-void quit (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-void pbomb (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-void hbomb (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-void quit (const char *fmt, ...);
-void pbomb (const char *fmt, ...);
-void hbomb (const char *fmt, ...);
-#endif
-void set_signal_handler (int signum, signal_handler_t sig_handler_func);
-
-/* Global variables */
-char g_program_name[100];       /* Initialised from argv[0] in ParseArgs() */
-
-	int
-main (int argc, char *argv[])
-{
-	struct in_addr remote_addr, local_addr;
-	unsigned short remote_port, local_port;
-	int listen_fd;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr,
-			&local_port);
-
-	Initialise ();
-
-	/* Create server socket before becoming a daemon so there is still a
-	 *      chance to print an error message. */
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if (listen_fd < 0)
-		pbomb ("Unable to create server socket");
-
-	Daemonise ();
-
-	MainLoop (listen_fd, remote_addr, remote_port);       /* never returns */
-
-	exit (EXIT_SUCCESS);
-}
-
-/* ParseArgs(): Parse the command line arguments to extract the remote and
- *  * local adresses and port numbers, ra, rp, la & lp.  Exit the program
- *   * gracefully upon error.
- *    */
-	void
-ParseArgs (int argc, char *argv[], struct in_addr *ra, unsigned short *rp,
-		struct in_addr *la, unsigned short *lp)
-{
-	/*
-	 *    * argv[0] = program name
-	 *       * argv[1] = remote_addr
-	 *          * argv[2] = remote_port
-	 *             * argv[3] = local_addr (optional)
-	 *                * argv[4] = local_port (optional)
-	 *                   */
-
-	char *p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1,
-			sizeof (g_program_name) - 1);
-
-	if ((argc < 3) || (argc > 5))
-	{
-		fprintf (stderr,
-				"usage: %s remote_addr remote_port [local_addr] [local_port]\n",
-				argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if (NameToAddr (argv[1], ra))
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if (NameToPort (argv[2], rp, "tcp"))
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if (argc < 4)
-		la->s_addr = htonl (INADDR_ANY);
-	else if (NameToAddr (argv[3], la))
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if (argc < 5)
-		memcpy (lp, rp, sizeof (*lp));
-	else if (NameToPort (argv[4], lp, "tcp"))
-		quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-/* Initialise(): Setup syslog, signal handlers, and other intialisation.
- *  */
-	void
-Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/");                  /* Change working directory to the root. */
-
-	umask (0);                    /* Clear our file mode creation mask */
-
-	set_signal_handler (SIGCHLD, sig_child);
-
-	signal (SIGPIPE, SIG_IGN);
-}
-
-/* sig_child(): Handles SIGCHLD from exiting child processes.
- *  */
-	void
-sig_child (int signo)
-{
-	pid_t pid;
-
-	(void) signo;                 /* suppress compiler warning */
-
-	puts("AKI....................");
-	for (;;)
-	{
-		pid = waitpid (WAIT_ANY, NULL, WNOHANG);
-
-		if (pid > 0)
-			syslog (LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		else
-			break;
-	}
-
-	if ((pid < 0) && (errno != ECHILD))
-		syslog (LOG_ERR, "waitpid(): %m"), exit (EXIT_FAILURE);
-
-	return;
-}
-
-/* CreateServerSocket(): Create a socket, bind it to the specified address
- *  * and port, and set it to listen for client connections.  Returns <0 on
- *   * failure to bind, bombs on error otherwise, returns the fd of the new
- *    * socket on success.
- *     */
-	int
-CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err, fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	/* Create a socket and get its descriptor. */
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if (fd < 0)
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	/* Set SO_REUSEADDR socket option */
-	if (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0)
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	/* Load a sa structure with the specified address and port */
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	/* Bind our socket to the address and port specified */
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	/* Tell socket to listen and queue up to 5 incoming connections. */
-	if (listen (fd, 5) < 0)
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-/* Daemonise(): Put the program in the background, set PPID=1, create a new
- *  * session and process group, without a controlling tty.
- *   */
-	void
-Daemonise (void)
-{
-	pid_t pid;
-
-	/* Close stdin, stdout & stderr */
-	/* TODO: open /dev/null and dup the fd to stdin, stdout & stderr
-	 *      close(STDIN_FILENO);
-	 *           close(STDOUT_FILENO);
-	 *                close(STDERR_FILENO);
-	 *                   */
-
-	syslog (LOG_INFO, "%s daemonising", g_program_name);
-
-	/* Fork the process to put it in the background. */
-
-	pid = fork ();
-	if (pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	/* parent terminates here, so shell thinks the command is done. */
-	if (pid)
-		exit (0);
-
-	syslog (LOG_INFO, "%s in background", g_program_name);
-
-	/* 1st child continues to run in the background with PPID=1 */
-
-	/* Become leader of a new session and a new process group,
-	 *      with no controlling tty.  */
-	setsid ();
-
-	/* Fork again to guarantee the process will not be able to aquire a
-	 *      controlling tty. */
-
-	/*signal (SIGHUP, SIG_IGN); *//* required according to Stevens' UNP2 p333 */
-
-	pid = fork ();
-	if (pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if (pid)                      /* 1st child terminates */
-		exit (0);
-
-	/* 2nd child continues, no longer a session or group leader */
-
-	syslog (LOG_INFO, "%s daemonised", g_program_name);
-}
-
-/* MainLoop(): Classic concurrent server model. Wait for a client to connect,
- *  * fork a child process to do the business with the client, parent process
- *   * continues to wait for the next connection.  This function does not return.
- *    */
-	void
-MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	int server_fd, client_fd;
-	pid_t child_pid;
-
-	for (;;)
-	{
-		client_fd = AcceptClientConnection (listen_fd);
-
-		child_pid = fork ();
-		if (child_pid == -1)
-			syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-		if (child_pid)            /* parent */
-		{
-			close (client_fd);
-
-			syslog (LOG_INFO, "Forked child pid %d to deal with client",
-					child_pid);
-
-			continue;
-		}
-		else                      /* child */
-		{
-			close (listen_fd);
-
-			server_fd = ConnectToServer (rem_addr, rem_port);
-
-			Proxy (server_fd, client_fd);
-
-			syslog (LOG_INFO, "exiting");
-			_exit (0);
-		}
-	}
-}
-
-/* Proxy(): Copies data between server_fd and client_fd in both directions
- *  * until one or other peer closes their connection.
- *   */
-	void
-Proxy (int server_fd, int client_fd)
-{
-	pid_t helper_pid;
-
-	syslog (LOG_INFO, "Proxy(fd%d, fd%d)", server_fd, client_fd);
-
-	signal (SIGCHLD, SIG_IGN);
-
-	helper_pid = fork ();
-	if (helper_pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if (helper_pid)               /* parent */
-	{
-		syslog (LOG_INFO, "Forked child pid %d to help with proxying",
-				helper_pid);
-
-		Cat (server_fd, client_fd);
-
-		shutdown (client_fd, 1);
-		close (server_fd);
-		close (client_fd);
-
-		wait (0);                 /* wait for helper to exit */
-	}
-	else                          /* child (helper) */
-	{
-		Cat (client_fd, server_fd);
-
-		shutdown (server_fd, 1);
-
-		syslog (LOG_INFO, "exiting");
-		exit (0);                 /* helper exits here */
-	}
-}
-
-/* AcceptClientConnection(): waits for a tcp connect to the socket listen_fd,
- *  * which must already be bound and set to listen on a local port.  Bombs on
- *   * error, returns the fd of the new socket on success.
- *    */
-	int
-AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	/* Accept the connection and create a new socket for it. */
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ((newfd < 0) && (errno == EINTR));
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if (newfd < 0)
-		syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
-
-	if (socklen != sizeof (sa))
-		syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
-
-	return (newfd);
-}
-
-/* ConnectToServer(): attempts a tcp connect to the server specified by addr
- *  * and port.  Bombs on failure to connect, returns the fd of the new socket
- *   * on success.
- *    */
-	int
-ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	/* TODO: have a timeout for connect() - see Unix socket FAQ 6.2 */
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	/* Create a socket and get its descriptor. */
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if (fd < 0)
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		exit (EXIT_FAILURE);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-/* Cat(): read data from in_fd and write it to out_fd until the connection is
- *  * closed by one of the peers.  Data is copied using a dynamically allocated
- *   * buffer.
- *    */
-	void
-Cat (int in_fd, int out_fd)
-{
-	unsigned char *const buf = malloc (BUF_SIZE);
-	int bytes_rcvd, bytes_sent = 0, i;
-
-	syslog (LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if (buf == NULL)
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-		for (i = 0; i < bytes_rcvd; i += bytes_sent)
-		{
-			bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-			if (bytes_sent < 0)
-				break;
-		}
-
-	}
-	while ((bytes_rcvd > 0) && (bytes_sent > 0));
-
-	if ((bytes_rcvd < 0) && (errno != ECONNRESET))
-		syslog (LOG_ERR, "recv(): %m"), exit (EXIT_FAILURE);
-
-	if ((bytes_sent < 0) && (errno != EPIPE))
-		syslog (LOG_ERR, "send(): %m"), exit (EXIT_FAILURE);
-
-	free (buf);
-}
-
-/* NameToAddress(): Convert name to an ip address.  Returns 0 on success,
- *  * -1 on failure.
- *   */
-	int
-NameToAddr (const char *name, struct in_addr *p_inaddr)
-{
-	struct hostent *he;
-
-	/* First, attempt to convert from string ip format */
-	/* TODO: use inet_aton() instead */
-	p_inaddr->s_addr = inet_addr (name);
-	if (p_inaddr->s_addr != -1U)  /* Success */
-		return 0;
-
-	/* Next, attempt to read from /etc/hosts or do a DNS lookup */
-	he = gethostbyname (name);
-	if (he != NULL)               /* Success */
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1;                    /* Failed to resolve name to an ip address */
-}
-
-/* NameToPort(): Convert name to a port number. Name can either be a port
- *  * name (in which case proto must also be set to either "tcp" or "udp") or
- *   * name can be the ascii representation of the port number.  Returns 0 on
- *    * success, -1 on failure.
- *     */
-	int
-NameToPort (const char *name, unsigned short *port, const char *proto)
-{
-	unsigned long lport;
-	char *errpos;
-	struct servent *se;
-
-	/* First, attempt to convert string to integer */
-	lport = strtoul (name, &errpos, 0);
-	if ((*errpos == 0) && (lport <= 65535))       /* Success */
-	{
-		*port = lport;
-		return 0;
-	}
-
-	/* Next, attempt to read the string from /etc/services */
-	se = getservbyname (name, proto);
-	if (se != NULL)               /* Success */
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1;                    /* Failed to resolve port name to a number */
-}
-
-/* quit(), pbomb(), hbomb(): Print an error message to stderr and syslog, then
- *  * exit the program.  pbomb() and hbomb() additionally include the string
- *   * representation of errno and h_errno respectively.
- *    */
-	void
-quit (const char *fmt, ...)     /* quit with msg */
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-	void
-pbomb (const char *fmt, ...)    /* bomb with perror */
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-	void
-hbomb (const char *fmt, ...)    /* bomb with herror */
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-/* set_signal_handler(): Sets a signal handler function.  Similar to signal()
- *  * but this method is more portable between platforms.
- *   */
-	void
-set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if (sigaction (signum, &act, NULL) < 0)
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/rand.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/rand.c	(revision 216)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-/*
-
-#define MAX 10000
-
-int main(void)
-{
-	int i = (int)NULL;
-	int j =i;
-	long int vet[MAX];
-
-	for ( i = 0; i < MAX; ++i )
-	{
-		vet[i] = rand();
-		for ( j = 0; j < i; ++j )
-			if ( vet[i] == vet[j] )
-				printf("[%d]%d - [%d]%d\n", i, vet[i], j, vet[j]);
-	}
-	printf("rand_max: %d\n", RAND_MAX);
-	printf("time: %d\n", time(NULL));
-	printf("rand: %d\n", rand(1));
-}
-*/
-
-main(int ac, char **av)
-{
-	double x;
-	unsigned seed;
-
-	if (ac > 0) {
-		sscanf(microtime,"%u", &seed);
-		srand(seed);
-	}
-
-	x = rand()/(RAND_MAX+1.0);
-
-	printf("%g\n",x);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/teste_ldap.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/teste_ldap.c	(revision 216)
+++ 	(revision )
@@ -1,71 +1,0 @@
-#include <stdio.h>
-#include <ldap.h>
-
-int main(void)
-{
-	LDAP            *ld;
-	LDAPMessage     *res, *e;
-	int             i, rc;
-	char            *a, *dn;
-	BerElement      *ptr;
-	char            **vals;
-
-	/* open an LDAP session */
-	if ( (ld = ldap_init( "ldap.eparana.parana", 389 )) == NULL )
-	{
-		fprintf( stderr, "erro ao se conectar:");
-		return 1;
-	}
-
-	/* authenticate as nobody */
-	if (( rc = ldap_simple_bind_s( ld, NULL, NULL )) != LDAP_SUCCESS )
-	{
-		fprintf( stderr, "ldap_simple_bind_s: %s\n", ldap_err2string( rc ));
-		ldap_unbind( ld );
-		return 1;
-	}
-
-	/* search for entries with cn of "Babs Jensen", return all attrs  */
-	if (( rc = ldap_search_s( ld, "dc=pr, dc=gov, dc=br", LDAP_SCOPE_SUBTREE, "(uid=alexandrecorreia)", NULL, 0, &res )) != LDAP_SUCCESS )
-	{
-		fprintf( stderr, "ldap_search_s: %s\n", ldap_err2string( rc ));
-		if ( res == NULL )
-		{
-			ldap_unbind( ld );
-			return 1;
-		}
-	}
-
-	/* step through each entry returned */
-	for ( e = ldap_first_entry( ld, res ); e != NULL; e = ldap_next_entry( ld, e ) )
-	{
-		/* print its name */
-		dn = ldap_get_dn( ld, e );
-		printf( "uid: %s\n", dn );
-		ldap_memfree( dn );
-
-		/* print each attribute */
-		for ( a = ldap_first_attribute( ld, e, &ptr ); a != NULL; a = ldap_next_attribute( ld, e, ptr ) )
-		{
-			printf( "\tattribute: %s\n", a );
-
-			/* print each value */
-			vals = ldap_get_values( ld, e, a );
-
-			for ( i = 0; vals[i] != NULL; i++ )
-				printf( "\t\tvalue: %s\n", vals[i] );
-
-			ldap_value_free( vals );
-			ldap_memfree( a );
-		}
-		if ( ptr != NULL )
-			ber_free( ptr, 0 );
-	}
-	/* free the search results */
-	ldap_msgfree( res );
-
-	/* close and free connection resources */
-	ldap_unbind( ld );
-
-	return 0;
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_tls.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_tls.c	(revision 216)
+++ 	(revision )
@@ -1,247 +1,0 @@
-#include "server.h"
-
-int main(int argc, char* argv[])
-{
-	/* handle to socket */
-	int hSocket = (int)NULL,
-		hServerSocket = (int)NULL;
-
-	int nAddressSize = sizeof(struct sockaddr_in);
-	int nHostPort = (int)NULL;
-	int err;
-
-	/* holds info about a machine */
-	struct hostent * pHostInfo = (struct hostent *)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in Address;
-
-	struct client * clients = (struct client *)NULL;
-	pthread_t threads;
-	//pthread_t clients;
-
-	SSL_CTX * ctx;
-	SSL * myssl;
-
-	OpenSSL_add_all_algorithms();
-	SSL_library_init();
-	SSL_load_error_strings();
-
-
-	if ( !(ctx = SSL_CTX_new(TLSv1_server_method())) )
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	if ( SSL_CTX_set_cipher_list(ctx, CIPHER_LIST) < 1 )
-	{
-		printf("Error setting the cipher list.\n");
-		exit(0);
-	}
-
-	/*Indicate the certificate file to be used*/
-	if ( SSL_CTX_use_certificate_file(ctx, CERT_FILE, SSL_FILETYPE_PEM) < 1 )
-	{
-		printf("Error setting the certificate file.\n");
-		exit(0);
-	}
-
-	/*Load the password for the Private Key*/
-	SSL_CTX_set_default_passwd_cb_userdata(ctx, KEY_PASSWD);
-
-	/*Indicate the key file to be used*/
-	if ( SSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM) < 1 )
-	{
-		printf("Error setting the key file.\n");
-		exit(0);
-	}
-
-	/*Make sure the key and certificate file match*/
-	if ( !SSL_CTX_check_private_key(ctx) )
-	{
-		printf("Private key does not match the certificate public key\n");
-		exit(0);
-	}
-
-	/* Set the list of trusted CAs based on the file and/or directory provided*/
-	if ( SSL_CTX_load_verify_locations(ctx, CA_FILE, CA_DIR) < 1 )
-	{
-		printf("Error setting verify location\n");
-		exit(0);
-	}
-
-	/* Set for server verification*/
-	SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL);
-
-	if ( argc != 2 || (nHostPort = strtol(argv[1], 0, 10)) == 0 )
-	{
-		printf("\n<PORT>\n\n");
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	printf("\nStarting server");
-	printf("\nMaking socket");
-
-	/* make a socket */
-	hServerSocket = socket(AF_INET, SOCK_STREAM, 0);
-	if ( hServerSocket == SOCKET_ERROR )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	/* fill address struct */
-	Address.sin_addr.s_addr = INADDR_ANY;
-	Address.sin_port = htons(nHostPort);
-	Address.sin_family = AF_INET;
-
-	printf("\nBinding to port %d", nHostPort);
-
-	/* bind to a port */
-	if ( bind(hServerSocket, (struct sockaddr*)&Address, sizeof(Address)) == SOCKET_ERROR )
-	{
-		printf("\nCould not connect to host\n");
-		return 0;
-	}
-
-	/* get port number */
-	getsockname( hServerSocket, (struct sockaddr *) &Address,(socklen_t *)&nAddressSize);
-	printf("opened socket as fd (%d) on port (%d) for stream i/o\n", hServerSocket, ntohs(Address.sin_port));
-
-	printf("Server\n\
-			sin_family        = %d\n\
-			sin_addr.s_addr   = %d\n\
-			sin_port          = %d\n"
-			, Address.sin_family
-			, Address.sin_addr.s_addr
-			, ntohs(Address.sin_port)
-			);
-	printf("\nMaking a listen queue of %d elements", QUEUE_SIZE);
-
-	/* establish listen queue */
-	if ( listen(hServerSocket, QUEUE_SIZE) == SOCKET_ERROR )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		fflush(stdin);
-		fflush(stdout);
-		///printf("\nWaiting for a connection\n");
-		puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		hSocket = accept(hServerSocket, (struct sockaddr*)&Address, (socklen_t *)&nAddressSize);
-		clients = (struct client *) malloc(sizeof(struct client));
-		clients->hSocket = hSocket;
-
-		/*Create new ssl object*/
-		if( !(clients->myssl = SSL_new(ctx)) )
-		{
-			printf("Error creating SSL structure.\n");
-			exit(0);
-		}
-
-		/*Bind the socket to the SSL structure*/
-		SSL_set_fd(clients->myssl, hSocket);
-
-		puts("_____TESTE______");
-		/*Connect to the server, SSL layer.*/
-		err = SSL_accept(clients->myssl);
-		puts("_____TESTE______");
-
-		/*Check for error in connect.*/
-		if ( err < 1 )
-		{
-			printf("SSL error #%d in accept,program terminated\n", err);
-			err = SSL_get_error(clients->myssl, 0);
-			printf("SSL error #%d in accept,program terminated\n", err);
-
-			switch ( err )
-			{
-				case SSL_ERROR_NONE : puts("SSL_ERROR_NONE");break;
-				case SSL_ERROR_SSL : puts("SSL_ERROR_SSL");break;
-				case SSL_ERROR_WANT_READ : puts("SSL_ERROR_WANT_READ");
-			}
-
-			if ( err == 5 )
-				printf("sockerrno is: %d\n", err);
-
-
-			close(hSocket);
-			SSL_CTX_free(ctx);
-			exit(0);
-		}
-
-		//clients->myssl = myssl;
-		pthread_create(&threads, NULL, handler, (void *)clients);
-		clients = (struct client *)NULL;
-	}
-	pthread_exit(NULL);
-	puts("FIM LAssO");
-}
-
-void * handler(void * pClient)
-{
-    char pBuffer[BUFFER_SIZE];
-    struct client * client = (struct client *)pClient;
-    int i = 0, err;
-
-    printf("\nGot a connection");
-    strcpy(pBuffer,MESSAGE);
-    printf("\nSending \"%s\" to client",pBuffer);
-
-    /* number returned by read() and write() is the number of bytes
-    ** read or written, with -1 being that an error occured
-    ** write what we received back to the server */
-    //write(client->hSocket, pBuffer, strlen(pBuffer)+1);
-    err=SSL_write(client->myssl, pBuffer, strlen(pBuffer)+1);
-	 printf("-------%s\n\n", pBuffer);
-
-
-    /* read from socket into buffer */
-    //read(client->hSocket, pBuffer, BUFFER_SIZE);
-	 err = SSL_read(client->myssl, pBuffer, BUFFER_SIZE);
-
-	 printf("-------%s\n\n", pBuffer);
-
-    if ( strcmp(pBuffer, MESSAGE) == 0 )
-        printf("\nThe messages match");
-    else
-        printf("\nSomething was changed in the message");
-
-    while (i < 10)
-    {
-		 printf("%d\n", i);
-		 usleep(1000000);
-		 i++;
-    }
-
-    printf("\nClosing the socket");
-
-	 /*pBuffer[0] = '\0';
-	 printf("\n\nread = %s\n\nsd = %d\n\n\n", pBuffer, SSL_get_shutdown(client->myssl));
-	 SSL_shutdown(client->myssl);
-	 pBuffer[0] = '\0';
-	 printf("\n\nread = %s\n\nsd = %d\n\n\n", pBuffer, SSL_get_shutdown(client->myssl));
-	 SSL_shutdown(client->myssl);
-	 pBuffer[0] = '\0';
-	 printf("\n\nread = %s\n\nsd = %d\n\n\n", pBuffer, SSL_get_shutdown(client->myssl));
-    SSL_free(client->myssl);
-	*/
-    /* close socket */
-    if ( close(client->hSocket) == SOCKET_ERROR )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	 free(client);
-    pthread_exit(NULL);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/client_tls.c_bkp
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/client_tls.c_bkp	(revision 216)
+++ 	(revision )
@@ -1,270 +1,0 @@
-/*#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-*/
-/* define HOME to be dir for key and certificate files... */
-//#define HOME "/usr/local/ssl/"
-/* Make these what you want for certificate & key files */
-//#define CERT_FILE "mycert.pem"
-//#define KEY_FILE  "mycert.pem"
-
-/*Cipher list to be used*/
-//#define CIPHER_LIST "RC4-MD5"
-
-/*Trusted CAs location*/
-//#define CA_FILE CERT_FILE
-//#define CA_DIR  NULL
-
-/*Password for the key file*/
-//#define KEY_PASSWD ""
-
-//#define IP "im.celepar.parana"
-
-//#define PORT "5222"
-
-#include "server.h"
-
-
-int main(void)
-{
-	int jabber_fd       = (int)NULL,
-		jabber_port     = (int)NULL,
-		jabber_error    = (int)NULL;
-
-	struct sockaddr_in jabber_addr;
-
-	jabber_port = __DEFAULT_JABBER_PORT__;
-	jabber_fd = socket(AF_INET, SOCK_STREAM, 0);
-
-	fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | O_NDELAY);
-
-	jabber_addr.sin_family = AF_INET;
-	inet_aton(__DEFAULT_JABBER_IP__, &jabber_addr.sin_addr);
-	jabber_addr.sin_port = htons(jabber_port);
-
-	jabber_error = connect(jabber_fd, (struct sockaddr *) &(jabber_addr), sizeof(jabber_addr));
-
-	printf("Socket returned error #%d,program terminated\n", jabber_error);
-
-	exit(0);
-
-
-
-
-
-
-
-
-
-
-
-
-
-int socketfd, nHostPort;
-   int err;
-   char buff[32];
-struct sockaddr_in socketaddr;
-
-/*SSL PART*/
-SSL_METHOD *meth;
-SSL_CTX  *ctx;
-SSL  *myssl;
-/*SSL PART*/
-
-    if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-    {
-       printf("\n<port>\n\n");
-       printf("\ncould not make a socket\n");
-       return 0;
-    }
-
-   socketfd=socket(AF_INET,SOCK_STREAM,0);
-
-socketaddr.sin_family=AF_INET;
-inet_aton("im.celepar.parana", &socketaddr.sin_addr);
-socketaddr.sin_port=htons(5222);
-
-/* Connect to the server, TCP/IP layer,*/
-   err=connect(socketfd,(struct sockaddr*)&socketaddr,sizeof(socketaddr));
-   if(err<0){
-      printf("Socket returned error #%d,program terminated\n", err);
-      exit(0);
-   }
-    exit(0);
-
-   /* SSL Part*/
-SSL_library_init();
-SSL_load_error_strings();
-
-   meth=TLSv1_client_method();
-  
-   ctx=SSL_CTX_new(meth);
-   if (!ctx) {
-    printf("Error creating the context.\n");
-    exit(0);
-}
-
-/*
-   if (SSL_CTX_set_cipher_list(ctx,CIPHER_LIST) <= 0) {
-printf("Error setting the cipher list.\n");
-exit(0);
-}
-*/
-   /*Indicate the certificate file to be used*/
-  /* if (SSL_CTX_use_certificate_file(ctx,CERT_FILE, SSL_FILETYPE_PEM) <= 0) {
-   printf("Error setting the certificate file.\n");
-   exit(0);
-}*/
-
-
-
-/*Load the password for the Private Key*/
-   //SSL_CTX_set_default_passwd_cb_userdata(ctx,KEY_PASSWD);
-
-
-/*Indicate the key file to be used*/
-/*if (SSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM) <= 0) {
-printf("Error setting the key file.\n");
-exit(0);
-}*/
-
-/*Make sure the key and certificate file match*/
-/*if (!SSL_CTX_check_private_key(ctx)) {
-    printf("Private key does not match the certificate public key\n");
-    exit(0);
-}*/
-
-/* Set the list of trusted CAs based on the file and/or directory provided*/
-/*   if(SSL_CTX_load_verify_locations(ctx,CA_FILE,CA_DIR)<1){
-            printf("Error setting verify location\n");
-            exit(0);
-   }*/
-
-/* Set for server verification*/
-//   SSL_CTX_set_verify(ctx,SSL_VERIFY_PEER,NULL);
-
-/*Create new ssl object*/
-myssl=SSL_new(ctx);
-
-   if(!myssl){
-      printf("Error creating SSL structure.\n");
-      exit(0);
-   }
-
-/*Bind the socket to the SSL structure*/
-SSL_set_fd(myssl,socketfd);
-
-/*Connect to the server, SSL layer.*/
-err=SSL_connect(myssl);
-   /*Check for error in connect.*/
-if (err<1) {
-
-      err=SSL_get_error(myssl,err);
-      printf("SSL error #%d in accept,program terminated\n",err);
-
-      if(err==5){printf("sockerrno is:\n");}
-
-      close(socketfd);
-      SSL_CTX_free(ctx);
-      exit(0);
-   }
-
-/*Print out connection details*/
-   printf("SSL connection on socket %x,Version: %s, Cipher: %s\n",
-      socketfd,
-   SSL_get_version(myssl),
-SSL_get_cipher(myssl));
-
-puts("_________OK_______________");
-exit(0);
-/*Send message to the server.*/
-   err=SSL_write(myssl,"Hello there!!!!",sizeof("Hello there!!!!")+1);
-   /*Check for error in write.*/
-   if(err<1){
-      err=SSL_get_error(myssl,err);
-      printf("Error #%d in write,program terminated\n",err);
-      /********************************/
-      /* If err=6 it means the client */
-      /* issued an SSL_shutdown. You  */
-      /* must respond with a shutdown */
-      /* to complete a graceful       */
-      /* shutdown                     */
-      /********************************/
-      if(err==6){
-         SSL_shutdown(myssl);
-      }
-      SSL_free(myssl);
-      close(socketfd);
-      SSL_CTX_free(ctx);
-      exit(0);
-   }
-
-/*Read servers response.*/
-   err = SSL_read (myssl, buff, sizeof(buff));
-   /*Check for error in read.*/
-   if(err<1){
-      err=SSL_get_error(myssl,err);
-      printf("Error #%d in read,program terminated\n",err);
-      /********************************/
-      /* If err=6 it means the client */
-      /* issued an SSL_shutdown. You  */
-      /* must respond with a shutdown */
-      /* to complete a graceful       */
-      /* shutdown                     */
-      /********************************/
-      if(err==6){
-         SSL_shutdown(myssl);
-      }
-      SSL_free(myssl);
-      close(socketfd);
-      SSL_CTX_free(ctx);
-      exit(0);
-   }
-   printf("Server said: %s\n",buff);
-   err=SSL_shutdown(myssl);
-	buff[0] = '\0';
-   SSL_read (myssl, buff, sizeof(buff));
-   /*********************************/
-   /* If err is equal to 0 you are  */
-   /* issuing the shutdown first.   */
-   /* If its 1 then you are         */
-   /* responding to a previously    */
-   /* issued shutdown message       */
-   /*********************************/
-   if(err==0)
-	{
-      err=SSL_shutdown(myssl);
-		buff[0] = '\0';
-	   SSL_read (myssl, buff, sizeof(buff));
-      if(err<1){
-         printf("#1 Error in shutdown\n");
-      }else if(err==1){
-         printf("Client exited gracefully\n");
-      }
-   }else if(err<0){
-         printf("Error in shutdown\n");
-
-   }else if(err==1){
-      printf("Client exited gracefully\n");
-   }
-   close(socketfd);
-SSL_free(myssl);
-SSL_CTX_free(ctx);
-   exit(0);
-
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_24092007.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/server_24092007.c	(revision 216)
+++ 	(revision )
@@ -1,197 +1,0 @@
-#include "server.h"
-
-int main(int argc, char* argv[])
-{
-	/* fd -> file descriptor */
-	int socket_server_fd	= (int)NULL,
-		socket_server_port	= (int)NULL,
-		socket_accept_fd	= (int)NULL,
-		sockaddr_in_size	= sizeof(struct sockaddr_in),
-		err					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	struct client * clients = (struct client *) NULL,
-				  * atual = (struct client *) NULL;
-	pthread_t threads;
-
-	/* clear screen */
-	system(__CLEAR_SCREEN__);
-
-	if ( argc != 2 || (socket_server_port = strtol(argv[1], 0, 10)) == 0 )
-		usage();
-
-	/* make a socket */
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == SOCKET_ERROR )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	/* fill address struct */
-	//server_addr.sin_addr.s_addr = inet_aton("10.15.20.42");//INADDR_ANY;
-	//inet_aton(INADDR_ANY, &server_addr.sin_addr);//INADDR_ANY;
-	server_addr.sin_addr.s_addr = INADDR_ANY;
-	server_addr.sin_port = htons(socket_server_port);
-	server_addr.sin_family = AF_INET;
-
-	printf("\nBinding to port %d...\n", socket_server_port);
-
-	/* bind to a port */
-	if ( bind(socket_server_fd, (struct sockaddr *)&server_addr, sizeof(server_addr)) == SOCKET_ERROR )
-	{
-		printf("\nCould not connect to host\n");
-		exit(1);
-	}
-
-	/* get port number */
-	getsockname(socket_server_fd, (struct sockaddr *)&server_addr, (socklen_t *)&sockaddr_in_size);
-	printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-	printf("Server\n\
-			sin_family        = %d\n\
-			sin_addr.s_addr   = %d\n\
-			sin_port          = %d\n"
-			, server_addr.sin_family
-			, server_addr.sin_addr.s_addr
-			, ntohs(server_addr.sin_port)
-			);
-	printf("\nMaking a listen queue of %d elements", QUEUE_SIZE);
-
-	/* establish listen queue */
-	if ( listen(socket_server_fd, QUEUE_SIZE) == SOCKET_ERROR )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &accept_addr, (socklen_t *) &sockaddr_in_size);
-		if ( socket_accept_fd > -1 )
-		{
-			/*
-			char ip[46];
-			unsigned short port;
-			printf("%d\n\n", inet_ntoa(server_addr.sin_addr.s_addr));
-			printf("%d\n\n", inet_ntoa(accept_addr.sin_addr.s_addr));
-			inet_ntop (AF_INET, &accept_addr.sin_addr, ip, sizeof (ip));
-			port = ntohs(accept_addr.sin_port);
-			printf("connection from %s, port %hu\n", ip, port);
-			*/
-
-
-			/*
-			 if ( close(socket_accept_fd) == SOCKET_ERROR )
-				printf("\nCould not close socket\n");
-			*/
-
-			if ( clients == (struct client *) NULL )
-				atual = clients;
-			else
-				while ( (atual = clients->next) != (struct client *) NULL );
-
-			atual = (struct client *) malloc(sizeof(struct client));
-			atual->next = (struct client *) NULL;
-			atual->fd = socket_accept_fd;
-			atual->sockaddr = accept_addr;
-			atual->last = time(NULL);
-
-			pthread_create(&threads, NULL, handler, (void *)atual);
-			//clients = (struct client *)NULL;
-		}
-		puts("jah era #5");
-	}
-	pthread_exit(NULL);
-}
-
-void * handler(void * pClient)
-{
-    char pBuffer[BUFFER_SIZE];
-    struct client * client = (struct client *) pClient;
-    int i = 0, err;
-	time_t last;
-
-	char ip[46];
-	unsigned short port;
-	//printf("%d\n\n", inet_ntoa(client->fd));
-	//printf("%d\n\n", inet_ntoa(client->sockaddr.sin_addr.s_addr));
-	inet_ntop(AF_INET, &client->sockaddr.sin_addr, ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-
-    if ( close(client->fd) == SOCKET_ERROR )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-    /*
-
-	last = time(NULL);
-	while ( time(NULL) - client->last < 10 )
-	{
-		printf("%s\n\n", "teste");
-		sleep(1);
-	}
-
-	client->last = time(NULL);
-	*/
-
-    /**
-	 * number returned by read() and write() is the number of bytes
-     * read or written, with -1 being that an error occured
-     * write what we received back to the server
-	 **/
-
-    /*
-	strcpy(pBuffer, MESSAGE);
-    printf("\nSending \"%s\" to client\n",pBuffer);
-    write(client->hSocket, pBuffer, strlen(pBuffer)+1);
-	*/
-
-	/* read from socket into buffer */
-	/*read(client->hSocket, pBuffer, sizeof(pBuffer));
-
-	printf("Received from client: %s\n", pBuffer);
-
-    if ( strcmp(pBuffer, MESSAGE) == 0 )
-        printf("The messages match\n");
-    else
-        printf("Something was changed in the message\n");
-	*/
-
-    /*while (i < 10)
-    {
-		 printf("%d\n", i);
-		 usleep(1000000);
-		 i++;
-    }*/
-
-    /* close socket */
-    /*printf("\nClosing the socket");
-    if ( close(client->hSocket) == SOCKET_ERROR )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-	*/
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/client.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/client.c	(revision 216)
+++ 	(revision )
@@ -1,73 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#define IP "10.15.20.116"
-
-#define PORT "8888"
-
-int main(void)
-{
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-	int err,
-		i,
-		unit;
-	char buff[4096];
-	char * _xml = (char)NULL,
-		 * xml_connect = {"<?xml version='1.0' encoding='UTF-8'?><stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"};
-
-	_xml = (char *)malloc(sizeof(xml_connect));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	//socketaddr.sin_addr.s_addr = INADDR_ANY;//inet_addr(IP);
-	//socketaddr.sin_addr.s_addr = inet_addr("10.15.20.42");
-	inet_aton("10.15.20.42", &socketaddr.sin_addr);
-	socketaddr.sin_port = htons(nHostPort);
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	struct hostent *hp;
-	hp = gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET);
-
-	printf("\n\n%s\n\n", inet_ntoa(socketaddr.sin_addr));
-	printf("\n\n%d\n\n", inet_network("expresso.pr.gov.br"));
-
-	//printf("\n\n%d\n\n", socketaddr.sin_addr.s_addr);
-	//printf("\n\n%s\n\n", gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET));
-
-
-	sprintf(_xml, xml_connect, "localhost");
-
-	write(socketfd, _xml, strlen(_xml));
-
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-	//sleep(10);
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/server.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/server.c	(revision 216)
+++ 	(revision )
@@ -1,263 +1,0 @@
-#include "server.h"
-
-void my_shutdown(int n){
-	printf("server recvd SIGPIPE");
-	exit(1);
-}
-
-int main(int argc, char ** argv)
-{
-	/* variables to parse arguments */
-	extern int optind,
-			   optopt;
-	extern char * optarg;
-
-	char * log_file;
-	int c		= (int)NULL,
-		errflg	= (int)NULL,
-		verbose	= (int)NULL,
-		optval	= 1;
-
-	socklen_t optlen = sizeof(optval);
-
-	/* fd -> file descriptor */
-	int socket_server_fd	= (int)NULL,
-		socket_server_port	= (int)NULL,
-		socket_accept_fd	= (int)NULL,
-		sockaddr_in_size	= sizeof(struct sockaddr_in),
-		err					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	struct client * clients = (struct client *) NULL,
-				  * current = (struct client *) NULL;
-
-	pthread_t threads;
-
-	/* clear screen */
-	system(__CLEAR_SCREEN__);
-	signal(SIGPIPE, my_shutdown);
-
-	while ( (c = getopt(argc, argv, ":vp:")) != -1 )
-	{
-		switch ( c )
-		{
-			case 'p':
-				if ( socket_server_port = strtol(optarg, 0, 10) == 0 )
-				{
-					fprintf(stderr, "Option -%c requires a valid port and '%s' isn't valid\n", optopt, optarg);
-					++errflg;
-				}
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			case ':':
-				/* -f or -o without operand */
-				fprintf(stderr, "Option -%c requires an operand\n", optopt);
-				++errflg;
-				break;
-			case '?':
-				fprintf(stderr, "Unrecognized option: -%c\n", optopt);
-				++errflg;
-		}
-	}
-	if ( errflg )
-	{
-		fprintf(stderr, "usage: . . . \n\n");
-		exit(2);
-	}
-	//exit(0);
-
-	/*if ( argc != 2 || (socket_server_port = strtol(argv[1], 0, 10)) == 0 )
-		usage();*/
-
-	/* make a socket */
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	if ( !socket_server_port )
-		socket_server_port = __DEFAULT_OPEN_PORT__;
-
-	/* fill address struct */
-	server_addr.sin_addr.s_addr	= INADDR_ANY;
-	server_addr.sin_port		= htons(socket_server_port);
-	server_addr.sin_family		= AF_INET;
-	bzero(&(server_addr.sin_zero), 8);
-
-	if ( __DEBUG__  || verbose )
-		printf("\nBinding to port %d...\n", socket_server_port);
-
-	/* bind to a port */
-	if ( bind(socket_server_fd, (struct sockaddr *)&(server_addr), sizeof(server_addr)) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not connect to host\n");
-		exit(1);
-	}
-
-	/* get port number */
-	getsockname(socket_server_fd, (struct sockaddr *)&(server_addr), (socklen_t *) &(sockaddr_in_size));
-	if ( __DEBUG__  || verbose )
-	{
-		printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-		printf("Server\n\
-				sin_family        = %d\n\
-				sin_addr.s_addr   = %d\n\
-				sin_port          = %d\n"
-				, server_addr.sin_family
-				, server_addr.sin_addr.s_addr
-				, ntohs(server_addr.sin_port)
-			  );
-		printf("\nMaking a listen queue of %d elements", __QUEUE_SIZE__);
-	}
-
-	/* establish listen queue */
-	if ( listen(socket_server_fd, __QUEUE_SIZE__) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		if ( __DEBUG__  || verbose )
-			puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &(accept_addr), (socklen_t *) &(sockaddr_in_size));
-		fcntl(socket_accept_fd, F_SETFL, fcntl(socket_accept_fd, F_GETFL, 0) | O_NDELAY);
-
-		if ( setsockopt(socket_accept_fd, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0)
-		{
-			perror("setsockopt()");
-			exit(EXIT_FAILURE);
-		}
-
-		int val;
-		val = 10; /* 10 sec before starting probes */
-		setsockopt (socket_accept_fd, SOL_TCP, TCP_KEEPIDLE, &val, sizeof (val));
-		val = 2; /* 2 probes max */
-		setsockopt (socket_accept_fd, SOL_TCP, TCP_KEEPCNT, &val, sizeof (val));
-		val = 5; /* 5 seconds between each probe */
-		setsockopt (socket_accept_fd, SOL_TCP, TCP_KEEPINTVL, &val, sizeof (val));
-
-
-		if ( socket_accept_fd > -1 )
-		{
-			if ( clients == (struct client *) NULL )
-				current = clients;
-			else
-				while ( (current = clients->next) != (struct client *) NULL );
-
-			current				= (struct client *) malloc(sizeof(struct client));
-			current->next		= (struct client *) NULL;
-			current->fd			= socket_accept_fd;
-			current->sockaddr	= accept_addr;
-			current->last		= time(NULL);
-
-			pthread_create(&(threads), NULL, handler, (void *) current);
-		}
-		puts("jah era #5");
-	}
-	pthread_exit(NULL);
-}
-
-void * handler(void * pClient)
-{
-    char buffer_client[__BUFFER_SIZE__],
-		 buffer_jabber[__BUFFER_SIZE__];
-    struct client * client = (struct client *) pClient;
-    int i = 0, err;
-	time_t last;
-
-	char ip[46];
-	unsigned short port;
-	inet_ntop(AF_INET, &(client->sockaddr.sin_addr), ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-	//fcntl( client->fd, F_SETFL, fcntl( client->fd, F_GETFL ) & ~O_NONBLOCK );
-	//printf(":::client %d\n\n\n", fcntl( client->fd, F_GETFL, 0));
-	//printf(":::client %d\n\n\n", fcntl( client->fd, F_SETFL, fcntl( client->fd, F_GETFL ) & ~O_NONBLOCK ));
-	/*---------------------------------------------------*/
-
-	int jabber_fd		= (int)NULL,
-		jabber_port		= (int)NULL,
-		jabber_error	= (int)NULL;
-
-	struct sockaddr_in jabber_addr;
-
-	jabber_port = __DEFAULT_JABBER_PORT__;
-	//jabber_port = strtol(__DEFAULT_JABBER_PORT__, 0, 10);
-	jabber_fd = socket(AF_INET, SOCK_STREAM, 0);
-	fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | O_NDELAY);
-
-	jabber_addr.sin_family = AF_INET;
-	inet_aton(__DEFAULT_JABBER_IP__, &jabber_addr.sin_addr);
-	jabber_addr.sin_port = htons(jabber_port);
-
-	jabber_error = connect(jabber_fd, (struct sockaddr *) &(jabber_addr), sizeof(jabber_addr));
-
-	last = time(NULL);
-	int client_is_connected = -1;
-	int jabber_is_connected = -1;
-	int sockaddr_in_size    = sizeof(struct sockaddr_in);
-	while ( client_is_connected != 0 )
-	{
-		puts("begin loop");
-		/* read from client */
-		puts("\tread - client");
-		bzero(buffer_client, __BUFFER_SIZE__);
-		if ( (client_is_connected = read(client->fd, buffer_client, __BUFFER_SIZE__)) != 0 && strlen(buffer_jabber) > 0 )
-		{
-			puts("\twrite - jabber");
-			/* write in the client */
-			write(client->fd, buffer_jabber, strlen(buffer_jabber));
-		}
-
-		/*if ( client_is_connected == 0 )
-			break;*/
-
-		/* read from jabber service */
-		puts("\tread - jabber");
-		bzero(buffer_jabber, __BUFFER_SIZE__);
-		if ( (jabber_is_connected = read(jabber_fd, buffer_jabber, __BUFFER_SIZE__)) && strlen(buffer_client) > 0 )
-		{
-			puts("\twrite - client");
-			/* write in the jabber service */
-			write(jabber_fd, buffer_client, strlen(buffer_client));
-		}
-
-		if ( jabber_is_connected == 0 )
-			client_is_connected = jabber_is_connected;
-
-		puts("end loop");
-		usleep(500000);
-	}
-
-    if ( close(jabber_fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close jabber socket\n");
-        return 0;
-    }
-	/*---------------------------------------------------*/
-    if ( close(client->fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/server.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/server.h	(revision 216)
+++ 	(revision )
@@ -1,103 +1,0 @@
-#include <fcntl.h>
-
-#include <linux/tcp.h>
-
-#include <netdb.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-
-#include <pthread.h>
-
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <unistd.h>
-
-/* define max clients per child */
-#ifndef __CLIENTS__
-   #define __CLIENTS__ 100
-#endif
-
-/* define max clients waiting in the queue for connect */
-#ifndef __QUEUE_SIZE__
-	#define __QUEUE_SIZE__ 10
-#endif
-
-/* __SOCKET_ERROR__ must be -1, don't change this */
-#ifndef __SOCKET_ERROR__
-	#define __SOCKET_ERROR__ -1
-#endif
-
-/* open port when this server is activated */
-#ifndef __DEFAULT_OPEN_PORT__
-	#define __DEFAULT_OPEN_PORT__ 8888
-#endif
-
-/* ip of jabber service */
-#ifndef __DEFAULT_JABBER_PORT__
-	#define __DEFAULT_JABBER_PORT__ 5222
-#endif
-
-/* port to connect on jabber service */
-#ifndef __DEFAULT_JABBER_IP__
-	#define __DEFAULT_JABBER_IP__ "10.15.20.202"
-#endif
-
-/* the jabber's documentation recommends read the packages of socket with size of 4096 (2^12) KB */
-#ifndef __BUFFER_SIZE__
-	#define __BUFFER_SIZE__ 4096
-#endif
-
-#define MESSAGE			"This is the message I'm sending back and forth"
-
-/* Make these what you want for certificate & key files */
-#define CERT_FILE "mycert.pem"
-#define KEY_FILE  "mycert.pem"
-
-/*Cipher list to be used*/
-#define CIPHER_LIST "RC4-MD5"
-
-/*Trusted CAs location*/
-#define CA_FILE CERT_FILE
-#define CA_DIR NULL
-
-/*Password for the key file*/
-#define KEY_PASSWD ""
-
-#ifndef __CLEAR_SCREEN__
-	#define __CLEAR_SCREEN__ "clear"
-#endif
-
-/* 0 -> false; 1 -> true */
-#ifndef __DEBUG__
-	#define __DEBUG__ 0
-#endif
-
-struct client
-{
-	int fd;
-	struct sockaddr_in sockaddr;
-	pthread_t thread;
-	SSL * myssl;
-	time_t last;
-	struct client * next;
-};
-
-void * handler(void *);
-
-void usage (void)
-{
-	puts("usage: ./server <PORT>\n\n");
-	exit (-1);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/mycert.pem
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/mycert.pem	(revision 216)
+++ 	(revision )
@@ -1,34 +1,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXAIBAAKBgQDY8Tao9bylsCI6LVR8yWWO7HgfnQQCwh2cqigKHaSnuo5n67R5
-Cp7dAbYkVf1V7BZ+V3nn7eVQ2FXcb8BooBQY51J9j7Q75IT5AZRar1ket5pRnVJH
-THGpm8trQsP54gV14lRToI36zXFzxakR08B1iKRyyLUVwp8RvAUxS+kKHwIDAQAB
-AoGAFIbWTixaOi8tPeX2HYyM0HYtc4hOzdgCJ0WuXi6p2rj7KngR7nYDzBOSYWPF
-gbDB/BhYz4oh7YFatm3Yfc3PuNLbuTxaMuuevDl9Qy+0cVI3FL7ban5jgEXMZVB8
-rgIfxmem8Kj7Eu/WtF/UJiz+epJQgrndlNtWJTWSDHoLRqkCQQD3lf4kRwiJJrAS
-Hj48/FVaR+0nvcEia7YsF44is8Yd++BG1tKNZZaKpdhssVA/9Pd+8hC9Sqzji+Mc
-ZXdbAoh1AkEA4FCeoH/ZfWZ3KfCyGfK6T2SEf3tJB/bleFg1mdmv9INuk6HSKMKW
-62mhxAk4DjcYcoM8QSeAE4FN7aOwB3OVwwJAeL/7qf/G5vUqbDu5yQ6cJiLsRDSk
-rD/yIkD+vmgFWPxOHt6I5BNGv6oxCpnT9M1po801Ysy302aXRnMqKgXrPQJBAMYG
-ZgNK2rXZv1lHI/PEVLXCBzaDn/VoASw8sxUfGDbD0NqEAQP6xUEN/8EQYmwqN2rg
-cFEUjfyqKiGgX8Y0RAECQGTEkKvhDzgyyphx5JkYem7sAUI7gFGKZxJaVU+KkN5e
-pU4pgNiFUT0uTbfFzzOYQKeyVlBqGiv7rVn3BO3pfV4=
------END RSA PRIVATE KEY-----
------BEGIN CERTIFICATE-----
-MIIDKzCCApSgAwIBAgIJAOkSDgQDK1oGMA0GCSqGSIb3DQEBBQUAMG0xCzAJBgNV
-BAYTAkJSMQswCQYDVQQIEwJQUjEMMAoGA1UEBxMDQ1dCMQ0wCwYDVQQKEwRTQ0tU
-MQ0wCwYDVQQLEwRzY2t0MSUwIwYDVQQDExxlY2VsZXBhcjkxMTM3LmNlbGVwYXIu
-cGFyYW5hMB4XDTA3MDgwOTE2Mzg0MVoXDTA4MDgwODE2Mzg0MVowbTELMAkGA1UE
-BhMCQlIxCzAJBgNVBAgTAlBSMQwwCgYDVQQHEwNDV0IxDTALBgNVBAoTBFNDS1Qx
-DTALBgNVBAsTBHNja3QxJTAjBgNVBAMTHGVjZWxlcGFyOTExMzcuY2VsZXBhci5w
-YXJhbmEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANjxNqj1vKWwIjotVHzJ
-ZY7seB+dBALCHZyqKAodpKe6jmfrtHkKnt0BtiRV/VXsFn5Xeeft5VDYVdxvwGig
-FBjnUn2PtDvkhPkBlFqvWR63mlGdUkdMcamby2tCw/niBXXiVFOgjfrNcXPFqRHT
-wHWIpHLItRXCnxG8BTFL6QofAgMBAAGjgdIwgc8wHQYDVR0OBBYEFDqDGL/fTaKt
-NtkTuuzBet9mgcSOMIGfBgNVHSMEgZcwgZSAFDqDGL/fTaKtNtkTuuzBet9mgcSO
-oXGkbzBtMQswCQYDVQQGEwJCUjELMAkGA1UECBMCUFIxDDAKBgNVBAcTA0NXQjEN
-MAsGA1UEChMEU0NLVDENMAsGA1UECxMEc2NrdDElMCMGA1UEAxMcZWNlbGVwYXI5
-MTEzNy5jZWxlcGFyLnBhcmFuYYIJAOkSDgQDK1oGMAwGA1UdEwQFMAMBAf8wDQYJ
-KoZIhvcNAQEFBQADgYEAVHm/1+iybB3u48nP0NDIocPIhUC55e8iL9h0GOmvJalp
-IpCeIuefCTPCkrJHNMSVNqz6q3UfJLNXe91UdaAYvXEqWLP0mYUz5DWnzUYIIb/y
-W1BZ2WqcX8KZeJJgF/Gu0BJj5oGaf8LMVQoS58TiWgQABg1UTFHnHoXJhABQ1Qo=
------END CERTIFICATE-----
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server_bkp.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server_bkp.c	(revision 216)
+++ 	(revision )
@@ -1,335 +1,0 @@
-#include "server.h"
-
-int main(int argc, char ** argv)
-{
-	/* variables to parse arguments */
-	extern int optind,
-			   optopt;
-	extern char * optarg;
-
-	char * log_file;
-	int c		= (int)NULL,
-		errflg	= (int)NULL,
-		verbose	= (int)NULL,
-		optval	= 1;
-
-	socklen_t optlen = sizeof(optval);
-
-	/* fd -> file descriptor */
-	int socket_server_fd	= (int)NULL,
-		socket_server_port	= (int)NULL,
-		socket_accept_fd	= (int)NULL,
-		sockaddr_in_size	= sizeof(struct sockaddr_in),
-		err					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	struct client * clients = (struct client *) NULL,
-				  * current = (struct client *) NULL;
-
-	pthread_t threads;
-
-	/* clear screen */
-	system(__CLEAR_SCREEN__);
-
-	while ( (c = getopt(argc, argv, ":vp:")) != -1 )
-	{
-		switch ( c )
-		{
-			case 'p':
-				if ( socket_server_port = strtol(optarg, 0, 10) == 0 )
-				{
-					fprintf(stderr, "Option -%c requires a valid port and '%s' isn't valid\n", optopt, optarg);
-					++errflg;
-				}
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			case ':':
-				/* -f or -o without operand */
-				fprintf(stderr, "Option -%c requires an operand\n", optopt);
-				++errflg;
-				break;
-			case '?':
-				fprintf(stderr, "Unrecognized option: -%c\n", optopt);
-				++errflg;
-		}
-	}
-	if ( errflg )
-	{
-		fprintf(stderr, "usage: . . . \n\n");
-		exit(2);
-	}
-
-	/* make a socket */
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	if ( !socket_server_port )
-		socket_server_port = __DEFAULT_OPEN_PORT__;
-
-	/* fill address struct */
-	server_addr.sin_addr.s_addr	= INADDR_ANY;
-	server_addr.sin_port		= htons(socket_server_port);
-	server_addr.sin_family		= AF_INET;
-	bzero(&(server_addr.sin_zero), 8);
-
-	if ( __DEBUG__  || verbose )
-		printf("\nBinding to port %d...\n", socket_server_port);
-
-	/* bind to a port */
-	if ( bind(socket_server_fd, (struct sockaddr *)&(server_addr), sizeof(server_addr)) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not connect to host\n");
-		exit(1);
-	}
-
-	/* get port number */
-	getsockname(socket_server_fd, (struct sockaddr *)&(server_addr), (socklen_t *) &(sockaddr_in_size));
-	if ( __DEBUG__  || verbose )
-	{
-		printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-		printf("Server\n\
-				sin_family        = %d\n\
-				sin_addr.s_addr   = %d\n\
-				sin_port          = %d\n"
-				, server_addr.sin_family
-				, server_addr.sin_addr.s_addr
-				, ntohs(server_addr.sin_port)
-			  );
-		printf("\nMaking a listen queue of %d elements", __QUEUE_SIZE__);
-	}
-
-	/* establish listen queue */
-	if ( listen(socket_server_fd, __QUEUE_SIZE__) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		if ( __DEBUG__  || verbose )
-			puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &(accept_addr), (socklen_t *) &(sockaddr_in_size));
-		fcntl(socket_accept_fd, F_SETFL, fcntl(socket_accept_fd, F_GETFL, 0) | O_NDELAY);
-
-		if ( socket_accept_fd > -1 )
-		{
-			if ( clients == (struct client *) NULL )
-				current = clients;
-			else
-				while ( (current = clients->next) != (struct client *) NULL );
-
-			current				= (struct client *) malloc(sizeof(struct client));
-			current->next		= (struct client *) NULL;
-			current->fd			= socket_accept_fd;
-			current->sockaddr	= accept_addr;
-			current->last		= time(NULL);
-
-			pthread_create(&(threads), NULL, handler, (void *) current);
-		}
-	}
-	pthread_exit(NULL);
-}
-
-int starttls(int * jabberfd, int * clientfd)
-{
-	int err;
-
-	SSL_CTX * ctx;
-	SSL * clientssl,
-		* jabberssl;
-
-	OpenSSL_add_all_algorithms();
-	SSL_library_init();
-	SSL_load_error_strings();
-
-
-	if ( !(ctx = SSL_CTX_new(TLSv1_server_method())) )
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-	
-	/*
-	clientssl = SSL_new(ctx);
-
-	puts("#1");
-	SSL_set_fd(clientssl, *(clientfd));
-
-	puts("accept");
-	err = SSL_accept(clientssl);
-	// Check for error in connect.
-	if ( err < 1 )
-	{
-		puts("server");
-		SSL_CTX_free(ctx);
-		return 0;
-	}
-	*/
-
-	jabberssl = SSL_new(ctx);
-
-	puts("#2");
-	SSL_set_fd(jabberssl, *(jabberfd));
-
-	puts("connect");
-	err = SSL_connect(jabberssl);
-	/* Check for error in connect. */
-	if ( err < 1 )
-	{
-		puts("client");
-		SSL_CTX_free(ctx);
-		return 0;
-	}
-
-	return 1;
-}
-
-void * handler(void * pClient)
-{
-    char buffer_client[__BUFFER_SIZE__],
-		 buffer_jabber[__BUFFER_SIZE__];
-    struct client * client = (struct client *) pClient;
-    int i = 0, err;
-	time_t last;
-
-	char ip[46];
-	unsigned short port;
-	inet_ntop(AF_INET, &(client->sockaddr.sin_addr), ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-	/*---------------------------------------------------*/
-
-	int jabber_fd		= (int)NULL,
-		jabber_port		= (int)NULL,
-		jabber_error	= (int)NULL;
-
-	struct sockaddr_in jabber_addr;
-
-	jabber_port = __DEFAULT_JABBER_PORT__;
-	jabber_fd = socket(AF_INET, SOCK_STREAM, 0);
-
-	fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | O_NDELAY);
-
-	jabber_addr.sin_family = AF_INET;
-	inet_aton(__DEFAULT_JABBER_IP__, &jabber_addr.sin_addr);
-	//jabber_addr.sin_addr.s_addr = inet_addr(__DEFAULT_JABBER_IP__);
-	jabber_addr.sin_port = htons(jabber_port);
-
-	jabber_error = connect(jabber_fd, (struct sockaddr *) &(jabber_addr), sizeof(jabber_addr));
-
-	last = time(NULL);
-	int client_is_connected = -1;
-	int jabber_is_connected = -1;
-	int sockaddr_in_size    = sizeof(struct sockaddr_in);
-	while ( client_is_connected != 0 )
-	{
-		/* read from client */
-		puts("\tread - client");
-		bzero(buffer_client, __BUFFER_SIZE__);
-		if ( (client_is_connected = read(client->fd, buffer_client, __BUFFER_SIZE__)) != 0 && strlen(buffer_jabber) > 0 )
-		{
-			puts("\twrite - client");
-			printf("\t%s\n", buffer_jabber);
-			/* write in the client */
-			write(client->fd, buffer_jabber, strlen(buffer_jabber));
-		}
-
-		/* read from jabber service */
-		puts("\tread - jabber");
-		bzero(buffer_jabber, __BUFFER_SIZE__);
-		if ( (jabber_is_connected = read(jabber_fd, buffer_jabber, __BUFFER_SIZE__))  && strlen(buffer_client) > 0 )
-		{
-				puts("\twrite - jabber");
-				printf("\t%s\n", buffer_client);
-				/* write in the jabber service */
-				if ( !strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-					write(jabber_fd, buffer_client, strlen(buffer_client));
-		}
-		if ( strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-		{
-			fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | ~O_NDELAY);
-			//starttls(&jabber_fd, &client->fd);
-			int err;
-
-			SSL_CTX * ctx;
-			SSL * jabberssl;
-
-			//OpenSSL_add_all_algorithms();
-
-			SSL_library_init();
-			SSL_load_error_strings();
-
-			if ( !(ctx = SSL_CTX_new(TLSv1_server_method())) )
-			{
-				printf("Error creating the context.\n");
-				exit(0);
-			}
-
-			SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-
-			jabberssl = SSL_new(ctx);
-
-			puts("#1");
-			err=SSL_set_fd(jabberssl, jabber_fd);
-			if ( err < 1 )
-			{
-				puts("shsfghdfgh");
-				SSL_CTX_free(ctx);
-			}
-
-			puts("connect");
-			err = SSL_connect(jabberssl);
-			if ( err < 1 )
-			{
-				puts("client");
-				err = SSL_get_error(jabberssl, err);
-				printf("%d\n", err);
-				char err_str[1024];
-				ERR_error_string_n(ERR_get_error(), err_str, sizeof(err_str));
-				printf("%s\n", err_str);
-				SSL_CTX_free(ctx);
-			}
-		}
-
-		if ( jabber_is_connected == 0 )
-			client_is_connected = jabber_is_connected;
-
-		puts("end loop");
-		usleep(500000);
-	}
-
-    if ( close(jabber_fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close jabber socket\n");
-        return 0;
-    }
-	/*---------------------------------------------------*/
-    if ( close(client->fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server_bkp_20071008_2.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server_bkp_20071008_2.c	(revision 216)
+++ 	(revision )
@@ -1,439 +1,0 @@
-#include "server.h"
-#include "xmpp.h"
-
-#define HOST "im.celepar.parana"
-#define IP "10.15.20.219"
-#define PORT "5222"
-
-int tls = 0;
-
-void Read(void * fd, void *buf, int count)
-{
-	bzero(buf, count);
-	if ( tls == 0 )
-		read(*(int *) fd, buf, (ssize_t)count);
-	else
-		SSL_read((SSL *) fd, buf, count);
-}
-
-void Write(void * fd, void *buf, int count)
-{
-	if ( tls == 0 )
-		write(*(int *) fd, buf, (ssize_t)count);
-	else
-		SSL_write((SSL *) fd, buf, count);
-}
-
-int main(int argc, char ** argv)
-{
-	/* variables to parse arguments */
-	extern int optind,
-			   optopt;
-	extern char * optarg;
-
-	char * log_file;
-	int c		= (int)NULL,
-		errflg	= (int)NULL,
-		verbose	= (int)NULL,
-		optval	= 1;
-
-	socklen_t optlen = sizeof(optval);
-
-	/* fd -> file descriptor */
-	int socket_server_fd	= (int)NULL,
-		socket_server_port	= (int)NULL,
-		socket_accept_fd	= (int)NULL,
-		sockaddr_in_size	= sizeof(struct sockaddr_in),
-		err					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	struct client * clients = (struct client *) NULL,
-				  * current = (struct client *) NULL;
-
-	pthread_t threads;
-
-	/* clear screen */
-	system(__CLEAR_SCREEN__);
-
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-
-	char buff[4096];
-	char * xml = (char)NULL;
-	SSL_CTX  *ctx;
-	SSL  *myssl;
-
-	xml = (char *) malloc(sizeof(__CONNECT__));
-
-	while ( (c = getopt(argc, argv, ":vp:")) != -1 )
-	{
-		switch ( c )
-		{
-			case 'p':
-				if ( socket_server_port = strtol(optarg, 0, 10) == 0 )
-				{
-					fprintf(stderr, "Option -%c requires a valid port and '%s' isn't valid\n", optopt, optarg);
-					++errflg;
-				}
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			case ':':
-				/* -f or -o without operand */
-				fprintf(stderr, "Option -%c requires an operand\n", optopt);
-				++errflg;
-				break;
-			case '?':
-				fprintf(stderr, "Unrecognized option: -%c\n", optopt);
-				++errflg;
-		}
-	}
-	if ( errflg )
-	{
-		fprintf(stderr, "usage: . . . \n\n");
-		exit(2);
-	}
-
-	/* make a socket */
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	if ( !socket_server_port )
-		socket_server_port = __DEFAULT_OPEN_PORT__;
-
-	/* fill address struct */
-	server_addr.sin_addr.s_addr	= INADDR_ANY;
-	server_addr.sin_port		= htons(socket_server_port);
-	server_addr.sin_family		= AF_INET;
-	bzero(&(server_addr.sin_zero), 8);
-
-	if ( __DEBUG__  || verbose )
-		printf("\nBinding to port %d...\n", socket_server_port);
-
-	/* bind to a port */
-	if ( bind(socket_server_fd, (struct sockaddr *)&(server_addr), sizeof(server_addr)) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not connect to host\n");
-		exit(1);
-	}
-
-	/* get port number */
-	getsockname(socket_server_fd, (struct sockaddr *)&(server_addr), (socklen_t *) &(sockaddr_in_size));
-	if ( __DEBUG__  || verbose )
-	{
-		printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-		printf("Server\n\
-				sin_family        = %d\n\
-				sin_addr.s_addr   = %d\n\
-				sin_port          = %d\n"
-				, server_addr.sin_family
-				, server_addr.sin_addr.s_addr
-				, ntohs(server_addr.sin_port)
-			  );
-		printf("\nMaking a listen queue of %d elements", __QUEUE_SIZE__);
-	}
-
-	/* establish listen queue */
-	if ( listen(socket_server_fd, __QUEUE_SIZE__) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		if ( __DEBUG__  || verbose )
-			puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &(accept_addr), (socklen_t *) &(sockaddr_in_size));
-		//fcntl(socket_accept_fd, F_SETFL, fcntl(socket_accept_fd, F_GETFL, 0) | O_NDELAY);
-
-		if ( socket_accept_fd > -1 )
-		{
-			if ( clients == (struct client *) NULL )
-				current = clients;
-			else
-				while ( (current = clients->next) != (struct client *) NULL );
-
-			current				= (struct client *) malloc(sizeof(struct client));
-			current->next		= (struct client *) NULL;
-			current->fd			= socket_accept_fd;
-			current->sockaddr	= accept_addr;
-			current->last		= time(NULL);
-
-			if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-			{
-				printf("\n<port>\n\n");
-				printf("\ncould not make a socket\n");
-				return 0;
-			}
-
-			socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-			socketaddr.sin_family = AF_INET;
-			//socketaddr.sin_addr.s_addr = INADDR_ANY;//inet_addr(IP);
-			socketaddr.sin_addr.s_addr = inet_addr(IP);
-			socketaddr.sin_port = htons(nHostPort);
-
-			SSL_library_init();
-			if ( !(ctx = SSL_CTX_new(TLSv1_client_method())) )
-			{
-				printf("Error creating the context.\n");
-				exit(0);
-			}
-
-			err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-
-			if ( err < 0 )
-			{
-				printf("Socket returned error #%d,program terminated\n", err);
-				exit(0);
-			}
-
-			sprintf(xml, __CONNECT__, HOST);
-			Write(&socketfd, xml, strlen(xml));
-			int stop = 0;
-			do
-			{
-				Read (&socketfd, buff, sizeof(buff));
-				if ( strstr(buff, __FEATURES_BEGIN__) )
-					stop = 1;
-				else
-					usleep(100);
-			}
-			while ( !stop );
-
-			puts(buff);
-			stop = 0;
-			int starttls = 0;
-
-			if ( strstr(buff, __STARTTLS_SERVER__) )
-				starttls = 1;
-
-			if ( starttls )
-			{
-				sprintf(xml, __STARTTLS_CLIENT__);
-				Write(&socketfd, xml, strlen(xml));
-
-				stop = 0;
-				do
-				{
-					Read (&socketfd, buff, sizeof(buff));
-					if ( strstr(buff, __PROCEED__) )
-						stop = 1;
-					else
-						usleep(100);
-				}
-				while ( !stop );
-				printf("%s\n\n", buff);
-				bzero(buff, 4096);
-
-				SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-				/*Create new ssl object*/
-				myssl=SSL_new(ctx);
-
-				if(!myssl){
-					printf("Error creating SSL structure.\n");
-					exit(0);
-				}
-
-				/*Bind the socket to the SSL structure*/
-				SSL_set_fd(myssl,socketfd);
-
-				/*Connect to the server, SSL layer.*/
-				err=SSL_connect(myssl);
-				printf("SSL error #%d in accept,program terminated\n",err);
-				/*Check for error in connect.*/
-				if (err<1) {
-
-					err=SSL_get_error(myssl,err);
-					printf("SSL error #%d in accept,program terminated\n",err);
-					printf("%d -- %d\n\n", SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE);
-
-					if(err==5){printf("sockerrno is:\n");}
-
-					close(socketfd);
-					SSL_CTX_free(ctx);
-					exit(0);
-				}
-
-				tls = 1;
-
-				printf("SSL connection on socket %x,Version: %s, Cipher: %s\n\n\n",
-						socketfd,
-						SSL_get_version(myssl),
-						SSL_get_cipher(myssl));
-
-				sprintf(xml, __CONNECT__, HOST);
-				SSL_write(myssl, xml, strlen(xml));
-				usleep(10000);
-				SSL_read(myssl, buff, sizeof(buff));
-				printf("%s\n\n", buff);
-				bzero(buff, 4096);
-
-				usleep(10000);
-				SSL_read(myssl, buff, sizeof(buff));
-				printf("%s\n\n", buff);
-				bzero(buff, 4096);
-
-				SSL_clear(myssl);
-				SSL_shutdown(myssl);
-				SSL_free(myssl);
-				SSL_CTX_free(ctx);
-			}
-			fflush(stdin);
-			fflush(stdout);
-
-
-
-			//pthread_create(&(threads), NULL, handler, (void *) current);
-		}
-	}
-	pthread_exit(NULL);
-}
-
-void * handler(void * pClient)
-{
-    char buffer_client[__BUFFER_SIZE__],
-		 buffer_jabber[__BUFFER_SIZE__];
-    struct client * client = (struct client *) pClient;
-    int i = 0, err;
-	time_t last;
-
-	char ip[46];
-	unsigned short port;
-	inet_ntop(AF_INET, &(client->sockaddr.sin_addr), ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-	/*---------------------------------------------------*/
-
-	int jabber_fd		= (int)NULL,
-		jabber_port		= (int)NULL,
-		jabber_error	= (int)NULL;
-
-	struct sockaddr_in jabber_addr;
-
-	jabber_port = __DEFAULT_JABBER_PORT__;
-	jabber_fd = socket(AF_INET, SOCK_STREAM, 0);
-
-	fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | O_NDELAY);
-
-	jabber_addr.sin_family = AF_INET;
-	inet_aton(__DEFAULT_JABBER_IP__, &jabber_addr.sin_addr);
-	//jabber_addr.sin_addr.s_addr = inet_addr(__DEFAULT_JABBER_IP__);
-	jabber_addr.sin_port = htons(jabber_port);
-
-	jabber_error = connect(jabber_fd, (struct sockaddr *) &(jabber_addr), sizeof(jabber_addr));
-
-	last = time(NULL);
-	int client_is_connected = -1;
-	int jabber_is_connected = -1;
-	int sockaddr_in_size    = sizeof(struct sockaddr_in);
-	while ( client_is_connected != 0 )
-	{
-		/* read from client */
-		puts("\tread - client");
-		bzero(buffer_client, __BUFFER_SIZE__);
-		if ( (client_is_connected = read(client->fd, buffer_client, __BUFFER_SIZE__)) != 0 && strlen(buffer_jabber) > 0 )
-		{
-			puts("\twrite - client");
-			printf("\t%s\n", buffer_jabber);
-			/* write in the client */
-			write(client->fd, buffer_jabber, strlen(buffer_jabber));
-		}
-
-		/* read from jabber service */
-		puts("\tread - jabber");
-		bzero(buffer_jabber, __BUFFER_SIZE__);
-		if ( (jabber_is_connected = read(jabber_fd, buffer_jabber, __BUFFER_SIZE__))  && strlen(buffer_client) > 0 )
-		{
-				puts("\twrite - jabber");
-				printf("\t%s\n", buffer_client);
-				/* write in the jabber service */
-				if ( !strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-					write(jabber_fd, buffer_client, strlen(buffer_client));
-		}
-		if ( strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-		{
-			fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | ~O_NDELAY);
-			//starttls(&jabber_fd, &client->fd);
-			int err;
-
-			SSL_CTX * ctx;
-			SSL * jabberssl;
-
-			//OpenSSL_add_all_algorithms();
-
-			SSL_library_init();
-			SSL_load_error_strings();
-
-			if ( !(ctx = SSL_CTX_new(TLSv1_server_method())) )
-			{
-				printf("Error creating the context.\n");
-				exit(0);
-			}
-
-			SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-
-			jabberssl = SSL_new(ctx);
-
-			puts("#1");
-			err=SSL_set_fd(jabberssl, jabber_fd);
-			if ( err < 1 )
-			{
-				puts("shsfghdfgh");
-				SSL_CTX_free(ctx);
-			}
-
-			puts("connect");
-			err = SSL_connect(jabberssl);
-			if ( err < 1 )
-			{
-				puts("client");
-				err = SSL_get_error(jabberssl, err);
-				printf("%d\n", err);
-				char err_str[1024];
-				ERR_error_string_n(ERR_get_error(), err_str, sizeof(err_str));
-				printf("%s\n", err_str);
-				SSL_CTX_free(ctx);
-			}
-		}
-
-		if ( jabber_is_connected == 0 )
-			client_is_connected = jabber_is_connected;
-
-		puts("end loop");
-		usleep(500000);
-	}
-
-    if ( close(jabber_fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close jabber socket\n");
-        return 0;
-    }
-	/*---------------------------------------------------*/
-    if ( close(client->fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server.c	(revision 216)
+++ 	(revision )
@@ -1,422 +1,0 @@
-#include "server.h"
-#include "xmpp.h"
-
-#define HOST "im.celepar.parana"
-#define IP "10.15.20.219"
-#define PORT "5222"
-
-int tls = 0;
-
-void Read(void * fd, void *buf, int count)
-{
-	bzero(buf, count);
-	if ( tls == 0 )
-		read(*(int *) fd, buf, (ssize_t)count);
-	else
-		SSL_read((SSL *) fd, buf, count);
-}
-
-void Write(void * fd, void *buf, int count)
-{
-	if ( tls == 0 )
-		write(*(int *) fd, buf, (ssize_t)count);
-	else
-		SSL_write((SSL *) fd, buf, count);
-}
-
-int main(int argc, char ** argv)
-{
-	/* variables to parse arguments */
-	extern int optind,
-			   optopt;
-	extern char * optarg;
-
-	char * log_file;
-	int c		= (int)NULL,
-		errflg	= (int)NULL,
-		verbose	= (int)NULL,
-		optval	= 1;
-
-	socklen_t optlen = sizeof(optval);
-
-	/* fd -> file descriptor */
-	int socket_server_fd	= (int)NULL,
-		socket_server_port	= (int)NULL,
-		socket_accept_fd	= (int)NULL,
-		sockaddr_in_size	= sizeof(struct sockaddr_in),
-		err					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	struct client * clients = (struct client *) NULL,
-				  * current = (struct client *) NULL;
-
-	SSL_CTX * ctx;
-
-	pthread_t threads;
-
-	// clear screen
-	system(__CLEAR_SCREEN__);
-
-	while ( (c = getopt(argc, argv, ":vp:")) != -1 )
-	{
-		switch ( c )
-		{
-			case 'p':
-				if ( socket_server_port = strtol(optarg, 0, 10) == 0 )
-				{
-					fprintf(stderr, "Option -%c requires a valid port and '%s' isn't valid\n", optopt, optarg);
-					++errflg;
-				}
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			case ':':
-				// -f or -o without operand
-				fprintf(stderr, "Option -%c requires an operand\n", optopt);
-				++errflg;
-				break;
-			case '?':
-				fprintf(stderr, "Unrecognized option: -%c\n", optopt);
-				++errflg;
-		}
-	}
-	if ( errflg )
-	{
-		fprintf(stderr, "usage: . . . \n\n");
-		exit(2);
-	}
-
-	OpenSSL_add_all_algorithms();
-	SSL_library_init();
-	SSL_load_error_strings();
-
-	if ( !(ctx = SSL_CTX_new(TLSv1_server_method())) )
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	if ( SSL_CTX_set_cipher_list(ctx, CIPHER_LIST) < 1 )
-	{
-		printf("Error setting the cipher list.\n");
-		exit(0);
-	}
-
-	//Indicate the certificate file to be used
-	if ( SSL_CTX_use_certificate_file(ctx, CERT_FILE, SSL_FILETYPE_PEM) < 1 )
-	{
-		printf("Error setting the certificate file.\n");
-		exit(0);
-	}
-
-	//Load the password for the Private Key
-	SSL_CTX_set_default_passwd_cb_userdata(ctx, KEY_PASSWD);
-
-	//Indicate the key file to be used
-	if ( SSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM) < 1 )
-	{
-		printf("Error setting the key file.\n");
-		exit(0);
-	}
-
-	//Make sure the key and certificate file match
-	if ( !SSL_CTX_check_private_key(ctx) )
-	{
-		printf("Private key does not match the certificate public key\n");
-		exit(0);
-	}
-
-	// Set the list of trusted CAs based on the file and/or directory provided
-	if ( SSL_CTX_load_verify_locations(ctx, CA_FILE, CA_DIR) < 1 )
-	{
-		printf("Error setting verify location\n");
-		exit(0);
-	}
-
-	// Set for server verification
-	SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
-
-	/* make a socket */
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	if ( !socket_server_port )
-		socket_server_port = __DEFAULT_OPEN_PORT__;
-
-	/* fill address struct */
-	server_addr.sin_addr.s_addr	= INADDR_ANY;
-	server_addr.sin_port		= htons(socket_server_port);
-	server_addr.sin_family		= AF_INET;
-	bzero(&(server_addr.sin_zero), 8);
-
-	if ( __DEBUG__  || verbose )
-		printf("\nBinding to port %d...\n", socket_server_port);
-
-	/* bind to a port */
-	if ( bind(socket_server_fd, (struct sockaddr *)&(server_addr), sizeof(server_addr)) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not connect to host\n");
-		exit(1);
-	}
-
-	/* get port number */
-	getsockname(socket_server_fd, (struct sockaddr *)&(server_addr), (socklen_t *) &(sockaddr_in_size));
-	if ( __DEBUG__  || verbose )
-	{
-		printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-		printf("Server\n\
-				sin_family        = %d\n\
-				sin_addr.s_addr   = %d\n\
-				sin_port          = %d\n"
-				, server_addr.sin_family
-				, server_addr.sin_addr.s_addr
-				, ntohs(server_addr.sin_port)
-			  );
-		printf("\nMaking a listen queue of %d elements", __QUEUE_SIZE__);
-	}
-
-	/* establish listen queue */
-	if ( listen(socket_server_fd, __QUEUE_SIZE__) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		if ( __DEBUG__  || verbose )
-			puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &(accept_addr), (socklen_t *) &(sockaddr_in_size));
-		fcntl(socket_accept_fd, F_SETFL, fcntl(socket_accept_fd, F_GETFL, 0) | O_NDELAY);
-
-		if ( socket_accept_fd > -1 )
-		{
-			if ( clients == (struct client *) NULL )
-				current = clients;
-			else
-				while ( (current = clients->next) != (struct client *) NULL );
-
-			current				= (struct client *) malloc(sizeof(struct client));
-			current->next		= (struct client *) NULL;
-			current->fd			= socket_accept_fd;
-			current->sockaddr	= accept_addr;
-			current->ctx		= ctx;
-			current->last		= time(NULL);
-
-			pthread_create(&(threads), NULL, handler, (void *) current);
-		}
-	}
-	pthread_exit(NULL);
-}
-
-void * handler(void * pClient)
-{
-    char buffer_client[__BUFFER_SIZE__],
-		 buffer_jabber[__BUFFER_SIZE__];
-    struct client * client = (struct client *) pClient;
-    int i = 0, err;
-	time_t last;
-
-	char ip[46];
-	unsigned short port;
-	inet_ntop(AF_INET, &(client->sockaddr.sin_addr), ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-	/*---------------------------------------------------*/
-
-	int client_is_connected = -1;
-	int jabber_is_connected = -1;
-
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-
-	char buff[4096];
-	char * xml = (char)NULL;
-	SSL_CTX  *ctx;
-	SSL  *myssl;
-
-	char * old_host,
-		 * replace_host;
-
-	xml = (char *) malloc(sizeof(__CONNECT__));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	socketaddr.sin_addr.s_addr = inet_addr(IP);
-	socketaddr.sin_port = htons(nHostPort);
-
-	if ( !(ctx = SSL_CTX_new(TLSv1_client_method())) )
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-	fcntl(socketfd, F_SETFL, fcntl(socketfd, F_GETFL, 0) | O_NDELAY);
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	while ( client_is_connected != 0 )
-	{
-		/* read from client */
-		puts("\tread - client");
-		bzero(buffer_client, __BUFFER_SIZE__);
-		if ( (client_is_connected = read(client->fd, buffer_client, __BUFFER_SIZE__)) != 0 )
-		{
-			if ( strlen(buffer_jabber) > 0 )
-			{
-				puts("\twrite - client");
-				printf("\t%s\n", buffer_jabber);
-				/* write in the client */
-				write(client->fd, buffer_jabber, strlen(buffer_jabber));
-			}
-
-			if ( strstr(buffer_client, "<stream:stream") && (old_host = strstr(buffer_client, "to=")) )
-			{
-				strncpy(replace_host, buffer_client, (strlen(buffer_client) - strlen(old_host))+4);
-				strcat(replace_host, HOST);
-				old_host = strstr(old_host, " ");
-				old_host--;
-				strcat(replace_host, old_host);
-				strcpy(buffer_client, replace_host);
-			}
-		}
-
-		/* read from jabber service */
-		puts("\tread - jabber");
-		bzero(buffer_jabber, __BUFFER_SIZE__);
-		if ( (jabber_is_connected = read(socketfd, buffer_jabber, __BUFFER_SIZE__))  && strlen(buffer_client) > 0 )
-		{
-			puts("\twrite - jabber");
-			printf("\t%s\n", buffer_client);
-			/* write in the jabber service */
-			write(socketfd, buffer_client, strlen(buffer_client));
-		}
-
-		if ( strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-		{
-			fcntl( socketfd, F_SETFL, fcntl( socketfd, F_GETFL ) & ~O_NDELAY );
-			SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-			//Create new ssl object
-			myssl=SSL_new(ctx);
-
-			if(!myssl){
-				printf("Error creating SSL structure.\n");
-				exit(0);
-			}
-
-			//Bind the socket to the SSL structure
-			SSL_set_fd(myssl,socketfd);
-
-			//Connect to the server, SSL layer.
-			err=SSL_connect(myssl);
-			printf("SSL error #%d in accept,program terminated\n",err);
-			//Check for error in connect.
-			if (err<1) {
-
-				err=SSL_get_error(myssl,err);
-				printf("SSL error #%d in accept,program terminated\n",err);
-				printf("%d -- %d\n\n", SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE);
-
-				if(err==5){printf("sockerrno is:\n");}
-
-				close(socketfd);
-				SSL_CTX_free(ctx);
-				exit(0);
-			}
-
-			fcntl(socketfd, F_SETFL, fcntl(socketfd, F_GETFL, 0) | O_NDELAY);
-
-			write(client->fd, buffer_jabber, strlen(buffer_jabber));
-			bzero(buffer_jabber, __BUFFER_SIZE__);
-
-			fcntl( client->fd, F_SETFL, fcntl( client->fd, F_GETFL ) & ~O_NDELAY );
-
-			//Create new ssl object
-			if( !(client->myssl = SSL_new(client->ctx)) )
-			{
-				printf("Error creating SSL structure.\n");
-				exit(0);
-			}
-
-			//Bind the socket to the SSL structure
-			SSL_set_fd(client->myssl, client->fd);
-
-			puts("_____TESTE______");
-			//Connect to the server, SSL layer.
-			err = SSL_accept(client->myssl);
-			puts("_____TESTE______");
-
-			//Check for error in connect.
-			if ( err < 1 )
-			{
-				printf("SSL error #%d in accept,program terminated\n", err);
-				err = SSL_get_error(client->myssl, 0);
-				printf("SSL error #%d in accept,program terminated\n", err);
-
-				switch ( err )
-				{
-					case SSL_ERROR_NONE : puts("SSL_ERROR_NONE");break;
-					case SSL_ERROR_SSL : puts("SSL_ERROR_SSL");break;
-					case SSL_ERROR_WANT_READ : puts("SSL_ERROR_WANT_READ");
-				}
-
-				if ( err == 5 )
-					printf("sockerrno is: %d\n", err);
-
-
-				SSL_CTX_free(client->ctx);
-				client_is_connected = 0;
-			}
-		}
-
-		if ( jabber_is_connected == 0 )
-			client_is_connected = jabber_is_connected;
-
-		puts("end loop");
-		usleep(500000);
-	}
-    if ( close(socketfd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close jabber socket\n");
-        return 0;
-    }
-	//---------------------------------------------------
-    if ( close(client->fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/unp.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/unp.h	(revision 216)
+++ 	(revision )
@@ -1,28 +1,0 @@
-/**
- * unp.h
- * Unix Network Programming
- **/
-
-#include <fcntl.h>
-
-#include <netdb.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-
-#include <pthread.h>
-
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <unistd.h>
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server_bkp_20071008_jabber_tls.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server_bkp_20071008_jabber_tls.c	(revision 216)
+++ 	(revision )
@@ -1,333 +1,0 @@
-#include "server.h"
-#include "xmpp.h"
-
-#define HOST "im.celepar.parana"
-#define IP "10.15.20.219"
-#define PORT "5222"
-
-int tls = 0;
-
-void Read(void * fd, void *buf, int count)
-{
-	bzero(buf, count);
-	if ( tls == 0 )
-		read(*(int *) fd, buf, (ssize_t)count);
-	else
-		SSL_read((SSL *) fd, buf, count);
-}
-
-void Write(void * fd, void *buf, int count)
-{
-	if ( tls == 0 )
-		write(*(int *) fd, buf, (ssize_t)count);
-	else
-		SSL_write((SSL *) fd, buf, count);
-}
-
-int main(int argc, char ** argv)
-{
-	/* variables to parse arguments */
-	extern int optind,
-			   optopt;
-	extern char * optarg;
-
-	char * log_file;
-	int c		= (int)NULL,
-		errflg	= (int)NULL,
-		verbose	= (int)NULL,
-		optval	= 1;
-
-	socklen_t optlen = sizeof(optval);
-
-	/* fd -> file descriptor */
-	int socket_server_fd	= (int)NULL,
-		socket_server_port	= (int)NULL,
-		socket_accept_fd	= (int)NULL,
-		sockaddr_in_size	= sizeof(struct sockaddr_in),
-		err					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	struct client * clients = (struct client *) NULL,
-				  * current = (struct client *) NULL;
-
-	pthread_t threads;
-
-	/* clear screen */
-	system(__CLEAR_SCREEN__);
-
-	while ( (c = getopt(argc, argv, ":vp:")) != -1 )
-	{
-		switch ( c )
-		{
-			case 'p':
-				if ( socket_server_port = strtol(optarg, 0, 10) == 0 )
-				{
-					fprintf(stderr, "Option -%c requires a valid port and '%s' isn't valid\n", optopt, optarg);
-					++errflg;
-				}
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			case ':':
-				/* -f or -o without operand */
-				fprintf(stderr, "Option -%c requires an operand\n", optopt);
-				++errflg;
-				break;
-			case '?':
-				fprintf(stderr, "Unrecognized option: -%c\n", optopt);
-				++errflg;
-		}
-	}
-	if ( errflg )
-	{
-		fprintf(stderr, "usage: . . . \n\n");
-		exit(2);
-	}
-
-	/* make a socket */
-	int one = 1;
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	if ( !socket_server_port )
-		socket_server_port = __DEFAULT_OPEN_PORT__;
-
-	/* fill address struct */
-	server_addr.sin_addr.s_addr	= INADDR_ANY;
-	server_addr.sin_port		= htons(socket_server_port);
-	server_addr.sin_family		= AF_INET;
-	bzero(&(server_addr.sin_zero), 8);
-
-	if ( __DEBUG__  || verbose )
-		printf("\nBinding to port %d...\n", socket_server_port);
-
-	/* bind to a port */
-	if ( bind(socket_server_fd, (struct sockaddr *)&(server_addr), sizeof(server_addr)) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not connect to host\n");
-		exit(1);
-	}
-
-	/* get port number */
-	getsockname(socket_server_fd, (struct sockaddr *)&(server_addr), (socklen_t *) &(sockaddr_in_size));
-	if ( __DEBUG__  || verbose )
-	{
-		printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-		printf("Server\n\
-				sin_family        = %d\n\
-				sin_addr.s_addr   = %d\n\
-				sin_port          = %d\n"
-				, server_addr.sin_family
-				, server_addr.sin_addr.s_addr
-				, ntohs(server_addr.sin_port)
-			  );
-		printf("\nMaking a listen queue of %d elements", __QUEUE_SIZE__);
-	}
-
-	/* establish listen queue */
-	if ( listen(socket_server_fd, __QUEUE_SIZE__) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		if ( __DEBUG__  || verbose )
-			puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &(accept_addr), (socklen_t *) &(sockaddr_in_size));
-		fcntl(socket_accept_fd, F_SETFL, fcntl(socket_accept_fd, F_GETFL, 0) | O_NDELAY);
-
-		if ( socket_accept_fd > -1 )
-		{
-			if ( clients == (struct client *) NULL )
-				current = clients;
-			else
-				while ( (current = clients->next) != (struct client *) NULL );
-
-			current				= (struct client *) malloc(sizeof(struct client));
-			current->next		= (struct client *) NULL;
-			current->fd			= socket_accept_fd;
-			current->sockaddr	= accept_addr;
-			current->last		= time(NULL);
-
-			pthread_create(&(threads), NULL, handler, (void *) current);
-		}
-	}
-	pthread_exit(NULL);
-}
-
-void * handler(void * pClient)
-{
-    char buffer_client[__BUFFER_SIZE__],
-		 buffer_jabber[__BUFFER_SIZE__];
-    struct client * client = (struct client *) pClient;
-    int i = 0, err;
-	time_t last;
-
-	char ip[46];
-	unsigned short port;
-	inet_ntop(AF_INET, &(client->sockaddr.sin_addr), ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-	/*---------------------------------------------------*/
-
-	int client_is_connected = -1;
-	int jabber_is_connected = -1;
-
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-
-	char buff[4096];
-	char * xml = (char)NULL;
-	SSL_CTX  *ctx;
-	SSL  *myssl;
-
-	char * old_host,
-		 * replace_host;
-
-	xml = (char *) malloc(sizeof(__CONNECT__));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	socketaddr.sin_addr.s_addr = inet_addr(IP);
-	socketaddr.sin_port = htons(nHostPort);
-
-	OpenSSL_add_all_algorithms();
-	SSL_library_init();
-	SSL_load_error_strings();
-
-	if ( !(ctx = SSL_CTX_new(TLSv1_client_method())) )
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-	fcntl(socketfd, F_SETFL, fcntl(socketfd, F_GETFL, 0) | O_NDELAY);
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	while ( client_is_connected != 0 )
-	{
-		/* read from client */
-		puts("\tread - client");
-		bzero(buffer_client, __BUFFER_SIZE__);
-		if ( (client_is_connected = read(client->fd, buffer_client, __BUFFER_SIZE__)) != 0 )
-		{
-			if ( strlen(buffer_jabber) > 0 )
-			{
-				puts("\twrite - client");
-				printf("\t%s\n", buffer_jabber);
-				/* write in the client */
-				write(client->fd, buffer_jabber, strlen(buffer_jabber));
-			}
-
-			if ( strstr(buffer_client, "<stream:stream") && (old_host = strstr(buffer_client, "to=")) )
-			{
-				strncpy(replace_host, buffer_client, (strlen(buffer_client) - strlen(old_host))+4);
-				strcat(replace_host, HOST);
-				old_host = strstr(old_host, " ");
-				old_host--;
-				strcat(replace_host, old_host);
-				strcpy(buffer_client, replace_host);
-			}
-		}
-
-		/* read from jabber service */
-		puts("\tread - jabber");
-		bzero(buffer_jabber, __BUFFER_SIZE__);
-		if ( (jabber_is_connected = read(socketfd, buffer_jabber, __BUFFER_SIZE__))  && strlen(buffer_client) > 0 )
-		{
-			puts("\twrite - jabber");
-			printf("\t%s\n", buffer_client);
-			/* write in the jabber service */
-			write(socketfd, buffer_client, strlen(buffer_client));
-		}
-
-		if ( strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-		{
-			fcntl( socketfd, F_SETFL, fcntl( socketfd, F_GETFL ) & ~O_NDELAY );
-			SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-			//Create new ssl object
-			myssl=SSL_new(ctx);
-
-			if(!myssl){
-				printf("Error creating SSL structure.\n");
-				exit(0);
-			}
-
-			//Bind the socket to the SSL structure
-			SSL_set_fd(myssl,socketfd);
-
-			//Connect to the server, SSL layer.
-			err=SSL_connect(myssl);
-			printf("SSL error #%d in accept,program terminated\n",err);
-			//Check for error in connect.
-			if (err<1) {
-
-				err=SSL_get_error(myssl,err);
-				printf("SSL error #%d in accept,program terminated\n",err);
-				printf("%d -- %d\n\n", SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE);
-
-				if(err==5){printf("sockerrno is:\n");}
-
-				close(socketfd);
-				SSL_CTX_free(ctx);
-				exit(0);
-			}
-
-
-			fcntl(socketfd, F_SETFL, fcntl(socketfd, F_GETFL, 0) | O_NDELAY);
-		}
-
-		if ( jabber_is_connected == 0 )
-			client_is_connected = jabber_is_connected;
-
-		puts("end loop");
-		usleep(500000);
-	}
-    if ( close(socketfd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close jabber socket\n");
-        return 0;
-    }
-	//---------------------------------------------------
-    if ( close(client->fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server.h	(revision 216)
+++ 	(revision )
@@ -1,102 +1,0 @@
-#include <fcntl.h>
-
-#include <netdb.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-
-#include <pthread.h>
-
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <unistd.h>
-
-/* define max clients per child */
-#ifndef __CLIENTS__
-   #define __CLIENTS__ 100
-#endif
-
-/* define max clients waiting in the queue for connect */
-#ifndef __QUEUE_SIZE__
-	#define __QUEUE_SIZE__ 10
-#endif
-
-/* __SOCKET_ERROR__ must be -1, don't change this */
-#ifndef __SOCKET_ERROR__
-	#define __SOCKET_ERROR__ -1
-#endif
-
-/* open port when this server is activated */
-#ifndef __DEFAULT_OPEN_PORT__
-	#define __DEFAULT_OPEN_PORT__ 8888
-#endif
-
-/* ip of jabber service */
-#ifndef __DEFAULT_JABBER_PORT__
-	#define __DEFAULT_JABBER_PORT__ 5222
-#endif
-
-/* port to connect on jabber service */
-#ifndef __DEFAULT_JABBER_IP__
-	#define __DEFAULT_JABBER_IP__ "im.celepar.parana"
-#endif
-
-/* the jabber's documentation recommends read the packages of socket with size of 4096 (2^12) KB */
-#ifndef __BUFFER_SIZE__
-	#define __BUFFER_SIZE__ 4096
-#endif
-
-#define MESSAGE			"This is the message I'm sending back and forth"
-
-/* Make these what you want for certificate & key files */
-#define CERT_FILE "mycert.pem"
-#define KEY_FILE  "mycert.pem"
-
-/*Cipher list to be used*/
-#define CIPHER_LIST "RC4-MD5"
-
-/*Trusted CAs location*/
-#define CA_FILE CERT_FILE
-#define CA_DIR NULL
-
-/*Password for the key file*/
-#define KEY_PASSWD ""
-
-#ifndef __CLEAR_SCREEN__
-	#define __CLEAR_SCREEN__ "clear"
-#endif
-
-/* 0 -> false; 1 -> true */
-#ifndef __DEBUG__
-	#define __DEBUG__ 0
-#endif
-
-struct client
-{
-	int fd;
-	struct sockaddr_in sockaddr;
-	pthread_t thread;
-	SSL_CTX  *ctx;
-	SSL * myssl;
-	time_t last;
-	struct client * next;
-};
-
-void * handler(void *);
-
-void usage (void)
-{
-	puts("usage: ./server <PORT>\n\n");
-	exit (-1);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/client.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/client.c	(revision 216)
+++ 	(revision )
@@ -1,73 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#define IP "200.189.113.148"
-
-#define PORT "5222"
-
-int main(void)
-{
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-	int err,
-		i,
-		unit;
-	char buff[4096];
-	char * _xml = (char)NULL,
-		 * xml_connect = {"<?xml version='1.0' encoding='UTF-8'?><stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"};
-
-	_xml = (char *)malloc(sizeof(xml_connect));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	//socketaddr.sin_addr.s_addr = INADDR_ANY;//inet_addr(IP);
-	//socketaddr.sin_addr.s_addr = inet_addr("10.15.20.42");
-	inet_aton(IP, &socketaddr.sin_addr);
-	socketaddr.sin_port = htons(nHostPort);
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	struct hostent *hp;
-	hp = gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET);
-
-	printf("\n\n%s\n\n", inet_ntoa(socketaddr.sin_addr));
-	printf("\n\n%d\n\n", inet_network("expresso.pr.gov.br"));
-
-	//printf("\n\n%d\n\n", socketaddr.sin_addr.s_addr);
-	//printf("\n\n%s\n\n", gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET));
-
-
-	sprintf(_xml, xml_connect, IP);
-
-	write(socketfd, _xml, strlen(_xml));
-
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-	//sleep(10);
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/teste_bkp.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/teste_bkp.c	(revision 216)
+++ 	(revision )
@@ -1,185 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-
-
-//#define HOST "im.pr.gov.br"
-//#define IP "200.189.113.148"
-#define HOST "localhost"
-#define IP "10.15.20.42"
-//#define HOST "im.celepar.parana"
-//#define IP "10.15.20.219"
-#define PORT "5222"
-
-int tls = 0;
-
-void Read(void * fd, void *buf, int count)
-{
-	if ( tls == 0 )
-		read(*(int *) fd, buf, (ssize_t)count);
-	else
-		SSL_read((SSL *) fd, buf, count);
-}
-
-void Write(void * fd, void *buf, int count)
-{
-	if ( tls == 0 )
-		write(*(int *) fd, buf, (ssize_t)count);
-	else
-		SSL_write((SSL *) fd, buf, count);
-}
-
-int main(void)
-{
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-	int err,
-		i,
-		unit;
-	extern int tls;
-	char buff[4096];
-	char * _xml = (char)NULL,
-		 * xml_connect = {"<?xml version='1.0' encoding='UTF-8'?><stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"},
-		 * xml_starttls = {"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"};
-
-	/*SSL PART*/
-	SSL_METHOD *meth;
-	SSL_CTX  *ctx;
-	SSL  *myssl;
-	/*SSL PART*/
-
-	_xml = (char *) malloc(sizeof(xml_connect));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	//socketaddr.sin_addr.s_addr = INADDR_ANY;//inet_addr(IP);
-	socketaddr.sin_addr.s_addr = inet_addr(IP);
-	socketaddr.sin_port = htons(nHostPort);
-
-	OpenSSL_add_all_algorithms();
-	SSL_library_init();
-	SSL_load_error_strings();
-
-	meth=TLSv1_client_method();
-
-	ctx=SSL_CTX_new(meth);
-	if (!ctx)
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-	//fcntl(socketfd, F_SETFL, fcntl(socketfd, F_GETFL, 0) | O_NDELAY | O_NONBLOCK);
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	sprintf(_xml, xml_connect, HOST);
-	Write(&socketfd, _xml, strlen(_xml));
-	//usleep(500);
-	Read (&socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-	bzero(buff, 4096);
-
-	puts("-----------\n");
-
-	/*
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-	bzero(buff, 4096);
-
-	puts("-----------\n");
-	*/
-
-	sprintf(_xml, xml_starttls);
-	Write(&socketfd, _xml, strlen(_xml));
-	//usleep(500);
-	Read (&socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-	bzero(buff, 4096);
-
-	SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-	/*Create new ssl object*/
-	myssl=SSL_new(ctx);
-
-	if(!myssl){
-		printf("Error creating SSL structure.\n");
-		exit(0);
-	}
-
-	/*Bind the socket to the SSL structure*/
-	SSL_set_fd(myssl,socketfd);
-
-	/*Connect to the server, SSL layer.*/
-	err=SSL_connect(myssl);
-	printf("SSL error #%d in accept,program terminated\n",err);
-	/*Check for error in connect.*/
-	if (err<1) {
-
-		err=SSL_get_error(myssl,err);
-		printf("SSL error #%d in accept,program terminated\n",err);
-		printf("%d -- %d\n\n", SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE);
-
-		if(err==5){printf("sockerrno is:\n");}
-
-		close(socketfd);
-		SSL_CTX_free(ctx);
-		exit(0);
-	}
-
-	tls = 1;
-
-	/*Print out connection details*/
-	printf("SSL connection on socket %x,Version: %s, Cipher: %s\n\n\n",
-			socketfd,
-			SSL_get_version(myssl),
-			SSL_get_cipher(myssl));
-
-	sprintf(_xml, xml_connect, HOST);
-	SSL_write(myssl, _xml, strlen(_xml));
-	usleep(10000);
-	SSL_read(myssl, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-	bzero(buff, 4096);
-
-	usleep(10000);
-	SSL_read(myssl, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-	bzero(buff, 4096);
-
-	SSL_clear(myssl);
-	SSL_shutdown(myssl);
-	SSL_free(myssl);
-	SSL_CTX_free(ctx);
-	fflush(stdin);
-    fflush(stdout);
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server_bkp_20071008.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/server_bkp_20071008.c	(revision 216)
+++ 	(revision )
@@ -1,406 +1,0 @@
-#include "server.h"
-
-int main(int argc, char ** argv)
-{
-	/* variables to parse arguments */
-	extern int optind,
-			   optopt;
-	extern char * optarg;
-
-	char * log_file;
-	int c		= (int)NULL,
-		errflg	= (int)NULL,
-		verbose	= (int)NULL,
-		optval	= 1;
-
-	socklen_t optlen = sizeof(optval);
-
-	/* fd -> file descriptor */
-	int socket_server_fd	= (int)NULL,
-		socket_server_port	= (int)NULL,
-		socket_accept_fd	= (int)NULL,
-		sockaddr_in_size	= sizeof(struct sockaddr_in),
-		err					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	struct client * clients = (struct client *) NULL,
-				  * current = (struct client *) NULL;
-
-	pthread_t threads;
-
-	/* clear screen */
-	system(__CLEAR_SCREEN__);
-
-	while ( (c = getopt(argc, argv, ":vp:")) != -1 )
-	{
-		switch ( c )
-		{
-			case 'p':
-				if ( socket_server_port = strtol(optarg, 0, 10) == 0 )
-				{
-					fprintf(stderr, "Option -%c requires a valid port and '%s' isn't valid\n", optopt, optarg);
-					++errflg;
-				}
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			case ':':
-				/* -f or -o without operand */
-				fprintf(stderr, "Option -%c requires an operand\n", optopt);
-				++errflg;
-				break;
-			case '?':
-				fprintf(stderr, "Unrecognized option: -%c\n", optopt);
-				++errflg;
-		}
-	}
-	if ( errflg )
-	{
-		fprintf(stderr, "usage: . . . \n\n");
-		exit(2);
-	}
-
-	/* make a socket */
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	if ( !socket_server_port )
-		socket_server_port = __DEFAULT_OPEN_PORT__;
-
-	/* fill address struct */
-	server_addr.sin_addr.s_addr	= INADDR_ANY;
-	server_addr.sin_port		= htons(socket_server_port);
-	server_addr.sin_family		= AF_INET;
-	bzero(&(server_addr.sin_zero), 8);
-
-	if ( __DEBUG__  || verbose )
-		printf("\nBinding to port %d...\n", socket_server_port);
-
-	/* bind to a port */
-	if ( bind(socket_server_fd, (struct sockaddr *)&(server_addr), sizeof(server_addr)) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not connect to host\n");
-		exit(1);
-	}
-
-	/* get port number */
-	getsockname(socket_server_fd, (struct sockaddr *)&(server_addr), (socklen_t *) &(sockaddr_in_size));
-	if ( __DEBUG__  || verbose )
-	{
-		printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-		printf("Server\n\
-				sin_family        = %d\n\
-				sin_addr.s_addr   = %d\n\
-				sin_port          = %d\n"
-				, server_addr.sin_family
-				, server_addr.sin_addr.s_addr
-				, ntohs(server_addr.sin_port)
-			  );
-		printf("\nMaking a listen queue of %d elements", __QUEUE_SIZE__);
-	}
-
-	/* establish listen queue */
-	if ( listen(socket_server_fd, __QUEUE_SIZE__) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		if ( __DEBUG__  || verbose )
-			puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &(accept_addr), (socklen_t *) &(sockaddr_in_size));
-		fcntl(socket_accept_fd, F_SETFL, fcntl(socket_accept_fd, F_GETFL, 0) | O_NDELAY);
-
-		if ( socket_accept_fd > -1 )
-		{
-			if ( clients == (struct client *) NULL )
-				current = clients;
-			else
-				while ( (current = clients->next) != (struct client *) NULL );
-
-			current				= (struct client *) malloc(sizeof(struct client));
-			current->next		= (struct client *) NULL;
-			current->fd			= socket_accept_fd;
-			current->sockaddr	= accept_addr;
-			current->last		= time(NULL);
-
-    char buffer_client[__BUFFER_SIZE__],
-		 buffer_jabber[__BUFFER_SIZE__];
-    struct client * client = current;//(struct client *) pClient;
-    int i = 0, err;
-	time_t last;
-
-	char ip[46];
-	unsigned short port;
-	inet_ntop(AF_INET, &(client->sockaddr.sin_addr), ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-	/*---------------------------------------------------*/
-
-	int jabber_fd		= (int)NULL,
-		jabber_port		= (int)NULL,
-		jabber_error	= (int)NULL;
-
-	struct sockaddr_in jabber_addr;
-
-	jabber_port = __DEFAULT_JABBER_PORT__;
-	jabber_fd = socket(AF_INET, SOCK_STREAM, 0);
-
-	fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | O_NDELAY);
-
-	jabber_addr.sin_family = AF_INET;
-	inet_aton(__DEFAULT_JABBER_IP__, &jabber_addr.sin_addr);
-	//jabber_addr.sin_addr.s_addr = inet_addr(__DEFAULT_JABBER_IP__);
-	jabber_addr.sin_port = htons(jabber_port);
-
-	jabber_error = connect(jabber_fd, (struct sockaddr *) &(jabber_addr), sizeof(jabber_addr));
-
-	last = time(NULL);
-	int client_is_connected = -1;
-	int jabber_is_connected = -1;
-	int sockaddr_in_size    = sizeof(struct sockaddr_in);
-	while ( client_is_connected != 0 )
-	{
-		/* read from client */
-		puts("\tread - client");
-		bzero(buffer_client, __BUFFER_SIZE__);
-		if ( (client_is_connected = read(client->fd, buffer_client, __BUFFER_SIZE__)) != 0 && strlen(buffer_jabber) > 0 )
-		{
-			puts("\twrite - client");
-			printf("\t%s\n", buffer_jabber);
-			/* write in the client */
-			write(client->fd, buffer_jabber, strlen(buffer_jabber));
-		}
-
-		/* read from jabber service */
-		puts("\tread - jabber");
-		bzero(buffer_jabber, __BUFFER_SIZE__);
-		if ( (jabber_is_connected = read(jabber_fd, buffer_jabber, __BUFFER_SIZE__))  && strlen(buffer_client) > 0 )
-		{
-				puts("\twrite - jabber");
-				printf("\t%s\n", buffer_client);
-				/* write in the jabber service */
-				if ( !strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-					write(jabber_fd, buffer_client, strlen(buffer_client));
-		}
-		if ( strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-		{
-			fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | ~O_NDELAY);
-			//starttls(&jabber_fd, &client->fd);
-			int err;
-
-			SSL_CTX * ctx;
-			SSL * jabberssl;
-
-			//OpenSSL_add_all_algorithms();
-
-			SSL_library_init();
-			SSL_load_error_strings();
-
-			if ( !(ctx = SSL_CTX_new(TLSv1_server_method())) )
-			{
-				printf("Error creating the context.\n");
-				exit(0);
-			}
-
-			SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-
-			jabberssl = SSL_new(ctx);
-
-			puts("#1");
-			err=SSL_set_fd(jabberssl, jabber_fd);
-			if ( err < 1 )
-			{
-				puts("shsfghdfgh");
-				SSL_CTX_free(ctx);
-			}
-
-			puts("connect");
-			err = SSL_connect(jabberssl);
-			if ( err < 1 )
-			{
-				puts("client");
-				err = SSL_get_error(jabberssl, err);
-				printf("%d\n", err);
-				char err_str[1024];
-				ERR_error_string_n(ERR_get_error(), err_str, sizeof(err_str));
-				printf("%s\n", err_str);
-				SSL_CTX_free(ctx);
-			}
-		}
-
-		if ( jabber_is_connected == 0 )
-			client_is_connected = jabber_is_connected;
-
-		puts("end loop");
-		usleep(500000);
-	}
-
-    if ( close(jabber_fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close jabber socket\n");
-        return 0;
-    }
-	/*---------------------------------------------------*/
-    if ( close(client->fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-			//pthread_create(&(threads), NULL, handler, (void *) current);
-		}
-	}
-	pthread_exit(NULL);
-}
-
-void * handler(void * pClient)
-{
-    char buffer_client[__BUFFER_SIZE__],
-		 buffer_jabber[__BUFFER_SIZE__];
-    struct client * client = (struct client *) pClient;
-    int i = 0, err;
-	time_t last;
-
-	char ip[46];
-	unsigned short port;
-	inet_ntop(AF_INET, &(client->sockaddr.sin_addr), ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-	/*---------------------------------------------------*/
-
-	int jabber_fd		= (int)NULL,
-		jabber_port		= (int)NULL,
-		jabber_error	= (int)NULL;
-
-	struct sockaddr_in jabber_addr;
-
-	jabber_port = __DEFAULT_JABBER_PORT__;
-	jabber_fd = socket(AF_INET, SOCK_STREAM, 0);
-
-	fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | O_NDELAY);
-
-	jabber_addr.sin_family = AF_INET;
-	inet_aton(__DEFAULT_JABBER_IP__, &jabber_addr.sin_addr);
-	//jabber_addr.sin_addr.s_addr = inet_addr(__DEFAULT_JABBER_IP__);
-	jabber_addr.sin_port = htons(jabber_port);
-
-	jabber_error = connect(jabber_fd, (struct sockaddr *) &(jabber_addr), sizeof(jabber_addr));
-
-	last = time(NULL);
-	int client_is_connected = -1;
-	int jabber_is_connected = -1;
-	int sockaddr_in_size    = sizeof(struct sockaddr_in);
-	while ( client_is_connected != 0 )
-	{
-		/* read from client */
-		puts("\tread - client");
-		bzero(buffer_client, __BUFFER_SIZE__);
-		if ( (client_is_connected = read(client->fd, buffer_client, __BUFFER_SIZE__)) != 0 && strlen(buffer_jabber) > 0 )
-		{
-			puts("\twrite - client");
-			printf("\t%s\n", buffer_jabber);
-			/* write in the client */
-			write(client->fd, buffer_jabber, strlen(buffer_jabber));
-		}
-
-		/* read from jabber service */
-		puts("\tread - jabber");
-		bzero(buffer_jabber, __BUFFER_SIZE__);
-		if ( (jabber_is_connected = read(jabber_fd, buffer_jabber, __BUFFER_SIZE__))  && strlen(buffer_client) > 0 )
-		{
-				puts("\twrite - jabber");
-				printf("\t%s\n", buffer_client);
-				/* write in the jabber service */
-				if ( !strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-					write(jabber_fd, buffer_client, strlen(buffer_client));
-		}
-		if ( strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-		{
-			fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | ~O_NDELAY);
-			//starttls(&jabber_fd, &client->fd);
-			int err;
-
-			SSL_CTX * ctx;
-			SSL * jabberssl;
-
-			//OpenSSL_add_all_algorithms();
-
-			SSL_library_init();
-			SSL_load_error_strings();
-
-			if ( !(ctx = SSL_CTX_new(TLSv1_server_method())) )
-			{
-				printf("Error creating the context.\n");
-				exit(0);
-			}
-
-			SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-
-			jabberssl = SSL_new(ctx);
-
-			puts("#1");
-			err=SSL_set_fd(jabberssl, jabber_fd);
-			if ( err < 1 )
-			{
-				puts("shsfghdfgh");
-				SSL_CTX_free(ctx);
-			}
-
-			puts("connect");
-			err = SSL_connect(jabberssl);
-			if ( err < 1 )
-			{
-				puts("client");
-				err = SSL_get_error(jabberssl, err);
-				printf("%d\n", err);
-				char err_str[1024];
-				ERR_error_string_n(ERR_get_error(), err_str, sizeof(err_str));
-				printf("%s\n", err_str);
-				SSL_CTX_free(ctx);
-			}
-		}
-
-		if ( jabber_is_connected == 0 )
-			client_is_connected = jabber_is_connected;
-
-		puts("end loop");
-		usleep(500000);
-	}
-
-    if ( close(jabber_fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close jabber socket\n");
-        return 0;
-    }
-	/*---------------------------------------------------*/
-    if ( close(client->fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/teste.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/teste.c	(revision 216)
+++ 	(revision )
@@ -1,200 +1,0 @@
-#include "unp.h"
-#include "xmpp.h"
-#include <malloc.h>
-
-//#define HOST "im.pr.gov.br"
-//#define IP "200.189.113.148"
-//#define HOST "localhost"
-//#define IP "10.15.20.42"
-#define HOST "im.celepar.parana"
-#define IP "10.15.20.219"
-#define PORT "5222"
-
-
-int tls = 0;
-
-void Read(void * fd, void *buf, int count)
-{
-	bzero(buf, count);
-	if ( tls == 0 )
-		read(*(int *) fd, buf, (ssize_t)count);
-	else
-		SSL_read((SSL *) fd, buf, count);
-}
-
-void Write(void * fd, void *buf, int count)
-{
-	if ( tls == 0 )
-		write(*(int *) fd, buf, (ssize_t)count);
-	else
-		SSL_write((SSL *) fd, buf, count);
-}
-
-int main(void)
-{
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-	int err,
-		i,
-		unit;
-	extern int tls;
-	char buff[4096];
-	char * xml = (char)NULL;
-
-	/*SSL PART*/
-	//SSL_METHOD *meth;
-	SSL_CTX  *ctx;
-	SSL  *myssl;
-	/*SSL PART*/
-
-	xml = (char *) malloc(sizeof(__CONNECT__));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	//socketaddr.sin_addr.s_addr = INADDR_ANY;//inet_addr(IP);
-	socketaddr.sin_addr.s_addr = inet_addr(IP);
-	socketaddr.sin_port = htons(nHostPort);
-
-	//OpenSSL_add_all_algorithms();
-	SSL_library_init();
-	//SSL_load_error_strings();
-
-	//meth=TLSv1_client_method();
-
-	//ctx=SSL_CTX_new(TLSv1_client_method());
-	if ( !(ctx = SSL_CTX_new(TLSv1_client_method())) )
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-	//fcntl(socketfd, F_SETFL, fcntl(socketfd, F_GETFL, 0) | O_NDELAY | O_NONBLOCK);
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	sprintf(xml, __CONNECT__, HOST);
-	Write(&socketfd, xml, strlen(xml));
-	//usleep(500);
-	int stop = 0;
-	do
-	{
-		Read (&socketfd, buff, sizeof(buff));
-		if ( strstr(buff, __FEATURES_BEGIN__) )
-			stop = 1;
-		else
-			usleep(100);
-	}
-	while ( !stop );
-
-puts(buff);
-	stop = 0;
-	int starttls = 0;
-
-	if ( strstr(buff, __STARTTLS_SERVER__) )
-		starttls = 1;
-
-/*	if ( !strstr(buff, __FEATURES_END__) )
-	{
-		do
-		{
-			Read (&socketfd, buff, sizeof(buff));
-			if ( strstr(buff, __STARTTLS_SERVER__) )
-				starttls = 1;
-			if ( strstr(buff, __FEATURES_END__) )
-				stop = 1;
-			else
-				usleep(100);
-		}
-		while ( !stop );
-	}*/
-
-	if ( starttls )
-	{
-		sprintf(xml, __STARTTLS_CLIENT__);
-		Write(&socketfd, xml, strlen(xml));
-
-		stop = 0;
-		do
-		{
-			Read (&socketfd, buff, sizeof(buff));
-			if ( strstr(buff, __PROCEED__) )
-				stop = 1;
-			else
-				usleep(100);
-		}
-		while ( !stop );
-		printf("%s\n\n", buff);
-		bzero(buff, 4096);
-
-		SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-		/*Create new ssl object*/
-		myssl=SSL_new(ctx);
-
-		if(!myssl){
-			printf("Error creating SSL structure.\n");
-			exit(0);
-		}
-
-		/*Bind the socket to the SSL structure*/
-		SSL_set_fd(myssl,socketfd);
-
-		/*Connect to the server, SSL layer.*/
-		err=SSL_connect(myssl);
-		printf("SSL error #%d in accept,program terminated\n",err);
-		/*Check for error in connect.*/
-		if (err<1) {
-
-			err=SSL_get_error(myssl,err);
-			printf("SSL error #%d in accept,program terminated\n",err);
-			printf("%d -- %d\n\n", SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE);
-
-			if(err==5){printf("sockerrno is:\n");}
-
-			close(socketfd);
-			SSL_CTX_free(ctx);
-			exit(0);
-		}
-
-		tls = 1;
-
-		/*Print out connection details*/
-		printf("SSL connection on socket %x,Version: %s, Cipher: %s\n\n\n",
-				socketfd,
-				SSL_get_version(myssl),
-				SSL_get_cipher(myssl));
-
-		sprintf(xml, __CONNECT__, HOST);
-		SSL_write(myssl, xml, strlen(xml));
-		usleep(10000);
-		SSL_read(myssl, buff, sizeof(buff));
-		printf("%s\n\n", buff);
-		bzero(buff, 4096);
-
-		usleep(10000);
-		SSL_read(myssl, buff, sizeof(buff));
-		printf("%s\n\n", buff);
-		bzero(buff, 4096);
-
-		SSL_clear(myssl);
-		SSL_shutdown(myssl);
-		SSL_free(myssl);
-		SSL_CTX_free(ctx);
-	}
-	fflush(stdin);
-    fflush(stdout);
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/xmpp.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/xmpp.h	(revision 216)
+++ 	(revision )
@@ -1,9 +1,0 @@
-#define __CONNECT__	"<?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='%s' version='1.0'>"
-
-#define __FEATURES_BEGIN__ "<stream:features"
-#define __FEATURES_END__ "</stream:features>"
-
-#define __STARTTLS_SERVER__	"<starttls"
-#define __STARTTLS_CLIENT__	"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"
-
-#define __PROCEED__		"<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/cexcept.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/cexcept.h	(revision 216)
+++ 	(revision )
@@ -1,244 +1,0 @@
-/*===
-cexcept.h 1.0.0 (2000-Jun-21-Wed)
-Adam M. Costello <amc@cs.berkeley.edu>
-
-An interface for exception-handling in ANSI C, developed jointly with
-Cosmin Truta <cosmin@cs.toronto.edu>.
-
-    Copyright (c) 2000 Adam M. Costello and Cosmin Truta.  Everyone
-    is hereby granted permission to do whatever they like with this
-    file, provided that if they modify it they take reasonable steps to
-    avoid confusing or misleading people about the authors, version,
-    and terms of use of the derived file.  The copyright holders make
-    no guarantees about the correctness of this file, and are not
-    responsible for any damage resulting from its use.
-
-If this interface is used by multiple .c files, they shouldn't include
-this header file directly.  Instead, create a wrapper header file that
-includes this header file and then invokes the define_exception_type
-macro (see below), and let your .c files include that header file.
-
-The interface consists of one type, one well-known name, and six macros.
-
-
-define_exception_type(type_name);
-
-    This macro is used like an external declaration.  It specifies
-    the type of object that gets copied from the exception thrower to
-    the exception catcher.  The type_name can be any type that can be
-    assigned to, that is, a non-constant arithmetic type, struct, union,
-    or pointer.  Examples:
-
-        define_exception_type(int);
-
-        enum exception { out_of_memory, bad_arguments, disk_full };
-        define_exception_type(enum exception);
-
-        struct exception { int code; const char *msg; };
-        define_exception_type(struct exception);
-
-
-struct exception_context;
-
-    This type may be used after the define_exception_type() macro has
-    been invoked.  A struct exception_context must be known to both
-    the thrower and the catcher.  It is expected that there be one
-    context for each thread that uses exceptions.  It would certainly
-    be dangerous for multiple threads to access the same context.
-    One thread can use multiple contexts, but that is likely to be
-    confusing and not typically useful.  The application can allocate
-    this structure in any way it pleases--automatic, static, or dynamic.
-    The application programmer should pretend not to know the structure
-    members, which are subject to change.
-
-
-struct exception_context *the_exception_context;
-
-    The Try/Catch and Throw statements (described below) implicitly
-    refer to a context, using the name the_exception_context.  It is
-    the application's responsibility to make sure that this name yields
-    the address of a mutable (non-constant) struct exception_context
-    wherever those statements are used.  Subject to that constraint, the
-    application may declare a variable of this name anywhere it likes
-    (inside a function, in a parameter list, or externally), and may
-    use whatever storage class specifiers (static, extern, etc) or type
-    qualifiers (const, volatile) it likes.  Examples:
-
-        static struct exception_context
-          * const the_exception_context = &foo;
-
-        { struct exception_context *the_exception_context = bar; ... }
-
-        int blah(struct exception_context *the_exception_context, ...);
-
-        extern struct exception_context the_exception_context[1];
-
-    The last example illustrates a trick that avoids creating a pointer
-    object separate from the structure object.
-
-    The name could even be a macro, for example:
-
-        struct exception_context ec_array[numthreads];
-        #define the_exception_context (ec_array + thread_id)
-
-    Be aware that the_exception_context is used several times by the
-    Try/Catch/Throw macros, so it shouldn't be expensive or have side
-    effects.  The expansion must be a drop-in replacement for an
-    identifier, so it's safest to put parentheses around it.
-
-
-void init_exception_context(struct exception_context *ec);
-
-    For context structures allocated statically (by an external
-    definition or using the "static" keyword), the implicit
-    initialization to all zeros is sufficient, but contexts allocated
-    by other means must be initialized using this macro before they
-    are used by a Try/Catch statement.  It does no harm to initialize
-    a context more than once (by using this macro on a statically
-    allocated context, or using this macro twice on the same context),
-    but a context must not be re-initialized after it has been used by a
-    Try/Catch statement.
-
-
-Try statement
-Catch (expression) statement
-
-    The Try/Catch/Throw macros are capitalized in order to avoid
-    confusion with the C++ keywords, which have subtly different
-    semantics.
-
-    A Try/Catch statement has a syntax similar to an if/else
-    statement, except that the parenthesized expression goes after
-    the second keyword rather than the first.  As with if/else,
-    there are two clauses, each of which may be a simple statement
-    ending with a semicolon or a brace-enclosed compound statement.
-    But whereas the else clause is optional, the Catch clause is
-    required.  The expression must be a modifiable lvalue (something
-    capable of being assigned to) of the exact same type passed to
-    define_exception_type().
-
-    If a Throw that uses the same exception context as the Try/Catch is
-    executed within the Try clause (typically within a function called
-    by the Try clause), and the exception is not caught by a nested
-    Try/Catch statement, then a copy of the exception will be assigned
-    to the expression, and control will jump to the Catch clause.  If no
-    such Throw is executed, then the assignment is not performed, and
-    the Catch clause is not executed.
-
-    Regardless of whether an exception is caught, the expression is
-    always evaluated exactly once, which is significant if it has side
-    effects, for example:
-
-        Try foo();
-        Catch (p[++i].e) { ... }
-
-    IMPORTANT: Jumping into or out of a Try clause (for example via
-    return, break, continue, goto, longjmp) is forbidden--the compiler
-    will not complain, but bad things will happen at run-time.  Jumping
-    into or out of a Catch clause is okay, and so is jumping around
-    inside a Try clause.  In many cases where one is tempted to return
-    from a Try clause, it will suffice to use Throw, and then return
-    from the Catch clause.  Another option is to set a flag variable and
-    use goto to jump to the end of the Try clause, then check the flag
-    after the Try/Catch statement.
-
-    IMPORTANT: The values of any non-volatile automatic variables
-    changed within the Try clause are undefined after an exception is
-    caught.  Therefore, variables modified inside the Try block whose
-    values are needed later outside the Try block must either use static
-    storage or be declared with the "volatile" type qualifier.
-
-
-Throw expression;
-
-    A Throw statement is very much like a return statement, except that
-    the expression is required.  Whereas return jumps back to the place
-    where the current function was called, Throw jumps back to the Catch
-    clause of the innermost enclosing Try clause.  The expression must
-    be compatible with the type passed to define_exception_type().  The
-    exception must be caught, otherwise the program may crash.
-
-    Slight limitation:  If the expression is a comma-expression it must
-    be enclosed in parentheses.
-
-
-Try statement
-Catch_anonymous statement
-
-    When the value of the exception is not needed, a Try/Catch statement
-    can use Catch_anonymous instead of Catch (expression).
-
-
-Everything below this point is for the benefit of the compiler.  The
-application programmer should pretend not to know any of it, because it
-is subject to change.
-
-===*/
-
-
-#ifndef CEXCEPT_H
-#define CEXCEPT_H
-
-
-#include <setjmp.h>
-
-#define define_exception_type(etype) \
-struct exception__state { \
-  etype *exception; \
-  jmp_buf env; \
-}
-
-struct exception_context { \
-  struct exception__state *last; \
-  int caught; \
-};
-
-#define init_exception_context(ec) ((void)((ec)->last = 0))
-
-#define Catch(e) exception__catch(&(e))
-#define Catch_anonymous exception__catch(0)
-
-#define Try \
-  { \
-    struct exception__state *exception__p, exception__s; \
-    int exception__i; \
-    exception__p = the_exception_context->last; \
-    the_exception_context->last = &exception__s; \
-    for (exception__i = 0; ; exception__i = 1) \
-      if (exception__i) { \
-        if (setjmp(exception__s.env) == 0) { \
-          if (&exception__s)
-
-#define exception__catch(e_addr) \
-          else { } \
-          the_exception_context->caught = 0; \
-        } \
-        else the_exception_context->caught = 1; \
-        the_exception_context->last = exception__p; \
-        break; \
-      } \
-      else exception__s.exception = e_addr; \
-  } \
-  if (!the_exception_context->caught) { } \
-  else
-
-/* Try ends with if(), and Catch begins and ends with else.  This     */
-/* ensures that the Try/Catch syntax is really the same as the        */
-/* if/else syntax.                                                    */
-/*                                                                    */
-/* We use &exception__s instead of 1 to appease compilers that        */
-/* warn about constant expressions inside if().  Most compilers       */
-/* should still recognize that &exception__s is never zero and avoid  */
-/* generating test code.                                              */
-/*                                                                    */
-/* We use the variable exception__i to start the loop at the bottom,  */
-/* rather than jump into the loop using a switch statement, to        */
-/* appease compilers that warn about jumping into loops.              */
-
-#define Throw \
-  for (;; longjmp(the_exception_context->last->env, 1)) \
-    if (the_exception_context->last->exception) \
-      *the_exception_context->last->exception =
-
-
-#endif /* CEXCEPT_H */
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/mycert.pem
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/mycert.pem	(revision 216)
+++ 	(revision )
@@ -1,34 +1,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXAIBAAKBgQDY8Tao9bylsCI6LVR8yWWO7HgfnQQCwh2cqigKHaSnuo5n67R5
-Cp7dAbYkVf1V7BZ+V3nn7eVQ2FXcb8BooBQY51J9j7Q75IT5AZRar1ket5pRnVJH
-THGpm8trQsP54gV14lRToI36zXFzxakR08B1iKRyyLUVwp8RvAUxS+kKHwIDAQAB
-AoGAFIbWTixaOi8tPeX2HYyM0HYtc4hOzdgCJ0WuXi6p2rj7KngR7nYDzBOSYWPF
-gbDB/BhYz4oh7YFatm3Yfc3PuNLbuTxaMuuevDl9Qy+0cVI3FL7ban5jgEXMZVB8
-rgIfxmem8Kj7Eu/WtF/UJiz+epJQgrndlNtWJTWSDHoLRqkCQQD3lf4kRwiJJrAS
-Hj48/FVaR+0nvcEia7YsF44is8Yd++BG1tKNZZaKpdhssVA/9Pd+8hC9Sqzji+Mc
-ZXdbAoh1AkEA4FCeoH/ZfWZ3KfCyGfK6T2SEf3tJB/bleFg1mdmv9INuk6HSKMKW
-62mhxAk4DjcYcoM8QSeAE4FN7aOwB3OVwwJAeL/7qf/G5vUqbDu5yQ6cJiLsRDSk
-rD/yIkD+vmgFWPxOHt6I5BNGv6oxCpnT9M1po801Ysy302aXRnMqKgXrPQJBAMYG
-ZgNK2rXZv1lHI/PEVLXCBzaDn/VoASw8sxUfGDbD0NqEAQP6xUEN/8EQYmwqN2rg
-cFEUjfyqKiGgX8Y0RAECQGTEkKvhDzgyyphx5JkYem7sAUI7gFGKZxJaVU+KkN5e
-pU4pgNiFUT0uTbfFzzOYQKeyVlBqGiv7rVn3BO3pfV4=
------END RSA PRIVATE KEY-----
------BEGIN CERTIFICATE-----
-MIIDKzCCApSgAwIBAgIJAOkSDgQDK1oGMA0GCSqGSIb3DQEBBQUAMG0xCzAJBgNV
-BAYTAkJSMQswCQYDVQQIEwJQUjEMMAoGA1UEBxMDQ1dCMQ0wCwYDVQQKEwRTQ0tU
-MQ0wCwYDVQQLEwRzY2t0MSUwIwYDVQQDExxlY2VsZXBhcjkxMTM3LmNlbGVwYXIu
-cGFyYW5hMB4XDTA3MDgwOTE2Mzg0MVoXDTA4MDgwODE2Mzg0MVowbTELMAkGA1UE
-BhMCQlIxCzAJBgNVBAgTAlBSMQwwCgYDVQQHEwNDV0IxDTALBgNVBAoTBFNDS1Qx
-DTALBgNVBAsTBHNja3QxJTAjBgNVBAMTHGVjZWxlcGFyOTExMzcuY2VsZXBhci5w
-YXJhbmEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANjxNqj1vKWwIjotVHzJ
-ZY7seB+dBALCHZyqKAodpKe6jmfrtHkKnt0BtiRV/VXsFn5Xeeft5VDYVdxvwGig
-FBjnUn2PtDvkhPkBlFqvWR63mlGdUkdMcamby2tCw/niBXXiVFOgjfrNcXPFqRHT
-wHWIpHLItRXCnxG8BTFL6QofAgMBAAGjgdIwgc8wHQYDVR0OBBYEFDqDGL/fTaKt
-NtkTuuzBet9mgcSOMIGfBgNVHSMEgZcwgZSAFDqDGL/fTaKtNtkTuuzBet9mgcSO
-oXGkbzBtMQswCQYDVQQGEwJCUjELMAkGA1UECBMCUFIxDDAKBgNVBAcTA0NXQjEN
-MAsGA1UEChMEU0NLVDENMAsGA1UECxMEc2NrdDElMCMGA1UEAxMcZWNlbGVwYXI5
-MTEzNy5jZWxlcGFyLnBhcmFuYYIJAOkSDgQDK1oGMAwGA1UdEwQFMAMBAf8wDQYJ
-KoZIhvcNAQEFBQADgYEAVHm/1+iybB3u48nP0NDIocPIhUC55e8iL9h0GOmvJalp
-IpCeIuefCTPCkrJHNMSVNqz6q3UfJLNXe91UdaAYvXEqWLP0mYUz5DWnzUYIIb/y
-W1BZ2WqcX8KZeJJgF/Gu0BJj5oGaf8LMVQoS58TiWgQABg1UTFHnHoXJhABQ1Qo=
------END CERTIFICATE-----
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/server_bkp_20071009.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/server_bkp_20071009.c	(revision 216)
+++ 	(revision )
@@ -1,444 +1,0 @@
-#include "server.h"
-
-/* Globally accessible storage for the exception context: */
-struct exception_context the_exception_context[1];
-
-#define HOST "im.celepar.parana"
-#define IP "10.15.20.219"
-#define PORT "5222"
-
-int main(int argc, char ** argv)
-{
-	/* variables to parse arguments */
-	extern int optind,
-			   optopt;
-	extern char * optarg;
-
-	char * log_file;
-	int c		= (int)NULL,
-		errflg	= (int)NULL,
-		verbose	= (int)NULL,
-		optval	= 1;
-
-	socklen_t optlen = sizeof(optval);
-
-	/* fd -> file descriptor */
-	int socket_server_fd	= (int)NULL,
-		socket_server_port	= (int)NULL,
-		socket_accept_fd	= (int)NULL,
-		sockaddr_in_size	= sizeof(struct sockaddr_in),
-		err					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	struct client * clients = (struct client *) NULL,
-				  * current = (struct client *) NULL;
-
-	SSL_CTX * ctx;
-
-	pthread_t threads;
-
-	// clear screen
-	system(__CLEAR_SCREEN__);
-
-	while ( (c = getopt(argc, argv, ":vp:")) != -1 )
-	{
-		switch ( c )
-		{
-			case 'p':
-				if ( socket_server_port = strtol(optarg, 0, 10) == 0 )
-				{
-					fprintf(stderr, "Option -%c requires a valid port and '%s' isn't valid\n", optopt, optarg);
-					++errflg;
-				}
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			case ':':
-				// -f or -o without operand
-				fprintf(stderr, "Option -%c requires an operand\n", optopt);
-				++errflg;
-				break;
-			case '?':
-				fprintf(stderr, "Unrecognized option: -%c\n", optopt);
-				++errflg;
-		}
-	}
-	if ( errflg )
-	{
-		fprintf(stderr, "usage: . . . \n\n");
-		exit(2);
-	}
-
-	OpenSSL_add_all_algorithms();
-	SSL_library_init();
-	SSL_load_error_strings();
-
-	if ( !(ctx = SSL_CTX_new(SSLv23_method())) )
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	if ( SSL_CTX_set_cipher_list(ctx, CIPHER_LIST) < 1 )
-	{
-		printf("Error setting the cipher list.\n");
-		exit(0);
-	}
-
-	//Indicate the certificate file to be used
-	if ( SSL_CTX_use_certificate_file(ctx, CERT_FILE, SSL_FILETYPE_PEM) < 1 )
-	{
-		printf("Error setting the certificate file.\n");
-		exit(0);
-	}
-
-	//Load the password for the Private Key
-	SSL_CTX_set_default_passwd_cb_userdata(ctx, KEY_PASSWD);
-
-	//Indicate the key file to be used
-	if ( SSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM) < 1 )
-	{
-		printf("Error setting the key file.\n");
-		exit(0);
-	}
-
-	//Make sure the key and certificate file match
-	if ( !SSL_CTX_check_private_key(ctx) )
-	{
-		printf("Private key does not match the certificate public key\n");
-		exit(0);
-	}
-
-	// Set the list of trusted CAs based on the file and/or directory provided
-	if ( SSL_CTX_load_verify_locations(ctx, CA_FILE, CA_DIR) < 1 )
-	{
-		printf("Error setting verify location\n");
-		exit(0);
-	}
-
-	// Set for server verification
-	SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
-
-	/* make a socket */
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	if ( !socket_server_port )
-		socket_server_port = __DEFAULT_OPEN_PORT__;
-
-	/* fill address struct */
-	server_addr.sin_addr.s_addr	= INADDR_ANY;
-	server_addr.sin_port		= htons(socket_server_port);
-	server_addr.sin_family		= AF_INET;
-	bzero(&(server_addr.sin_zero), 8);
-
-	if ( __DEBUG__  || verbose )
-		printf("\nBinding to port %d...\n", socket_server_port);
-
-	/* bind to a port */
-	if ( bind(socket_server_fd, (struct sockaddr *)&(server_addr), sizeof(server_addr)) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not connect to host\n");
-		exit(1);
-	}
-
-	/* get port number */
-	getsockname(socket_server_fd, (struct sockaddr *)&(server_addr), (socklen_t *) &(sockaddr_in_size));
-	if ( __DEBUG__  || verbose )
-	{
-		printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-		printf("Server\n\
-				sin_family        = %d\n\
-				sin_addr.s_addr   = %d\n\
-				sin_port          = %d\n"
-				, server_addr.sin_family
-				, server_addr.sin_addr.s_addr
-				, ntohs(server_addr.sin_port)
-			  );
-		printf("\nMaking a listen queue of %d elements", __QUEUE_SIZE__);
-	}
-
-	/* establish listen queue */
-	if ( listen(socket_server_fd, __QUEUE_SIZE__) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		if ( __DEBUG__  || verbose )
-			puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &(accept_addr), (socklen_t *) &(sockaddr_in_size));
-		fcntl(socket_accept_fd, F_SETFL, fcntl(socket_accept_fd, F_GETFL, 0) | O_NONBLOCK | O_NDELAY);
-
-		if ( socket_accept_fd > -1 )
-		{
-			if ( clients == (struct client *) NULL )
-				current = clients;
-			else
-				while ( (current = clients->next) != (struct client *) NULL );
-
-			current				= (struct client *) malloc(sizeof(struct client));
-			current->next		= (struct client *) NULL;
-			current->fd			= socket_accept_fd;
-			current->sockaddr	= accept_addr;
-			current->ctx		= ctx;
-			current->last		= time(NULL);
-
-			pthread_create(&(threads), NULL, handler, (void *) current);
-		}
-	}
-	pthread_exit(NULL);
-}
-
-void * handler(void * pClient)
-{
-    char buffer_client[__BUFFER_SIZE__],
-		 buffer_jabber[__BUFFER_SIZE__];
-    struct client * client = (struct client *) pClient;
-    int i = 0, err, e;
-	time_t last;
-
-	int tls = 0;
-
-	char ip[46];
-	unsigned short port;
-	inet_ntop(AF_INET, &(client->sockaddr.sin_addr), ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-	/*---------------------------------------------------*/
-
-	int client_is_connected = -1;
-	int jabber_is_connected = -1;
-
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-
-	char buff[4096];
-	SSL_CTX  *ctx;
-	SSL  *myssl;
-
-	char * old_host,
-		 * replace_host;
-
-	replace_host = (char *) malloc(__BUFFER_SIZE__*sizeof(char));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	socketaddr.sin_addr.s_addr = inet_addr(IP);
-	socketaddr.sin_port = htons(nHostPort);
-
-	if ( !(ctx = SSL_CTX_new(SSLv23_method())) )
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-	fcntl(socketfd, F_SETFL, fcntl(socketfd, F_GETFL, 0) | O_NONBLOCK | O_NDELAY);
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	while ( client_is_connected != 0 )
-	{
-		// read from client
-		//puts("\tread - client");
-		bzero(buffer_client, __BUFFER_SIZE__);
-		if ( !tls )
-			client_is_connected = read(client->fd, buffer_client, __BUFFER_SIZE__);
-		else
-			client_is_connected = SSL_read(client->myssl, buffer_client, __BUFFER_SIZE__);
-
-		if ( client_is_connected != 0 )
-		{
-			if ( strlen(buffer_jabber) > 0 )
-			{
-				puts("\twriting - client");
-				printf("\t%s\n\n", buffer_jabber);
-				// write in the client
-				Try
-				{
-					if ( !tls )
-						write(client->fd, buffer_jabber, strlen(buffer_jabber));
-					else
-						SSL_write(client->myssl, buffer_jabber, strlen(buffer_jabber));
-				}
-				Catch(e) fprintf(stderr, "exception %d\n", e);
-				puts("\twrote - client");
-			}
-
-			if ( strstr(buffer_client, "<stream:stream") && (old_host = strstr(buffer_client, "to=")) )
-			{
-				bzero(replace_host, __BUFFER_SIZE__);
-				strncpy(replace_host, buffer_client, (strlen(buffer_client) - strlen(old_host))+4);
-				strcat(replace_host, HOST);
-				old_host = strstr(old_host, " ");
-				old_host--;
-				strcat(replace_host, old_host);
-				bzero(buffer_client, __BUFFER_SIZE__);
-				strcpy(buffer_client, replace_host);
-			}
-		}
-
-		// read from jabber service
-		//puts("\tread - jabber");
-		bzero(buffer_jabber, __BUFFER_SIZE__);
-
-		if ( !tls )
-			jabber_is_connected = read(socketfd, buffer_jabber, __BUFFER_SIZE__);
-		else
-			jabber_is_connected = SSL_read(myssl, buffer_jabber, __BUFFER_SIZE__);
-
-
-		if ( jabber_is_connected != 0 && strlen(buffer_client) > 0 )
-		{
-			puts("\twriting - jabber");
-			printf("\t%s\n\n", buffer_client);
-			// write in the jabber service
-			Try
-			{
-				if ( !tls )
-					write(socketfd, buffer_client, strlen(buffer_client));
-				else
-					SSL_write(myssl, buffer_client, strlen(buffer_client));
-			}
-			Catch(e) fprintf(stderr, "exception %d\n", e);
-			puts("\twrote - jabber");
-		}
-
-		if ( strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-		{
-			puts("\tbegin tls with jabber");
-			fcntl( socketfd, F_SETFL, fcntl( socketfd, F_GETFL ) & ~O_NONBLOCK & ~O_NDELAY);
-			SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-			//Create new ssl object
-			myssl = SSL_new(ctx);
-
-			if ( !myssl )
-			{
-				printf("Error creating SSL structure.\n");
-				exit(0);
-			}
-
-			//Bind the socket to the SSL structure
-			SSL_set_fd(myssl, socketfd);
-
-			//Connect to the server, SSL layer.
-			err = SSL_connect(myssl);
-			//printf("SSL error #%d in accept,program terminated\n",err);
-			//Check for error in connect.
-			if ( err < 1 )
-			{
-				err = SSL_get_error(myssl,err);
-				printf("SSL error #%d in accept, program terminated\n",err);
-				printf("%d -- %d\n\n", SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE);
-
-				if(err==5){printf("sockerrno is:\n");}
-
-				SSL_CTX_free(ctx);
-				client_is_connected = 0;
-			}
-
-			fcntl(socketfd, F_SETFL, fcntl(socketfd, F_GETFL, 0) | O_NONBLOCK | O_NDELAY);
-			puts("\tend tls with jabber");
-
-			puts("\twriting proceed in the client");
-			printf("%s - %d\n", buffer_jabber, strlen(buffer_jabber));
-			write(client->fd, buffer_jabber, strlen(buffer_jabber));
-			bzero(buffer_jabber, __BUFFER_SIZE__);
-
-			puts("\tbegin tls with client");
-			fcntl( client->fd, F_SETFL, fcntl( client->fd, F_GETFL ) & ~O_NONBLOCK & ~O_NDELAY );
-
-			//Create new ssl object
-			if( !(client->myssl = SSL_new(client->ctx)) )
-			{
-				printf("Error creating SSL structure.\n");
-				exit(0);
-			}
-
-			//Bind the socket to the SSL structure
-			SSL_set_fd(client->myssl, client->fd);
-
-			//Connect to the server, SSL layer.
-			err = SSL_accept(client->myssl);
-
-			//Check for error in connect.
-			if ( err < 1 )
-			{
-				printf("SSL error #%d in accept,program terminated\n", err);
-				err = SSL_get_error(client->myssl, 0);
-				printf("SSL error #%d in accept,program terminated\n", err);
-
-				switch ( err )
-				{
-					case SSL_ERROR_NONE : puts("SSL_ERROR_NONE");break;
-					case SSL_ERROR_SSL : puts("SSL_ERROR_SSL");break;
-					case SSL_ERROR_WANT_READ : puts("SSL_ERROR_WANT_READ");
-				}
-
-				if ( err == 5 )
-					printf("sockerrno is: %d\n", err);
-
-
-				SSL_CTX_free(client->ctx);
-				client_is_connected = 0;
-			}
-			fcntl(client->fd, F_SETFL, fcntl(client->fd, F_GETFL, 0) | O_NONBLOCK | O_NDELAY);
-			puts("\tend tls with client");
-
-			tls = 1;
-		}
-
-		if ( jabber_is_connected == 0 )
-			client_is_connected = jabber_is_connected;
-
-		//puts("end loop");
-		usleep(1000);
-	}
-	puts("\n=========================\n");
-    if ( close(socketfd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close jabber socket\n");
-        return 0;
-    }
-	//---------------------------------------------------
-    if ( close(client->fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/server.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/server.c	(revision 216)
+++ 	(revision )
@@ -1,452 +1,0 @@
-#include "server.h"
-
-/* Globally accessible storage for the exception context: */
-struct exception_context the_exception_context[1];
-
-//#define HOST "im.celepar.parana"
-//#define IP "10.15.20.219"
-#define HOST "im.pr.gov.br"
-#define IP "200.189.113.148"
-#define PORT "5222"
-
-int main(int argc, char ** argv)
-{
-	/* variables to parse arguments */
-	extern int optind,
-			   optopt;
-	extern char * optarg;
-
-	char * log_file;
-	int c		= (int)NULL,
-		errflg	= (int)NULL,
-		verbose	= (int)NULL,
-		optval	= 1,
-		pid;
-
-	socklen_t optlen = sizeof(optval);
-
-	/* fd -> file descriptor */
-	int socket_server_fd	= (int)NULL,
-		socket_server_port	= (int)NULL,
-		socket_accept_fd	= (int)NULL,
-		sockaddr_in_size	= sizeof(struct sockaddr_in),
-		err					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	struct client * clients = (struct client *) NULL,
-				  * current = (struct client *) NULL;
-
-	SSL_CTX * ctx;
-
-	pthread_t threads;
-
-	// clear screen
-	system(__CLEAR_SCREEN__);
-
-	while ( (c = getopt(argc, argv, ":vp:")) != -1 )
-	{
-		switch ( c )
-		{
-			case 'p':
-				if ( socket_server_port = strtol(optarg, 0, 10) == 0 )
-				{
-					fprintf(stderr, "Option -%c requires a valid port and '%s' isn't valid\n", optopt, optarg);
-					++errflg;
-				}
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			case ':':
-				// -f or -o without operand
-				fprintf(stderr, "Option -%c requires an operand\n", optopt);
-				++errflg;
-				break;
-			case '?':
-				fprintf(stderr, "Unrecognized option: -%c\n", optopt);
-				++errflg;
-		}
-	}
-	if ( errflg )
-	{
-		fprintf(stderr, "usage: . . . \n\n");
-		exit(2);
-	}
-
-	OpenSSL_add_all_algorithms();
-	SSL_library_init();
-	SSL_load_error_strings();
-
-	/* make a socket */
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not make a socket\n");
-		return 0;
-	}
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	if ( !socket_server_port )
-		socket_server_port = __DEFAULT_OPEN_PORT__;
-
-	/* fill address struct */
-	server_addr.sin_addr.s_addr	= INADDR_ANY;
-	server_addr.sin_port		= htons(socket_server_port);
-	server_addr.sin_family		= AF_INET;
-	bzero(&(server_addr.sin_zero), 8);
-
-	if ( __DEBUG__  || verbose )
-		printf("\nBinding to port %d...\n", socket_server_port);
-
-	/* bind to a port */
-	if ( bind(socket_server_fd, (struct sockaddr *)&(server_addr), sizeof(server_addr)) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not connect to host\n");
-		exit(1);
-	}
-
-	/* get port number */
-	getsockname(socket_server_fd, (struct sockaddr *)&(server_addr), (socklen_t *) &(sockaddr_in_size));
-	if ( __DEBUG__  || verbose )
-	{
-		printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-		printf("Server\n\
-				sin_family        = %d\n\
-				sin_addr.s_addr   = %d\n\
-				sin_port          = %d\n"
-				, server_addr.sin_family
-				, server_addr.sin_addr.s_addr
-				, ntohs(server_addr.sin_port)
-			  );
-		printf("\nMaking a listen queue of %d elements", __QUEUE_SIZE__);
-	}
-
-	/* establish listen queue */
-	if ( listen(socket_server_fd, __QUEUE_SIZE__) == __SOCKET_ERROR__ )
-	{
-		printf("\nCould not listen\n");
-		return 0;
-	}
-
-	for ( ; ; )
-	{
-		if ( __DEBUG__  || verbose )
-			puts("\nWaiting for a connection\n");
-
-		/* get the connected socket */
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &(accept_addr), (socklen_t *) &(sockaddr_in_size));
-
-		if ( socket_accept_fd > -1 )
-		{
-			pid = fork();
-			if ( pid == 0 )
-			{
-	if ( !(ctx = SSL_CTX_new(SSLv23_method())) )
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	if ( SSL_CTX_set_cipher_list(ctx, CIPHER_LIST) < 1 )
-	{
-		printf("Error setting the cipher list.\n");
-		exit(0);
-	}
-
-	//Indicate the certificate file to be used
-	if ( SSL_CTX_use_certificate_file(ctx, CERT_FILE, SSL_FILETYPE_PEM) < 1 )
-	{
-		printf("Error setting the certificate file.\n");
-		exit(0);
-	}
-
-	//Load the password for the Private Key
-	SSL_CTX_set_default_passwd_cb_userdata(ctx, KEY_PASSWD);
-
-	//Indicate the key file to be used
-	if ( SSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM) < 1 )
-	{
-		printf("Error setting the key file.\n");
-		exit(0);
-	}
-
-	//Make sure the key and certificate file match
-	if ( !SSL_CTX_check_private_key(ctx) )
-	{
-		printf("Private key does not match the certificate public key\n");
-		exit(0);
-	}
-
-	// Set the list of trusted CAs based on the file and/or directory provided
-	if ( SSL_CTX_load_verify_locations(ctx, CA_FILE, CA_DIR) < 1 )
-	{
-		printf("Error setting verify location\n");
-		exit(0);
-	}
-
-	// Set for server verification
-	SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
-
-				fcntl(socket_accept_fd, F_SETFL, fcntl(socket_accept_fd, F_GETFL, 0) | O_NONBLOCK | O_NDELAY);
-
-				if ( clients == (struct client *) NULL )
-					current = clients;
-				else
-					while ( (current = clients->next) != (struct client *) NULL );
-
-				current				= (struct client *) malloc(sizeof(struct client));
-				current->next		= (struct client *) NULL;
-				current->fd			= socket_accept_fd;
-				current->sockaddr	= accept_addr;
-				current->ctx		= ctx;
-				current->last		= time(NULL);
-
-				pthread_create(&(threads), NULL, handler, (void *) current);
-			}
-		}
-	}
-	pthread_exit(NULL);
-}
-
-void * handler(void * pClient)
-{
-    char buffer_client[__BUFFER_SIZE__],
-		 buffer_jabber[__BUFFER_SIZE__];
-    struct client * client = (struct client *) pClient;
-    int i = 0, err, e;
-	time_t last;
-
-	int tls = 0;
-
-	char ip[46];
-	unsigned short port;
-	inet_ntop(AF_INET, &(client->sockaddr.sin_addr), ip, sizeof (ip));
-	port = ntohs(client->sockaddr.sin_port);
-	printf("\nGot a connection from %s, port %hu\n", ip, port);
-	/*---------------------------------------------------*/
-
-	int client_is_connected = -1;
-	int jabber_is_connected = -1;
-
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-
-	char buff[4096];
-	SSL_CTX  *ctx;
-	SSL  *myssl;
-
-	char * old_host,
-		 * replace_host;
-
-	replace_host = (char *) malloc(__BUFFER_SIZE__*sizeof(char));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	socketaddr.sin_addr.s_addr = inet_addr(IP);
-	socketaddr.sin_port = htons(nHostPort);
-
-	if ( !(ctx = SSL_CTX_new(SSLv23_method())) )
-	{
-		printf("Error creating the context.\n");
-		exit(0);
-	}
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-	fcntl(socketfd, F_SETFL, fcntl(socketfd, F_GETFL, 0) | O_NONBLOCK | O_NDELAY);
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	while ( client_is_connected != 0 )
-	{
-		// read from client
-		//puts("\tread - client");
-		bzero(buffer_client, __BUFFER_SIZE__);
-		if ( !tls )
-			client_is_connected = read(client->fd, buffer_client, __BUFFER_SIZE__);
-		else
-			client_is_connected = SSL_read(client->myssl, buffer_client, __BUFFER_SIZE__);
-
-		if ( client_is_connected != 0 )
-		{
-			if ( strlen(buffer_jabber) > 0 )
-			{
-				puts("\twriting - client");
-				printf("\t%s\n\n", buffer_jabber);
-				// write in the client
-				Try
-				{
-					if ( !tls )
-						write(client->fd, buffer_jabber, strlen(buffer_jabber));
-					else
-						SSL_write(client->myssl, buffer_jabber, strlen(buffer_jabber));
-				}
-				Catch(e) fprintf(stderr, "exception %d\n", e);
-				puts("\twrote - client");
-			}
-
-			if ( strstr(buffer_client, "<stream:stream") && (old_host = strstr(buffer_client, "to=")) )
-			{
-				bzero(replace_host, __BUFFER_SIZE__);
-				strncpy(replace_host, buffer_client, (strlen(buffer_client) - strlen(old_host))+4);
-				strcat(replace_host, HOST);
-				old_host = strstr(old_host, " ");
-				old_host--;
-				strcat(replace_host, old_host);
-				bzero(buffer_client, __BUFFER_SIZE__);
-				strcpy(buffer_client, replace_host);
-			}
-		}
-
-		// read from jabber service
-		//puts("\tread - jabber");
-		bzero(buffer_jabber, __BUFFER_SIZE__);
-
-		if ( !tls )
-			jabber_is_connected = read(socketfd, buffer_jabber, __BUFFER_SIZE__);
-		else
-			jabber_is_connected = SSL_read(myssl, buffer_jabber, __BUFFER_SIZE__);
-
-
-		if ( jabber_is_connected != 0 && strlen(buffer_client) > 0 )
-		{
-			puts("\twriting - jabber");
-			printf("\t%s\n\n", buffer_client);
-			// write in the jabber service
-			Try
-			{
-				if ( !tls )
-					write(socketfd, buffer_client, strlen(buffer_client));
-				else
-					SSL_write(myssl, buffer_client, strlen(buffer_client));
-			}
-			Catch(e) fprintf(stderr, "exception %d\n", e);
-			puts("\twrote - jabber");
-		}
-
-		if ( strstr(buffer_jabber, "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") )
-		{
-			puts("\tbegin tls with jabber");
-			fcntl( socketfd, F_SETFL, fcntl( socketfd, F_GETFL ) & ~O_NONBLOCK & ~O_NDELAY);
-			SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL);
-			//Create new ssl object
-			myssl = SSL_new(ctx);
-
-			if ( !myssl )
-			{
-				printf("Error creating SSL structure.\n");
-				exit(0);
-			}
-
-			//Bind the socket to the SSL structure
-			SSL_set_fd(myssl, socketfd);
-
-			//Connect to the server, SSL layer.
-			err = SSL_connect(myssl);
-			//printf("SSL error #%d in accept,program terminated\n",err);
-			//Check for error in connect.
-			if ( err < 1 )
-			{
-				err = SSL_get_error(myssl,err);
-				printf("SSL error #%d in accept, program terminated\n",err);
-				printf("%d -- %d\n\n", SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE);
-
-				if(err==5){printf("sockerrno is:\n");}
-
-				SSL_CTX_free(ctx);
-				client_is_connected = 0;
-			}
-
-			fcntl(socketfd, F_SETFL, fcntl(socketfd, F_GETFL, 0) | O_NONBLOCK | O_NDELAY);
-			puts("\tend tls with jabber");
-
-			puts("\twriting proceed in the client");
-			printf("%s - %d\n", buffer_jabber, strlen(buffer_jabber));
-			write(client->fd, buffer_jabber, strlen(buffer_jabber));
-			bzero(buffer_jabber, __BUFFER_SIZE__);
-
-			puts("\tbegin tls with client");
-			fcntl( client->fd, F_SETFL, fcntl( client->fd, F_GETFL ) & ~O_NONBLOCK & ~O_NDELAY );
-
-			//Create new ssl object
-			if( !(client->myssl = SSL_new(client->ctx)) )
-			{
-				printf("Error creating SSL structure.\n");
-				exit(0);
-			}
-
-			//Bind the socket to the SSL structure
-			SSL_set_fd(client->myssl, client->fd);
-
-			//Connect to the server, SSL layer.
-			err = SSL_accept(client->myssl);
-
-			//Check for error in connect.
-			if ( err < 1 )
-			{
-				printf("SSL error #%d in accept,program terminated\n", err);
-				err = SSL_get_error(client->myssl, 0);
-				printf("SSL error #%d in accept,program terminated\n", err);
-
-				switch ( err )
-				{
-					case SSL_ERROR_NONE : puts("SSL_ERROR_NONE");break;
-					case SSL_ERROR_SSL : puts("SSL_ERROR_SSL");break;
-					case SSL_ERROR_WANT_READ : puts("SSL_ERROR_WANT_READ");
-				}
-
-				if ( err == 5 )
-					printf("sockerrno is: %d\n", err);
-
-
-				SSL_CTX_free(client->ctx);
-				client_is_connected = 0;
-			}
-			fcntl(client->fd, F_SETFL, fcntl(client->fd, F_GETFL, 0) | O_NONBLOCK | O_NDELAY);
-			puts("\tend tls with client");
-
-			tls = 1;
-		}
-
-		if ( jabber_is_connected == 0 )
-			client_is_connected = jabber_is_connected;
-
-		//puts("end loop");
-		usleep(1000);
-	}
-	puts("\n=========================\n");
-    if ( close(socketfd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close jabber socket\n");
-        return 0;
-    }
-	//---------------------------------------------------
-    if ( close(client->fd) == __SOCKET_ERROR__ )
-    {
-        printf("\nCould not close socket\n");
-        return 0;
-    }
-
-    fflush(stdin);
-    fflush(stdout);
-	free(client);
-    pthread_exit(NULL);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/server.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/server.h	(revision 216)
+++ 	(revision )
@@ -1,114 +1,0 @@
-#include <fcntl.h>
-
-#include <netdb.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-
-#include <pthread.h>
-
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <unistd.h>
-
-#include "cexcept.h"
-define_exception_type(int);
-extern struct exception_context the_exception_context[1];
-
-void demo_throw(int fail)
-{
-	//fprintf(stderr, "enter demo_throw(%d)\n", fail);
-	if (fail) Throw 42;
-	//fprintf(stderr, "return from demo_throw(%d)\n", fail);
-}
-
-
-/* define max clients per child */
-#ifndef __CLIENTS__
-   #define __CLIENTS__ 100
-#endif
-
-/* define max clients waiting in the queue for connect */
-#ifndef __QUEUE_SIZE__
-	#define __QUEUE_SIZE__ 10
-#endif
-
-/* __SOCKET_ERROR__ must be -1, don't change this */
-#ifndef __SOCKET_ERROR__
-	#define __SOCKET_ERROR__ -1
-#endif
-
-/* open port when this server is activated */
-#ifndef __DEFAULT_OPEN_PORT__
-	#define __DEFAULT_OPEN_PORT__ 8888
-#endif
-
-/* ip of jabber service */
-#ifndef __DEFAULT_JABBER_PORT__
-	#define __DEFAULT_JABBER_PORT__ 5222
-#endif
-
-/* port to connect on jabber service */
-#ifndef __DEFAULT_JABBER_IP__
-	#define __DEFAULT_JABBER_IP__ "im.celepar.parana"
-#endif
-
-/* the jabber's documentation recommends read the packages of socket with size of 4096 (2^12) KB */
-#ifndef __BUFFER_SIZE__
-	#define __BUFFER_SIZE__ 4096
-#endif
-
-#define MESSAGE			"This is the message I'm sending back and forth"
-
-/* Make these what you want for certificate & key files */
-#define CERT_FILE "mycert.pem"
-#define KEY_FILE  "mycert.pem"
-
-/*Cipher list to be used*/
-#define CIPHER_LIST "RC4-MD5"
-
-/*Trusted CAs location*/
-#define CA_FILE CERT_FILE
-#define CA_DIR NULL
-
-/*Password for the key file*/
-#define KEY_PASSWD ""
-
-#ifndef __CLEAR_SCREEN__
-	#define __CLEAR_SCREEN__ "clear"
-#endif
-
-/* 0 -> false; 1 -> true */
-#ifndef __DEBUG__
-	#define __DEBUG__ 0
-#endif
-
-struct client
-{
-	int fd;
-	struct sockaddr_in sockaddr;
-	pthread_t thread;
-	SSL_CTX  *ctx;
-	SSL * myssl;
-	time_t last;
-	struct client * next;
-};
-
-void * handler(void *);
-
-void usage (void)
-{
-	puts("usage: ./server <PORT>\n\n");
-	exit (-1);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/client.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/client.c	(revision 216)
+++ 	(revision )
@@ -1,98 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#define IP "127.0.0.1"
-
-#define PORT "8888"
-
-int main(void)
-{
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-	int err,
-		i,
-		unit;
-	char buff[4096];
-	char * _xml = (char)NULL,
-		 //* xml_connect = {"fromBrowser"};
-		 * xml_connect = {"<?xml version='1.0' encoding='UTF-8'?><stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"};
-
-	_xml = (char *) malloc(sizeof(buff));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	//socketaddr.sin_addr.s_addr = INADDR_ANY;//inet_addr(IP);
-	//socketaddr.sin_addr.s_addr = inet_addr("10.15.20.42");
-	inet_aton(IP, &socketaddr.sin_addr);
-	socketaddr.sin_port = htons(nHostPort);
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	struct hostent *hp;
-	hp = gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET);
-
-	//printf("\n\n%s\n\n", inet_ntoa(socketaddr.sin_addr));
-	//printf("\n\n%d\n\n", inet_network("expresso.pr.gov.br"));
-
-	//printf("\n\n%d\n\n", socketaddr.sin_addr.s_addr);
-	//printf("\n\n%s\n\n", gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET));
-
-
-	//sprintf(_xml, xml_connect, IP);
-	//_xml[strlen(_xml)] = '\0';
-	//++_xml;
-	//*_xml = '\0';
-	//puts(_xml);
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "from_browser");
-	write(socketfd, _xml, strlen(_xml));
-
-	/*bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "user@domine");
-	write(socketfd, _xml, strlen(_xml));
-
-	bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "password");
-	write(socketfd, _xml, strlen(_xml));
-
-	bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);*/
-
-	//sleep(10);
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/server_bkp_20071010.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/server_bkp_20071010.h	(revision 216)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#include <fcntl.h>
-
-#include <netdb.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-
-#include <pthread.h>
-
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <unistd.h>
-
-// define max clients waiting in the queue for connect
-#ifndef __QUEUE_SIZE__
-	#define __QUEUE_SIZE__ 10
-#endif
-
-// __SOCKET_ERROR__ must be -1, don't change this
-#ifndef __SOCKET_ERROR__
-	#define __SOCKET_ERROR__ -1
-#endif
-
-// the jabber's documentation recommends read the
-// packages of socket with size of 4096 (2^12) KB
-#ifndef __BUFFER_SIZE__
-	#define __BUFFER_SIZE__ 4096
-#endif
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/server_versao_1.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/server_versao_1.c	(revision 216)
+++ 	(revision )
@@ -1,536 +1,0 @@
-#include "server.h"
-
-int main (int argc, char ** argv)
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise ();
-
-	// Create server socket before becoming a daemon so
-	// there is still a chance to print an error message.
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb ("Unable to create server socket");
-
-	Daemonise ();
-
-	MainLoop (listen_fd, remote_addr, remote_port); // never returns
-
-	exit (EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char ** argv, struct in_addr * ra, unsigned short * rp, struct in_addr * la, unsigned short * lp)
-{
-	// argv[0] = program name
-	// argv[1] = remote_addr
-	// argv[2] = remote_port
-	// argv[3] = local_addr (optional)
-	// argv[4] = local_port (optional)
-
-	char * p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr (argv[1], ra) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort (argv[2], rp, "tcp") )
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl (INADDR_ANY);
-	else
-		if ( NameToAddr (argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy (lp, rp, sizeof (*lp));
-	else
-		if ( NameToPort (argv[4], lp, "tcp") )
-			quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	set_signal_handler (SIGCHLD, sig_child);
-
-	signal (SIGPIPE, SIG_IGN);
-}
-
-// sig_child()
-// Handles SIGCHLD from exiting child processes.
-void sig_child (int signo)
-{
-	pid_t pid;
-
-	(void) signo; // suppress compiler warning
-
-	for ( ; ; )
-	{
-		pid = waitpid (WAIT_ANY, NULL, WNOHANG);
-
-		if ( pid > 0 )
-			syslog (LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		else
-			break;
-	}
-
-	if ( (pid < 0) && (errno != ECHILD) )
-		syslog (LOG_ERR, "waitpid(): %m"), exit (EXIT_FAILURE);
-
-	return;
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if ( err < 0 )
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-// Daemonise()
-// Put the program in the background, set PPID=1, create a
-// new session and process group, without a controlling tty.
-void Daemonise (void)
-{
-	pid_t pid;
-
-	// Close stdin, stdout & stderr
-	// TODO:
-	//		open /dev/null and dup the fd to stdin, stdout & stderr
-	//		close(STDIN_FILENO);
-	//		close(STDOUT_FILENO);
-	//		close(STDERR_FILENO);
-
-	syslog (LOG_INFO, "%s daemonising", g_program_name);
-
-	// Fork the process to put it in the background.
-
-	pid = fork ();
-	if ( pid == -1 )
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	// parent terminates here, so shell thinks the command is done.
-	if ( pid )
-		exit (0);
-
-	syslog (LOG_INFO, "%s in background", g_program_name);
-
-	// 1st child continues to run in the background with PPID=1
-
-	// Become leader of a new session and a new process group,
-	// with no controlling tty.
-	setsid ();
-
-	// Fork again to guarantee the process will
-	// not be able to aquire a controlling tty.
-
-	// signal (SIGHUP, SIG_IGN);
-	// required according to Stevens' UNP2 p333
-
-	pid = fork ();
-	if (pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if ( pid ) // 1st child terminates
-		exit (0);
-
-	// 2nd child continues, no longer a session or group leader
-
-	syslog (LOG_INFO, "%s daemonised", g_program_name);
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	int server_fd,
-		client_fd;
-	pid_t child_pid;
-
-	for ( ; ; )
-	{
-		client_fd = AcceptClientConnection (listen_fd);
-
-		child_pid = fork ();
-
-		if ( child_pid == -1 )
-			syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-		if ( child_pid ) // parent
-		{
-			close (client_fd);
-
-			syslog (LOG_INFO, "Forked child pid %d to deal with client", child_pid);
-
-			continue;
-		}
-		else // child
-		{
-			close (listen_fd);
-
-			server_fd = ConnectToServer (rem_addr, rem_port);
-
-			Proxy (server_fd, client_fd);
-
-			syslog (LOG_INFO, "exiting");
-			_exit (0);
-		}
-	}
-}
-
-// Proxy()
-// Copies data between server_fd and client_fd in both directions
-// until one or other peer closes their connection.
-void Proxy (int server_fd, int client_fd)
-{
-	pid_t helper_pid;
-
-	syslog (LOG_INFO, "Proxy(fd%d, fd%d)", server_fd, client_fd);
-
-	signal (SIGCHLD, SIG_IGN);
-
-	helper_pid = fork ();
-	if ( helper_pid == -1 )
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if ( helper_pid ) // parent
-	{
-		syslog (LOG_INFO, "Forked child pid %d to help with proxying", helper_pid);
-
-		Cat (server_fd, client_fd);
-
-		shutdown (client_fd, 1);
-		close (server_fd);
-		close (client_fd);
-
-		wait (0); // wait for helper to exit
-	}
-	else // child (helper)
-	{
-		Cat (client_fd, server_fd);
-
-		shutdown (server_fd, 1);
-
-		syslog (LOG_INFO, "exiting");
-		exit (0); // helper exits here
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-int AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
-
-	if ( socklen != sizeof (sa) )
-		syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
-
-	return (newfd);
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO: have a timeout for connect() - see Unix socket FAQ 6.2
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		exit (EXIT_FAILURE);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-void Cat (int in_fd, int out_fd)
-{
-	unsigned char * const buf = malloc (BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = 0,
-		i;
-
-	syslog (LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-		for ( i = 0; i < bytes_rcvd; i += bytes_sent )
-		{
-			bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-			if ( bytes_sent < 0 )
-				break;
-		}
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-	if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-		syslog (LOG_ERR, "recv(): %m"), exit (EXIT_FAILURE);
-
-	if ( (bytes_sent < 0) && (errno != EPIPE) )
-		syslog (LOG_ERR, "send(): %m"), exit (EXIT_FAILURE);
-
-	free (buf);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO: use inet_aton() instead
-	p_inaddr->s_addr = inet_addr (name);
-	if ( p_inaddr->s_addr != -1U ) // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname (name);
-	if ( he != NULL ) // Success
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul (name, &errpos, 0);
-	if ( (*errpos == 0) && (lport <= 65535) ) // Success
-	{
-		*port = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname (name, proto);
-	if ( se != NULL) // Success
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char * fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char * fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char * fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction (signum, &act, NULL) < 0 )
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/server.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/server.c	(revision 216)
+++ 	(revision )
@@ -1,584 +1,0 @@
-#include "server.h"
-
-int main (int argc, char ** argv)
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise ();
-
-	// Create server socket before becoming a daemon so
-	// there is still a chance to print an error message.
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb ("Unable to create server socket");
-
-	Daemonise ();
-
-	MainLoop (listen_fd, remote_addr, remote_port); // never returns
-
-	exit (EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char ** argv, struct in_addr * ra, unsigned short * rp, struct in_addr * la, unsigned short * lp)
-{
-	// argv[0] = program name
-	// argv[1] = remote_addr
-	// argv[2] = remote_port
-	// argv[3] = local_addr (optional)
-	// argv[4] = local_port (optional)
-
-	char * p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr (argv[1], ra) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort (argv[2], rp, "tcp") )
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl (INADDR_ANY);
-	else
-		if ( NameToAddr (argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy (lp, rp, sizeof (*lp));
-	else
-		if ( NameToPort (argv[4], lp, "tcp") )
-			quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	set_signal_handler (SIGCHLD, sig_child);
-
-	signal (SIGPIPE, SIG_IGN);
-}
-
-// sig_child()
-// Handles SIGCHLD from exiting child processes.
-void sig_child (int signo)
-{
-	pid_t pid;
-
-	(void) signo; // suppress compiler warning
-
-	for ( ; ; )
-	{
-		pid = waitpid (WAIT_ANY, NULL, WNOHANG);
-
-		if ( pid > 0 )
-			syslog (LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		else
-			break;
-	}
-
-	if ( (pid < 0) && (errno != ECHILD) )
-		syslog (LOG_ERR, "waitpid(): %m"), exit (EXIT_FAILURE);
-
-	return;
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if ( err < 0 )
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-// Daemonise()
-// Put the program in the background, set PPID=1, create a
-// new session and process group, without a controlling tty.
-void Daemonise (void)
-{
-	pid_t pid;
-
-	// Close stdin, stdout & stderr
-	// TODO:
-	//		open /dev/null and dup the fd to stdin, stdout & stderr
-	//		close(STDIN_FILENO);
-	//		close(STDOUT_FILENO);
-	//		close(STDERR_FILENO);
-
-	syslog (LOG_INFO, "%s daemonising", g_program_name);
-
-	// Fork the process to put it in the background.
-
-	pid = fork ();
-	if ( pid == -1 )
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	// parent terminates here, so shell thinks the command is done.
-	if ( pid )
-		exit (0);
-
-	syslog (LOG_INFO, "%s in background", g_program_name);
-
-	// 1st child continues to run in the background with PPID=1
-
-	// Become leader of a new session and a new process group,
-	// with no controlling tty.
-	setsid ();
-
-	// Fork again to guarantee the process will
-	// not be able to aquire a controlling tty.
-
-	// signal (SIGHUP, SIG_IGN);
-	// required according to Stevens' UNP2 p333
-
-	pid = fork ();
-	if (pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if ( pid ) // 1st child terminates
-		exit (0);
-
-	// 2nd child continues, no longer a session or group leader
-
-	syslog (LOG_INFO, "%s daemonised", g_program_name);
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	int server_fd,
-		client_fd;
-	pid_t child_pid;
-	struct client * clients = (struct client *)NULL;
-	struct client * current = (struct client *)NULL;
-	int i = 1;
-
-	setbuf(stdout, NULL);
-	for ( ; ; )
-	{
-		if ( clients == (struct client *)NULL )
-		{
-			printf("INIT\n");
-			fflush(stdout);
-
-			clients = (struct client *) malloc(sizeof(struct client));
-			clients->user = (unsigned char *) malloc(sizeof(unsigned char) * 100);
-			clients->key = (unsigned char *) malloc(sizeof(unsigned char) * 100);
-
-			clients->next = (struct client *)NULL;
-			clients->previous = (struct client *)NULL;
-		}
-		else
-		{
-			current = clients;
-			i = 1;
-
-			while ( current->next != (struct client *)NULL )
-			{
-				current = current->next;
-				++i;
-				printf("i: %d\n", i);
-				fflush(stdout);
-			}
-			printf("NEXT\n");
-			//current->user = (unsigned char *) malloc(sizeof(unsigned char) * 100);
-			//current->key = (unsigned char *) malloc(sizeof(unsigned char) * 100);
-			//current->next = (struct client *) malloc(sizeof(struct client));
-			//current->next->previous = current;
-			//current->next->next = (struct client *)NULL;
-			//current = current->next;
-		}
-
-		printf("children: %d\n", i);
-		fflush(stdout);
-		client_fd = AcceptClientConnection (listen_fd);
-
-		child_pid = fork ();
-		if ( child_pid == -1 )
-			syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-		int * keep_connection_with_jabber;
-		keep_connection_with_jabber = (int *) malloc (sizeof(int));
-
-		if ( child_pid ) // parent
-		{
-			close (client_fd);
-
-			syslog (LOG_INFO, "Forked child pid %d to deal with client", child_pid);
-
-			continue;
-		}
-		else // child
-		{
-			close (listen_fd);
-
-			server_fd = ConnectToServer (rem_addr, rem_port);
-
-			Proxy (server_fd, client_fd, keep_connection_with_jabber);
-
-			syslog (LOG_INFO, "exiting");
-			_exit (0);
-		}
-	}
-}
-
-// Proxy()
-// Copies data between server_fd and client_fd in both directions
-// until one or other peer closes their connection.
-void Proxy (int server_fd, int client_fd, int * keep_connection_with_jabber)
-{
-	pid_t helper_pid;
-
-	syslog (LOG_INFO, "Proxy(fd%d, fd%d)", server_fd, client_fd);
-
-	signal (SIGCHLD, SIG_IGN);
-
-	helper_pid = fork ();
-	if ( helper_pid == -1 )
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if ( helper_pid ) // parent
-	{
-		syslog (LOG_INFO, "Forked child pid %d to help with proxying", helper_pid);
-
-		Cat (server_fd, client_fd, keep_connection_with_jabber);
-
-		shutdown (client_fd, 1);
-		if ( *(keep_connection_with_jabber) != 1 )
-			close (server_fd);
-		close (client_fd);
-
-		wait (0); // wait for helper to exit
-	}
-	else // child (helper)
-	{
-		Cat (client_fd, server_fd, keep_connection_with_jabber);
-
-		if ( *(keep_connection_with_jabber) != 1 )
-			shutdown (server_fd, 1);
-
-		syslog (LOG_INFO, "exiting");
-		exit (0); // helper exits here
-	}
-	free(keep_connection_with_jabber);
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-int AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
-
-	if ( socklen != sizeof (sa) )
-		syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
-
-	return (newfd);
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO: have a timeout for connect() - see Unix socket FAQ 6.2
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		exit (EXIT_FAILURE);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-void Cat (int in_fd, int out_fd, int * keep_connection_with_jabber)
-{
-	unsigned char * const buf = (char *) malloc (sizeof(char) * BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = (int) NULL,
-		i;
-
-	syslog (LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		bzero(buf, BUF_SIZE);
-		bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-		if ( (bytes_sent == (int) NULL) && (strcmp(buf, "fromBrowser") == 0) )
-			*(keep_connection_with_jabber) = 1;
-		else
-			for ( i = 0; i < bytes_rcvd; i += bytes_sent )
-			{
-				bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-				if ( bytes_sent < 0 )
-					break;
-			}
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-	if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-		syslog (LOG_ERR, "recv(): %m"), exit (EXIT_FAILURE);
-
-	if ( (bytes_sent < 0) && (errno != EPIPE) )
-		syslog (LOG_ERR, "send(): %m"), exit (EXIT_FAILURE);
-
-	free (buf);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO: use inet_aton() instead
-	p_inaddr->s_addr = inet_addr (name);
-	if ( p_inaddr->s_addr != -1U ) // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname (name);
-	if ( he != NULL ) // Success
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul (name, &errpos, 0);
-	if ( (*errpos == 0) && (lport <= 65535) ) // Success
-	{
-		*port = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname (name, proto);
-	if ( se != NULL) // Success
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char * fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char * fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char * fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction (signum, &act, NULL) < 0 )
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/server.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/server.h	(revision 216)
+++ 	(revision )
@@ -1,64 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <semaphore.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-// Buffer size, in bytes, used for copying in the Cat() function.
-const size_t BUF_SIZE = 4096;
-
-// Global variables
-char g_program_name[100];	// Initialised from argv[0] in ParseArgs()
-
-
-// structs
-struct client
-{
-	unsigned char * user;
-	unsigned char * key;
-	int jabber;
-	int shmid;
-	struct client * next,
-				  * previous;
-};
-
-// Typedef for a signal handler function.
-typedef void (* signal_handler_t) (int);
-
-// Prototypes for functions in this file.
-void ParseArgs (int, char **, struct in_addr *, unsigned short *, struct in_addr *, unsigned short *);
-void Initialise (void);
-void sig_child (int);
-int CreateServerSocket (struct in_addr, unsigned short);
-void Daemonise (void);
-void MainLoop (int, struct in_addr, unsigned short);
-void Proxy (int, int, int *);
-int AcceptClientConnection (int);
-int ConnectToServer (struct in_addr, unsigned short);
-void Cat (int, int, int *);
-int NameToAddr (const char *, struct in_addr *);
-int NameToPort (const char *, unsigned short *, const char *);
-#ifdef __GNUC__
-	void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *, ...);
-	void pbomb (const char *, ...);
-	void hbomb (const char *, ...);
-#endif
-void set_signal_handler (int, signal_handler_t);
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/server_bkp_20071010.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/server_bkp_20071010.c	(revision 216)
+++ 	(revision )
@@ -1,105 +1,0 @@
-#include "server.h"
-
-static void handle_request(int, struct sockaddr_in);
-
-int main(int argc, char ** argv)
-{
-	// fd -> file descriptor
-	int socket_server_fd    = (int)NULL,
-		socket_server_port  = (int)NULL,
-		socket_accept_fd    = (int)NULL,
-		sockaddr_in_size    = sizeof(struct sockaddr_in),
-		err                 = (int)NULL,
-		pid					= (int)NULL;
-
-	/* Internet socket address stuct */
-	struct sockaddr_in server_addr,
-					   accept_addr;
-
-	bzero((char *) &server_addr, sockaddr_in_size);
-	bzero((char *) &accept_addr, sockaddr_in_size);
-
-	// make a socket
-	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( socket_server_fd == __SOCKET_ERROR__ )
-	{
-		fprintf(stderr, "\nCould not make a socket\n");
-		exit(EXIT_FAILURE);
-	}
-
-	// fill address struct
-	server_addr.sin_addr.s_addr = INADDR_ANY;
-	server_addr.sin_port        = htons(8888);
-	server_addr.sin_family      = AF_INET;
-	bzero(&(server_addr.sin_zero), 8);
-
-	// bind to a port
-	if ( bind(socket_server_fd, (struct sockaddr *)&(server_addr), sizeof(server_addr)) == __SOCKET_ERROR__ )
-	{
-		fprintf(stderr, "\nCould not connect to host\n");
-		exit(EXIT_FAILURE);
-	}
-
-	// get port number
-	getsockname(socket_server_fd, (struct sockaddr *)&(server_addr), (socklen_t *) &(sockaddr_in_size));
-	//if ( __DEBUG__  || verbose )
-	//{
-		printf("\nopened socket as fd (%d) on port (%d) for stream i/o\n", socket_server_fd, ntohs(server_addr.sin_port));
-
-		printf("Server\n\
-				sin_family        = %d\n\
-				sin_addr.s_addr   = %d\n\
-				sin_port          = %d\n"
-				, server_addr.sin_family
-				, server_addr.sin_addr.s_addr
-				, ntohs(server_addr.sin_port)
-			  );
-		printf("\nMaking a listen queue of %d elements", __QUEUE_SIZE__);
-	//}
-
-	// establish listen queue
-	if ( listen(socket_server_fd, __QUEUE_SIZE__) == __SOCKET_ERROR__ )
-	{
-		fprintf(stderr, "\nCould not listen\n");
-		exit(EXIT_FAILURE);
-	}
-
-	while ( 1 )
-	{
-		//if ( __DEBUG__  || verbose )
-			puts("\nWaiting for a connection\n");
-
-		// get the connected socket
-		socket_accept_fd = accept(socket_server_fd, (struct sockaddr *) &(accept_addr), (socklen_t *) &(sockaddr_in_size));
-
-		if ( socket_accept_fd > -1 )
-		{
-			pid = fork();
-			if ( pid )
-			{
-				close(socket_accept_fd);
-				continue;
-			}
-			else
-			{
-				close(socket_server_fd);
-				handle_request(socket_accept_fd, accept_addr);
-				close(socket_accept_fd);
-			}
-			//close(socket_accept_fd);
-		}
-	}
-}
-
-static void handle_request(int sock, struct sockaddr_in client_addr)
-{
-	char * buffer_client;
-
-	buffer_client = (char *) malloc(sizeof(char) * __BUFFER_SIZE__);
-	bzero(buffer_client, __BUFFER_SIZE__);
-
-	read(sock, buffer_client, __BUFFER_SIZE__);
-	printf("%s\n", buffer_client);
-
-	free(buffer_client);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/client.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/client.c	(revision 216)
+++ 	(revision )
@@ -1,98 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#define IP "127.0.0.1"
-
-#define PORT "8888"
-
-int main(void)
-{
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-	int err,
-		i,
-		unit;
-	char buff[4096];
-	char * _xml = (char)NULL,
-		 //* xml_connect = {"fromBrowser"};
-		 * xml_connect = {"<?xml version='1.0' encoding='UTF-8'?><stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"};
-
-	_xml = (char *) malloc(sizeof(buff));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	//socketaddr.sin_addr.s_addr = INADDR_ANY;//inet_addr(IP);
-	//socketaddr.sin_addr.s_addr = inet_addr("10.15.20.42");
-	inet_aton(IP, &socketaddr.sin_addr);
-	socketaddr.sin_port = htons(nHostPort);
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	struct hostent *hp;
-	hp = gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET);
-
-	//printf("\n\n%s\n\n", inet_ntoa(socketaddr.sin_addr));
-	//printf("\n\n%d\n\n", inet_network("expresso.pr.gov.br"));
-
-	//printf("\n\n%d\n\n", socketaddr.sin_addr.s_addr);
-	//printf("\n\n%s\n\n", gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET));
-
-
-	//sprintf(_xml, xml_connect, IP);
-	//_xml[strlen(_xml)] = '\0';
-	//++_xml;
-	//*_xml = '\0';
-	//puts(_xml);
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "from_browser");
-	write(socketfd, _xml, strlen(_xml));
-
-	/*bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "user@domine");
-	write(socketfd, _xml, strlen(_xml));
-
-	bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "password");
-	write(socketfd, _xml, strlen(_xml));
-
-	bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);*/
-
-	//sleep(10);
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/proxy.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/proxy.c	(revision 216)
+++ 	(revision )
@@ -1,587 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <stdarg.h>
-#include <syslog.h>
-
-/* Buffer size, in bytes, used for copying in the Cat() function. */
-const size_t BUF_SIZE = 10240;
-
-/* Typedef for a signal handler function. */
-typedef void (*signal_handler_t) (int);
-
-/* Prototypes for functions in this file. */
-void ParseArgs (int argc, char *argv[], struct in_addr *ra,
-		unsigned short *rp, struct in_addr *la, unsigned short *lp);
-void Initialise (void);
-void sig_child (int signo);
-int CreateServerSocket (struct in_addr addr, unsigned short port);
-void Daemonise (void);
-void MainLoop (int listen_fd, struct in_addr rem_addr,
-		unsigned short rem_port);
-void Proxy (int server_fd, int client_fd);
-int AcceptClientConnection (int listen_fd);
-int ConnectToServer (struct in_addr addr, unsigned short port);
-void Cat (int in_fd, int out_fd);
-int NameToAddr (const char *name, struct in_addr *p_inaddr);
-int NameToPort (const char *name, unsigned short *port, const char *proto);
-#ifdef __GNUC__
-void quit (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-void pbomb (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-void hbomb (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-void quit (const char *fmt, ...);
-void pbomb (const char *fmt, ...);
-void hbomb (const char *fmt, ...);
-#endif
-void set_signal_handler (int signum, signal_handler_t sig_handler_func);
-
-/* Global variables */
-char g_program_name[100];       /* Initialised from argv[0] in ParseArgs() */
-
-	int
-main (int argc, char *argv[])
-{
-	struct in_addr remote_addr, local_addr;
-	unsigned short remote_port, local_port;
-	int listen_fd;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr,
-			&local_port);
-
-	Initialise ();
-
-	/* Create server socket before becoming a daemon so there is still a
-	 *      chance to print an error message. */
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if (listen_fd < 0)
-		pbomb ("Unable to create server socket");
-
-	Daemonise ();
-
-	MainLoop (listen_fd, remote_addr, remote_port);       /* never returns */
-
-	exit (EXIT_SUCCESS);
-}
-
-/* ParseArgs(): Parse the command line arguments to extract the remote and
- *  * local adresses and port numbers, ra, rp, la & lp.  Exit the program
- *   * gracefully upon error.
- *    */
-	void
-ParseArgs (int argc, char *argv[], struct in_addr *ra, unsigned short *rp,
-		struct in_addr *la, unsigned short *lp)
-{
-	/*
-	 *    * argv[0] = program name
-	 *       * argv[1] = remote_addr
-	 *          * argv[2] = remote_port
-	 *             * argv[3] = local_addr (optional)
-	 *                * argv[4] = local_port (optional)
-	 *                   */
-
-	char *p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1,
-			sizeof (g_program_name) - 1);
-
-	if ((argc < 3) || (argc > 5))
-	{
-		fprintf (stderr,
-				"usage: %s remote_addr remote_port [local_addr] [local_port]\n",
-				argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if (NameToAddr (argv[1], ra))
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if (NameToPort (argv[2], rp, "tcp"))
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if (argc < 4)
-		la->s_addr = htonl (INADDR_ANY);
-	else if (NameToAddr (argv[3], la))
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if (argc < 5)
-		memcpy (lp, rp, sizeof (*lp));
-	else if (NameToPort (argv[4], lp, "tcp"))
-		quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-/* Initialise(): Setup syslog, signal handlers, and other intialisation.
- *  */
-	void
-Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/");                  /* Change working directory to the root. */
-
-	umask (0);                    /* Clear our file mode creation mask */
-
-	set_signal_handler (SIGCHLD, sig_child);
-
-	signal (SIGPIPE, SIG_IGN);
-}
-
-/* sig_child(): Handles SIGCHLD from exiting child processes.
- *  */
-	void
-sig_child (int signo)
-{
-	pid_t pid;
-
-	(void) signo;                 /* suppress compiler warning */
-
-	for (;;)
-	{
-		pid = waitpid (WAIT_ANY, NULL, WNOHANG);
-
-		if (pid > 0)
-			syslog (LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		else
-			break;
-	}
-
-	if ((pid < 0) && (errno != ECHILD))
-		syslog (LOG_ERR, "waitpid(): %m"), exit (EXIT_FAILURE);
-
-	return;
-}
-
-/* CreateServerSocket(): Create a socket, bind it to the specified address
- *  * and port, and set it to listen for client connections.  Returns <0 on
- *   * failure to bind, bombs on error otherwise, returns the fd of the new
- *    * socket on success.
- *     */
-	int
-CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err, fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	/* Create a socket and get its descriptor. */
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if (fd < 0)
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	/* Set SO_REUSEADDR socket option */
-	if (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0)
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	/* Load a sa structure with the specified address and port */
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	/* Bind our socket to the address and port specified */
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	/* Tell socket to listen and queue up to 5 incoming connections. */
-	if (listen (fd, 5) < 0)
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-/* Daemonise(): Put the program in the background, set PPID=1, create a new
- *  * session and process group, without a controlling tty.
- *   */
-	void
-Daemonise (void)
-{
-	pid_t pid;
-
-	/* Close stdin, stdout & stderr */
-	/* TODO: open /dev/null and dup the fd to stdin, stdout & stderr
-	 *      close(STDIN_FILENO);
-	 *           close(STDOUT_FILENO);
-	 *                close(STDERR_FILENO);
-	 *                   */
-
-	syslog (LOG_INFO, "%s daemonising", g_program_name);
-
-	/* Fork the process to put it in the background. */
-
-	pid = fork ();
-	if (pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	/* parent terminates here, so shell thinks the command is done. */
-	if (pid)
-		exit (0);
-
-	syslog (LOG_INFO, "%s in background", g_program_name);
-
-	/* 1st child continues to run in the background with PPID=1 */
-
-	/* Become leader of a new session and a new process group,
-	 *      with no controlling tty.  */
-	setsid ();
-
-	/* Fork again to guarantee the process will not be able to aquire a
-	 *      controlling tty. */
-
-	/*signal (SIGHUP, SIG_IGN); *//* required according to Stevens' UNP2 p333 */
-
-	pid = fork ();
-	if (pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if (pid)                      /* 1st child terminates */
-		exit (0);
-
-	/* 2nd child continues, no longer a session or group leader */
-
-	syslog (LOG_INFO, "%s daemonised", g_program_name);
-}
-
-/* MainLoop(): Classic concurrent server model. Wait for a client to connect,
- *  * fork a child process to do the business with the client, parent process
- *   * continues to wait for the next connection.  This function does not return.
- *    */
-	void
-MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	int server_fd, client_fd;
-	pid_t child_pid;
-
-	for (;;)
-	{
-		client_fd = AcceptClientConnection (listen_fd);
-
-		child_pid = fork ();
-		if (child_pid == -1)
-			syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-		if (child_pid)            /* parent */
-		{
-			close (client_fd);
-
-			syslog (LOG_INFO, "Forked child pid %d to deal with client",
-					child_pid);
-
-			continue;
-		}
-		else                      /* child */
-		{
-			close (listen_fd);
-
-			server_fd = ConnectToServer (rem_addr, rem_port);
-
-			Proxy (server_fd, client_fd);
-
-			syslog (LOG_INFO, "exiting");
-			_exit (0);
-		}
-	}
-}
-
-/* Proxy(): Copies data between server_fd and client_fd in both directions
- *  * until one or other peer closes their connection.
- *   */
-	void
-Proxy (int server_fd, int client_fd)
-{
-	pid_t helper_pid;
-
-	syslog (LOG_INFO, "Proxy(fd%d, fd%d)", server_fd, client_fd);
-
-	signal (SIGCHLD, SIG_IGN);
-
-	helper_pid = fork ();
-	if (helper_pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if (helper_pid)               /* parent */
-	{
-		syslog (LOG_INFO, "Forked child pid %d to help with proxying",
-				helper_pid);
-
-		Cat (server_fd, client_fd);
-
-		shutdown (client_fd, 1);
-		close (server_fd);
-		close (client_fd);
-
-		wait (0);                 /* wait for helper to exit */
-	}
-	else                          /* child (helper) */
-	{
-		Cat (client_fd, server_fd);
-
-		shutdown (server_fd, 1);
-
-		syslog (LOG_INFO, "exiting");
-		exit (0);                 /* helper exits here */
-	}
-}
-
-/* AcceptClientConnection(): waits for a tcp connect to the socket listen_fd,
- *  * which must already be bound and set to listen on a local port.  Bombs on
- *   * error, returns the fd of the new socket on success.
- *    */
-	int
-AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	/* Accept the connection and create a new socket for it. */
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ((newfd < 0) && (errno == EINTR));
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if (newfd < 0)
-		syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
-
-	if (socklen != sizeof (sa))
-		syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
-
-	return (newfd);
-}
-
-/* ConnectToServer(): attempts a tcp connect to the server specified by addr
- *  * and port.  Bombs on failure to connect, returns the fd of the new socket
- *   * on success.
- *    */
-	int
-ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	/* TODO: have a timeout for connect() - see Unix socket FAQ 6.2 */
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	/* Create a socket and get its descriptor. */
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if (fd < 0)
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		exit (EXIT_FAILURE);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-/* Cat(): read data from in_fd and write it to out_fd until the connection is
- *  * closed by one of the peers.  Data is copied using a dynamically allocated
- *   * buffer.
- *    */
-	void
-Cat (int in_fd, int out_fd)
-{
-	unsigned char *const buf = malloc (BUF_SIZE);
-	int bytes_rcvd, bytes_sent = 0, i;
-
-	syslog (LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if (buf == NULL)
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-		for (i = 0; i < bytes_rcvd; i += bytes_sent)
-		{
-			bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-			if (bytes_sent < 0)
-				break;
-		}
-
-	}
-	while ((bytes_rcvd > 0) && (bytes_sent > 0));
-
-	if ((bytes_rcvd < 0) && (errno != ECONNRESET))
-		syslog (LOG_ERR, "recv(): %m"), exit (EXIT_FAILURE);
-
-	if ((bytes_sent < 0) && (errno != EPIPE))
-		syslog (LOG_ERR, "send(): %m"), exit (EXIT_FAILURE);
-
-	free (buf);
-}
-
-/* NameToAddress(): Convert name to an ip address.  Returns 0 on success,
- *  * -1 on failure.
- *   */
-	int
-NameToAddr (const char *name, struct in_addr *p_inaddr)
-{
-	struct hostent *he;
-
-	/* First, attempt to convert from string ip format */
-	/* TODO: use inet_aton() instead */
-	p_inaddr->s_addr = inet_addr (name);
-	if (p_inaddr->s_addr != -1U)  /* Success */
-		return 0;
-
-	/* Next, attempt to read from /etc/hosts or do a DNS lookup */
-	he = gethostbyname (name);
-	if (he != NULL)               /* Success */
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1;                    /* Failed to resolve name to an ip address */
-}
-
-/* NameToPort(): Convert name to a port number. Name can either be a port
- *  * name (in which case proto must also be set to either "tcp" or "udp") or
- *   * name can be the ascii representation of the port number.  Returns 0 on
- *    * success, -1 on failure.
- *     */
-	int
-NameToPort (const char *name, unsigned short *port, const char *proto)
-{
-	unsigned long lport;
-	char *errpos;
-	struct servent *se;
-
-	/* First, attempt to convert string to integer */
-	lport = strtoul (name, &errpos, 0);
-	if ((*errpos == 0) && (lport <= 65535))       /* Success */
-	{
-		*port = lport;
-		return 0;
-	}
-
-	/* Next, attempt to read the string from /etc/services */
-	se = getservbyname (name, proto);
-	if (se != NULL)               /* Success */
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1;                    /* Failed to resolve port name to a number */
-}
-
-/* quit(), pbomb(), hbomb(): Print an error message to stderr and syslog, then
- *  * exit the program.  pbomb() and hbomb() additionally include the string
- *   * representation of errno and h_errno respectively.
- *    */
-	void
-quit (const char *fmt, ...)     /* quit with msg */
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-	void
-pbomb (const char *fmt, ...)    /* bomb with perror */
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-	void
-hbomb (const char *fmt, ...)    /* bomb with herror */
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-/* set_signal_handler(): Sets a signal handler function.  Similar to signal()
- *  * but this method is more portable between platforms.
- *   */
-	void
-set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if (sigaction (signum, &act, NULL) < 0)
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/server.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/server.c	(revision 216)
+++ 	(revision )
@@ -1,542 +1,0 @@
-#include "server.h"
-
-int main (int argc, char ** argv)
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise ();
-
-	// Create server socket before becoming a daemon so
-	// there is still a chance to print an error message.
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb ("Unable to create server socket");
-
-	//Daemonise ();
-
-	MainLoop (listen_fd, remote_addr, remote_port); // never returns
-
-	exit (EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char ** argv, struct in_addr * ra, unsigned short * rp, struct in_addr * la, unsigned short * lp)
-{
-	// argv[0] = program name
-	// argv[1] = remote_addr
-	// argv[2] = remote_port
-	// argv[3] = local_addr (optional)
-	// argv[4] = local_port (optional)
-
-	char * p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr (argv[1], ra) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort (argv[2], rp, "tcp") )
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl (INADDR_ANY);
-	else
-		if ( NameToAddr (argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy (lp, rp, sizeof (*lp));
-	else
-		if ( NameToPort (argv[4], lp, "tcp") )
-			quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	set_signal_handler (SIGCHLD, sig_child);
-
-	signal (SIGPIPE, SIG_IGN);
-}
-
-// sig_child()
-// Handles SIGCHLD from exiting child processes.
-void sig_child (int signo)
-{
-	pid_t pid;
-
-	(void) signo; // suppress compiler warning
-
-	for ( ; ; )
-	{
-		write(1, "SIG\n", sizeof("SIG\n"));
-		pid = waitpid (WAIT_ANY, NULL, WNOHANG);
-
-		if ( pid > 0 )
-			syslog (LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		else
-			break;
-	}
-	write(1, "SIG...\n", sizeof("SIG...\n"));
-
-	if ( (pid < 0) && (errno != ECHILD) )
-		syslog (LOG_ERR, "waitpid(): %m"), exit (EXIT_FAILURE);
-
-	return;
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if ( err < 0 )
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-// Daemonise()
-// Put the program in the background, set PPID=1, create a
-// new session and process group, without a controlling tty.
-void Daemonise (void)
-{
-	pid_t pid;
-
-	// Close stdin, stdout & stderr
-	// TODO:
-	//		open /dev/null and dup the fd to stdin, stdout & stderr
-	//		close(STDIN_FILENO);
-	//		close(STDOUT_FILENO);
-	//		close(STDERR_FILENO);
-
-	syslog (LOG_INFO, "%s daemonising", g_program_name);
-
-	// Fork the process to put it in the background.
-
-	pid = fork ();
-	if ( pid == -1 )
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	// parent terminates here, so shell thinks the command is done.
-	if ( pid )
-		exit (0);
-
-	syslog (LOG_INFO, "%s in background", g_program_name);
-
-	// 1st child continues to run in the background with PPID=1
-
-	// Become leader of a new session and a new process group,
-	// with no controlling tty.
-	setsid ();
-
-	// Fork again to guarantee the process will
-	// not be able to aquire a controlling tty.
-
-	// signal (SIGHUP, SIG_IGN);
-	// required according to Stevens' UNP2 p333
-
-	pid = fork ();
-	if (pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if ( pid ) // 1st child terminates
-		exit (0);
-
-	// 2nd child continues, no longer a session or group leader
-
-	syslog (LOG_INFO, "%s daemonised", g_program_name);
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	int server_fd,
-		client_fd;
-	pid_t child_pid;
-
-	for ( ; ; )
-	{
-		client_fd = AcceptClientConnection (listen_fd);
-
-		child_pid = fork ();
-		if ( child_pid == -1 )
-			syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-		if ( child_pid ) // parent
-		{
-			close (client_fd);
-
-			syslog (LOG_INFO, "Forked child pid %d to deal with client", child_pid);
-
-			continue;
-		}
-		else // child
-		{
-			close (listen_fd);
-
-			server_fd = ConnectToServer (rem_addr, rem_port);
-
-			Proxy (server_fd, client_fd);
-
-			syslog (LOG_INFO, "exiting");
-			_exit (0);
-		}
-	}
-}
-
-// Proxy()
-// Copies data between server_fd and client_fd in both directions
-// until one or other peer closes their connection.
-void Proxy (int server_fd, int client_fd)
-{
-	pid_t helper_pid;
-
-	syslog (LOG_INFO, "Proxy(fd%d, fd%d)", server_fd, client_fd);
-
-	signal (SIGCHLD, SIG_IGN);
-
-	helper_pid = fork ();
-	if ( helper_pid == -1 )
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if ( helper_pid ) // parent
-	{
-		syslog (LOG_INFO, "Forked child pid %d to help with proxying", helper_pid);
-
-		Cat (server_fd, client_fd);
-
-		shutdown (client_fd, 1);
-		close (server_fd);
-		close (client_fd);
-
-		wait (0); // wait for helper to exit
-	}
-	else // child (helper)
-	{
-		Cat (client_fd, server_fd);
-
-		shutdown (server_fd, 1);
-
-		syslog (LOG_INFO, "exiting");
-		exit (0); // helper exits here
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-int AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
-
-	if ( socklen != sizeof (sa) )
-		syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
-
-	return (newfd);
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO: have a timeout for connect() - see Unix socket FAQ 6.2
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		exit (EXIT_FAILURE);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-void Cat (int in_fd, int out_fd)
-{
-	unsigned char * const buf = (char *) malloc (sizeof(char) * BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = (int) NULL,
-		i;
-
-	syslog (LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		write(1, "DO\n", sizeof("DO\n"));
-		bzero(buf, BUF_SIZE);
-		bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-		for ( i = 0; i < bytes_rcvd; i += bytes_sent )
-		{
-			bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-			if ( bytes_sent < 0 )
-				break;
-		}
-		write(1, "WHILE\n", sizeof("WHILE\n"));
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-	
-	write(1, "...\n", sizeof("...\n"));
-
-	if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-		syslog (LOG_ERR, "recv(): %m"), exit (EXIT_FAILURE);
-
-	if ( (bytes_sent < 0) && (errno != EPIPE) )
-		syslog (LOG_ERR, "send(): %m"), exit (EXIT_FAILURE);
-
-	free (buf);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO: use inet_aton() instead
-	p_inaddr->s_addr = inet_addr (name);
-	if ( p_inaddr->s_addr != -1U ) // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname (name);
-	if ( he != NULL ) // Success
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul (name, &errpos, 0);
-	if ( (*errpos == 0) && (lport <= 65535) ) // Success
-	{
-		*port = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname (name, proto);
-	if ( se != NULL) // Success
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char * fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char * fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char * fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction (signum, &act, NULL) < 0 )
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/server.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/server.h	(revision 216)
+++ 	(revision )
@@ -1,64 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <semaphore.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-// Buffer size, in bytes, used for copying in the Cat() function.
-const size_t BUF_SIZE = 4096;
-
-// Global variables
-char g_program_name[100];	// Initialised from argv[0] in ParseArgs()
-
-
-// structs
-struct client
-{
-	unsigned char * user;
-	unsigned char * key;
-	int jabber;
-	int shmid;
-	struct client * next,
-				  * previous;
-};
-
-// Typedef for a signal handler function.
-typedef void (* signal_handler_t) (int);
-
-// Prototypes for functions in this file.
-void ParseArgs (int, char **, struct in_addr *, unsigned short *, struct in_addr *, unsigned short *);
-void Initialise (void);
-void sig_child (int);
-int CreateServerSocket (struct in_addr, unsigned short);
-void Daemonise (void);
-void MainLoop (int, struct in_addr, unsigned short);
-void Proxy (int, int);
-int AcceptClientConnection (int);
-int ConnectToServer (struct in_addr, unsigned short);
-void Cat (int, int);
-int NameToAddr (const char *, struct in_addr *);
-int NameToPort (const char *, unsigned short *, const char *);
-#ifdef __GNUC__
-	void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *, ...);
-	void pbomb (const char *, ...);
-	void hbomb (const char *, ...);
-#endif
-void set_signal_handler (int, signal_handler_t);
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/server_thread.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/server_thread.h	(revision 216)
+++ 	(revision )
@@ -1,70 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <semaphore.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <pthread.h>
-#include <ctype.h>
-
-
-// Buffer size, in bytes, used for copying in the Cat() function.
-const size_t BUF_SIZE = 4096;
-
-// Global variables
-char g_program_name[100];	// Initialised from argv[0] in ParseArgs()
-
-// structs
-/*struct client
-{
-	unsigned char * user;
-	unsigned char * key;
-	int jabber;
-	int shmid;
-	struct client * next,
-				  * previous;
-};*/
-
-// Typedef for a signal handler function.
-typedef void (* signal_handler_t) (int);
-
-// Prototypes for functions in this file.
-void ParseArgs (int, char **, struct in_addr *, unsigned short *, struct in_addr *, unsigned short *);
-void Initialise (void);
-void sig_child (int);
-int CreateServerSocket (struct in_addr, unsigned short);
-void Daemonise (void);
-void MainLoop (int, struct in_addr, unsigned short);
-void ClearList(void);
-void Proxy (int, int);
-struct accept * AcceptClientConnection (int);
-void VerifyClient(void *);
-struct client * Handshake(int);
-int ConnectToServer (struct in_addr, unsigned short);
-//void Cat (int, int);
-void Cat (void *);
-int NameToAddr (const char *, struct in_addr *);
-int NameToPort (const char *, unsigned short *, const char *);
-#ifdef __GNUC__
-	void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *, ...);
-	void pbomb (const char *, ...);
-	void hbomb (const char *, ...);
-#endif
-void set_signal_handler (int, signal_handler_t);
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/server.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/server.c	(revision 216)
+++ 	(revision )
@@ -1,730 +1,0 @@
-#include "server.h"
-
-struct accept
-{
-	int newfd;
-	struct sockaddr_in sa;
-	struct in_addr jabber_addr;
-	unsigned short jabber_port;
-};
-
-struct client
-{
-	char * user;
-	int client_fd,
-		jabber_fd,
-		keep_alive;
-	time_t last_action;
-	struct client * next,
-				  * previous;
-};
-
-struct cat
-{
-	int in_fd,
-		out_fd,
-		jabber,
-		keep_alive;
-	struct client * client;
-};
-
-struct client * clients = (struct client *)NULL;
-
-pthread_mutex_t mutexsum;
-
-int main (int argc, char ** argv)
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise ();
-
-	// Create server socket before becoming a daemon so
-	// there is still a chance to print an error message.
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb ("Unable to create server socket");
-
-	//Daemonise ();
-
-	MainLoop (listen_fd, remote_addr, remote_port); // never returns
-
-	exit (EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char ** argv, struct in_addr * ra, unsigned short * rp, struct in_addr * la, unsigned short * lp)
-{
-	// argv[0] = program name
-	// argv[1] = remote_addr
-	// argv[2] = remote_port
-	// argv[3] = local_addr (optional)
-	// argv[4] = local_port (optional)
-
-	char * p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr (argv[1], ra) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort (argv[2], rp, "tcp") )
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl (INADDR_ANY);
-	else
-		if ( NameToAddr (argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy (lp, rp, sizeof (*lp));
-	else
-		if ( NameToPort (argv[4], lp, "tcp") )
-			quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	set_signal_handler (SIGCHLD, sig_child);
-
-	signal (SIGPIPE, SIG_IGN);
-}
-
-// sig_child()
-// Handles SIGCHLD from exiting child processes.
-void sig_child (int signo)
-{
-	pid_t pid;
-
-	(void) signo; // suppress compiler warning
-
-	for ( ; ; )
-	{
-		pid = waitpid (WAIT_ANY, NULL, WNOHANG);
-
-		if ( pid > 0 )
-			syslog (LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		else
-			break;
-	}
-
-	if ( (pid < 0) && (errno != ECHILD) )
-		syslog (LOG_ERR, "waitpid(): %m"), exit (EXIT_FAILURE);
-
-	return;
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	//sa.sin_addr = addr;
-	sa.sin_addr.s_addr = htonl(INADDR_ANY);
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if ( err < 0 )
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	struct accept * accept;
-	pthread_t accept_thread,
-			  clear_list_thread;
-
-	pthread_mutex_init(&mutexsum, NULL);
-
-	pthread_create(&clear_list_thread, NULL, (void *) &ClearList, (void *)NULL );
-
-	for ( ; ; )
-	{
-		accept = AcceptClientConnection (listen_fd);
-		accept->jabber_addr = rem_addr;
-		accept->jabber_port = rem_port;
-
-		pthread_create(&accept_thread, NULL, (void *) &VerifyClient, (void *) accept);
-	}
-	pthread_mutex_destroy(&mutexsum);
-	pthread_exit(NULL);
-}
-
-void ClearList(void)
-{
-	struct client * current,
-				  * previous = (struct client *)NULL;
-	int last_action = (int)NULL;
-
-	for ( ; ; )
-	{
-		pthread_mutex_lock(&mutexsum);
-		current = clients;
-		while ( current != (struct client *)NULL )
-		{
-			last_action = time(NULL) - current->last_action;
-			if ( last_action > 10 )
-			{
-				shutdown(current->client_fd, SHUT_RDWR);
-				close(current->client_fd);
-				current->client_fd = (int)NULL;
-			}
-			if ( last_action > 20 )
-			{
-				shutdown(current->jabber_fd, SHUT_RDWR);
-				close(current->jabber_fd);
-				current->jabber_fd = (int)NULL;
-			}
-			if ( last_action > 30 )
-			{
-				if ( current->previous == (struct client *)NULL )
-				{
-					if ( current->next == (struct client *)NULL )
-						clients = (struct client *)NULL;
-					else
-					{
-						clients = current->next;
-						clients->previous = (struct client *)NULL;
-					}
-				}
-				else
-					if ( current->next != (struct client *)NULL )
-					{
-						current->previous->next = current->next;
-						current->next->previous = current->previous;
-					}
-					else
-						current->previous->next = (struct client *)NULL;
-
-				previous = current;
-				current = current->next;
-				free(previous);
-
-			}
-			else
-				current = current->next;
-		}
-		pthread_mutex_unlock(&mutexsum);
-		sleep(2);
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-struct accept * AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
-
-	if ( socklen != sizeof (sa) )
-		syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
-
-	struct accept * new_accept = (struct accept *) malloc(sizeof(struct accept));
-	new_accept->newfd = newfd;
-	new_accept->sa = sa;
-
-	return (new_accept);
-}
-
-void VerifyClient(void * accept)
-{
-	int jabber_fd = (int)NULL;
-	struct accept * client = (struct accept *) accept;
-	struct client * user = (struct client *)NULL;
-	struct cat * info_1,
-			   * info_2;
-	pthread_t client_server_thread,
-			  server_client_thread;
-
-	unsigned int addr = 0;
-	char buf[250];
-	addr = ntohl(client->sa.sin_addr.s_addr);
-	sprintf(buf,"%d.%d.%d.%d",
-			(addr >> 24), (addr >> 16) & 0xFF,
-			(addr >> 8) & 0xFF,  addr & 0xFF);
-	//printf("New connection: %s\n", buf);
-
-	//if ( strcmp(buf, "200.189.113.134") == 0 || strcmp(buf, "200.189.113.135") == 0 )
-	/*if ( strcmp(buf, "127.0.0.1") == 0 )
-	{
-		user = Handshake(&client->newfd);
-		jabber_fd = user->jabber_fd;
-	}*/
-
-	if ( jabber_fd == (int)NULL )
-	{
-		jabber_fd = ConnectToServer(client->jabber_addr, client->jabber_port);
-
-		if ( user != (struct client *)NULL )
-			user->jabber_fd = jabber_fd;
-	}
-
-	info_1 = (struct cat *) malloc(sizeof(struct cat));
-	info_2 = (struct cat *) malloc(sizeof(struct cat));
-
-	info_1->out_fd = jabber_fd;
-	info_1->in_fd = client->newfd;
-	info_1->jabber = (int)NULL;
-	info_1->keep_alive = (int)NULL;
-	info_1->client = user;
-
-	//pthread_create(&client_server_thread, NULL, (void *) &Cat, (void *)info_1 );
-
-	info_2->in_fd = jabber_fd;
-	info_2->out_fd = client->newfd;
-	info_2->jabber = jabber_fd;
-	info_2->keep_alive = (int)NULL;
-	if ( user != (struct client *)NULL )
-		info_2->keep_alive = 1;
-	info_2->client = (struct client *)NULL;
-
-	//pthread_create(&client_server_thread, NULL, (void *) &Cat, (void *)info_2 );
-
-
-	int pid;
-	pid = fork();
-
-	if ( pid == 0 )
-	{
-		int pid_helper;
-		pid_helper = fork();
-		if ( pid_helper == 0 )
-		{
-			Cat(info_1);
-			exit(0);
-		}
-		else
-		{
-			Cat(info_2);
-			wait(0);
-		}
-	}
-
-	pthread_exit(0);
-}
-
-struct client * Handshake(int * newfd)
-{
-	float is_new_client;// = (float) NULL;
-	int bytes_rcvd,
-		bytes_sent,
-		i;
-
-	unsigned char * const buf = (char *) malloc (sizeof(char) * 5);
-	char * user = (char *) malloc(128 * sizeof(char)),
-		 * pass = (char *) malloc(128 * sizeof(char));
-
-	//struct client * clients = (struct client *)NULL;
-	struct client * new_client = (struct client *)NULL;
-
-	bzero(buf, 5);
-	sprintf(buf, "user");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (*newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(user, 128);
-	if ( (bytes_rcvd = recv (*newfd, user, 128, 0)) < 1 )
-		pthread_exit(0);
-
-	bzero(buf, 5);
-	sprintf(buf, "pass");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (*newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(pass, 128);
-	if ( (bytes_rcvd = recv (*newfd, pass, 128, 0)) < 1 )
-		pthread_exit(0);
-
-	pthread_mutex_lock (&mutexsum);
-	if ( clients == (struct client *)NULL )
-	{
-		clients = (struct client *) malloc(sizeof(struct client));
-
-		new_client = clients;
-		new_client->previous = (struct client *)NULL;
-		is_new_client = 1;
-	}
-	else
-	{
-		new_client = clients;
-		while ( ((is_new_client = (float)strcmp(new_client->user, user)) != 0) && (new_client->next != (struct client *)NULL) )
-			new_client = new_client->next;
-
-		if ( is_new_client != 0 )
-		{
-			new_client->next = (struct client *) malloc(sizeof(struct client));
-
-			new_client->next->previous = new_client;
-			new_client = new_client->next;
-		}
-	}
-
-	if ( is_new_client != 0 )
-	{
-		new_client->user = user;
-		new_client->client_fd = (int)NULL;
-		new_client->jabber_fd = (int)NULL;
-		new_client->keep_alive = 1;
-		new_client->next = (struct client *)NULL;
-	}
-	if ( is_new_client != 0 || new_client->jabber_fd == (int)NULL  )
-	{
-		bzero(buf, 5);
-		sprintf(buf, "new");
-		for ( i = 0; i < sizeof(buf); i += bytes_sent )
-		{
-			bytes_sent = send (*newfd, buf + i, sizeof(buf) - i, 0);
-
-			if ( bytes_sent < 0 )
-				break;
-		}
-	}
-	else
-	{
-		bzero(buf, 5);
-		sprintf(buf, "rec");
-		for ( i = 0; i < sizeof(buf); i += bytes_sent )
-		{
-			bytes_sent = send (*newfd, buf + i, sizeof(buf) - i, 0);
-
-			if ( bytes_sent < 0 )
-				break;
-		}
-	}
-	new_client->client_fd = *newfd;
-	new_client->last_action = time(NULL);
-	pthread_mutex_unlock(&mutexsum);
-
-	return new_client;
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO: have a timeout for connect() - see Unix socket FAQ 6.2
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), pthread_exit(0);//exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		//exit (EXIT_FAILURE);
-		pthread_exit(0);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-//void Cat (int in_fd, int out_fd)
-//void Cat (int in_fd, int out_fd)
-void Cat (void * info)
-{
-	unsigned char * const buf = (char *) malloc (sizeof(char) * BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = (int) NULL,
-		i,
-		in_fd,
-		out_fd;
-	struct cat * user = (struct cat *) info;
-	in_fd = user->in_fd;
-	out_fd = user->out_fd;
-
-	syslog (LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		bzero(buf, BUF_SIZE);
-		bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-		/*
-		puts("\n");
-		puts(buf);
-		puts("\n");
-		*/
-
-		for ( i = 0; i < bytes_rcvd; i += bytes_sent )
-		{
-			bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-			if ( bytes_sent < 0 )
-				break;
-		}
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-	if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-		syslog (LOG_ERR, "recv(): %m"), exit (EXIT_FAILURE);
-
-	if ( (bytes_sent < 0) && (errno != EPIPE) )
-		syslog (LOG_ERR, "send(): %m"), exit (EXIT_FAILURE);
-
-	if ( user->jabber && !user->keep_alive )
-	{
-		shutdown(user->jabber, SHUT_RDWR);
-		close(user->jabber);
-	}
-	pthread_exit(0);
-	free (buf);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO: use inet_aton() instead
-	p_inaddr->s_addr = inet_addr (name);
-	if ( p_inaddr->s_addr != -1U ) // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname (name);
-	if ( he != NULL ) // Success
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul (name, &errpos, 0);
-	if ( (*errpos == 0) && (lport <= 65535) ) // Success
-	{
-		*port = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname (name, proto);
-	if ( se != NULL) // Success
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char * fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char * fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char * fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction (signum, &act, NULL) < 0 )
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/server.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/server.h	(revision 216)
+++ 	(revision )
@@ -1,70 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <semaphore.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <pthread.h>
-#include <ctype.h>
-
-
-// Buffer size, in bytes, used for copying in the Cat() function.
-const size_t BUF_SIZE = 4096;
-
-// Global variables
-char g_program_name[100];	// Initialised from argv[0] in ParseArgs()
-
-// structs
-/*struct client
-{
-	unsigned char * user;
-	unsigned char * key;
-	int jabber;
-	int shmid;
-	struct client * next,
-				  * previous;
-};*/
-
-// Typedef for a signal handler function.
-typedef void (* signal_handler_t) (int);
-
-// Prototypes for functions in this file.
-void ParseArgs (int, char **, struct in_addr *, unsigned short *, struct in_addr *, unsigned short *);
-void Initialise (void);
-void sig_child (int);
-int CreateServerSocket (struct in_addr, unsigned short);
-void Daemonise (void);
-void MainLoop (int, struct in_addr, unsigned short);
-void ClearList(void);
-void Proxy (int, int);
-struct accept * AcceptClientConnection (int);
-void VerifyClient(void *);
-struct client * Handshake(int *);
-int ConnectToServer (struct in_addr, unsigned short);
-//void Cat (int, int);
-void Cat (void *);
-int NameToAddr (const char *, struct in_addr *);
-int NameToPort (const char *, unsigned short *, const char *);
-#ifdef __GNUC__
-	void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *, ...);
-	void pbomb (const char *, ...);
-	void hbomb (const char *, ...);
-#endif
-void set_signal_handler (int, signal_handler_t);
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/client.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/client.c	(revision 216)
+++ 	(revision )
@@ -1,102 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-//#define IP "127.0.0.1"
-//#define IP "127.0.0.1"
-#define IP "10.15.20.42"
-//#define IP "10.15.20.202"
-
-#define PORT "8888"
-
-int main(void)
-{
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-	int err,
-		i,
-		unit;
-	char buff[4096];
-	char * _xml = (char)NULL,
-		 //* xml_connect = {"fromBrowser"};
-		 * xml_connect = {"<?xml version='1.0' encoding='UTF-8'?><stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"};
-
-	_xml = (char *) malloc(sizeof(buff));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	//socketaddr.sin_addr.s_addr = INADDR_ANY;//inet_addr(IP);
-	socketaddr.sin_addr.s_addr = inet_addr(IP);
-	//socketaddr.sin_addr.s_addr = inet_addr("10.15.20.42");
-	//inet_aton(IP, &socketaddr.sin_addr);
-	socketaddr.sin_port = htons(nHostPort);
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	struct hostent *hp;
-	hp = gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET);
-
-	//printf("\n\n%s\n\n", inet_ntoa(socketaddr.sin_addr));
-	//printf("\n\n%d\n\n", inet_network("expresso.pr.gov.br"));
-
-	//printf("\n\n%d\n\n", socketaddr.sin_addr.s_addr);
-	//printf("\n\n%s\n\n", gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET));
-
-
-	//sprintf(_xml, xml_connect, IP);
-	//_xml[strlen(_xml)] = '\0';
-	//++_xml;
-	//*_xml = '\0';
-	//puts(_xml);
-
-	//bzero(_xml, sizeof(buff));
-	//sprintf(_xml, "from_browser");
-	//write(socketfd, _xml, strlen(_xml));
-
-	bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "user@domine");
-	write(socketfd, _xml, strlen(_xml));
-
-	bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "password");
-	write(socketfd, _xml, strlen(_xml));
-
-	/*bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);*/
-
-	//sleep(10);
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/server_thread.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/server_thread.c	(revision 216)
+++ 	(revision )
@@ -1,614 +1,0 @@
-#include "server.h"
-
-struct accept
-{
-	int newfd;
-	struct sockaddr_in sa;
-	struct in_addr jabber_addr;
-	unsigned short jabber_port;
-};
-
-struct client
-{
-	char * user;
-	int client_fd;
-	int jabber_fd;
-	int keep_alive;
-	time_t last_action;
-	struct client * next;
-};
-
-struct cat
-{
-	int in_fd,
-		out_fd;
-	int jabber,
-		keep_alive;
-	struct client * client;
-};
-
-struct client * clients = (struct client *)NULL;
-
-pthread_mutex_t mutexsum;
-
-int main (int argc, char ** argv)
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise ();
-
-	// Create server socket before becoming a daemon so
-	// there is still a chance to print an error message.
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb ("Unable to create server socket");
-
-	//Daemonise ();
-
-	MainLoop (listen_fd, remote_addr, remote_port); // never returns
-
-	exit (EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char ** argv, struct in_addr * ra, unsigned short * rp, struct in_addr * la, unsigned short * lp)
-{
-	// argv[0] = program name
-	// argv[1] = remote_addr
-	// argv[2] = remote_port
-	// argv[3] = local_addr (optional)
-	// argv[4] = local_port (optional)
-
-	char * p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr (argv[1], ra) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort (argv[2], rp, "tcp") )
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl (INADDR_ANY);
-	else
-		if ( NameToAddr (argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy (lp, rp, sizeof (*lp));
-	else
-		if ( NameToPort (argv[4], lp, "tcp") )
-			quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	//set_signal_handler (SIGCHLD, sig_child);
-
-	//signal (SIGPIPE, SIG_IGN);
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	//sa.sin_addr = addr;
-	sa.sin_addr.s_addr = htonl(INADDR_ANY);
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if ( err < 0 )
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	struct accept * accept;
-	pthread_t accept_thread,
-			  clear_list_thread;
-
-	pthread_mutex_init(&mutexsum, NULL);
-
-	pthread_create(&clear_list_thread, NULL, (void *) &ClearList, (void *)NULL );
-
-	for ( ; ; )
-	{
-		accept = AcceptClientConnection (listen_fd);
-		accept->jabber_addr = rem_addr;
-		accept->jabber_port = rem_port;
-
-		pthread_create(&accept_thread, NULL, (void *) &VerifyClient, (void *) accept);
-	}
-	pthread_mutex_destroy(&mutexsum);
-	pthread_exit(NULL);
-}
-
-void ClearList(void)
-{
-	struct client * current;
-
-	for ( ; ; )
-	{
-		current = clients;
-		pthread_mutex_lock(&mutexsum);
-		while ( current != (struct client *)NULL )
-		{
-			if ( time(NULL) - current->last_action > 30 )
-			{
-				shutdown(current->jabber_fd, SHUT_RDWR);
-				close(current->jabber_fd);
-				current->jabber_fd = (int)NULL;
-			}
-			current = current->next;
-		}
-		pthread_mutex_unlock(&mutexsum);
-		sleep(2);
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-struct accept * AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
-
-	if ( socklen != sizeof (sa) )
-		syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
-
-	struct accept * new_accept = (struct accept *) malloc(sizeof(struct accept));
-	new_accept->newfd = newfd;
-	new_accept->sa = sa;
-
-	return (new_accept);
-}
-
-void VerifyClient(void * accept)
-{
-	int jabber_fd = (int)NULL;
-	struct accept * client = (struct accept *) accept;
-	struct client * user = (struct client *)NULL;
-	struct cat * info_1,
-			   * info_2;
-	pthread_t client_server_thread,
-			  server_client_thread;
-
-	unsigned int addr = 0;
-	char buf[250];
-	addr = ntohl(client->sa.sin_addr.s_addr);
-	sprintf(buf,"%d.%d.%d.%d",
-			(addr >> 24)  , (addr >> 16) & 0xFF ,
-			(addr >> 8) & 0xFF ,  addr & 0xFF);
-	//printf("New connection: %s\n", buf);
-
-	if ( strcmp(buf, "10.15.20.202") == 0 )
-	{
-		user = Handshake(client->newfd);
-		jabber_fd = user->jabber_fd;
-	}
-
-	if ( jabber_fd == (int)NULL )
-	{
-		jabber_fd = ConnectToServer(client->jabber_addr, client->jabber_port);
-
-		if ( user != (struct client *)NULL )
-			user->jabber_fd = jabber_fd;
-	}
-
-	info_1 = (struct cat *) malloc(sizeof(struct cat));
-	info_2 = (struct cat *) malloc(sizeof(struct cat));
-
-	info_1->out_fd = jabber_fd;
-	info_1->in_fd = client->newfd;
-	info_1->jabber = (int)NULL;
-	info_1->keep_alive = (int)NULL;
-	info_1->client = user;
-
-	pthread_create(&client_server_thread, NULL, (void *) &Cat, (void *)info_1 );
-
-	info_2->in_fd = jabber_fd;
-	info_2->out_fd = client->newfd;
-	info_2->jabber = jabber_fd;
-	info_2->keep_alive = (int)NULL;
-	if ( user != (struct client *)NULL )
-		info_2->keep_alive = 1;
-	info_2->client = (struct client *)NULL;
-
-	pthread_create(&client_server_thread, NULL, (void *) &Cat, (void *)info_2 );
-
-	pthread_exit(0);
-}
-
-struct client * Handshake(int newfd)
-{
-	float is_new_client;// = (float) NULL;
-	int bytes_rcvd,
-		bytes_sent,
-		i;
-
-	unsigned char * const buf = (char *) malloc (sizeof(char) * 5);
-	char * user = (char *) malloc(128 * sizeof(char)),
-		 * pass = (char *) malloc(128 * sizeof(char));
-
-	//struct client * clients = (struct client *)NULL;
-	struct client * new_client = (struct client *)NULL;
-
-	bzero(buf, 5);
-	sprintf(buf, "user");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(user, 128);
-	if ( (bytes_rcvd = recv (newfd, user, 128, 0)) < 1 )
-		pthread_exit(0);
-
-	bzero(buf, 5);
-	sprintf(buf, "pass");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(pass, 128);
-	if ( (bytes_rcvd = recv (newfd, pass, 128, 0)) < 1 )
-		pthread_exit(0);
-
-	pthread_mutex_lock (&mutexsum);
-	if ( clients == (struct client *)NULL )
-	{
-		clients = (struct client *) malloc(sizeof(struct client));
-
-		new_client = clients;
-		is_new_client = 1;
-	}
-	else
-	{
-		new_client = clients;
-		while ( ((is_new_client = (float)strcmp(new_client->user, user)) != 0) && (new_client->next != (struct client *)NULL) )
-			new_client = new_client->next;
-
-		if ( is_new_client != 0 )
-		{
-			new_client->next = (struct client *) malloc(sizeof(struct client));
-			new_client = new_client->next;
-		}
-	}
-
-	if ( is_new_client != 0 )
-	{
-		new_client->user = user;
-		new_client->jabber_fd = (int)NULL;
-		new_client->keep_alive = 1;
-		new_client->next = (struct client *)NULL;
-	}
-	new_client->client_fd = newfd;
-	new_client->last_action = time(NULL);
-	pthread_mutex_unlock(&mutexsum);
-
-	return new_client;
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO: have a timeout for connect() - see Unix socket FAQ 6.2
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), pthread_exit(0);//exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		//exit (EXIT_FAILURE);
-		pthread_exit(0);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-//void Cat (int in_fd, int out_fd)
-//void Cat (int in_fd, int out_fd)
-void Cat (void * info)
-{
-	unsigned char * const buf = (char *) malloc (sizeof(char) * BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = (int) NULL,
-		i,
-		in_fd,
-		out_fd;
-	struct cat * user = (struct cat *) info;
-	in_fd = user->in_fd;
-	out_fd = user->out_fd;
-
-	syslog (LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		bzero(buf, BUF_SIZE);
-		bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-		for ( i = 0; i < bytes_rcvd; i += bytes_sent )
-		{
-			bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-			if ( bytes_sent < 0 )
-				break;
-		}
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-	if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-		syslog (LOG_ERR, "recv(): %m"), exit (EXIT_FAILURE);
-
-	if ( (bytes_sent < 0) && (errno != EPIPE) )
-		syslog (LOG_ERR, "send(): %m"), exit (EXIT_FAILURE);
-
-	if ( user->jabber && !user->keep_alive )
-	{
-		shutdown(user->jabber, SHUT_RDWR);
-		close(user->jabber);
-	}
-	pthread_exit(0);
-	free (buf);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO: use inet_aton() instead
-	p_inaddr->s_addr = inet_addr (name);
-	if ( p_inaddr->s_addr != -1U ) // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname (name);
-	if ( he != NULL ) // Success
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul (name, &errpos, 0);
-	if ( (*errpos == 0) && (lport <= 65535) ) // Success
-	{
-		*port = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname (name, proto);
-	if ( se != NULL) // Success
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char * fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char * fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char * fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction (signum, &act, NULL) < 0 )
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/server_bkp.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/server_bkp.c	(revision 216)
+++ 	(revision )
@@ -1,707 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <stdarg.h>
-#include <syslog.h>
-
-//#include <iostream>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <semaphore.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-
-// Buffer size, in bytes, used for copying in the Cat() function.
-const size_t BUF_SIZE = 10240;
-
-// Typedef for a signal handler function.
-typedef void (*signal_handler_t) (int);
-
-// Prototypes for functions in this file.
-void ParseArgs (int, char **, struct in_addr *, unsigned short *, struct in_addr *, unsigned short *);
-void Initialise (void);
-void sig_child (int);
-int CreateServerSocket (struct in_addr, unsigned short);
-void Daemonise (void);
-void MainLoop (int, struct in_addr, unsigned short);
-void Proxy (int, int);
-int AcceptClientConnection (int);
-int ConnectToServer (struct in_addr, unsigned short);
-void Cat (int, int);
-int NameToAddr (const char *, struct in_addr *);
-int NameToPort (const char *, unsigned short *, const char *);
-#ifdef __GNUC__
-	void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *, ...);
-	void pbomb (const char *, ...);
-	void hbomb (const char *, ...);
-#endif
-void set_signal_handler (int, signal_handler_t);
-
-// Global variables
-char g_program_name[100]; // Initialised from argv[0] in ParseArgs()
-
-struct accept
-{
-	int newfd;
-	struct sockaddr_in sa;
-	struct in_addr jabber_addr;
-	unsigned short jabber_port;
-};
-
-int main (int argc, char *argv[])
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs(argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise();
-
-	// Create server socket before becoming
-	// a daemon so there is still a chance
-	// to print an error message.
-
-	listen_fd = CreateServerSocket(local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb("Unable to create server socket");
-
-	Daemonise();
-
-	MainLoop(listen_fd, remote_addr, remote_port); // never returns
-
-	exit(EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char *argv[], struct in_addr *ra, unsigned short *rp, struct in_addr *la, unsigned short *lp)
-{
-	 // argv[0] = program name
-	 // argv[1] = remote_addr
-	 // argv[2] = remote_port
-	 // argv[3] = local_addr (optional)
-	 // argv[4] = local_port (optional)
-
-	char * p = strrchr(argv[0], '/');
-
-	strncpy(g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof(g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr(argv[1], ra) )
-		hbomb("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort(argv[2], rp, "tcp") )
-		quit("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl(INADDR_ANY);
-	else
-		if ( NameToAddr(argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy(lp, rp, sizeof(*lp));
-	else
-		if ( NameToPort(argv[4], lp, "tcp") )
-			quit("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog(g_program_name, LOG_PID, LOG_USER);
-	syslog(LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	set_signal_handler(SIGCHLD, sig_child);
-
-	signal(SIGPIPE, SIG_IGN);
-}
-
-// sig_child()
-// Handles SIGCHLD from exiting child processes.
-void sig_child (int signo)
-{
-	pid_t pid = 1;
-
-	(void) signo; // suppress compiler warning
-
-	while ( pid > 0 )
-	{
-		pid = waitpid(WAIT_ANY, NULL, WNOHANG);
-
-		if ( pid > 0 )
-			syslog(LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		//else
-		//	break;
-	}
-
-	if ( (pid < 0) && (errno != ECHILD) )
-		syslog(LOG_ERR, "waitpid(): %m"), exit(EXIT_FAILURE);
-
-	return;
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog(LOG_ERR, "socket(): %m"), exit(EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0 )
-		syslog(LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons(port);
-	sa.sin_addr = addr;
-	memset(sa.sin_zero, 0, sizeof(sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind(fd, (struct sockaddr *) &sa, sizeof(sa));
-	if ( err < 0 )
-	{
-		syslog(LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog(LOG_ERR, "listen(): %m"), exit(EXIT_FAILURE);
-
-	return fd;
-}
-
-// Daemonise()
-// Put the program in the background, set
-// PPID=1, create a new session and process
-// group, without a controlling tty.
-void Daemonise (void)
-{
-	pid_t pid;
-
-	// Close stdin, stdout & stderr
-	// TODO:
-	// open /dev/null and dup the fd to stdin, stdout & stderr
-	// close(STDIN_FILENO);
-	// close(STDOUT_FILENO);
-	// close(STDERR_FILENO);
-
-	syslog (LOG_INFO, "%s daemonising", g_program_name);
-
-	// Fork the process to put it in the background.
-
-	pid = fork();
-	if ( pid == -1 )
-		syslog (LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-	// parent terminates here, so shell thinks the command is done.
-	if ( pid )
-		exit(0);
-
-	syslog(LOG_INFO, "%s in background", g_program_name);
-
-	// 1st child continues to run in the background with PPID=1
-
-	// Become leader of a new session and a new process group,
-	// with no controlling tty.
-	setsid();
-
-	// Fork again to guarantee the process will not be able
-	// to aquire a controlling tty.
-
-	// signal (SIGHUP, SIG_IGN); // required according to Stevens' UNP2 p333
-
-	pid = fork();
-	if ( pid == -1 )
-		syslog(LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-	if ( pid ) // 1st child terminates
-		exit(0);
-
-	// 2nd child continues, no longer a session or group leader
-
-	syslog(LOG_INFO, "%s daemonised", g_program_name);
-}
-
-struct shared {
-	sem_t mutex;
-	int count;
-	char * teste;//[10];
-} shared;
-
-void teste(void)
-{
-	puts("TESTE REFERENCIA DE FUNCAO\n\n");
-}
-
-void share_memory(void (* func)(void), ...)
-{
-	static int fd = (int)NULL;
-	int i,
-		nloop = 10;
-	static struct shared *ptr;
-	va_list ap;
-
-	if ( fd == (int)NULL )
-	{
-		if ( (fd = open("data.txt", O_RDWR | O_CREAT, 0660)) == -1 )
-			fprintf(stderr,"error opening file\n");
-		write(fd, &shared, sizeof(struct shared));
-		ptr = (struct shared *) mmap(NULL, sizeof(struct shared), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-		close(fd);
-
-		if ( sem_init(&ptr->mutex, 1, 1) != 0 )
-			fprintf(stderr,"sem_init error"), exit(-2);
-	}
-
-	setbuf(stdout, NULL);
-
-	sem_wait(&ptr->mutex);
-	printf("current value: %d\n", ptr->count++);
-	//va_start(func, ap);
-	//func(ap);
-	//va_end(ap);
-	sem_post(&ptr->mutex);
-}
-/*
-struct cli
-{
-	char user[100];
-};
-
-struct shared
-{
-	int count;
-	sem_t mutex;
-	struct cli clients[100];
-} shared;
-
-void teste(void)
-{
-	puts("TESTE REFERENCIA DE FUNCAO\n\n");
-}
-
-#define SHARED_MEMORY "/tmp/user_%04d.txt"
-
-void share_memory(void (* func)(void), ...)
-{
-	static struct shared * ptr = (struct shared *)NULL;
-	int fd = (int)NULL,
-		i = (int)NULL;
-	va_list ap;
-	char file_name[15];
-
-	setbuf(stdout, NULL);
-
-	bzero(file_name, 15);
-
-	if ( ptr == (struct shared *)NULL )
-	{
-		sprintf(file_name, SHARED_MEMORY, i++);
-
-		if ( (fd = open(file_name, O_RDWR | O_CREAT, 0660)) == -1 )
-			fprintf(stderr,"error opening file for sharing memory\n");
-		write(fd, &shared, sizeof(struct shared));
-		ptr = (struct shared *) mmap(NULL, sizeof(struct shared), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-		close(fd);
-
-		if ( sem_init(&ptr->mutex, 1, 1) != 0 )
-			fprintf(stderr,"sem_init error"), exit(-2);
-
-		ptr->count = (int)NULL;
-	}
-	sem_wait(&ptr->mutex);
-
-	//ptr->count++;
-	//bzero(ptr->clients[ptr->count].user, 100);
-	//sprintf(ptr->clients[ptr->count].user, "teste - %d", i);
-
-	//for ( i = 0; i <= ptr->count; i++)
-	//	printf("%d: %s\n", i, ptr->clients[i].user);
-
-
-	//va_start(func, ap);
-	//func(ap);
-	//va_end(ap);
-	sem_post(&ptr->mutex);
-}
-*/
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	int server_fd,
-		client_fd;
-	pid_t child_pid;
-
-	for ( ; ; )
-	{
-		client_fd = AcceptClientConnection (listen_fd);
-		share_memory(teste);
-
-		child_pid = fork();
-		if ( child_pid == -1 )
-			syslog(LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-		if ( child_pid ) // parent
-		{
-			close(client_fd);
-
-			syslog(LOG_INFO, "Forked child pid %d to deal with client", child_pid);
-		}
-		else // child
-		{
-			close(listen_fd);
-
-			server_fd = ConnectToServer(rem_addr, rem_port);
-
-			Proxy(server_fd, client_fd);
-
-			syslog(LOG_INFO, "exiting");
-			_exit(0);
-		}
-	}
-}
-
-// Proxy()
-// Copies data between server_fd and client_fd
-// in both directions until one or other peer
-// closes their connection.
-void Proxy (int server_fd, int client_fd)
-{
-	pid_t helper_pid;
-
-	syslog(LOG_INFO, "Proxy(fd%d, fd%d)", server_fd, client_fd);
-
-	signal(SIGCHLD, SIG_IGN);
-
-	helper_pid = fork();
-	if ( helper_pid == -1 )
-		syslog(LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-	if ( helper_pid ) // parent
-	{
-		syslog(LOG_INFO, "Forked child pid %d to help with proxying", helper_pid);
-
-		Cat(server_fd, client_fd);
-
-		shutdown(client_fd, 1);
-		close(server_fd);
-		close(client_fd);
-
-		wait(0); // wait for helper to exit
-	}
-	else // child (helper)
-	{
-		Cat(client_fd, server_fd);
-
-		shutdown(server_fd, 1);
-
-		syslog(LOG_INFO, "exiting");
-		exit(0); // helper exits here
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-int AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog(LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof(sa);
-	memset(&sa, 0, socklen);
-	do
-	{
-		newfd = accept(listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog(LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog(LOG_ERR, "accept(): %m"), exit(EXIT_FAILURE);
-
-	if ( socklen != sizeof(sa) )
-		syslog(LOG_ERR, "accept() screwed up!"), exit(EXIT_FAILURE);
-
-	return newfd;
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO:
-	// have a timeout for connect()
-	// see Unix socket FAQ 6.2
-
-	int fd,
-		err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog(LOG_ERR, "socket(): %m"), exit(EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons(port);
-	sa.sin_addr = addr;
-	memset(sa.sin_zero, 0, sizeof(sa.sin_zero));
-
-	err = connect(fd, (struct sockaddr *) &sa, sizeof(sa));
-	if ( err < 0 )
-	{
-		syslog(LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		exit(EXIT_FAILURE);
-	}
-
-	syslog(LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-void Cat (int in_fd, int out_fd)
-{
-	unsigned char * const buf = malloc(BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = 0,
-		i;
-
-	syslog(LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf == NULL )
-		syslog(LOG_ERR, "malloc(): %m"), exit(EXIT_FAILURE);
-
-	do
-	{
-		bytes_rcvd = recv(in_fd, buf, BUF_SIZE, 0);
-
-		for ( i = 0; i < bytes_rcvd || bytes_sent < 0; i += bytes_sent )
-		{
-			bytes_sent = send(out_fd, buf + i, bytes_rcvd - i, 0);
-
-			//if ( bytes_sent < 0 )
-			//	break;
-		}
-
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-	if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-		syslog(LOG_ERR, "recv(): %m"), exit(EXIT_FAILURE);
-
-	if ( (bytes_sent < 0) && (errno != EPIPE) )
-		syslog(LOG_ERR, "send(): %m"), exit(EXIT_FAILURE);
-
-	free(buf);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO:
-	// use inet_aton() instead
-	p_inaddr->s_addr = inet_addr(name);
-	if ( p_inaddr->s_addr != -1U )  // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname(name);
-	if ( he != NULL ) // Success
-	{
-		memcpy(p_inaddr, he->h_addr, sizeof(struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul(name, &errpos, 0);
-	if ( (*(errpos) == 0) && (lport <= 65535) ) // Success
-	{
-		*(port) = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname(name, proto);
-	if ( se != NULL ) // Success
-	{
-		*(port) = ntohs(se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char *fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush(stdout);
-
-	fprintf(stderr, "%s: ", g_program_name);
-
-	va_start(ap, fmt);
-	vfprintf(stderr, fmt, ap);
-	va_end(ap);
-
-	fputc('\n', stderr);
-
-	syslog(LOG_ERR, "I quit!");
-
-	exit(EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char *fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush(stdout);
-
-	fprintf(stderr, "%s: ", g_program_name);
-
-	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
-	va_end(ap);
-
-	errno = errno_save;
-	perror(buf);
-
-	syslog(LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit(EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char *fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
-	va_end(ap);
-
-	h_errno = h_errno_save;
-	herror(buf);
-
-	syslog(LOG_ERR, "Bang!: %s: %s", buf, hstrerror(h_errno));
-
-	exit(EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction(signum, &act, NULL) < 0 )
-	{
-		syslog(LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit(EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/server.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/server.c	(revision 216)
+++ 	(revision )
@@ -1,730 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <stdarg.h>
-#include <syslog.h>
-
-//#include <iostream>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <semaphore.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-
-// Buffer size, in bytes, used for copying in the Cat() function.
-const size_t BUF_SIZE = 10240;
-
-// Typedef for a signal handler function.
-typedef void (*signal_handler_t) (int);
-
-// Prototypes for functions in this file.
-void ParseArgs (int, char **, struct in_addr *, unsigned short *, struct in_addr *, unsigned short *);
-void Initialise (void);
-void sig_child (int);
-int CreateServerSocket (struct in_addr, unsigned short);
-void Daemonise (void);
-void MainLoop (int, struct in_addr, unsigned short);
-void Proxy (int, int);
-int AcceptClientConnection (int);
-int ConnectToServer (struct in_addr, unsigned short);
-void Cat (int, int);
-int NameToAddr (const char *, struct in_addr *);
-int NameToPort (const char *, unsigned short *, const char *);
-#ifdef __GNUC__
-	void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *, ...);
-	void pbomb (const char *, ...);
-	void hbomb (const char *, ...);
-#endif
-void set_signal_handler (int, signal_handler_t);
-
-// Global variables
-char g_program_name[100]; // Initialised from argv[0] in ParseArgs()
-
-struct accept
-{
-	int newfd;
-	struct sockaddr_in sa;
-	struct in_addr jabber_addr;
-	unsigned short jabber_port;
-};
-
-int main (int argc, char *argv[])
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs(argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise();
-
-	// Create server socket before becoming
-	// a daemon so there is still a chance
-	// to print an error message.
-
-	listen_fd = CreateServerSocket(local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb("Unable to create server socket");
-
-	Daemonise();
-
-	MainLoop(listen_fd, remote_addr, remote_port); // never returns
-
-	exit(EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char *argv[], struct in_addr *ra, unsigned short *rp, struct in_addr *la, unsigned short *lp)
-{
-	 // argv[0] = program name
-	 // argv[1] = remote_addr
-	 // argv[2] = remote_port
-	 // argv[3] = local_addr (optional)
-	 // argv[4] = local_port (optional)
-
-	char * p = strrchr(argv[0], '/');
-
-	strncpy(g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof(g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr(argv[1], ra) )
-		hbomb("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort(argv[2], rp, "tcp") )
-		quit("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl(INADDR_ANY);
-	else
-		if ( NameToAddr(argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy(lp, rp, sizeof(*lp));
-	else
-		if ( NameToPort(argv[4], lp, "tcp") )
-			quit("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog(g_program_name, LOG_PID, LOG_USER);
-	syslog(LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	set_signal_handler(SIGCHLD, sig_child);
-
-	signal(SIGPIPE, SIG_IGN);
-}
-
-// sig_child()
-// Handles SIGCHLD from exiting child processes.
-void sig_child (int signo)
-{
-	pid_t pid = 1;
-
-	(void) signo; // suppress compiler warning
-
-	while ( pid > 0 )
-	{
-		pid = waitpid(WAIT_ANY, NULL, WNOHANG);
-
-		if ( pid > 0 )
-			syslog(LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		//else
-		//	break;
-	}
-
-	if ( (pid < 0) && (errno != ECHILD) )
-		syslog(LOG_ERR, "waitpid(): %m"), exit(EXIT_FAILURE);
-
-	return;
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog(LOG_ERR, "socket(): %m"), exit(EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0 )
-		syslog(LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons(port);
-	sa.sin_addr = addr;
-	memset(sa.sin_zero, 0, sizeof(sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind(fd, (struct sockaddr *) &sa, sizeof(sa));
-	if ( err < 0 )
-	{
-		syslog(LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog(LOG_ERR, "listen(): %m"), exit(EXIT_FAILURE);
-
-	return fd;
-}
-
-// Daemonise()
-// Put the program in the background, set
-// PPID=1, create a new session and process
-// group, without a controlling tty.
-void Daemonise (void)
-{
-	pid_t pid;
-
-	// Close stdin, stdout & stderr
-	// TODO:
-	// open /dev/null and dup the fd to stdin, stdout & stderr
-	// close(STDIN_FILENO);
-	// close(STDOUT_FILENO);
-	// close(STDERR_FILENO);
-
-	syslog (LOG_INFO, "%s daemonising", g_program_name);
-
-	// Fork the process to put it in the background.
-
-	pid = fork();
-	if ( pid == -1 )
-		syslog (LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-	// parent terminates here, so shell thinks the command is done.
-	if ( pid )
-		exit(0);
-
-	syslog(LOG_INFO, "%s in background", g_program_name);
-
-	// 1st child continues to run in the background with PPID=1
-
-	// Become leader of a new session and a new process group,
-	// with no controlling tty.
-	setsid();
-
-	// Fork again to guarantee the process will not be able
-	// to aquire a controlling tty.
-
-	// signal (SIGHUP, SIG_IGN); // required according to Stevens' UNP2 p333
-
-	pid = fork();
-	if ( pid == -1 )
-		syslog(LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-	if ( pid ) // 1st child terminates
-		exit(0);
-
-	// 2nd child continues, no longer a session or group leader
-
-	syslog(LOG_INFO, "%s daemonised", g_program_name);
-}
-
-struct cli
-{
-	char user[100];
-};
-
-struct client
-{
-	char user[100];
-	struct client * next;
-} client;
-
-struct shared {
-	sem_t mutex;
-	int count;
-	//struct cli clients[100];
-	struct client * clients;
-} shared;
-
-void teste(struct client * current)
-{
-	while ( current != (struct client *)NULL )
-	{
-		printf("%s...\n", current->user);
-		current = current->next;
-	}
-	//puts("\nFIM FUNCAO TEST\n\n");
-}
-
-void share_memory(void (* func)(struct client *))
-{
-	static struct shared * ptr = (struct shared *)NULL;
-	int fd = (int)NULL;
-	struct client * new,
-				  * current;
-
-	if ( ptr == (struct shared *)NULL )
-	{
-		if ( (fd = open("/tmp/data.txt", O_RDWR | O_CREAT, 0660)) == -1 )
-			fprintf(stderr,"error opening file\n");
-
-		write(fd, &shared, sizeof(struct shared));
-		ptr = (struct shared *) mmap(NULL, sizeof(struct shared), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-		close(fd);
-
-		fd = (int)NULL;
-
-		if ( sem_init(&ptr->mutex, 1, 1) != 0 )
-			fprintf(stderr,"sem_init error"), exit(-2);
-
-		ptr->count = 0;
-		ptr->clients = (struct client *)NULL;
-	}
-
-	// begin mutex
-	sem_wait(&ptr->mutex);
-
-	if ( ptr->clients == (struct client *)NULL )
-	{
-		if ( (fd = open("/tmp/clients.txt", O_RDWR | O_CREAT, 0660)) == -1 )
-			fprintf(stderr,"error opening file\n");
-		write(fd, &client, sizeof(struct client));
-		ptr->clients= (struct client *) mmap(NULL, 10 * sizeof(struct client), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-		close(fd);
-
-		fd = (int)NULL;
-
-		current = ptr->clients;
-		current->next = (struct client *)NULL;
-	}
-	else
-	{
-		/*
-		current = ptr->clients;
-		if ( current->next == (struct client *)NULL )
-		{
-			if ( (fd = open("clients.txt", O_RDWR | O_APPEND | O_CREAT, 0660)) == -1 )
-				fprintf(stderr,"error opening file\n");
-
-			puts("write");
-			write(fd, &client, sizeof(struct client));
-			puts("mmap");
-			current->next = (struct client *) mmap(NULL, sizeof(struct client), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-			puts("close");
-			close(fd);
-
-			puts("ATRIBUINDO NULL");
-			current->next->next = (struct client *)NULL;
-			puts("CURRENT = CURRENT->NEXT");
-			current = current->next;
-			puts("__");
-		}
-		else
-		{
-			puts("\nINICIADA\n");
-		}*/
-
-		current = ptr->clients;
-		while ( current->next != (struct client *)NULL )
-			current = current->next;
-
-		/*if ( (fd = open("clients.txt", O_RDWR | O_APPEND | O_CREAT, 0660)) == -1 )
-			fprintf(stderr,"error opening file\n");
-		write(fd, &client, sizeof(struct client));
-		new = / *(struct client *)* / mmap(NULL, sizeof(struct client), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-		//current->next = (struct client *) mmap(NULL, sizeof(struct client), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-		close(fd);*/
-
-		current = current->next = new;
-		current->next = (struct client *)NULL;
-	}
-
-	puts("\nWORKING\n\n");
-
-	setbuf(stdout, NULL);
-
-	printf("current value: %d\n", ptr->count);
-	bzero(current->user, 100);
-	sprintf(current->user, "teste - %d", ptr->count);
-
-	func(ptr->first);
-
-	ptr->count++;
-
-	// end mutex
-	sem_post(&ptr->mutex);
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	int server_fd,
-		client_fd;
-	pid_t child_pid;
-
-	for ( ; ; )
-	{
-		client_fd = AcceptClientConnection (listen_fd);
-		share_memory(teste);
-
-		child_pid = fork();
-		if ( child_pid == -1 )
-			syslog(LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-		if ( child_pid ) // parent
-		{
-			close(client_fd);
-
-			syslog(LOG_INFO, "Forked child pid %d to deal with client", child_pid);
-		}
-		else // child
-		{
-			close(listen_fd);
-
-			server_fd = ConnectToServer(rem_addr, rem_port);
-
-			Proxy(server_fd, client_fd);
-
-			syslog(LOG_INFO, "exiting");
-			_exit(0);
-		}
-	}
-}
-
-// Proxy()
-// Copies data between server_fd and client_fd
-// in both directions until one or other peer
-// closes their connection.
-void Proxy (int server_fd, int client_fd)
-{
-	pid_t helper_pid;
-
-	syslog(LOG_INFO, "Proxy(fd%d, fd%d)", server_fd, client_fd);
-
-	signal(SIGCHLD, SIG_IGN);
-
-	helper_pid = fork();
-	if ( helper_pid == -1 )
-		syslog(LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-	if ( helper_pid ) // parent
-	{
-		syslog(LOG_INFO, "Forked child pid %d to help with proxying", helper_pid);
-
-		Cat(server_fd, client_fd);
-
-		shutdown(client_fd, 1);
-		close(server_fd);
-		close(client_fd);
-
-		wait(0); // wait for helper to exit
-	}
-	else // child (helper)
-	{
-		Cat(client_fd, server_fd);
-
-		shutdown(server_fd, 1);
-
-		syslog(LOG_INFO, "exiting");
-		exit(0); // helper exits here
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-int AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog(LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof(sa);
-	memset(&sa, 0, socklen);
-	do
-	{
-		newfd = accept(listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog(LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog(LOG_ERR, "accept(): %m"), exit(EXIT_FAILURE);
-
-	if ( socklen != sizeof(sa) )
-		syslog(LOG_ERR, "accept() screwed up!"), exit(EXIT_FAILURE);
-
-	return newfd;
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO:
-	// have a timeout for connect()
-	// see Unix socket FAQ 6.2
-
-	int fd,
-		err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog(LOG_ERR, "socket(): %m"), exit(EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons(port);
-	sa.sin_addr = addr;
-	memset(sa.sin_zero, 0, sizeof(sa.sin_zero));
-
-	err = connect(fd, (struct sockaddr *) &sa, sizeof(sa));
-	if ( err < 0 )
-	{
-		syslog(LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		exit(EXIT_FAILURE);
-	}
-
-	syslog(LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-void Cat (int in_fd, int out_fd)
-{
-	unsigned char * const buf = malloc(BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = 0,
-		i;
-
-	syslog(LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf == NULL )
-		syslog(LOG_ERR, "malloc(): %m"), exit(EXIT_FAILURE);
-
-	do
-	{
-		bytes_rcvd = recv(in_fd, buf, BUF_SIZE, 0);
-
-		for ( i = 0; i < bytes_rcvd || bytes_sent < 0; i += bytes_sent )
-		{
-			bytes_sent = send(out_fd, buf + i, bytes_rcvd - i, 0);
-
-			//if ( bytes_sent < 0 )
-			//	break;
-		}
-
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-	if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-		syslog(LOG_ERR, "recv(): %m"), exit(EXIT_FAILURE);
-
-	if ( (bytes_sent < 0) && (errno != EPIPE) )
-		syslog(LOG_ERR, "send(): %m"), exit(EXIT_FAILURE);
-
-	free(buf);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO:
-	// use inet_aton() instead
-	p_inaddr->s_addr = inet_addr(name);
-	if ( p_inaddr->s_addr != -1U )  // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname(name);
-	if ( he != NULL ) // Success
-	{
-		memcpy(p_inaddr, he->h_addr, sizeof(struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul(name, &errpos, 0);
-	if ( (*(errpos) == 0) && (lport <= 65535) ) // Success
-	{
-		*(port) = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname(name, proto);
-	if ( se != NULL ) // Success
-	{
-		*(port) = ntohs(se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char *fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush(stdout);
-
-	fprintf(stderr, "%s: ", g_program_name);
-
-	va_start(ap, fmt);
-	vfprintf(stderr, fmt, ap);
-	va_end(ap);
-
-	fputc('\n', stderr);
-
-	syslog(LOG_ERR, "I quit!");
-
-	exit(EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char *fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush(stdout);
-
-	fprintf(stderr, "%s: ", g_program_name);
-
-	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
-	va_end(ap);
-
-	errno = errno_save;
-	perror(buf);
-
-	syslog(LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit(EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char *fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
-	va_end(ap);
-
-	h_errno = h_errno_save;
-	herror(buf);
-
-	syslog(LOG_ERR, "Bang!: %s: %s", buf, hstrerror(h_errno));
-
-	exit(EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction(signum, &act, NULL) < 0 )
-	{
-		syslog(LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit(EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/BKP_20071105/server_default.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/BKP_20071105/server_default.c	(revision 216)
+++ 	(revision )
@@ -1,584 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <stdarg.h>
-#include <syslog.h>
-
-/* Buffer size, in bytes, used for copying in the Cat() function. */
-const size_t BUF_SIZE = 10240;
-
-/* Typedef for a signal handler function. */
-typedef void (*signal_handler_t) (int);
-
-/* Prototypes for functions in this file. */
-void ParseArgs (int argc, char *argv[], struct in_addr *ra, unsigned short *rp, struct in_addr *la, unsigned short *lp);
-void Initialise (void);
-void sig_child (int signo);
-int CreateServerSocket (struct in_addr addr, unsigned short port);
-void Daemonise (void);
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port);
-void Proxy (int server_fd, int client_fd);
-int AcceptClientConnection (int listen_fd);
-int ConnectToServer (struct in_addr addr, unsigned short port);
-void Cat (int in_fd, int out_fd);
-int NameToAddr (const char *name, struct in_addr *p_inaddr);
-int NameToPort (const char *name, unsigned short *port, const char *proto);
-#ifdef __GNUC__
-	void quit (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *fmt, ...);
-	void pbomb (const char *fmt, ...);
-	void hbomb (const char *fmt, ...);
-#endif
-void set_signal_handler (int signum, signal_handler_t sig_handler_func);
-
-/* Global variables */
-char g_program_name[100]; /* Initialised from argv[0] in ParseArgs() */
-
-int main (int argc, char *argv[])
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs(argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise();
-
-	// Create server socket before becoming
-	// a daemon so there is still a chance
-	// to print an error message.
-
-	listen_fd = CreateServerSocket(local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb("Unable to create server socket");
-
-	Daemonise();
-
-	MainLoop(listen_fd, remote_addr, remote_port); // never returns
-
-	exit(EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char *argv[], struct in_addr *ra, unsigned short *rp, struct in_addr *la, unsigned short *lp)
-{
-	 // argv[0] = program name
-	 // argv[1] = remote_addr
-	 // argv[2] = remote_port
-	 // argv[3] = local_addr (optional)
-	 // argv[4] = local_port (optional)
-
-	char * p = strrchr(argv[0], '/');
-
-	strncpy(g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof(g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr(argv[1], ra) )
-		hbomb("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort(argv[2], rp, "tcp") )
-		quit("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl(INADDR_ANY);
-	else
-		if ( NameToAddr(argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy(lp, rp, sizeof(*lp));
-	else
-		if ( NameToPort(argv[4], lp, "tcp") )
-			quit("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog(g_program_name, LOG_PID, LOG_USER);
-	syslog(LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	set_signal_handler(SIGCHLD, sig_child);
-
-	signal(SIGPIPE, SIG_IGN);
-}
-
-// sig_child()
-// Handles SIGCHLD from exiting child processes.
-void sig_child (int signo)
-{
-	pid_t pid = 1;
-
-	(void) signo; // suppress compiler warning
-
-	while ( pid > 0 )
-	{
-		pid = waitpid(WAIT_ANY, NULL, WNOHANG);
-
-		if ( pid > 0 )
-			syslog(LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		//else
-		//	break;
-	}
-
-	if ( (pid < 0) && (errno != ECHILD) )
-		syslog(LOG_ERR, "waitpid(): %m"), exit(EXIT_FAILURE);
-
-	return;
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog(LOG_ERR, "socket(): %m"), exit(EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0 )
-		syslog(LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons(port);
-	sa.sin_addr = addr;
-	memset(sa.sin_zero, 0, sizeof(sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind(fd, (struct sockaddr *) &sa, sizeof(sa));
-	if ( err < 0 )
-	{
-		syslog(LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog(LOG_ERR, "listen(): %m"), exit(EXIT_FAILURE);
-
-	return fd;
-}
-
-// Daemonise()
-// Put the program in the background, set
-// PPID=1, create a new session and process
-// group, without a controlling tty.
-void Daemonise (void)
-{
-	pid_t pid;
-
-	// Close stdin, stdout & stderr
-	// TODO:
-	// open /dev/null and dup the fd to stdin, stdout & stderr
-	// close(STDIN_FILENO);
-	// close(STDOUT_FILENO);
-	// close(STDERR_FILENO);
-
-	syslog (LOG_INFO, "%s daemonising", g_program_name);
-
-	// Fork the process to put it in the background.
-
-	pid = fork();
-	if ( pid == -1 )
-		syslog (LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-	// parent terminates here, so shell thinks the command is done.
-	if ( pid )
-		exit(0);
-
-	syslog(LOG_INFO, "%s in background", g_program_name);
-
-	// 1st child continues to run in the background with PPID=1
-
-	// Become leader of a new session and a new process group,
-	// with no controlling tty.
-	setsid();
-
-	// Fork again to guarantee the process will not be able
-	// to aquire a controlling tty.
-
-	// signal (SIGHUP, SIG_IGN); // required according to Stevens' UNP2 p333
-
-	pid = fork();
-	if ( pid == -1 )
-		syslog(LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-	if ( pid ) // 1st child terminates
-		exit(0);
-
-	// 2nd child continues, no longer a session or group leader
-
-	syslog(LOG_INFO, "%s daemonised", g_program_name);
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	int server_fd,
-		client_fd;
-	pid_t child_pid;
-
-	for ( ; ; )
-	{
-		client_fd = AcceptClientConnection (listen_fd);
-
-		child_pid = fork();
-		if ( child_pid == -1 )
-			syslog(LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-		if ( child_pid ) // parent
-		{
-			close(client_fd);
-
-			syslog(LOG_INFO, "Forked child pid %d to deal with client", child_pid);
-		}
-		else // child
-		{
-			close(listen_fd);
-
-			server_fd = ConnectToServer(rem_addr, rem_port);
-
-			Proxy(server_fd, client_fd);
-
-			syslog(LOG_INFO, "exiting");
-			_exit(0);
-		}
-	}
-}
-
-/* Proxy(): Copies data between server_fd and client_fd in both directions
- *  * until one or other peer closes their connection.
- *   */
-void Proxy (int server_fd, int client_fd)
-{
-	pid_t helper_pid;
-
-	syslog(LOG_INFO, "Proxy(fd%d, fd%d)", server_fd, client_fd);
-
-	signal(SIGCHLD, SIG_IGN);
-
-	helper_pid = fork();
-	if ( helper_pid == -1 )
-		syslog(LOG_ERR, "fork(): %m"), exit(EXIT_FAILURE);
-
-	if ( helper_pid ) // parent
-	{
-		syslog(LOG_INFO, "Forked child pid %d to help with proxying", helper_pid);
-
-		Cat(server_fd, client_fd);
-
-		shutdown(client_fd, 1);
-		close(server_fd);
-		close(client_fd);
-
-		wait(0); // wait for helper to exit
-	}
-	else // child (helper)
-	{
-		Cat(client_fd, server_fd);
-
-		shutdown(server_fd, 1);
-
-		syslog(LOG_INFO, "exiting");
-		exit(0); // helper exits here
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-int AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog(LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof(sa);
-	memset(&sa, 0, socklen);
-	do
-	{
-		newfd = accept(listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog(LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog(LOG_ERR, "accept(): %m"), exit(EXIT_FAILURE);
-
-	if ( socklen != sizeof(sa) )
-		syslog(LOG_ERR, "accept() screwed up!"), exit(EXIT_FAILURE);
-
-	return newfd;
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO:
-	// have a timeout for connect()
-	// see Unix socket FAQ 6.2
-
-	int fd,
-		err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket(AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog(LOG_ERR, "socket(): %m"), exit(EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons(port);
-	sa.sin_addr = addr;
-	memset(sa.sin_zero, 0, sizeof(sa.sin_zero));
-
-	err = connect(fd, (struct sockaddr *) &sa, sizeof(sa));
-	if ( err < 0 )
-	{
-		syslog(LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		exit(EXIT_FAILURE);
-	}
-
-	syslog(LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-void Cat (int in_fd, int out_fd)
-{
-	unsigned char * const buf = malloc(BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = 0,
-		i;
-
-	syslog(LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf == NULL )
-		syslog(LOG_ERR, "malloc(): %m"), exit(EXIT_FAILURE);
-
-	do
-	{
-		bytes_rcvd = recv(in_fd, buf, BUF_SIZE, 0);
-
-		for ( i = 0; i < bytes_rcvd || bytes_sent < 0; i += bytes_sent )
-		{
-			bytes_sent = send(out_fd, buf + i, bytes_rcvd - i, 0);
-
-			//if ( bytes_sent < 0 )
-			//	break;
-		}
-
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-	if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-		syslog(LOG_ERR, "recv(): %m"), exit(EXIT_FAILURE);
-
-	if ( (bytes_sent < 0) && (errno != EPIPE) )
-		syslog(LOG_ERR, "send(): %m"), exit(EXIT_FAILURE);
-
-	free(buf);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO:
-	// use inet_aton() instead
-	p_inaddr->s_addr = inet_addr(name);
-	if ( p_inaddr->s_addr != -1U )  // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname(name);
-	if ( he != NULL ) // Success
-	{
-		memcpy(p_inaddr, he->h_addr, sizeof(struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul(name, &errpos, 0);
-	if ( (*(errpos) == 0) && (lport <= 65535) ) // Success
-	{
-		*(port) = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname(name, proto);
-	if ( se != NULL ) // Success
-	{
-		*(port) = ntohs(se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char *fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush(stdout);
-
-	fprintf(stderr, "%s: ", g_program_name);
-
-	va_start(ap, fmt);
-	vfprintf(stderr, fmt, ap);
-	va_end(ap);
-
-	fputc('\n', stderr);
-
-	syslog(LOG_ERR, "I quit!");
-
-	exit(EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char *fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush(stdout);
-
-	fprintf(stderr, "%s: ", g_program_name);
-
-	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
-	va_end(ap);
-
-	errno = errno_save;
-	perror(buf);
-
-	syslog(LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit(EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char *fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start(ap, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, ap);
-	va_end(ap);
-
-	h_errno = h_errno_save;
-	herror(buf);
-
-	syslog(LOG_ERR, "Bang!: %s: %s", buf, hstrerror(h_errno));
-
-	exit(EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction(signum, &act, NULL) < 0 )
-	{
-		syslog(LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit(EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/ms
===================================================================
--- /trunk/instant_messenger/bkp/socket/ms	(revision 216)
+++ 	(revision )
@@ -1,3 +1,0 @@
-Alexandre,
-de uma olhada na adiÃ§Ã£o de contatos do expresso. Nao estou conseguindo adicionar quando eu clico na imagem cartao que aparece logo apos o email quando eu recebo uma msg.
-abraÃ§o
Index: unk/instant_messenger/bkp/socket/server.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/server.c	(revision 216)
+++ 	(revision )
@@ -1,709 +1,0 @@
-#include "server.h"
-
-struct accept
-{
-	int newfd;
-	struct sockaddr_in sa;
-	struct in_addr jabber_addr;
-	unsigned short jabber_port;
-};
-
-struct client
-{
-	char * user;
-	int client_fd;
-	int jabber_fd;
-	int keep_alive;
-	time_t last_action;
-	struct client * next;
-	struct client * previous;
-};
-
-struct cat
-{
-	int in_fd,
-		out_fd;
-	int jabber,
-		keep_alive;
-	struct client * client;
-};
-
-struct client * clients = (struct client *)NULL;
-
-pthread_mutex_t mutexsum;
-
-int main (int argc, char ** argv)
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise ();
-
-	// Create server socket before becoming a daemon so
-	// there is still a chance to print an error message.
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb ("Unable to create server socket");
-
-	//Daemonise ();
-
-	MainLoop (listen_fd, remote_addr, remote_port); // never returns
-
-	syslog (LOG_ERR, "fim MainLoop(): %m");
-	exit (EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char ** argv, struct in_addr * ra, unsigned short * rp, struct in_addr * la, unsigned short * lp)
-{
-	// argv[0] = program name
-	// argv[1] = remote_addr
-	// argv[2] = remote_port
-	// argv[3] = local_addr (optional)
-	// argv[4] = local_port (optional)
-
-	char * p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr (argv[1], ra) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort (argv[2], rp, "tcp") )
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl (INADDR_ANY);
-	else
-		if ( NameToAddr (argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy (lp, rp, sizeof (*lp));
-	else
-		if ( NameToPort (argv[4], lp, "tcp") )
-			quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	//set_signal_handler (SIGCHLD, sig_child);
-
-	//signal (SIGPIPE, SIG_IGN);
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	//sa.sin_addr = addr;
-	sa.sin_addr.s_addr = htonl(INADDR_ANY);
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if ( err < 0 )
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	struct accept * accept;
-	pthread_t accept_thread,
-			  clear_list_thread;
-
-	pthread_mutex_init(&mutexsum, NULL);
-
-	pthread_create(&clear_list_thread, NULL, (void *) &ClearList, (void *)NULL );
-
-	for ( ; ; )
-	{
-		accept = AcceptClientConnection (listen_fd);
-		accept->jabber_addr = rem_addr;
-		accept->jabber_port = rem_port;
-
-		pthread_create(&accept_thread, NULL, (void *) &VerifyClient, (void *) accept);
-	}
-	pthread_mutex_destroy(&mutexsum);
-	pthread_exit(NULL);
-}
-
-void ClearList(void)
-{
-	struct client * current,
-				  * client_remove;
-
-	for ( ; ; )
-	{
-		current = clients;
-		pthread_mutex_lock(&mutexsum);
-		while ( current != (struct client *)NULL )
-		{
-			//printf("client: %s....\n", current->user);
-			if ( time(NULL) - current->last_action > 60 )
-			{
-				//puts("\t#1 morto!");
-				shutdown(current->jabber_fd, SHUT_RDWR);
-				close(current->jabber_fd);
-				current->jabber_fd = (int)NULL;
-				//if ( current->previous == (struct client *)NULL )
-				//{
-				//puts("\t#2 morto!");
-					//if ( current->next != (struct client *)NULL )
-					//	current->next->previous = (struct client *)NULL;
-					//clients = current->next;
-				//puts("\t#3 morto!");
-				//}
-				/*if ( current->previous != (struct client *)NULL )
-				{
-					current->previous->next = current->next;
-					current->next->previous = current->previous;
-				}
-				else
-				{
-					current->next->previous = (struct client *)NULL;
-				}*/
-				//puts("\t#4 morto!");
-				//client_remove = current;
-				current = current->next;
-				//free(client_remove);
-				//puts("\t#5 morto!");
-			}
-			else
-				current = current->next;
-		}
-		//puts("-------------------------------");
-		pthread_mutex_unlock(&mutexsum);
-		sleep(2);
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-struct accept * AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog (LOG_ERR, "accept(): %m"), pthread_exit(0);
-
-	if ( socklen != sizeof (sa) )
-		syslog (LOG_ERR, "accept() screwed up!"), pthread_exit(0);
-
-	struct accept * new_accept = (struct accept *) malloc(sizeof(struct accept));
-	new_accept->newfd = newfd;
-	new_accept->sa = sa;
-
-	return (new_accept);
-}
-
-void VerifyClient(void * accept)
-{
-	int jabber_fd = (int)NULL;
-	struct accept * client = (struct accept *) accept;
-	struct client * user = (struct client *)NULL;
-	struct cat * info;
-	pthread_t cat_thread;
-	
-	FILE *file;
-	char line[80];
-	char *ips[20];
-	int cont;
-	int j;
-
-	unsigned int addr = 0;
-	char buf[250];
-	addr = ntohl(client->sa.sin_addr.s_addr);
-	sprintf(buf,"%d.%d.%d.%d",
-			(addr >> 24)  , (addr >> 16) & 0xFF ,
-			(addr >> 8) & 0xFF ,  addr & 0xFF);
-	printf("New connection: %s\n\n", buf);
-
-	if(!(file = fopen("/etc/socket_im/hosts","r")))
-	{
-		printf("ImpossÃ­vel abrir o arquivo hosts \n");
-		exit(1);
-	}
-	
-	fgets(line, 80, file);
-	while(!feof(file))
-	{
-		ips[cont] = malloc(sizeof(char)*17);
-		line[strlen(line) - 1 ] = '\0';
-		strcpy(ips[cont], line);
-		fgets(line, 80, file);
-		cont++;
-	}
-	
-	fclose(file);
-
-	for( j = 0; j < cont; j++)
-	{
-		if( strcmp( buf, ips[j] ) == 0)
-		{
-			user = Handshake(client->newfd);
-			jabber_fd = user->jabber_fd;
-			break;
-		}
-	}
-
-	/*if ( strcmp(buf, "10.15.20.42") == 0 || strcmp(buf, "10.15.20.202") == 0 || strcmp(buf, "10.15.20.145") == 0 )
-	{
-		user = Handshake(client->newfd);
-		jabber_fd = user->jabber_fd;
-	}*/
-
-	if ( jabber_fd == (int)NULL )
-	{
-		jabber_fd = ConnectToServer(client->jabber_addr, client->jabber_port);
-
-		if ( user != (struct client *)NULL )
-			user->jabber_fd = jabber_fd;
-	}
-
-	info = (struct cat *) malloc(sizeof(struct cat));
-
-	info->out_fd = jabber_fd;
-	info->in_fd = client->newfd;
-	info->jabber = (int)NULL;
-	info->keep_alive = (int)NULL;
-	info->client = user;
-
-	pthread_create(&cat_thread, NULL, (void *) &Cat, (void *)info );
-
-	pthread_exit(0);
-}
-
-struct client * Handshake(int newfd)
-{
-	float is_new_client;// = (float) NULL;
-	int bytes_rcvd,
-		bytes_sent,
-		i;
-
-	unsigned char * const buf = (char *) malloc (sizeof(char) * 5);
-	char * user = (char *) malloc(128 * sizeof(char)),
-		 * pass = (char *) malloc(128 * sizeof(char));
-
-	//struct client * clients = (struct client *)NULL;
-	struct client * new_client = (struct client *)NULL;
-
-	bzero(buf, 5);
-	sprintf(buf, "user");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(user, 128);
-	if ( (bytes_rcvd = recv (newfd, user, 128, 0)) < 1 )
-		pthread_exit(0);
-
-	bzero(buf, 5);
-	sprintf(buf, "pass");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(pass, 128);
-	if ( (bytes_rcvd = recv (newfd, pass, 128, 0)) < 1 )
-		pthread_exit(0);
-
-	pthread_mutex_lock (&mutexsum);
-	if ( clients == (struct client *)NULL )
-	{
-		clients = (struct client *) malloc(sizeof(struct client));
-
-		new_client = clients;
-		new_client->previous = (struct client *)NULL;
-		is_new_client = 1;
-	}
-	else
-	{
-		new_client = clients;
-		while ( ((is_new_client = (float)strcmp(new_client->user, user)) != 0) && (new_client->next != (struct client *)NULL) )
-			new_client = new_client->next;
-
-		if ( is_new_client != 0 )
-		{
-			new_client->next = (struct client *) malloc(sizeof(struct client));
-			new_client->next->previous = new_client;
-			new_client = new_client->next;
-		}
-	}
-
-	if ( is_new_client != 0 )
-	{
-		new_client->user = user;
-		new_client->jabber_fd = (int)NULL;
-		new_client->keep_alive = 1;
-		new_client->next = (struct client *)NULL;
-	}
-
-	bzero(buf, 5);
-	if ( is_new_client != 0 || new_client->jabber_fd == (int)NULL  )
-		sprintf(buf, "new");
-	else
-		sprintf(buf, "rec");
-
-	send (newfd, buf, 3, 0);
-
-	new_client->client_fd = newfd;
-	new_client->last_action = time(NULL);
-	pthread_mutex_unlock(&mutexsum);
-
-	return new_client;
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO: have a timeout for connect() - see Unix socket FAQ 6.2
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), pthread_exit(0);//exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		//exit (EXIT_FAILURE);
-		pthread_exit(0);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-//void Cat (int in_fd, int out_fd)
-//void Cat (int in_fd, int out_fd)
-void Cat (void * info)
-{
-	unsigned char * const buf_in = (char *) malloc (sizeof(char) * BUF_SIZE);
-	unsigned char * const buf_out = (char *) malloc (sizeof(char) * BUF_SIZE);
-	int bytes_rcvd_in = (int) NULL,
-		bytes_sent_in = (int) NULL,
-		bytes_rcvd_out = (int) NULL,
-		bytes_sent_out = (int) NULL,
-		i,
-		in_fd,
-		out_fd;
-	struct cat * user = (struct cat *) info;
-	in_fd = user->in_fd;
-	out_fd = user->out_fd;
-
-	syslog (LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf_in == NULL || buf_out == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), pthread_exit(0);
-
-	fcntl(in_fd, F_SETFL, fcntl(in_fd, F_GETFL, 0) | O_NDELAY);
-	fcntl(out_fd, F_SETFL, fcntl(out_fd, F_GETFL, 0) | O_NDELAY);
-
-	bzero(buf_in, BUF_SIZE);
-	bzero(buf_out, BUF_SIZE);
-	do
-	{
-		bzero(buf_in, BUF_SIZE);
-		if ( (bytes_rcvd_in = recv (in_fd, buf_in, BUF_SIZE, 0)) != 0 && strlen(buf_out) > 0 )
-		{
-			for ( i = 0; i < bytes_rcvd_out; i += bytes_sent_in )
-			{
-				bytes_sent_in = send (in_fd, buf_out + i, bytes_rcvd_out - i, 0);
-
-				if ( bytes_sent_in < 0 )
-					break;
-			}
-		}
-
-		bzero(buf_out, BUF_SIZE);
-		if ( (bytes_rcvd_out = recv (out_fd, buf_out, BUF_SIZE, 0)) != 0 && strlen(buf_in) > 0 )
-		{
-			//printf("\n%s\n", buf_in);
-			for ( i = 0; i < bytes_rcvd_in; i += bytes_sent_out )
-			{
-				bytes_sent_out = send (out_fd, buf_in + i, bytes_rcvd_in - i, 0);
-
-				if ( bytes_sent_out < 0 )
-					break;
-			}
-		}
-		usleep(500);
-		//sleep(1);
-		//printf("bytes_rcvd_in: %d\nbytes_rcvd_out: %d\n\n", bytes_rcvd_in, bytes_rcvd_out);
-	}
-	while ( (bytes_rcvd_in != 0) && (bytes_rcvd_out != 0) );
-
-	//puts("FIM CAT");
-
-	/*
-	if ( ((bytes_rcvd_in < 0) || (bytes_rcvd_out < 0)) && (errno != ECONNRESET) )
-		syslog (LOG_ERR, "recv(): %m"), pthread_exit(0);
-
-	if ( ((bytes_sent_in < 0) || (bytes_sent_out < 0)) && (errno != EPIPE) )
-		syslog (LOG_ERR, "send(): %m"), pthread_exit(0);
-	*/
-
-	if ( user->jabber && !user->keep_alive )
-	{
-		shutdown(user->jabber, SHUT_RDWR);
-		close(user->jabber);
-	}
-	//puts("shutdown");
-	shutdown(user->in_fd, SHUT_RDWR);
-	//puts("close");
-	close(user->in_fd);
-	free (buf_in);
-	//free (buf_out);
-	pthread_exit(0);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO: use inet_aton() instead
-	p_inaddr->s_addr = inet_addr (name);
-	if ( p_inaddr->s_addr != -1U ) // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname (name);
-	if ( he != NULL ) // Success
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul (name, &errpos, 0);
-	if ( (*errpos == 0) && (lport <= 65535) ) // Success
-	{
-		*port = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname (name, proto);
-	if ( se != NULL) // Success
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char * fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char * fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char * fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction (signum, &act, NULL) < 0 )
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/server.h
===================================================================
--- /trunk/instant_messenger/bkp/socket/server.h	(revision 216)
+++ 	(revision )
@@ -1,70 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <semaphore.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <pthread.h>
-#include <ctype.h>
-
-
-// Buffer size, in bytes, used for copying in the Cat() function.
-const size_t BUF_SIZE = 4096;
-
-// Global variables
-char g_program_name[100];	// Initialised from argv[0] in ParseArgs()
-
-// structs
-/*struct client
-{
-	unsigned char * user;
-	unsigned char * key;
-	int jabber;
-	int shmid;
-	struct client * next,
-				  * previous;
-};*/
-
-// Typedef for a signal handler function.
-typedef void (* signal_handler_t) (int);
-
-// Prototypes for functions in this file.
-void ParseArgs (int, char **, struct in_addr *, unsigned short *, struct in_addr *, unsigned short *);
-void Initialise (void);
-void sig_child (int);
-int CreateServerSocket (struct in_addr, unsigned short);
-void Daemonise (void);
-void MainLoop (int, struct in_addr, unsigned short);
-void ClearList(void);
-void Proxy (int, int);
-struct accept * AcceptClientConnection (int);
-void VerifyClient(void *);
-struct client * Handshake(int);
-int ConnectToServer (struct in_addr, unsigned short);
-//void Cat (int, int);
-void Cat (void *);
-int NameToAddr (const char *, struct in_addr *);
-int NameToPort (const char *, unsigned short *, const char *);
-#ifdef __GNUC__
-	void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *, ...);
-	void pbomb (const char *, ...);
-	void hbomb (const char *, ...);
-#endif
-void set_signal_handler (int, signal_handler_t);
Index: unk/instant_messenger/bkp/socket/client.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/client.c	(revision 216)
+++ 	(revision )
@@ -1,103 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-//#define IP "127.0.0.1"
-#define IP "127.0.0.1"
-//#define IP "10.15.20.42"
-//#define IP "10.15.20.202"
-
-#define PORT "9001"
-
-int main(void)
-{
-	struct sockaddr_in socketaddr;
-	int socketfd,
-		nHostPort;
-	int err,
-		i,
-		unit;
-	char buff[4096];
-	char * _xml = (char)NULL,
-		 //* xml_connect = {"fromBrowser"};
-		 * xml_connect = {"<?xml version='1.0' encoding='UTF-8'?><stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"};
-
-	_xml = (char *) malloc(sizeof(buff));
-
-	if ( (nHostPort = strtol(PORT, 0, 10)) == 0 )
-	{
-		printf("\n<port>\n\n");
-		printf("\ncould not make a socket\n");
-		return 0;
-	}
-
-	socketfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	socketaddr.sin_family = AF_INET;
-	//socketaddr.sin_addr.s_addr = INADDR_ANY;//inet_addr(IP);
-	socketaddr.sin_addr.s_addr = inet_addr(IP);
-	//socketaddr.sin_addr.s_addr = inet_addr("10.15.20.42");
-	//inet_aton(IP, &socketaddr.sin_addr);
-	socketaddr.sin_port = htons(nHostPort);
-
-	err = connect(socketfd, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
-
-	if ( err < 0 )
-	{
-		printf("Socket returned error #%d,program terminated\n", err);
-		exit(0);
-	}
-
-	struct hostent *hp;
-	hp = gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET);
-
-	//printf("\n\n%s\n\n", inet_ntoa(socketaddr.sin_addr));
-	//printf("\n\n%d\n\n", inet_network("expresso.pr.gov.br"));
-
-	//printf("\n\n%d\n\n", socketaddr.sin_addr.s_addr);
-	//printf("\n\n%s\n\n", gethostbyaddr((char *)&socketaddr.sin_addr.s_addr, sizeof socketaddr.sin_addr.s_addr, AF_INET));
-
-
-	//sprintf(_xml, xml_connect, IP);
-	//_xml[strlen(_xml)] = '\0';
-	//++_xml;
-	//*_xml = '\0';
-	//puts(_xml);
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "moita");
-	write(socketfd, _xml, strlen(_xml));
-
-	bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-	/*
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "user_%d_@domine", time(NULL));
-	write(socketfd, _xml, strlen(_xml));
-
-	bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);
-
-	bzero(_xml, sizeof(buff));
-	sprintf(_xml, "password");
-	write(socketfd, _xml, strlen(_xml));*/
-
-	/*bzero(buff, sizeof(buff));
-	read (socketfd, buff, sizeof(buff));
-	printf("%s\n\n", buff);*/
-
-	//sleep(10);
-	exit(0);
-}
Index: unk/instant_messenger/bkp/socket/hosts
===================================================================
--- /trunk/instant_messenger/bkp/socket/hosts	(revision 216)
+++ 	(revision )
@@ -1,3 +1,0 @@
-10.15.20.42
-10.15.20.202
-10.15.20.6
Index: unk/instant_messenger/bkp/socket/proxy.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/proxy.c	(revision 216)
+++ 	(revision )
@@ -1,865 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <semaphore.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-// Buffer size, in bytes, used for copying in the Cat() function.
-const size_t BUF_SIZE = 4096;
-
-// Global variables
-char g_program_name[100];	// Initialised from argv[0] in ParseArgs()
-
-// structs
-struct accept
-{
-	int newfd;
-	struct sockaddr_in sa;
-	struct in_addr jabber_addr;
-	unsigned short jabber_port;
-};
-
-/*struct client
-{
-	unsigned char * user;
-	unsigned char * key;
-	int jabber;
-	int shmid;
-	struct client * next,
-				  * previous;
-};*/
-struct client
-{
-	char * user;
-	int client_fd;
-	int jabber_fd;
-	int keep_alive;
-	int connectionType; // 0 = read/write; 1 = read; -1 = write;
-	time_t last_action;
-	struct client * next;
-	struct client * previous;
-};
-
-struct cat
-{
-	int in_fd,
-		out_fd;
-	int jabber,
-		keep_alive;
-	struct client * client;
-	int connectionType;
-};
-
-struct client * clients = (struct client *)NULL;
-
-pthread_mutex_t mutexsum;
-
-// Typedef for a signal handler function.
-typedef void (* signal_handler_t) (int);
-
-// Prototypes for functions in this file.
-void ParseArgs (int, char **, struct in_addr *, unsigned short *, struct in_addr *, unsigned short *);
-void Initialise (void);
-void sig_child (int);
-int CreateServerSocket (struct in_addr, unsigned short);
-void Daemonise (void);
-void MainLoop (int, struct in_addr, unsigned short);
-struct accept * AcceptClientConnection (int);
-void VerifyClient(void *);
-struct client * Handshake(int);
-int ConnectToServer (struct in_addr, unsigned short);
-void Reading (void * info);
-void Writing (void * info);
-int NameToAddr (const char *, struct in_addr *);
-int NameToPort (const char *, unsigned short *, const char *);
-#ifdef __GNUC__
-	void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *, ...);
-	void pbomb (const char *, ...);
-	void hbomb (const char *, ...);
-#endif
-void set_signal_handler (int, signal_handler_t);
-
-int main (int argc, char ** argv)
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise ();
-
-	// Create server socket before becoming a daemon so
-	// there is still a chance to print an error message.
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb ("Unable to create server socket");
-
-	//Daemonise ();
-
-	MainLoop (listen_fd, remote_addr, remote_port); // never returns
-
-	exit (EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char ** argv, struct in_addr * ra, unsigned short * rp, struct in_addr * la, unsigned short * lp)
-{
-	// argv[0] = program name
-	// argv[1] = remote_addr
-	// argv[2] = remote_port
-	// argv[3] = local_addr (optional)
-	// argv[4] = local_port (optional)
-
-	char * p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr (argv[1], ra) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort (argv[2], rp, "tcp") )
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl (INADDR_ANY);
-	else
-		if ( NameToAddr (argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy (lp, rp, sizeof (*lp));
-	else
-		if ( NameToPort (argv[4], lp, "tcp") )
-			quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	//set_signal_handler (SIGCHLD, sig_child);
-
-	//signal (SIGPIPE, SIG_IGN);
-}
-
-// sig_child()
-// Handles SIGCHLD from exiting child processes.
-void sig_child (int signo)
-{
-	pid_t pid;
-
-	(void) signo; // suppress compiler warning
-
-	for ( ; ; )
-	{
-		write(1, "SIG\n", sizeof("SIG\n"));
-		pid = waitpid (WAIT_ANY, NULL, WNOHANG);
-
-		if ( pid > 0 )
-			syslog (LOG_INFO, "Caught SIGCHLD from pid %d", pid);
-		else
-			break;
-	}
-	write(1, "SIG...\n", sizeof("SIG...\n"));
-
-	if ( (pid < 0) && (errno != ECHILD) )
-		syslog (LOG_ERR, "waitpid(): %m"), exit (EXIT_FAILURE);
-
-	return;
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	//sa.sin_addr = addr;
-	sa.sin_addr.s_addr = htonl(INADDR_ANY);
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if ( err < 0 )
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-// Daemonise()
-// Put the program in the background, set PPID=1, create a
-// new session and process group, without a controlling tty.
-void Daemonise (void)
-{
-	pid_t pid;
-
-	// Close stdin, stdout & stderr
-	// @TODO:
-	//		open /dev/null and dup the fd to stdin, stdout & stderr
-	//		close(STDIN_FILENO);
-	//		close(STDOUT_FILENO);
-	//		close(STDERR_FILENO);
-
-	syslog (LOG_INFO, "%s daemonising", g_program_name);
-
-	// Fork the process to put it in the background.
-
-	pid = fork ();
-	if ( pid == -1 )
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	// parent terminates here, so shell thinks the command is done.
-	if ( pid )
-		exit (0);
-
-	syslog (LOG_INFO, "%s in background", g_program_name);
-
-	// 1st child continues to run in the background with PPID=1
-
-	// Become leader of a new session and a new process group,
-	// with no controlling tty.
-	setsid ();
-
-	// Fork again to guarantee the process will
-	// not be able to aquire a controlling tty.
-
-	// signal (SIGHUP, SIG_IGN);
-	// required according to Stevens' UNP2 p333
-
-	pid = fork ();
-	if (pid == -1)
-		syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
-
-	if ( pid ) // 1st child terminates
-		exit (0);
-
-	// 2nd child continues, no longer a session or group leader
-
-	syslog (LOG_INFO, "%s daemonised", g_program_name);
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	struct accept * accept;
-	pthread_t accept_thread,
-			  clear_list_thread;
-
-	pthread_mutex_init(&mutexsum, NULL);
-
-	//pthread_create(&clear_list_thread, NULL, (void *) &ClearList, (void *)NULL );
-
-	for ( ; ; )
-	{
-		accept = AcceptClientConnection (listen_fd);
-		accept->jabber_addr = rem_addr;
-		accept->jabber_port = rem_port;
-
-		pthread_create(&accept_thread, NULL, (void *) &VerifyClient, (void *) accept);
-	}
-	pthread_mutex_destroy(&mutexsum);
-	pthread_exit(NULL);
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-//int AcceptClientConnection (int listen_fd)
-struct accept * AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
-
-	if ( socklen != sizeof (sa) )
-		syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
-
-	//return (newfd);
-
-	struct accept * new_accept = (struct accept *) malloc(sizeof(struct accept));
-	new_accept->newfd = newfd;
-	new_accept->sa = sa;
-
-	return (new_accept);
-}
-
-void VerifyClient(void * accept)
-{
-	int jabber_fd = (int)NULL,
-		connectionType = 0;
-	struct accept * client = (struct accept *) accept;
-	struct client * user = (struct client *)NULL;
-	struct cat * info;
-	pthread_t cat_thread;
-
-	/*FILE *file;
-	char line[80];
-	char *ips[20];
-	int cont;
-	int j;*/
-
-	unsigned int addr = 0;
-	char buf[250];
-	addr = ntohl(client->sa.sin_addr.s_addr);
-	sprintf(buf,"%d.%d.%d.%d",
-			(addr >> 24)  , (addr >> 16) & 0xFF ,
-			(addr >> 8) & 0xFF ,  addr & 0xFF);
-	printf("\nNew connection: %s\n", buf);
-
-	/*if(!(file = fopen("/etc/socket_im/hosts","r")))
-	{
-		printf("ImpossÃ­vel abrir o arquivo hosts \n");
-		exit(1);
-	}
-
-	fgets(line, 80, file);
-	while(!feof(file))
-	{
-		ips[cont] = malloc(sizeof(char)*17);
-		line[strlen(line) - 1 ] = '\0';
-		strcpy(ips[cont], line);
-		fgets(line, 80, file);
-		cont++;
-	}
-
-	fclose(file);
-
-	for( j = 0; j < cont; j++)
-	{
-		if( strcmp( buf, ips[j] ) == 0)
-		{
-			user = Handshake(client->newfd);
-			jabber_fd = user->jabber_fd;
-			connectionType = user->connectionType;
-			break;
-		}
-	}*/
-
-	if ( strcmp(buf, "10.15.20.42") == 0 )//|| strcmp(buf, "10.15.20.202") == 0 || strcmp(buf, "10.15.20.145") == 0 )
-	{
-		user = Handshake(client->newfd);
-		jabber_fd = user->jabber_fd;
-		connectionType = user->connectionType;
-	}
-
-	if ( jabber_fd == (int)NULL )
-	{
-		jabber_fd = ConnectToServer(client->jabber_addr, client->jabber_port);
-
-		if ( user != (struct client *)NULL )
-			user->jabber_fd = jabber_fd;
-	}
-
-	info = (struct cat *) malloc(sizeof(struct cat));
-
-	info->in_fd = jabber_fd;
-	info->out_fd = client->newfd;
-	info->jabber = (int)NULL;
-	info->keep_alive = (int)NULL;
-	info->client = user;
-	info->connectionType = connectionType;
-
-	if ( !connectionType )
-	{
-		pthread_create(&cat_thread, NULL, (void *) &Reading, (void *)info );
-		pthread_create(&cat_thread, NULL, (void *) &Writing, (void *)info );
-	}
-	else
-	{
-		if ( connectionType == 1 )
-			pthread_create(&cat_thread, NULL, (void *) &Reading, (void *)info );
-		else
-			pthread_create(&cat_thread, NULL, (void *) &Writing, (void *)info );
-	}
-
-	pthread_exit(0);
-}
-
-struct client * Handshake(int newfd)
-{
-	float is_new_client;// = (float) NULL;
-	int bytes_rcvd,
-		bytes_sent,
-		connectionType,
-		i;
-
-	unsigned char * const buf = (char *) malloc (sizeof(char) * 5);
-	char * user = (char *) malloc(128 * sizeof(char)),
-		 * pass = (char *) malloc(128 * sizeof(char)),
-		 * type = (char *) malloc(128 * sizeof(char));
-
-	//struct client * clients = (struct client *)NULL;
-	struct client * new_client = (struct client *)NULL;
-
-	bzero(buf, 5);
-	sprintf(buf, "user");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(user, 128);
-	if ( (bytes_rcvd = recv (newfd, user, 128, 0)) < 1 )
-	{
-		printf("USER....: %s", user);
-		shutdown(newfd, SHUT_RDWR);
-		close(newfd);
-		pthread_exit(0);
-	}
-
-	bzero(buf, 5);
-	sprintf(buf, "pass");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(pass, 128);
-	if ( (bytes_rcvd = recv (newfd, pass, 128, 0)) < 1 )
-	{
-		printf("PASS....: %s", pass);
-		shutdown(newfd, SHUT_RDWR);
-		close(newfd);
-		pthread_exit(0);
-	}
-
-	bzero(buf, 5);
-	sprintf(buf, "type");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(type, 128);
-	if ( (bytes_rcvd = recv (newfd, type, 128, 0)) < 1 )
-	{
-		printf("TYPE....: %s", type);
-		shutdown(newfd, SHUT_RDWR);
-		close(newfd);
-		pthread_exit(0);
-	}
-
-	pthread_mutex_lock (&mutexsum);
-	if ( clients == (struct client *)NULL )
-	{
-		clients = (struct client *) malloc(sizeof(struct client));
-
-		new_client = clients;
-		new_client->previous = (struct client *)NULL;
-		is_new_client = 1;
-	}
-	else
-	{
-		new_client = clients;
-		while ( ((is_new_client = (float)strcmp(new_client->user, user)) != 0) && (new_client->next != (struct client *)NULL) )
-			new_client = new_client->next;
-	}
-
-	if ( is_new_client != 0 )
-	{
-		new_client->next = (struct client *) malloc(sizeof(struct client));
-		new_client->next->previous = new_client;
-		new_client = new_client->next;
-		new_client->user = user;
-		new_client->jabber_fd = (int)NULL;
-		new_client->keep_alive = 1;
-		new_client->next = (struct client *)NULL;
-	}
-
-	bzero(buf, 5);
-	if ( is_new_client != 0 || new_client->jabber_fd == (int)NULL  )
-		sprintf(buf, "new");
-	else
-		sprintf(buf, "rec");
-
-	send (newfd, buf, 3, 0);
-
-	new_client->client_fd = newfd;
-	new_client->last_action = time(NULL);
-	new_client->connectionType = 0;
-	pthread_mutex_unlock(&mutexsum);
-
-	if ( strcmp(type, "read") == 0 )
-		new_client->connectionType = 1;
-	else
-		if ( strcmp(type, "write") == 0 )
-			new_client->connectionType = 2;
-
-	return new_client;
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO: have a timeout for connect() - see Unix socket FAQ 6.2
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		exit (EXIT_FAILURE);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-void Reading (void * info)
-{
-	unsigned char * const buf = (char *) malloc (sizeof(char) * BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = (int) NULL,
-		i;
-
-	struct cat * user = (struct cat *) info;
-	int in_fd = user->in_fd,
-		out_fd = user->out_fd;
-
-	syslog (LOG_INFO, "Reading(fd%d, fd%d)", in_fd, out_fd);
-
-	// @TODO: verificar alocacao buffer
-	//if ( buf == NULL )
-	//	syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		bzero(buf, BUF_SIZE);
-		bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-		// descomentar para ver oq esta passado de informacao
-		//puts(buf);
-
-		for ( i = 0; i < bytes_rcvd; i += bytes_sent )
-		{
-			bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-			if ( bytes_sent < 0 )
-				break;
-		}
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-	//if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-	//	syslog (LOG_ERR, "recv(): %m"), exit (EXIT_FAILURE);
-
-	//if ( (bytes_sent < 0) && (errno != EPIPE) )
-	//	syslog (LOG_ERR, "send(): %m"), exit (EXIT_FAILURE);
-
-	free (buf);
-	//shutdown (user->out_fd, SHUT_RDWR);
-	close (user->out_fd);
-	close (user->out_fd);
-	pthread_exit(0);
-}
-
-void Writing (void * info)
-{
-	unsigned char * const buf = (char *) malloc (sizeof(char) * BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = (int) NULL,
-		i;
-
-	struct cat * user = (struct cat *) info;
-	int in_fd = user->out_fd,
-		out_fd = user->in_fd;
-
-	syslog (LOG_INFO, "Writing(fd%d, fd%d)", in_fd, out_fd);
-
-	// @TODO: verificar alocacao buffer
-	//if ( buf == NULL )
-	//	syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		bzero(buf, BUF_SIZE);
-		bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-		// descomentar para ver oq esta passado de informacao
-		//puts(buf);
-
-		for ( i = 0; i < bytes_rcvd; i += bytes_sent )
-		{
-			bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-			if ( bytes_sent < 0 )
-				break;
-		}
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-	//if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-	//	syslog (LOG_ERR, "recv(): %m"), exit (EXIT_FAILURE);
-
-	//if ( (bytes_sent < 0) && (errno != EPIPE) )
-	//	syslog (LOG_ERR, "send(): %m"), exit (EXIT_FAILURE);
-
-	free (buf);
-	//shutdown (user->out_fd, SHUT_RDWR);
-	close (user->out_fd);
-	close (user->out_fd);
-	pthread_exit(0);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO: use inet_aton() instead
-	p_inaddr->s_addr = inet_addr (name);
-	if ( p_inaddr->s_addr != -1U ) // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname (name);
-	if ( he != NULL ) // Success
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul (name, &errpos, 0);
-	if ( (*errpos == 0) && (lport <= 65535) ) // Success
-	{
-		*port = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname (name, proto);
-	if ( se != NULL) // Success
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char * fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char * fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char * fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction (signum, &act, NULL) < 0 )
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/afonso.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/afonso.c	(revision 216)
+++ 	(revision )
@@ -1,734 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <semaphore.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <pthread.h>
-#include <ctype.h>
-
-
-// Buffer size, in bytes, used for copying in the Cat() function.
-const size_t BUF_SIZE = 4096;
-
-// Global variables
-char g_program_name[100];	// Initialised from argv[0] in ParseArgs()
-
-// Typedef for a signal handler function.
-typedef void (* signal_handler_t) (int);
-
-// Prototypes for functions in this file.
-void ParseArgs (int, char **, struct in_addr *, struct in_addr *, struct in_addr *, struct in_addr *);
-void Initialise (void);
-void sig_child (int);
-int CreateServerSocket (int);
-void Daemonise (void);
-void MainLoop (int);//, struct in_addr *, struct in_addr *, struct in_addr *, struct in_addr *);
-void ClearList(void);
-void Proxy (int, int);
-struct accept * AcceptClientConnection (int);
-void VerifyClient(void *);
-struct client * Handshake(int);
-int ConnectToServer (struct in_addr, unsigned short);
-//void Cat (int, int);
-void Cat (void *);
-int NameToAddr (const char *, struct in_addr *);
-int NameToPort (const char *, unsigned short *, const char *);
-#ifdef __GNUC__
-	void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-	void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-	void quit (const char *, ...);
-	void pbomb (const char *, ...);
-	void hbomb (const char *, ...);
-#endif
-void set_signal_handler (int, signal_handler_t);
-
-#define __PORT__ 9000
-#define __MOITA_FOI_SOLICITADA__ "moita"
-#define __OK__ "ok"
-
-struct accept
-{
-	int newfd;
-	struct sockaddr_in sa;
-};
-
-struct main_loop
-{
-	int listen_fd,
-		ra_1,
-		ra_2,
-		ra_3,
-		ra_4;
-};
-
-struct client
-{
-	char * user;
-	int client_fd;
-	int jabber_fd;
-	int keep_alive;
-	time_t last_action;
-	struct client * next;
-	struct client * previous;
-};
-
-struct cat
-{
-	int in_fd,
-		out_fd;
-	int jabber,
-		keep_alive;
-	struct client * client;
-};
-
-struct client * clients = (struct client *)NULL;
-
-pthread_mutex_t mutexsum;
-
-int main (int argc, char ** argv)
-{
-	struct in_addr remote_addr_1,
-				   remote_addr_2,
-				   remote_addr_3,
-				   remote_addr_4;
-	int listen_fd_1,
-		listen_fd_2,
-		listen_fd_3,
-		listen_fd_4,
-		listen_fd_5;
-
-	pthread_t port_9001,
-			  port_9002,
-			  port_9003,
-			  port_9004,
-			  port_9005;
-
-	//ParseArgs (argc, argv, &remote_addr_1, &remote_addr_2, &remote_addr_3, &remote_addr_4);
-
-	// Create server socket before becoming a daemon so
-	// there is still a chance to print an error message.
-	listen_fd_1 = CreateServerSocket (9001);
-	listen_fd_2 = CreateServerSocket (9002);
-	listen_fd_3 = CreateServerSocket (9003);
-	listen_fd_4 = CreateServerSocket (9004);
-	listen_fd_5 = CreateServerSocket (9005);
-
-	if ( listen_fd_1 < 0 )
-		pbomb ("Unable to create server socket #1");
-
-	if ( listen_fd_2 < 0 )
-		pbomb ("Unable to create server socket #2");
-
-	if ( listen_fd_3 < 0 )
-		pbomb ("Unable to create server socket #3");
-
-	if ( listen_fd_4 < 0 )
-		pbomb ("Unable to create server socket #4");
-
-	if ( listen_fd_5 < 0 )
-		pbomb ("Unable to create server socket #5");
-
-	//Daemonise ();
-
-	//pthread_create(&port_900, NULL, (void *) &MainLoop, (void *) accept);
-	MainLoop (listen_fd_1);//, &remote_addr_1, &remote_addr_2, &remote_addr_3, &remote_addr_4); // never returns
-	//MainLoop (listen_fd, &remote_addr_1, &remote_addr_2, &remote_addr_3, &remote_addr_4); // never returns
-	//MainLoop (listen_fd, &remote_addr_1, &remote_addr_2, &remote_addr_3, &remote_addr_4); // never returns
-	//MainLoop (listen_fd, &remote_addr_1, &remote_addr_2, &remote_addr_3, &remote_addr_4); // never returns
-	//MainLoop (listen_fd, &remote_addr_1, &remote_addr_2, &remote_addr_3, &remote_addr_4); // never returns
-
-	syslog (LOG_ERR, "fim MainLoop(): %m");
-	exit (EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char ** argv, struct in_addr * ra_1, struct in_addr * ra_2, struct in_addr * ra_3, struct in_addr * ra_4)
-{
-	// argv[0] = program name
-	// argv[1] = remote_addr
-	// argv[2] = remote_port
-	// argv[3] = local_addr (optional)
-	// argv[4] = local_port (optional)
-
-	char * p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
-
-	if ( (argc < 5) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr_1 remote_addr_2 remote_addr_3 remote_addr_4\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr (argv[1], ra_1) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToAddr (argv[2], ra_2) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[2]);
-
-	if ( NameToAddr (argv[3], ra_3) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( NameToAddr (argv[4], ra_4) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	//set_signal_handler (SIGCHLD, sig_child);
-
-	//signal (SIGPIPE, SIG_IGN);
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (int port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_addr.s_addr = htonl(INADDR_ANY);
-	sa.sin_port = htons (port);
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if ( err < 0 )
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd)
-{
-	struct accept * client;
-	unsigned int addr = 0;
-	char buf[250];
-
-	int bytes_rcvd,
-		bytes_sent,
-		usando_moita = 0,
-		size_of_buffer,
-		i;
-
-	time_t inicio = time(NULL);
-
-	for ( ; ; )
-	{
-		client = AcceptClientConnection (listen_fd);
-		addr = ntohl(client->sa.sin_addr.s_addr);
-
-		sprintf(buf,"%d.%d.%d.%d",
-				(addr >> 24)  , (addr >> 16) & 0xFF ,
-				(addr >> 8) & 0xFF ,  addr & 0xFF);
-
-		printf("New connection: %s :: %d\n", buf, ntohs(client->sa.sin_port));
-
-		bzero(buf, 250);
-
-		if ( (bytes_rcvd = recv(client->newfd, buf, 128, 0)) < 1 )
-			printf("error in recv #1\n");
-		else
-		{
-			if ( strcmp(buf, __MOITA_FOI_SOLICITADA__) == 0 )
-				if ( !usando_moita )
-				{
-					bzero(buf, 250);
-					sprintf(buf, __OK__);
-					size_of_buffer = sizeof(buf);
-					for ( i = 0; i < size_of_buffer; i += bytes_sent )
-					{
-						bytes_sent = send (client->newfd, buf + i, sizeof(buf) - i, 0);
-
-						if ( bytes_sent < 0 )
-							break;
-					}
-				}
-		}
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-struct accept * AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog (LOG_ERR, "accept(): %m"), pthread_exit(0);
-
-	if ( socklen != sizeof (sa) )
-		syslog (LOG_ERR, "accept() screwed up!"), pthread_exit(0);
-
-	struct accept * new_accept = (struct accept *) malloc(sizeof(struct accept));
-	new_accept->newfd = newfd;
-	new_accept->sa = sa;
-
-	return (new_accept);
-}
-
-void VerifyClient(void * accept)
-{
-	int jabber_fd = (int)NULL;
-	struct accept * client = (struct accept *) accept;
-	struct client * user = (struct client *)NULL;
-	struct cat * info;
-	pthread_t cat_thread;
-
-	unsigned int addr = 0;
-	char buf[250];
-	addr = ntohl(client->sa.sin_addr.s_addr);
-	sprintf(buf,"%d.%d.%d.%d",
-			(addr >> 24)  , (addr >> 16) & 0xFF ,
-			(addr >> 8) & 0xFF ,  addr & 0xFF);
-	//printf("New connection: %s\n", buf);
-
-	//if ( strcmp(buf, "10.15.20.42") == 0 )//|| strcmp(buf, "10.15.20.202") == 0 )
-	//{
-	//	user = Handshake(client->newfd);
-	//	jabber_fd = user->jabber_fd;
-	//}
-
-	if ( jabber_fd == (int)NULL )
-	{
-		//jabber_fd = ConnectToServer(client->jabber_addr, client->jabber_port);
-
-		if ( user != (struct client *)NULL )
-			user->jabber_fd = jabber_fd;
-	}
-
-	info = (struct cat *) malloc(sizeof(struct cat));
-
-	info->out_fd = jabber_fd;
-	info->in_fd = client->newfd;
-	info->jabber = (int)NULL;
-	info->keep_alive = (int)NULL;
-	info->client = user;
-
-	pthread_create(&cat_thread, NULL, (void *) &Cat, (void *)info );
-
-	pthread_exit(0);
-}
-
-struct client * Handshake(int newfd)
-{
-	float is_new_client;// = (float) NULL;
-	int bytes_rcvd,
-		bytes_sent,
-		i;
-
-	unsigned char * const buf = (char *) malloc (sizeof(char) * 5);
-	char * user = (char *) malloc(128 * sizeof(char)),
-		 * pass = (char *) malloc(128 * sizeof(char));
-
-	//struct client * clients = (struct client *)NULL;
-	struct client * new_client = (struct client *)NULL;
-
-	bzero(buf, 5);
-	sprintf(buf, "user");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(user, 128);
-	if ( (bytes_rcvd = recv (newfd, user, 128, 0)) < 1 )
-		pthread_exit(0);
-
-	bzero(buf, 5);
-	sprintf(buf, "pass");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(pass, 128);
-	if ( (bytes_rcvd = recv (newfd, pass, 128, 0)) < 1 )
-		pthread_exit(0);
-
-	pthread_mutex_lock (&mutexsum);
-	if ( clients == (struct client *)NULL )
-	{
-		clients = (struct client *) malloc(sizeof(struct client));
-
-		new_client = clients;
-		new_client->previous = (struct client *)NULL;
-		is_new_client = 1;
-	}
-	else
-	{
-		new_client = clients;
-		while ( ((is_new_client = (float)strcmp(new_client->user, user)) != 0) && (new_client->next != (struct client *)NULL) )
-			new_client = new_client->next;
-
-		if ( is_new_client != 0 )
-		{
-			new_client->next = (struct client *) malloc(sizeof(struct client));
-			new_client->next->previous = new_client;
-			new_client = new_client->next;
-		}
-	}
-
-	if ( is_new_client != 0 )
-	{
-		new_client->user = user;
-		new_client->jabber_fd = (int)NULL;
-		new_client->keep_alive = 1;
-		new_client->next = (struct client *)NULL;
-	}
-
-	bzero(buf, 5);
-	if ( is_new_client != 0 || new_client->jabber_fd == (int)NULL  )
-		sprintf(buf, "new");
-	else
-		sprintf(buf, "rec");
-
-	send (newfd, buf, 3, 0);
-
-	new_client->client_fd = newfd;
-	new_client->last_action = time(NULL);
-	pthread_mutex_unlock(&mutexsum);
-
-	return new_client;
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO: have a timeout for connect() - see Unix socket FAQ 6.2
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), pthread_exit(0);//exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		//exit (EXIT_FAILURE);
-		pthread_exit(0);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-//void Cat (int in_fd, int out_fd)
-//void Cat (int in_fd, int out_fd)
-void Cat (void * info)
-{
-	unsigned char * const buf_in = (char *) malloc (sizeof(char) * BUF_SIZE);
-	unsigned char * const buf_out = (char *) malloc (sizeof(char) * BUF_SIZE);
-	int bytes_rcvd_in = (int) NULL,
-		bytes_sent_in = (int) NULL,
-		bytes_rcvd_out = (int) NULL,
-		bytes_sent_out = (int) NULL,
-		i,
-		in_fd,
-		out_fd;
-	struct cat * user = (struct cat *) info;
-	in_fd = user->in_fd;
-	out_fd = user->out_fd;
-
-	syslog (LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf_in == NULL || buf_out == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), pthread_exit(0);
-
-	fcntl(in_fd, F_SETFL, fcntl(in_fd, F_GETFL, 0) | O_NDELAY);
-	fcntl(out_fd, F_SETFL, fcntl(out_fd, F_GETFL, 0) | O_NDELAY);
-
-	bzero(buf_in, BUF_SIZE);
-	bzero(buf_out, BUF_SIZE);
-	do
-	{
-		bzero(buf_in, BUF_SIZE);
-		if ( (bytes_rcvd_in = recv (in_fd, buf_in, BUF_SIZE, 0)) != 0 && strlen(buf_out) > 0 )
-		{
-			for ( i = 0; i < bytes_rcvd_out; i += bytes_sent_in )
-			{
-				bytes_sent_in = send (in_fd, buf_out + i, bytes_rcvd_out - i, 0);
-
-				if ( bytes_sent_in < 0 )
-					break;
-			}
-		}
-
-		bzero(buf_out, BUF_SIZE);
-		if ( (bytes_rcvd_out = recv (out_fd, buf_out, BUF_SIZE, 0)) != 0 && strlen(buf_in) > 0 )
-		{
-			//printf("\n%s\n", buf_in);
-			for ( i = 0; i < bytes_rcvd_in; i += bytes_sent_out )
-			{
-				bytes_sent_out = send (out_fd, buf_in + i, bytes_rcvd_in - i, 0);
-
-				if ( bytes_sent_out < 0 )
-					break;
-			}
-		}
-		usleep(500);
-	}
-	while ( (bytes_rcvd_in != 0) && (bytes_rcvd_out != 0) );
-
-	if ( ((bytes_rcvd_in < 0) || (bytes_rcvd_out < 0)) && (errno != ECONNRESET) )
-		syslog (LOG_ERR, "recv(): %m"), pthread_exit(0);
-
-	if ( ((bytes_sent_in < 0) || (bytes_sent_out < 0)) && (errno != EPIPE) )
-		syslog (LOG_ERR, "send(): %m"), pthread_exit(0);
-
-	if ( user->jabber && !user->keep_alive )
-	{
-		shutdown(user->jabber, SHUT_RDWR);
-		close(user->jabber);
-	}
-	pthread_exit(0);
-	free (buf_in);
-	free (buf_out);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO: use inet_aton() instead
-	p_inaddr->s_addr = inet_addr (name);
-	if ( p_inaddr->s_addr != -1U ) // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname (name);
-	if ( he != NULL ) // Success
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul (name, &errpos, 0);
-	if ( (*errpos == 0) && (lport <= 65535) ) // Success
-	{
-		*port = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname (name, proto);
-	if ( se != NULL) // Success
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char * fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char * fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char * fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction (signum, &act, NULL) < 0 )
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/socket/server_thread.c
===================================================================
--- /trunk/instant_messenger/bkp/socket/server_thread.c	(revision 216)
+++ 	(revision )
@@ -1,614 +1,0 @@
-#include "server.h"
-
-struct accept
-{
-	int newfd;
-	struct sockaddr_in sa;
-	struct in_addr jabber_addr;
-	unsigned short jabber_port;
-};
-
-struct client
-{
-	char * user;
-	int client_fd;
-	int jabber_fd;
-	int keep_alive;
-	time_t last_action;
-	struct client * next;
-};
-
-struct cat
-{
-	int in_fd,
-		out_fd;
-	int jabber,
-		keep_alive;
-	struct client * client;
-};
-
-struct client * clients = (struct client *)NULL;
-
-pthread_mutex_t mutexsum;
-
-int main (int argc, char ** argv)
-{
-	struct in_addr remote_addr,
-				   local_addr;
-	unsigned short remote_port,
-				   local_port;
-	int listen_fd;
-
-	ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
-
-	Initialise ();
-
-	// Create server socket before becoming a daemon so
-	// there is still a chance to print an error message.
-	listen_fd = CreateServerSocket (local_addr, local_port);
-	if ( listen_fd < 0 )
-		pbomb ("Unable to create server socket");
-
-	//Daemonise ();
-
-	MainLoop (listen_fd, remote_addr, remote_port); // never returns
-
-	exit (EXIT_SUCCESS);
-}
-
-// ParseArgs()
-// Parse the command line arguments to extract the remote
-// and local adresses and port numbers, ra, rp, la & lp.
-// Exit the program gracefully upon error.
-void ParseArgs (int argc, char ** argv, struct in_addr * ra, unsigned short * rp, struct in_addr * la, unsigned short * lp)
-{
-	// argv[0] = program name
-	// argv[1] = remote_addr
-	// argv[2] = remote_port
-	// argv[3] = local_addr (optional)
-	// argv[4] = local_port (optional)
-
-	char * p = strrchr (argv[0], '/');
-
-	strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
-
-	if ( (argc < 3) || (argc > 5) )
-	{
-		fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
-		exit (EXIT_FAILURE);
-	}
-
-	if ( NameToAddr (argv[1], ra) )
-		hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
-
-	if ( NameToPort (argv[2], rp, "tcp") )
-		quit ("Unable to resolve \"%s\" to a port number", argv[2]);
-
-	if ( argc < 4 )
-		la->s_addr = htonl (INADDR_ANY);
-	else
-		if ( NameToAddr (argv[3], la) )
-			hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
-
-	if ( argc < 5 )
-		memcpy (lp, rp, sizeof (*lp));
-	else
-		if ( NameToPort (argv[4], lp, "tcp") )
-			quit ("Unable to resolve \"%s\" to a port number", argv[4]);
-}
-
-// Initialise()
-// Setup syslog, signal handlers, and other intialisation.
-void Initialise (void)
-{
-	openlog (g_program_name, LOG_PID, LOG_USER);
-	syslog (LOG_INFO, "%s started", g_program_name);
-
-	chdir ("/"); // Change working directory to the root.
-
-	umask (0); // Clear our file mode creation mask
-
-	//set_signal_handler (SIGCHLD, sig_child);
-
-	//signal (SIGPIPE, SIG_IGN);
-}
-
-// CreateServerSocket()
-// Create a socket, bind it to the specified address
-// and port, and set it to listen for client connections.
-// Returns < 0 on failure to bind, bombs on error otherwise,
-// returns the fd of the new socket on success.
-int CreateServerSocket (struct in_addr addr, unsigned short port)
-{
-	int err,
-		fd;
-	const int on = 1;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
-
-	// Set SO_REUSEADDR socket option
-	if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
-		syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
-
-	// Load a sa structure with the specified address and port
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	//sa.sin_addr = addr;
-	sa.sin_addr.s_addr = htonl(INADDR_ANY);
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	// Bind our socket to the address and port specified
-	err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if ( err < 0 )
-	{
-		syslog (LOG_ERR, "bind(): %m");
-		return err;
-	}
-
-	// Tell socket to listen and queue up to 5 incoming connections.
-	if ( listen (fd, 5) < 0 )
-		syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
-
-	return fd;
-}
-
-// MainLoop()
-// Classic concurrent server model.
-// Wait for a client to connect, fork a child process
-// to do the business with the client, parent process
-// continues to wait for the next connection.
-// This function does not return.
-void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
-{
-	struct accept * accept;
-	pthread_t accept_thread,
-			  clear_list_thread;
-
-	pthread_mutex_init(&mutexsum, NULL);
-
-	pthread_create(&clear_list_thread, NULL, (void *) &ClearList, (void *)NULL );
-
-	for ( ; ; )
-	{
-		accept = AcceptClientConnection (listen_fd);
-		accept->jabber_addr = rem_addr;
-		accept->jabber_port = rem_port;
-
-		pthread_create(&accept_thread, NULL, (void *) &VerifyClient, (void *) accept);
-	}
-	pthread_mutex_destroy(&mutexsum);
-	pthread_exit(NULL);
-}
-
-void ClearList(void)
-{
-	struct client * current;
-
-	for ( ; ; )
-	{
-		current = clients;
-		pthread_mutex_lock(&mutexsum);
-		while ( current != (struct client *)NULL )
-		{
-			if ( time(NULL) - current->last_action > 30 )
-			{
-				shutdown(current->jabber_fd, SHUT_RDWR);
-				close(current->jabber_fd);
-				current->jabber_fd = (int)NULL;
-			}
-			current = current->next;
-		}
-		pthread_mutex_unlock(&mutexsum);
-		sleep(2);
-	}
-}
-
-// AcceptClientConnection()
-// waits for a tcp connect to the socket listen_fd, which
-// must already be bound and set to listen on a local port.
-// Bombs on error, returns the fd of the new socket on success.
-struct accept * AcceptClientConnection (int listen_fd)
-{
-	int newfd;
-	struct sockaddr_in sa;
-	socklen_t socklen;
-
-	syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
-
-	// Accept the connection and create a new socket for it.
-	socklen = sizeof (sa);
-	memset (&sa, 0, socklen);
-	do
-	{
-		newfd = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
-	}
-	while ( (newfd < 0) && (errno == EINTR) );
-
-	syslog (LOG_INFO, "Accepted client connection on new socket fd%d", newfd);
-
-	if ( newfd < 0 )
-		syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
-
-	if ( socklen != sizeof (sa) )
-		syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
-
-	struct accept * new_accept = (struct accept *) malloc(sizeof(struct accept));
-	new_accept->newfd = newfd;
-	new_accept->sa = sa;
-
-	return (new_accept);
-}
-
-void VerifyClient(void * accept)
-{
-	int jabber_fd = (int)NULL;
-	struct accept * client = (struct accept *) accept;
-	struct client * user = (struct client *)NULL;
-	struct cat * info_1,
-			   * info_2;
-	pthread_t client_server_thread,
-			  server_client_thread;
-
-	unsigned int addr = 0;
-	char buf[250];
-	addr = ntohl(client->sa.sin_addr.s_addr);
-	sprintf(buf,"%d.%d.%d.%d",
-			(addr >> 24)  , (addr >> 16) & 0xFF ,
-			(addr >> 8) & 0xFF ,  addr & 0xFF);
-	//printf("New connection: %s\n", buf);
-
-	if ( strcmp(buf, "10.15.20.202") == 0 )
-	{
-		user = Handshake(client->newfd);
-		jabber_fd = user->jabber_fd;
-	}
-
-	if ( jabber_fd == (int)NULL )
-	{
-		jabber_fd = ConnectToServer(client->jabber_addr, client->jabber_port);
-
-		if ( user != (struct client *)NULL )
-			user->jabber_fd = jabber_fd;
-	}
-
-	info_1 = (struct cat *) malloc(sizeof(struct cat));
-	info_2 = (struct cat *) malloc(sizeof(struct cat));
-
-	info_1->out_fd = jabber_fd;
-	info_1->in_fd = client->newfd;
-	info_1->jabber = (int)NULL;
-	info_1->keep_alive = (int)NULL;
-	info_1->client = user;
-
-	pthread_create(&client_server_thread, NULL, (void *) &Cat, (void *)info_1 );
-
-	info_2->in_fd = jabber_fd;
-	info_2->out_fd = client->newfd;
-	info_2->jabber = jabber_fd;
-	info_2->keep_alive = (int)NULL;
-	if ( user != (struct client *)NULL )
-		info_2->keep_alive = 1;
-	info_2->client = (struct client *)NULL;
-
-	pthread_create(&client_server_thread, NULL, (void *) &Cat, (void *)info_2 );
-
-	pthread_exit(0);
-}
-
-struct client * Handshake(int newfd)
-{
-	float is_new_client;// = (float) NULL;
-	int bytes_rcvd,
-		bytes_sent,
-		i;
-
-	unsigned char * const buf = (char *) malloc (sizeof(char) * 5);
-	char * user = (char *) malloc(128 * sizeof(char)),
-		 * pass = (char *) malloc(128 * sizeof(char));
-
-	//struct client * clients = (struct client *)NULL;
-	struct client * new_client = (struct client *)NULL;
-
-	bzero(buf, 5);
-	sprintf(buf, "user");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(user, 128);
-	if ( (bytes_rcvd = recv (newfd, user, 128, 0)) < 1 )
-		pthread_exit(0);
-
-	bzero(buf, 5);
-	sprintf(buf, "pass");
-	for ( i = 0; i < sizeof(buf); i += bytes_sent )
-	{
-		bytes_sent = send (newfd, buf + i, sizeof(buf) - i, 0);
-
-		if ( bytes_sent < 0 )
-			break;
-	}
-
-	bzero(pass, 128);
-	if ( (bytes_rcvd = recv (newfd, pass, 128, 0)) < 1 )
-		pthread_exit(0);
-
-	pthread_mutex_lock (&mutexsum);
-	if ( clients == (struct client *)NULL )
-	{
-		clients = (struct client *) malloc(sizeof(struct client));
-
-		new_client = clients;
-		is_new_client = 1;
-	}
-	else
-	{
-		new_client = clients;
-		while ( ((is_new_client = (float)strcmp(new_client->user, user)) != 0) && (new_client->next != (struct client *)NULL) )
-			new_client = new_client->next;
-
-		if ( is_new_client != 0 )
-		{
-			new_client->next = (struct client *) malloc(sizeof(struct client));
-			new_client = new_client->next;
-		}
-	}
-
-	if ( is_new_client != 0 )
-	{
-		new_client->user = user;
-		new_client->jabber_fd = (int)NULL;
-		new_client->keep_alive = 1;
-		new_client->next = (struct client *)NULL;
-	}
-	new_client->client_fd = newfd;
-	new_client->last_action = time(NULL);
-	pthread_mutex_unlock(&mutexsum);
-
-	return new_client;
-}
-
-// ConnectToServer()
-// attempts a tcp connect to the server specified
-// by addr and port.  Bombs on failure to connect,
-// returns the fd of the new socket on success.
-int ConnectToServer (struct in_addr addr, unsigned short port)
-{
-	// TODO: have a timeout for connect() - see Unix socket FAQ 6.2
-
-	int fd, err;
-	struct sockaddr_in sa;
-
-	// Create a socket and get its descriptor.
-	fd = socket (AF_INET, SOCK_STREAM, 0);
-
-	if ( fd < 0 )
-		syslog (LOG_ERR, "socket(): %m"), pthread_exit(0);//exit (EXIT_FAILURE);
-
-	sa.sin_family = AF_INET;
-	sa.sin_port = htons (port);
-	sa.sin_addr = addr;
-	memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
-
-	err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
-	if (err < 0)
-	{
-		syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
-		//exit (EXIT_FAILURE);
-		pthread_exit(0);
-	}
-
-	syslog (LOG_INFO, "Connected socket fd%d to server", fd);
-
-	return fd;
-}
-
-// Cat()
-// read data from in_fd and write it to out_fd until
-// the connection is closed by one of the peers.
-// Data is copied using a dynamically allocated buffer.
-//void Cat (int in_fd, int out_fd)
-//void Cat (int in_fd, int out_fd)
-void Cat (void * info)
-{
-	unsigned char * const buf = (char *) malloc (sizeof(char) * BUF_SIZE);
-	int bytes_rcvd,
-		bytes_sent = (int) NULL,
-		i,
-		in_fd,
-		out_fd;
-	struct cat * user = (struct cat *) info;
-	in_fd = user->in_fd;
-	out_fd = user->out_fd;
-
-	syslog (LOG_INFO, "Cat(fd%d, fd%d)", in_fd, out_fd);
-
-	if ( buf == NULL )
-		syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
-
-	do
-	{
-		bzero(buf, BUF_SIZE);
-		bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
-
-		for ( i = 0; i < bytes_rcvd; i += bytes_sent )
-		{
-			bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
-
-			if ( bytes_sent < 0 )
-				break;
-		}
-	}
-	while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
-
-	if ( (bytes_rcvd < 0) && (errno != ECONNRESET) )
-		syslog (LOG_ERR, "recv(): %m"), exit (EXIT_FAILURE);
-
-	if ( (bytes_sent < 0) && (errno != EPIPE) )
-		syslog (LOG_ERR, "send(): %m"), exit (EXIT_FAILURE);
-
-	if ( user->jabber && !user->keep_alive )
-	{
-		shutdown(user->jabber, SHUT_RDWR);
-		close(user->jabber);
-	}
-	pthread_exit(0);
-	free (buf);
-}
-
-// NameToAddress()
-// Convert name to an ip address.
-// Returns 0 on success, -1 on failure.
-int NameToAddr (const char * name, struct in_addr * p_inaddr)
-{
-	struct hostent * he;
-
-	// First, attempt to convert from string ip format
-	// TODO: use inet_aton() instead
-	p_inaddr->s_addr = inet_addr (name);
-	if ( p_inaddr->s_addr != -1U ) // Success
-		return 0;
-
-	// Next, attempt to read from /etc/hosts or do a DNS lookup
-	he = gethostbyname (name);
-	if ( he != NULL ) // Success
-	{
-		memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
-		return 0;
-	}
-
-	return -1; // Failed to resolve name to an ip address
-}
-
-// NameToPort()
-// Convert name to a port number. Name can either be a port name
-// (in which case proto must also be set to either "tcp" or "udp")
-// or name can be the ascii representation of the port number.
-// Returns 0 on success, -1 on failure.
-int NameToPort (const char * name, unsigned short * port, const char * proto)
-{
-	unsigned long lport;
-	char * errpos;
-	struct servent * se;
-
-	// First, attempt to convert string to integer
-	lport = strtoul (name, &errpos, 0);
-	if ( (*errpos == 0) && (lport <= 65535) ) // Success
-	{
-		*port = lport;
-		return 0;
-	}
-
-	// Next, attempt to read the string from /etc/services
-	se = getservbyname (name, proto);
-	if ( se != NULL) // Success
-	{
-		*port = ntohs (se->s_port);
-		return 0;
-	}
-
-	return -1; // Failed to resolve port name to a number
-}
-
-// quit()
-// Print an error message to stderr
-// and syslog, then exit the program.
-void quit (const char * fmt, ...) // quit with msg
-{
-	va_list ap;
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vfprintf (stderr, fmt, ap);
-	va_end (ap);
-
-	fputc ('\n', stderr);
-
-	syslog (LOG_ERR, "I quit!");
-
-	exit (EXIT_FAILURE);
-}
-
-// pbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// pbomb() additionally include the
-// string representation of errno.
-void pbomb (const char * fmt, ...) // bomb with perror
-{
-	va_list ap;
-	int errno_save = errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	errno = errno_save;
-	perror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %m", buf);
-
-	exit (EXIT_FAILURE);
-}
-
-// hbomb()
-// Print an error message to stderr
-// and syslog, then exit the program.
-// hbomb() additionally include the
-// string representation of h_errno.
-void hbomb (const char * fmt, ...) // bomb with herror
-{
-	va_list ap;
-	int h_errno_save = h_errno;
-	char buf[100];
-
-	fflush (stdout);
-
-	fprintf (stderr, "%s: ", g_program_name);
-
-	va_start (ap, fmt);
-	vsnprintf (buf, sizeof (buf), fmt, ap);
-	va_end (ap);
-
-	h_errno = h_errno_save;
-	herror (buf);
-
-	syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
-
-	exit (EXIT_FAILURE);
-}
-
-// set_signal_handler()
-// Sets a signal handler function.
-// Similar to signal() but this method
-// is more portable between platforms.
-void set_signal_handler (int signum, signal_handler_t sa_handler_func)
-{
-	struct sigaction act;
-
-	act.sa_handler = sa_handler_func;
-	sigemptyset (&(act.sa_mask));
-	act.sa_flags = 0;
-
-	if ( sigaction (signum, &act, NULL) < 0 )
-	{
-		syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
-		exit (EXIT_FAILURE);
-	}
-}
Index: unk/instant_messenger/bkp/instant_messenger_32/setup/phpgw_pt-br.lang
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/setup/phpgw_pt-br.lang	(revision 151)
+++ 	(revision )
@@ -1,78 +1,0 @@
-Add	instant_messenger	pt-br	Adicionar
-Add Contatct	instant_messenger	pt-br	Adicionar Contato
-add contact	instant_messenger	pt-br	Adicionar Contato
-add new contact	instant_messenger	pt-br	Adicionar Novo Contato
-add user	instant_messenger	pt-br	Adicionar Usuário
-Added information!	instant_messenger	pt-br	Informações Adicionadas!
-Authorization	instant_messenger	pt-br	Autorização
-away	instant_messenger	pt-br	Ausente
-Birthday	instant_messenger	pt-br	Aniversário
-busy	instant_messenger	pt-br	Ocupado
-change your Status	instant_messenger	pt-br	Mude seu estado
-Choice Contact	instant_messenger	pt-br	Escolha Contato
-Close	instant_messenger	pt-br	Fechar
-Close this menu	instant_messenger	pt-br	Fechar Menu
-Color	instant_messenger	pt-br	Cor
-Contact	instant_messenger	pt-br	Contato
-Contact Add	instant_messenger	pt-br	Contato Adicionado
-Custom message...	instant_messenger	pt-br	Mensagem ...
-Delete	instant_messenger	pt-br	Remover
-Description	instant_messenger	pt-br	Descrição
-Error in the message!	instant_messenger	pt-br	Erro na mensagem!
-E-mail	instant_messenger	pt-br	E-mail
-Font	instant_messenger	pt-br	Fonte
-Full Name	instant_messenger	pt-br	Nome Completo
-Group	instant_messenger	pt-br	Grupo
-instant_messenger	common	pt-br	Mensageiro Instantâneo
-instant_messenger_t	instant_messenger	pt-br	Mensageiro Instantâneo
-Information	instant_messenger	pt-br	Informações Adicionais
-Information User	instant_messenger	pt-br	Informações Pessoais
-Jid Contact	instant_messenger	pt-br	Email Expresso
-List of Contacts	instant_messenger	pt-br	Lista de Contatos
-Loading...	instant_messenger	pt-br	Carregando...
-Maximize/Restore	instant_messenger	pt-br	Maximizar/Restaurar Janela
-Minimize	instant_messenger	pt-br	Minimizar Janela
-Name	instant_messenger	pt-br	Nome
-Name full	instant_messenger	pt-br	Nome Completo
-Name Organization	instant_messenger	pt-br	Nome Organização
-New Message!	instant_messenger	pt-br	Nova Mensagem!
-Nick	instant_messenger	pt-br	Apelido
-Nickname	instant_messenger	pt-br	Apelido
-Not Auth	instant_messenger	pt-br	Não Autorizado
-Orgname	instant_messenger	pt-br	Organização
-Orgunit	instant_messenger	pt-br	Setor
-online	instant_messenger	pt-br	Online
-offline	instant_messenger	pt-br	Offline
-Options	instant_messenger	pt-br	Opções
-Photo	instant_messenger	pt-br	Foto
-Problems in its register \n	instant_messenger	pt-br	Problemas em seu registro
-preferences	instant_messenger	pt-br	Preferências
-Quick Contacts	instant_messenger	pt-br	Contatos Rápidos
-Re-connect Expresso Messenger ?	instant_messenger	pt-br	Reconectar Expresso Messenger ?
-Remove	instant_messenger	pt-br	Remover
-Remove Contact	instant_messenger	pt-br	Remover Contato
-Resize	instant_messenger	pt-br	Redimensionar
-Role	instant_messenger	pt-br	Função
-save	instant_messenger	pt-br	Salvar
-Search	instant_messenger	pt-br	Pesquisar
-Search, add, or invite	instant_messenger	pt-br	Procure, adicione ou convide
-See Info	instant_messenger	pt-br	Ver Info
-Send	instant_messenger	pt-br	Enviar
-Send File	instant_messenger	pt-br	Enviar Arquivo
-Size	instant_messenger	pt-br	Tamanho
-speak	instant_messenger	pt-br	fala
-Successfully effected register!	instant_messenger	pt-br	Registro efetuado com sucesso!
-Status	instant_messenger	pt-br	Status
-Status of the Transference	instant_messenger	pt-br	Status da Transferência
-Style	instant_messenger	pt-br	Estilo
-Telephone	instant_messenger	pt-br	Telefone
-to see preferences	instant_messenger	pt-br	Ver Preferências
-To define user information	instant_messenger	pt-br	Definir informações do usuário
-Update	instant_messenger	pt-br	Atualizar
-Vcard	instant_messenger	pt-br	Vcard
-You desire to register in service IM?	instant_messenger	pt-br	Você deseja registrar no serviço IM?
-your status	instant_messenger	pt-br	Seu status
-Wait a moment !!	pt-br	instant_messenger	Aguarde um momento !!
-waiting	instant_messenger	pt-br	Aguardando
-without_group	instant_messenger	pt-br	Sem Grupo
-Workgroup	instant_messenger	pt-br	Setor
Index: unk/instant_messenger/bkp/instant_messenger_32/setup/tables_current.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/setup/tables_current.inc.php	(revision 151)
+++ 	(revision )
@@ -1,24 +1,0 @@
-<?php
-	/***************************************************************************\
-	* Mensageiro Instantâneo												    *
-	* Alexandre Correia / Rodrigo Souza										    *
-	* ------------------------------------------------------------------------- *
-	*  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.                                               *
-	\***************************************************************************/
-  
-	$phpgw_baseline = array(
-		'phpgw_im_auth_user' => array(
-			'fd' => array(
-				'im_from' => array( 'type' => 'varchar', 'precision' => 150, 'nullable' => false ),
-				'im_to' => array( 'type' => 'varchar', 'precision' => 150, 'nullable' => false )
-			),
-			'pk' => array(),
-			'fk' => array(),
-			'ix' => array(),
-			'uc' => array()
-		),
-	);
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/setup/setup.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/setup/setup.inc.php	(revision 151)
+++ 	(revision )
@@ -1,32 +1,0 @@
-<?php
-	/****************************************************\
-	 * Im - Instant Messenger							*
-	 * Alexandre Correia								*
-	 * Rodrigo Souza									*
-	\****************************************************/
-	
-	$setup_info['instant_messenger']['name']      	= 'instant_messenger';
-	$setup_info['instant_messenger']['title']     	= 'Mensageiro Instantâneo';
-	$setup_info['instant_messenger']['version']   	= '0.2';
-	$setup_info['instant_messenger']['app_order'] 	= 9;
-	$setup_info['instant_messenger']['enable']    	= 1;
-	
-	/* Conf Table */
-	$setup_info['instant_messenger']['tables'][] = 'phpgw_im_auth_user';
-
-	$setup_info['instant_messenger']['author'] 			= '<b>Coordenadores do Projeto</b> : <br> - Joao Alfredo Knopik Junior (jakjr@celepar.pr.gov.br)<br> - Nilton Emilio Buhrer Neto (niltonneto@celepar.pr.gov.br)<br> <b>Desenvolvedores</b> <br> - Alexandre Correia (alexandrecorreia@celepar.pr.gov.br)<br>- Rodrigo Souza Santos (rodsouza@celepar.pr.gov.br)';
-	$setup_info['instant_messenger']['maintainer']	 	=  'Os mesmos';
-	$setup_info['instant_messenger']['maintainer_email']= '';
-
-	$setup_info['instant_messenger']['license']  	= 'GPL';
-	$setup_info['instant_messenger']['description'] = 'Módulo de IM com protocolo Jabber';
-
-	/* The hooks this app includes, needed for hooks registration */
-	$setup_info['instant_messenger']['hooks'][] = 'admin';
-		
-	/* Dependencies for this app to work */
-	$setup_info['instant_messenger']['depends'][] = array(
-		'appname' => 'phpgwapi',
-		'versions' => Array('0.9.14','0.9.15','1.0.0')
-	);
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/remove_user.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/remove_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,18 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/remove_user">
-		<div style="margin:20px 20px">
-			<span><b><xsl:value-of select="lang1"/> .: </b></span> 
-			<div style="margin-top:3px">
-				<select id="im_remove_contact"></select>
-				<span style="margin-left:7px">
-					<input type="button" value="{lang2}" onclick="javascript:im.remove_contact('im_remove_contact');"/>
-					<input type="button" value="{lang3}" onclick="javascript:buildIM.window_close('remove_user_im');"/>
-				</span>
-			</div>
-		</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/vcard_contacts.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/vcard_contacts.xsl	(revision 151)
+++ 	(revision )
@@ -1,29 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/retorno/vcard">
-   <html>
-   <head>
-   </head>
-   <body>
-      <div id="_im_vcard_contacts_childs">
-         <xsl:apply-templates select="div" />
-      </div>
-   </body>
-   </html>
-</xsl:template>
-
-<xsl:template match="div">
-   <div id="{@id}">
-      <FN><xsl:value-of select="FN" /></FN>
-      <NICKNAME><xsl:value-of select="NICKNAME" /></NICKNAME>      
-      <ROLE><xsl:value-of select="ROLE" /></ROLE>
-      <ORGNAME><xsl:value-of select="ORG/ORGNAME" /></ORGNAME>
-      <ORGUNIT><xsl:value-of select="ORG/ORGUNIT" /></ORGUNIT>
-      <BDAY><xsl:value-of select="BDAY" /></BDAY>
-      <DESC><xsl:value-of select="DESC" /></DESC>
-   </div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/contacts.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/contacts.xsl	(revision 151)
+++ 	(revision )
@@ -1,31 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/retorno/contacts">
-   <html>
-   <head>
-   </head>
-   <body>
-      <div id="all_groups">
-         <xsl:apply-templates select="group" />
-      </div>
-   </body>
-   </html>
-</xsl:template>
-
-<xsl:template match="group">
-   <div style="margin-left:16px;overflow:hidden;" id="{@name}">
-      <b><xsl:value-of select="@name" /></b>
-      <br />
-      <xsl:apply-templates select="item" />
-   </div>
-</xsl:template>
-
-<xsl:template match="item">
-   <div style="cursor:pointer;margin-left:8px;width:2000px" onmouseover="this.className='contato_hover'" onmouseout="this.className=''" onmousedown="javascript:IM.action_button(event, '{@jid}');" id="{@jid}">
-      <xsl:value-of select="@name" />
-   </div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/user_not_auth.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/user_not_auth.xsl	(revision 151)
+++ 	(revision )
@@ -1,41 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/jids">
-   <html>
-   <head>
-   </head>
-   <body>
-		<div style="margin-left:5px;margin-top:20px">
-			<b>
-			O(s) contato(s) abaixo aguarda(m) sua autorização.
-		    Para adicionar este(s) novo(s) contato(s) ou remover
-		    o(s) clique nas opções "Sim / Não". Para ver detalhes
-		    sobre o novo contato clique em "?".
-			<p />
-			Contato(s) :
-			</b>
-			<p />
-			<xsl:apply-templates select="item" />
-		</div>				
-   </body>
-   </html>
-</xsl:template>
-
-<xsl:template match="item">
-	 <div id="{@id}">
-        <span alt="Contato">
-        	<xsl:value-of select="@jid" />
-        </span>
-	    <span style="margin-left:20px" >
-	   		<a href="javascript:void(0);" onclick="IM_Preferences.Info_Contact('{@jid}');"> ? </a>
-	   	</span>
-		<span style="margin-left:10px">
-			<a href="javascript:void(0);" onclick="IM_Preferences.AcceptRequestUser('{@jid}');"> Sim </a>/<a href="javascript:void(0)" onclick="IM_Preferences.DenyRequestUser('{@jid}');" > Não </a>
-			<span id="_span_not_{@jid}"></span>
-		</span>
-	</div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/preferences.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/preferences.xsl	(revision 151)
+++ 	(revision )
@@ -1,32 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/preferences">
-   <html>
-   <head>
-   </head>
-   <body>
-	  <div id="im_preferences" style="margin-left:5px;margin-top:5px">
-		  <fieldset><legend> Opções :</legend>
-			  <input id="ch_offline" type="checkbox" /> Exibir amigos desconectados
-		  </fieldset>
-		  <br />
-		  <fieldset><legend> Ausente : </legend>	
-  			  Ficar ausente depois de <input id="in_time" type="input" size="2" maxlength="2"/> minutos :
-		  </fieldset>		
-		  <br />	
-  		  <fieldset>
-  		  	  <legend> Ativar aviso de mensagens recebidas :</legend>
-	    	  <input id="rd_nm" type="radio" name="rd_aviso" /> Normal <br />
-			  <input id="rd_ch" type="radio" name="rd_aviso" /> Treme Tela
-  		  </fieldset>
-		  	<br/>
-		  	<input type="button" value="Salvar" onclick="javascript:IM_Preferences.SetYourPreferences();" />
-			<input type="button" value="Fechar" onclick="javascript:im_win.windowClose('divYourPreferences_im');"/>
-	  </div>
-   </body>
-   </html>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/del_user.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/del_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,23 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/deluser/body">
-	<html>
-		<head>
-		</head>
-		<body>	
-			<div style="margin-left:20px;margin-top:20px">
-				<span><b><xsl:value-of select="@lang1"/> .: </b></span> 
-				<div style="margin-top:3px">
-					<select id="sel_contact"></select>
-					<span style="margin-left:7px">
-						<input type="button" value="{@lang2}" onclick="javascript:IM_Preferences.RemoveContact()" />
-						<input type="button" value="{@lang3}" onclick="javascript:im_win.windowClose('divDelUser_im');"/>														
-					</span>
-				</div>
-			</div>
-		</body>
-	</html>
-</xsl:template>
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/information_user.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/information_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,102 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/info_user">
-	<html>
-		<head>
-		</head>
-		<body>
-			<table border="0" cellpadding="1" cellspacing="2" width="90%" style="margin-top:10px">
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/FN"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/fn">
-						<td><input id="FN" type="text" size="40" maxlength="40" value="{vcard/fn}"/></td>			          
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="FN" type="text" size="40" maxlength="40" value="{vcard/FN}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/NICKNAME"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/nickname">
-						<td><input id="NICKNAME" type="text" size="20" maxlength="20" value="{vcard/nickname}" /></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="NICKNAME" type="text" size="20" maxlength="20" value="{vcard/NICKNAME}" /></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/ORGNAME"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/orgname">
-						<td><input id="ORGNAME" type="text" size="17" maxlength="17" value="{vcard/orgname}"/></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="ORGNAME" type="text" size="17" maxlength="17" value="{vcard/ORGNAME}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/ORGUNIT"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/orgunit">
-						<td><input id="ORGUNIT" type="text" size="10" maxlength="10" value="{vcard/orgunit}"/></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="ORGUNIT" type="text" size="10" maxlength="10" value="{vcard/ORGUNIT}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/ROLE"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/role">
-						<td><input id="ROLE" type="text" size="25" maxlength="25" value="{vcard/role}"/></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="ROLE" type="text" size="25" maxlength="25" value="{vcard/ROLE}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/BDAY"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/bday">
-						<td><input id="BDAY" type="text" size="10" maxlength="10" value="{vcard/bday}"/></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="BDAY" type="text" size="10" maxlength="10" value="{vcard/BDAY}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-				<tr>
-					<td width="30%" align="right"><xsl:value-of select="getlang/DESC"/> .: </td>
-			     	<xsl:choose>
-			          <xsl:when test="vcard/desc">
-						<td><input id="DESC" type="text" size="40" maxlength="40" value="{vcard/desc}"/></td>
-					  </xsl:when>
-			          <xsl:otherwise>
-						<td><input id="DESC" type="text" size="40" maxlength="40" value="{vcard/DESC}"/></td>
-			          </xsl:otherwise>
-			        </xsl:choose>
-				</tr>
-			</table>
-
-			<table border="0" cellpading="1" cellspacing="2" width="100%">
-				<tr>
-					<td>
-						<input type="button" value="{getlang/SAVE}" onclick="javascript:IM_Preferences.vCardAdd();" />
-						<input type="button" value="{getlang/CLOSE}" onclick="javascript:im_win.windowClose('divInfoUser_im');"/>									
-					</td>
-				</tr>
-			</table>
-		</body>
-	</html>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/message.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/message.xsl	(revision 151)
+++ 	(revision )
@@ -1,15 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/">
-   <html>
-   <head>
-   </head>
-   <body>
-      <xsl:copy-of select="." />
-   </body>
-   </html>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/menu_preferences.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/menu_preferences.xsl	(revision 151)
+++ 	(revision )
@@ -1,18 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/">
- <html>
-  <body>
-   <dl id="dl_im_menu_preferences">
-   <xsl:for-each select="menu/item">
-      <dt><a href="javascript:void(0);" onclick="javascript:{@function}">
-      	  <xsl:value-of select="@lang"/></a>
-      </dt>
-   </xsl:for-each>
-   </dl>
- </body>
- </html>
-</xsl:template>
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/add_user.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/add_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,41 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="adduser">
-
-	<div style="margin-left:5px;margin-top:5px">
-		<b><xsl:value-of select="top/lang1"/> .: </b>
-		<select id="im_ldap_ou" onchange="im.ldap_search_ou(this);"></select>
-		<span id="_span_load_im" style="background-color:#cc4444;color:white;display:none;position:absolute;right:5px;top:26px">Carregando .....</span>	
-		<select id="im_ldap_user" size="10" class="add_user" onclick="im.ldap_adduser(this);"></select>
-	</div>
-
-	<table border="0" cellpadding="1" cellspacing="2" class="add_user">
-		<tr>
-			<td class="add_user"><b><xsl:value-of select="table/lang1"/>.:</b></td>
-			<td><input id="text0" type="text" size="40" maxlength="40" readonly="true" class="add_user" /></td>		
-		</tr>
-		<tr>
-			<td class="add_user"><b><xsl:value-of select="table/lang2"/>.:</b></td>
-			<td><input id="text1" type="text" size="20" maxlength="20" class="add_user" /></td>		
-		</tr>
-		<tr>
-			<td class="add_user"><b><xsl:value-of select="table/lang3"/>.:</b></td>
-			<td><input id="text2" type="text" size="20" maxlength="20" class="add_user" /></td>		
-		</tr>
-		<tr>
-			<td><input id="text3" type="hidden" size="30" maxlength="30" /></td>
-		</tr>							
-		<tr>
-			<td colspan="2">
-				<input type="button" value="{table/lang4}" />
-				<input type="button" value="{table/lang5}" onclick="javascript:buildIM.window_close('add_user_im');" />
-				<span id="im_status_add" style="color:#f00;font-weight:bold;margin-left:10px;"></span>			
-			</td>
-		</tr>
-   	</table>
-
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/info_contact.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/info_contact.xsl	(revision 151)
+++ 	(revision )
@@ -1,61 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="no"/>
-
-<xsl:template match="/info_contact">
-	<html>
-		<head>
-		</head>
-		<body>
-			<table border="0" cellpading="1" cellspacing="2" width="90%" style="margin-top:10px">
-				<tr>
-					<td width="30%" align="right">
-						<xsl:value-of select="getlang/FN" /> :
-					</td>
-					<td width="70%" align="left">
-						<xsl:value-of select="vcard/FN" />
-						<xsl:value-of select="vcard/fn" />						
-					</td>
-				</tr>
-				<tr>
-					<td width="30%" align="right">
-						<xsl:value-of select="getlang/NICKNAME" /> :
-					</td>
-					<td width="70%" align="left">
-						<xsl:value-of select="vcard/NICKNAME" />
-						<xsl:value-of select="vcard/nickname" />						
-					</td>
-				</tr>
-				<tr>
-					<td width="30%" align="right">
-						<xsl:value-of select="getlang/ORGUNIT" /> :
-					</td>
-					<td width="70%" align="left">
-						<xsl:value-of select="vcard/ORGUNIT" />
-						<xsl:value-of select="vcard/orgunit" />						
-					</td>
-				</tr>
-				<tr>
-					<td width="30%" align="right">
-						<xsl:value-of select="getlang/ROLE" /> :
-					</td>
-					<td width="70%" align="left">
-						<xsl:value-of select="vcard/ROLE" />
-						<xsl:value-of select="vcard/role" />						
-					</td>
-				</tr>
-				<tr>
-					<td width="30%" align="right">
-						<xsl:value-of select="getlang/BDAY" /> :
-					</td>
-					<td width="70%" align="left">
-						<xsl:value-of select="vcard/BDAY" />
-						<xsl:value-of select="vcard/bday" />
-					</td>
-				</tr>
-			</table>
-		</body>
-	</html>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/info_contact_ldap.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/info_contact_ldap.xsl	(revision 151)
+++ 	(revision )
@@ -1,40 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/info_user">
- <html>
-  <head>
-  </head>
-  <body>
-	<table style="background-color:#cbdae4;width:100%;border:1px solid #809aa9">
-		<tr>
-		   <td style="vertical-align:top;width:80%">
-				<xsl:apply-templates select="item" />
-		   </td>
-		   <td style="vertical-align:top">
-		   		<span id="im_span_avatar"></span>
-	   	   </td>
-   	    </tr>
-	</table>	
- </body>
- </html>
-</xsl:template>
-
-<xsl:template match="item">
-	<div style="padding-bottom"> 
-	   <span>
-	   		<b><label><xsl:value-of select='@lang_name' /></label></b>
-	   		<br/><xsl:value-of select='@name' />
-	   </span>
-	   		<br/>
-	   		<br/>
-	   <span>
-	   		<b><label><xsl:value-of select='@lang_email' /></label></b>
-	   		<br/><xsl:value-of select='@email' />
-	   </span>
-	   		<br/>
-   </div>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/upd_user.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/upd_user.xsl	(revision 151)
+++ 	(revision )
@@ -1,40 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/updUser">
- <html>
-  <head>
-  </head>
-  <body>
-		<table border='0' cellpadding='1' cellspacing='2' align='center' width='90%'>
-			<xsl:apply-templates select="body" />
-		</table>
- </body>
- </html>
-</xsl:template>
-
-<xsl:template match="body">
-		<tr>
-			<td>
-				<input id="text0" type="hidden" size="40" maxlength="40" />
-			</td>
-		</tr>
-		<tr>
-			<td><b>Contato .:</b></td>
-			<td><span id="span0"></span></td>
-		</tr>
-		<tr>
-			<td><b><xsl:value-of select="@lang1" />.:</b></td>
-			<td><input id="text1" type="text" size="20" maxlength="20" /></td>
-		</tr>
-		<tr>
-			<td><b><xsl:value-of select="@lang2" />.:</b></td>
-			<td><input id="text2" type="text" size="20" maxlength="20" /></td>
-		</tr>
-		<tr>
-			<td colspan="2"><input type="button" value="{@lang3}" onclick="IM_Preferences.Add_user('divUpdateUser_im')" /></td>
-		</tr>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/xsl/window.xsl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/xsl/window.xsl	(revision 151)
+++ 	(revision )
@@ -1,57 +1,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="html" omit-xml-declaration="yes"/>
-
-<xsl:template match="/window">
-   <html>
-   <head>
-   </head>
-   <body>
-      <div id="{@id}_im_window_master" class="master" style="top:{@top};left:{@left};height:{(@height + 48)};width:{(@width + 12)};{@style};">
-        <div id="{@id}_im_window" class="pai" style="height:{(@height + 40)};">
-         	<div id="{@id}_im_window_icon" class="im_window_icon" />
-            <div class="tit"><xsl:value-of select="@title" /></div>
-            <xsl:apply-templates select="/" mode='buttons' />
-            <div class="filho" id="{@id}_im_window_body_inner" style="width:{@width};height:{@height};" />
-         </div>      
-      </div>
-
-      <div class="im-windowfantom-des" id="{@id}_im_window_fantom" />
-      <div class="im-windowfantom-des" id="{@id}_im_window_movable" />
-      <div class="im-window-resizehandle" id="{@id}_im_window_resize" style="visibility:hidden;" />
-   </body>
-   </html>
-</xsl:template>
-
-<xsl:template match="/window" mode="buttons">
-   <xsl:if test='@close and @close="true"'>
-      <div class="im-window-button im-window-closebutton" style="z-index:6000;right:4px" onclick="im_win.windowClose(this.parentNode.id);" />
-   </xsl:if>
-
-   <xsl:if test='@maximize and @maximize="true"'>
-      <xsl:choose>
-         <xsl:when test='@close and @close="true"'>
-            <div class="im-window-button im-window-maximizerestorebutton" style="z-index:6000;right:20px" onclick="im_win.windowMaximizeRestore(this.parentNode.id);" />
-         </xsl:when>
-         <xsl:otherwise>
-            <div class="im-window-button im-window-maximizerestorebutton" style="z-index:6000;right:4px" onclick="im_win.windowMaximizeRestore(this.parentNode.id);" />
-         </xsl:otherwise>
-      </xsl:choose>
-   </xsl:if>
-
-   <xsl:if test='@minimize and @minimize="true"'>
-      <xsl:choose>
-         <xsl:when test='@close and @close="true" and @maximize and @maximize="true"'>
-            <div class="im-window-button im-window-minimizebutton" style="z-index:6000;right:36px" onclick="im_win.windowMinimize(this.parentNode.id);" />
-         </xsl:when>
-         <xsl:when test='(@close and @close="true" or @maximize and @maximize="true") and not (@close and @close="true" and @maximize and @maximize="true")'>
-            <div class="im-window-button im-window-minimizebutton" style="z-index:6000;right:20px" onclick="im_win.windowMinimize(this.parentNode.id);" />
-         </xsl:when>
-         <xsl:otherwise>
-            <div class="im-window-button im-window-minimizebutton" style="z-index:6000;right:4px" onclick="im_win.windowMinimize(this.parentNode.id);" />
-         </xsl:otherwise>
-      </xsl:choose>
-   </xsl:if>
-</xsl:template>
-
-</xsl:stylesheet>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/Socket.abstract.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/Socket.abstract.php	(revision 151)
+++ 	(revision )
@@ -1,85 +1,0 @@
-<?php
-/*
-+-------------------------------------------------------------------------+
-|                                                                         |
-| @FILE_NAME:   Socket.abstract.php                                       |
-| @CLASS_NAME:  (abstract) Jabber                                         |
-|                                                                         |
-| @DATE:        Wed May,16 2007 07:58:59                                  |
-| @LAST_CHANGE: Wed May,16 2007 08:03:28                                  |
-|                                                                         |
-| @AUTHOR:      [NUTS] Rodrigo Souza - rodsouza@celepar.pr.gov.br         |
-|                                                                         |
-| @BRIEF:       Abstract class for connect with a socket                  |
-|                                                                         |
-+-------------------------------------------------------------------------+
-*/
-
-abstract class Socket
-{
-	protected final function open( $pSocket = false, $pTimeOut = 1, $pBlockingMode = 0 )
-	{
-      if ( !$pSocket )
-         return false;
-
-      if ( $socket = @stream_socket_client($pSocket, $errno, $errstr) )
-      {
-         stream_set_blocking($socket, $pBlockingMode);
-         stream_set_timeout($socket, $pTimeOut);
-      }
-      return $socket;
-	}
-
-   protected final function blocking($pSocket = false, $pBlockingMode = 1)
-   {
-      if ( !$pSocket || !is_resource($pSocket) )
-         return false;
-
-      stream_set_blocking($pSocket, $pBlockingMode);
-   }
-
-
-	protected function read( $pSocket = false, $pLength = 4096 )
-	{
-      ini_set( 'track_errors', '1' );
-      $php_errormsg = '';
-
-      if ( !$pSocket || !is_resource($pSocket) )
-         return false;
-
-      set_magic_quotes_runtime(0);
-      $return = @fread($pSocket, $pLength);
-      set_magic_quotes_runtime(get_magic_quotes_gpc());
-
-
-      if ( $php_errormsg )
-         return false;
-
-      return $return;
-	}
-
-	protected function write( $pSocket = false, $pData = false )
-	{
-      ini_set( 'track_errors', '1' );
-      $php_errormsg = '';
-      
-      if ( (!$pSocket || !is_resource($pSocket)) || !$pData )
-         return false;
-
-	  $return = @fwrite($pSocket, $pData);
-      
-      if ( $php_errormsg )
-         return false;
-
-      return $return;
-	}
-
-	protected final function close( $pSocket = false )
-	{
-      if ( !$pSocket || !is_resource($pSocket) )
-         return false;
-
-		return fclose($pSocket);
-	}
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/im_acl.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/im_acl.inc.php	(revision 151)
+++ 	(revision )
@@ -1,76 +1,0 @@
-<?php
-   for ( $i = 0; $i < sizeof($GLOBALS['phpgw_info']['user']['acl']); $i++ )
-   {
-      if ( $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] == 'instant_messenger')
-      {
-			require_once("im_sessions.inc.php");
-         
-         $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
-         $wz_dragdrop = $webserver_url."/phpgwapi/js/wz_dragdrop/";
-         $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
-
-         if ( strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url)-1) )
-            $webserver_url .= '/';
-
-         $webserver_url = $webserver_url . 'instant_messenger/';
-
-         require_once("IMConfigure.php");
-
-         $_transport = TRANSPORT_NON_SECURITY;
-         $_port = PORT_NON_SECURITY;
-
-			$SERVER = "127.0.0.1";
-
-			$fp  = "";
-			@$fp = stream_socket_client($_transport . "://" . $SERVER . ":" . $_port, $errno, $errstr, 10);
-
-         if ( $fp )
-         {
-            fwrite($fp, "GET /" . CONNECT . ";" . session_id() . " HTTP/1.1\r\nHost: " . $SERVER . ":" . $_port . "\r\nAccept: */*\r\n\r\n");
-
-            $js = array(
-                        $webserver_url . 'js/XMLTools.js',
-                        $webserver_url . 'js/im_functions.js',
-                        $webserver_url . 'js/im_fcommon.js',
-                        $webserver_url . 'js/im_var_globals.js',
-                        $webserver_url . 'js/im_images.js',
-                        $webserver_url . 'js/im_smiles.js',
-                        $webserver_url . 'js/im_templates.js',
-                        $webserver_url . 'js/im_win.js',
-                        $webserver_url . 'js/im_menu_action.js',
-                        $webserver_url . 'js/im_conf_font.js',
-                        $webserver_url . 'js/im_preferences.js',
-                        $webserver_url . 'js/im_init.js',
-						      $webserver_url . 'js/im_subscription.js',
-                       );
-
-            require_once('load_lang.php');
-
-         	print '
-               <link rel="stylesheet" href="' . $webserver_url . 'templates/default/css.css" />
-               <link rel="stylesheet" href="' . $webserver_url . 'templates/default/messenger.css" />
-               <script>
-                  var im_path="' . $webserver_url . '";
-                  var ini_wzdd = false;
-                  if ( !window.dd )
-                  {
-                     ini_wzdd = true;
-                     document.write(\'\<script src="' . $wz_dragdrop . 'wz_dragdrop.js"\>\<\/script\>\');
-                     var im_path="' . $webserver_url . '";
-                  }
-               </script>';
-         
-          print '
-               <script>
-                  if ( ini_wzdd )
-                     SET_DHTML("backFantom"+NO_DRAG);
-               </script>';
-
-          foreach ( $js as $key => $val )
-             print '<script src="' . $val . '?' . filemtime($_SERVER['DOCUMENT_ROOT'] . '/' . $val) . '"></script>';
-          
-         }
-         break;
-      }
-   }
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/Jabberd2.abstract.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/Jabberd2.abstract.php	(revision 151)
+++ 	(revision )
@@ -1,117 +1,0 @@
-<?php
-
-ini_set('include_path', $_SERVER['DOCUMENT_ROOT'] . '/instant_messenger/inc/');
-
-require_once 'Jabber.abstract.php';
-
-class Jabberd2 extends Jabber
-{
-   final function connect($pUser = false, $pPassword = false)
-   {
-      try
-      {
-         if ( parent::connect($pUser, $pPassword) )
-            if ( $this->presence() )
-               return true;
-
-         return false;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-   function disconnect()
-   {
-      $this->_disconnect();
-   }
-
-   final function readSocket()
-   {
-      return $this->read();
-   }
-
-   final function writeSocket($pData)
-   {
-      return $this->write($pData);
-   }
-	
-	final function setPresence($pPresence)
-	{
-		$type = ( isset($pPresence['type']) ) ? $pPresence['type'] : NULL;
-		$to = ( isset($pPresence['to']) ) ? $pPresence['to'] : NULL;
-		$show = ( isset($pPresence['show']) ) ? $pPresence['show'] : NULL;
-		$status = ( isset($pPresence['status']) ) ? $pPresence['status'] : NULL;
-		$priority = ( isset($pPresence['priority']) ) ? $pPresence['priority'] : NULL;
-		
-		$this->presence($type, $to, $show, $status, $priority);
-	}
-	/*
-	 * Vcard
-	 */
-
-   final function getVcard($pVcard)
-   {
-		$this->iq('get', $pVcard, $pVcard, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>");
-   }
-
-   final function newVcard($NewVcard)
-   {
-   	$id = $_SESSION['phpgw_info']['instant_messenger']['user'];
-   	$this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard."</vCard>");	
-   }
-	
-	/*
-	 *  Contacts
-	 */
-
-   final function getContacts()
-   {
-		$this->iq('get', 'contacts', NULL, NULL, 'jabber:iq:roster');
-   }
-   
-   final function addContacts($pContact)
-   {
-   	$addid = "adduser_" . time();
-   	$this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $pContact);
-   }
-   
-   final function removeContact($pContact)
-   {
-   	$delid  = 'deluser_' . time();
-   	$this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact."' subscription='remove'/>");
-   }
-   
-   final function updateContact($pContact)
-   {
-   	$upid = 'updateuser_' . time();
-   	$this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $pContact);
-   }
-   
-   /*
-    * Presence 
-    */
-   
-   final function SubscriptionAcceptRequest($to = NULL)
-	{
-		$this->presence("subscribed", $to);
-	}
-
-	final function SubscriptionDenyRequest($to = NULL)
-	{
-		$this->presence("unsubscribed", $to);
-	}
-
-	final function Subscribe($to = NULL)
-	{
-		$this->presence("subscribe", $to);
-	}
-
-	final function Unsubscribe($to = NULL)
-	{
-		$this->presence("unsubscribe", $to);
-	}
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/class.contacts_im.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/class.contacts_im.inc.php	(revision 151)
+++ 	(revision )
@@ -1,120 +1,0 @@
-<?php
-
-require_once "class.ldap_im.inc.php";
-require_once "class.db_im.inc.php"; 
-
-class contacts_im
-{
-	private $ldap;
-	private $db_user;
-	
-	function __construct()
-	{
-		$this->ldap = new ldap_im();
-		$this->db_user = new db_im();		
-	}
-
-	private function users_auth_im()
-	{
-		$db_acls = $this->db_user->get_accounts_acl();
-		
-		$search_uids = "|";
-		foreach($db_acls as $tmp)
-			$search_uids .= "(uidNumber=".$tmp['acl_account'].")";
-
-		// Busca Usuarios
-		$uids = $this->ldap->list_users_ldap($search_uids);
-		
-		$search_groups = "|";
-		foreach($db_acls as $tmp)
-			$search_groups .= "(gidNumber=".$tmp['acl_account'].")";
- 
-		// Busca Grupos
-		$groups = $this->ldap->list_groups_ldap($search_groups);
-	
-		$search_uids = "|";
-		if($groups)
-		{
-			foreach($groups as $tmp)
-			{
-				$members = $tmp['members'];	
-				foreach($members as $mb)		
-					$search_uids .= "(uid=".$mb.")";			
-			}
-		}
-		
-		if($uids)
-		{
-			foreach($uids as $tmp)	
-				$search_uids .= "(uid=".$tmp['uid'].")";
-		}
-		$uids_members = $this->ldap->list_users_ldap($search_uids);	
-		
-		if(count($uids_members) > 0)
-			return $uids_members;
-		else
-			return 0; 
-	}
-		
-	function list_contacts($param)
-	{
-		$users = $this->users_auth_im();
-		$ordenar = array();
-		$return = array();
-		$i = 0;
-		
-		foreach($users as $tmp)
-			$ordenar[] = $tmp['cn'].";".$tmp['mail'].";".$tmp['uid'].";".$tmp['dn'];
-					
-		natsort($ordenar);
-		$uid_unique = @array_values(@array_unique($ordenar));
-		
-		foreach($uid_unique as $tmp)
-		{	
-			$result = explode(";",$tmp);
-			if(strtolower($result[3]) == strtolower($param['ou']))
-			{
-				$return[$i]['cn']   = $result[0];
-				$return[$i]['mail'] = $result[1];
-				$return[$i]['uid']  = $result[2];
-				$i++;
-			}
-			unset($result);
-		}			
-	
-		if(count($return) > 0)
-			return $return;
-		else
-			return 0;
-	}
-	
-	function UserPermission($param)
-	{
-		$db_acls = $this->db_user->get_accounts_acl();
-		$members = array();		
-		$search_uid 	= "";
-		$search_groups = "|";
-		
-		$search_uid = $this->ldap->list_users_ldap("uid=".$param['uid']);
-
-		foreach($db_acls as $tmp)
-			if($tmp['acl_account'] == $search_uid[0]['uidnumber'])
-				return 1;
-			else
-				$search_groups .= "(gidNumber=".$tmp['acl_account'].")";
-
-		$groups = $this->ldap->list_groups_ldap($search_groups);
-
-		if($groups)
-		foreach($groups as $tmp){
-			$members = $tmp['members'];	
-			foreach($members as $mb){		
-				if(trim($mb) == trim($search_uid[0]['uid']))
-					return 1;
-			}			
-		}
-		
-		return 0;
-	}
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/hook_admin.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/hook_admin.inc.php	(revision 151)
+++ 	(revision )
@@ -1,22 +1,0 @@
-<?php
-	/**************************************************************************\
-	* eGroupWare                                                               *
-	* http://www.egroupware.org                                                *
-	* Written by Joseph Engo <jengo@phpgroupware.org>                          *
-	* --------------------------------------------                             *
-	*  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.                                              *
-	\**************************************************************************/
-
-// Only Modify the $file and $title variables.....
-	$title = 'instant_messenger';
-	$file = array(
-		'Site Configuration'	=> $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)
-	);
-	
-//Do not modify below this line
-	display_section($appname,$title,$file);
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/load_lang.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/load_lang.php	(revision 151)
+++ 	(revision )
@@ -1,26 +1,0 @@
-<?
-if ( !isset($_SESSION['phpgw_info']['instant_messenger']['lang']) || !is_array($_SESSION['phpgw_info']['instant_messenger']['lang']) )
-   if ( file_exists(($fn = dirname(__FILE__) . '/../setup/phpgw_pt-br.lang')) )
-      if ( ($fp = fopen($fn,'r')) )
-      {
-         while ($data = fgets($fp,16000))
-         {
-            list($message_id, $app_name, $null, $content) = explode("\t",substr($data,0,-1));
-            $_SESSION['phpgw_info']['instant_messenger']['lang'][$message_id] = $content;
-         }
-         fclose($fp);
-      }
-
-$script  = '<script>';
-$script .= 'var lang_im = [];';
-
-foreach ( $_SESSION['phpgw_info']['instant_messenger']['lang'] as $key => $value )
-   $script .= "lang_im['" . strtolower(addslashes($key)) . "'] = '" . addslashes($value) . "';";
-
-   #$_key = str_replace("'","\'",strtolower($key));
-   #$_val = str_replace("'","\'",$value);
-
-$script .= '</script>';
-
-echo $script;
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/class.ldap_im.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/class.ldap_im.inc.php	(revision 151)
+++ 	(revision )
@@ -1,183 +1,0 @@
-<?php
-class ldap_im
-{
-	private $ldap_host;
-	private $ldap_context;
-	private $conn;
-	private $user;
-	private $password;
-	
-	function __construct()
-	{
-		$this->ldap_host 	= $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber'];
-		$this->ldap_context = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber'];
-		$this->user 		= $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber'];
-		$this->password 	= $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'];
-		$this->connect_ldap(false);
-	}
-	
-	function __destruct()
-	{
-		ldap_close($this->conn);
-	}
-	
-	function connect_ldap($refer)
-	{
-		$this->conn = ldap_connect($this->ldap_host);
-		ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3);
-		ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $refer);
-		if(trim($this->user) != "")
-			@ldap_bind($this->conn,$this->user,$this->password);
-		else		
-			@ldap_bind($this->conn);
-	}
-	
-	function get_photo_ldap($user,$getPhoto)
-	{
-		$user = ( $user == "user" ) ? $_SESSION['phpgw_info']['instant_messenger']['user'] : $user ;
-		
-		if ($this->conn) {
-			$filter="(&(uid=".$user.")(phpgwAccountType=u))";		
-			$justthese = array("jpegphoto");
-			$search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = ldap_first_entry($this->conn, $search);
-			$jpeg_data = @ldap_get_values_len($this->conn, $entry, "jpegphoto");
-			
-			if( count($jpeg_data) > 1){
-
-				$photo = imagecreatefromstring($jpeg_data[0]);
-				if($photo){
-					if($getPhoto){
-						header("Content-Type: image/jpeg");
-						$width = imagesx($photo);
-						$height = imagesy($photo);
-						$twidth = 49;
-						$theight = 65;
-						$small_photo = imagecreatetruecolor ($twidth, $theight);
-						imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
-						imagejpeg($small_photo,'',100);
-						return;		
-					}else{
-						return 1;
-					}				
-				}else{
-					return 0;
-				}
-			}else{
-				return 0;
-			}
-		}
-	}
-	
-	function photo_ldap($user)
-	{
-		$uid = ( $user['uid'] == "user" ) ? $_SESSION['phpgw_info']['instant_messenger']['user'] : $user['uid'] ;
-		return $this->get_photo_ldap($uid,false);
-	}
-	
-	function list_users_ldap($search)
-	{
-
-		if($this->conn){
-			$filter = "(&(".$search.")(phpgwAccountType=u))";
-			$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn");
-			$search = ldap_search($this->conn,$this->ldap_context,$filter,$justthese);
-			$entry = ldap_get_entries($this->conn,$search);
-		}
-		
-		if( $entry['count'] > 0){
-			$i = 0;
-			$result_user = array();
-			foreach($entry as $tmp)
-			{
-				if($tmp['uidnumber'][0] != "" && $tmp['phpgwaccountvisible'][0] != "-1"){
-					$result_user[$i]['uidnumber'] = $tmp['uidnumber'][0];			
-					$result_user[$i]['mail'] = $tmp['mail'][0];
-					$result_user[$i]['uid'] = $tmp['uid'][0];
-					$result_user[$i]['cn'] = $tmp['cn'][0];
-					$ou = explode("dc=",$tmp['dn']);
-					$ou = explode("ou=",$ou[0]);
-					$ou = array_pop($ou);
-					$result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1));					
-					$i++;
-				}				
-			}
-			return $result_user;
-		}
-		return 0;
-	}
-	
-	function list_groups_ldap($search)
-	{
-	
-		if( $this->conn ){
-			$filter = "(&(".$search.")(objectClass=posixGroup))";
-			$justthese = array("gidnumber","cn","memberuid");			
-			$search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = ldap_get_entries($this->conn,$search);
-		}
-
-		if($entry['count'] > 0){
-			$i = 0;
-			$result_groups = array();
-			foreach($entry as $tmpg){
-				if($tmpg['gidnumber'] != ""){
-					if(array_key_exists("memberuid", $tmpg)){
-						$result_groups[$i]['gidnumber'] = $tmpg['gidnumber'][0];						
-						@array_shift($tmpg['memberuid']);
-						foreach($tmpg['memberuid'] as $tmp)
-							$result_groups[$i]['members'][] = $tmp;					
-						$i++;
-					}
-				}
-			}	
-		}
-		
-		if(count($result_groups) > 0 ){
-			return $result_groups;
-		}else{
-			return 0;
-		}
-	}
-	
-	function list_organizations_ldap()
-	{
-		$result_org = array();
-		$i = 0;
-		if ($this->conn) {
-			$filter="ou=*";		
-			$justthese = array("ou");
-			$search = ldap_list($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = ldap_get_entries($this->conn, $search);
-		}
-		
-		foreach($entry as $tmp){
-			if($tmp['ou'][0] != ""){
-				$result_org[$i] = $tmp['ou'][0];
-				$i++;
-			}
-		}
-		sort($result_org);
-		return $result_org;
-	}
-	
-	function info_user($user)
-	{
-		$uid = "uid=".$user['uid'];
-		$i= 0;
-		
-		$entry = $this->list_users_ldap($uid);
-		
-		if( count($entry) > 0 )
-			return $entry;
-		else
-			return false;	
-	}
-}
-
-if(trim($_REQUEST['user']) != ""){
-	$obj_img = new ldap_im();
-	$obj_img->get_photo_ldap($_REQUEST['user'],true);
-}
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/class.download.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/class.download.inc.php	(revision 151)
+++ 	(revision )
@@ -1,155 +1,0 @@
-<?php
-
-class download
-{
-	
-	function Decode_String($string)
-	{
-		$base64 = $string;	
-		$base64_de = base64_decode($base64);
-		$array_info = unserialize($base64_de);
-	
-		if($array_info['server'] == $_SERVER['SERVER_ADDR']){
-			$this->down_file($array_info['fileUp']);
-		}else{
-			$url = "http://".$array_info['server'].$array_info['path'].$array_info['filePhp'].$base64;
-			header("Location:" . $url);
-		}
-	}
-
-	function down_file($file)
-	{   
-		 
-		ini_set("session.save_path","/php_sessions");
-		$size = filesize(ini_get("session.save_path").'/'. $file);
-		$NameFile = explode("_IM_SendFile_",$file);
-	
-		 if (!empty($file))
-	     {
-		        if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
-		           $UserBrowser = "Opera";
-		        elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
-		            $UserBrowser = "IE";
-	            else
-		            $UserBrowser = '';
-
-				$strFileType = strrev(substr(strrev($NameFile),0,4));
-				$ContentType = "application/octet-stream";
-
-			   	if ($strFileType == ".asf") 
-			   		$ContentType = "video/x-ms-asf";
-			   	if ($strFileType == ".avi")
-			   		$ContentType = "video/avi";
-			   	if ($strFileType == ".doc")
-			   		$ContentType = "application/msword";
-			   	if ($strFileType == ".zip")
-			   		$ContentType = "application/zip";
-			   	if ($strFileType == ".xls")
-			   		$ContentType = "application/vnd.ms-excel";
-			   	if ($strFileType == ".gif")
-			   		$ContentType = "image/gif";
-			   	if ($strFileType == ".jpg" || $strFileType == "jpeg")
-			   		$ContentType = "image/jpeg";
-			   	if ($strFileType == ".wav")
-			   		$ContentType = "audio/wav";
-			   	if ($strFileType == ".mp3")
-			   		$ContentType = "audio/mpeg3";
-			   	if ($strFileType == ".mpg" || $strFileType == "mpeg")
-			   		$ContentType = "video/mpeg";
-			   	if ($strFileType == ".rtf")
-			   		$ContentType = "application/rtf";
-			   	if ($strFileType == ".htm" || $strFileType == "html")
-			   		$ContentType = "text/html";
-			   	if ($strFileType == ".xml") 
-			   		$ContentType = "text/xml";
-			   	if ($strFileType == ".xsl") 
-			   		$ContentType = "text/xsl";
-			   	if ($strFileType == ".css") 
-			   		$ContentType = "text/css";
-			   	if ($strFileType == ".php") 
-			   		$ContentType = "text/php";
-			   	if ($strFileType == ".asp") 
-			   		$ContentType = "text/asp";
-			   	if ($strFileType == ".pdf")
-			   		$ContentType = "application/pdf";
-			   	if ($strFileType == ".txt")
-			   		$ContentType = "text/plain";
-			   	if ($strFileType == ".log")
-			   		$ContentType = "text/plain";
-			   	if ($strFileType == ".wmv")
-			   		$ContentType = "video/x-ms-wmv";
-				if ($strFileType == ".sxc")
-					$ContentType = "application/vnd.sun.xml.calc";
-				if ($strFileType == ".odt")
-					$ContentType = "application/vnd.oasis.opendocument.text";
-				if ($strFileType == ".stc")
-					$ContentType = "application/vnd.sun.xml.calc.template";
-				if ($strFileType == ".sxd")
-					$ContentType = "application/vnd.sun.xml.draw";
-				if ($strFileType == ".std")
-					$ContentType = "application/vnd.sun.xml.draw.template";
-				if ($strFileType == ".sxi")
-					$ContentType = "application/vnd.sun.xml.impress";
-				if ($strFileType == ".sti")
-					$ContentType = "application/vnd.sun.xml.impress.template";
-				if ($strFileType == ".sxm")
-					$ContentType = "application/vnd.sun.xml.math";
-				if ($strFileType == ".sxw")
-					$ContentType = "application/vnd.sun.xml.writer";
-				if ($strFileType == ".sxq")
-					$ContentType = "application/vnd.sun.xml.writer.global";
-				if ($strFileType == ".stw")
-					$ContentType = "application/vnd.sun.xml.writer.template";
-				if ($strFileType == ".ps")
-					$ContentType = "application/postscript";
-				if ($strFileType == ".pps")
-					$ContentType = "application/vnd.ms-powerpoint";
-				if ($strFileType == ".odt")
-					$ContentType = "application/vnd.oasis.opendocument.text";
-				if ($strFileType == ".ott")
-					$ContentType = "application/vnd.oasis.opendocument.text-template";
-				if ($strFileType == ".oth")
-					$ContentType = "application/vnd.oasis.opendocument.text-web";
-				if ($strFileType == ".odm")
-					$ContentType = "application/vnd.oasis.opendocument.text-master";
-				if ($strFileType == ".odg")
-					$ContentType = "application/vnd.oasis.opendocument.graphics";
-				if ($strFileType == ".otg")
-					$ContentType = "application/vnd.oasis.opendocument.graphics-template";
-				if ($strFileType == ".odp")
-					$ContentType = "application/vnd.oasis.opendocument.presentation";
-				if ($strFileType == ".otp")
-					$ContentType = "application/vnd.oasis.opendocument.presentation-template";
-				if ($strFileType == ".ods")
-					$ContentType = "application/vnd.oasis.opendocument.spreadsheet";
-				if ($strFileType == ".ots")
-					$ContentType = "application/vnd.oasis.opendocument.spreadsheet-template";
-				if ($strFileType == ".odc")
-					$ContentType = "application/vnd.oasis.opendocument.chart";
-				if ($strFileType == ".odf")
-					$ContentType = "application/vnd.oasis.opendocument.formula";
-				if ($strFileType == ".odi")
-					$ContentType = "application/vnd.oasis.opendocument.image";
-				if ($strFileType == ".ndl")
-					$ContentType = "application/vnd.lotus-notes";
-								
-		        $mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream';
-	
-		        header("Content-Type: $ContentType");
-		        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
-		        header("Pragma: public");
-		        header("Expires: 0");
-		        header("Content-Disposition: attachment; filename=\"" . $NameFile[1] . "\"");
-				header("Content-length: " . $size);
-				readfile(ini_get("session.save_path") . "/" . $file); 
-				die();
-	    }
-	}
-}
-
-if(isset ($_REQUEST['file'])){
-	$obj_down = new download();
-	$obj_down->Decode_String($_REQUEST['file']);
-}
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/im_sessions.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/im_sessions.inc.php	(revision 151)
+++ 	(revision )
@@ -1,41 +1,0 @@
-<?php
-		/*
-		$_SESSION['phpgw_info']['instant_messenger']['user']             = $GLOBALS['phpgw_info']['user']['account_lid'];
-		$_SESSION['phpgw_info']['instant_messenger']['passwd']           = $GLOBALS['phpgw_info']['user']['passwd'];
-		$_SESSION['phpgw_info']['instant_messenger']['name_jabber']      = $GLOBALS['phpgw_info']['server']['name_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['port_jabber']      = $GLOBALS['phpgw_info']['server']['port_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['resource_jabber']  = $GLOBALS['phpgw_info']['server']['resource_jabber'];
-		
-		$_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']   = $GLOBALS['phpgw_info']['server']['server_ldap_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']  = $GLOBALS['phpgw_info']['server']['context_ldap_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']     = $GLOBALS['phpgw_info']['server']['user_ldap_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['password_ldap_jabber'];
-		
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type'];
-		*/
-     
-		/**/
-		$_SESSION['phpgw_info']['instant_messenger']['user'] 			      	= "alexandrecorreia";
-		$_SESSION['phpgw_info']['instant_messenger']['passwd'] 			      = "jorge76";
-		$_SESSION['phpgw_info']['instant_messenger']['name_jabber'] 	      = "ecelepar08554";
-		$_SESSION['phpgw_info']['instant_messenger']['port_jabber'] 	      = "8888";
-		$_SESSION['phpgw_info']['instant_messenger']['resource_jabber']      = "IM";
-		
-		$_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']   = "ecelepar10612";
-		$_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']  = "dc=ecelepar10612,dc=pr,dc=gov,dc=br";
-		$_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']     = "cn=admin";
-		$_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'] = "senha";	
-		
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] 	= "expresso";
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_host'] 	= "localhost";
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_port'] 	= "5432";
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_user'] 	= "postgres";
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] 	= "";	
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] 	= "pgsql";
-		/**/
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/class.Ujabber.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/class.Ujabber.inc.php	(revision 151)
+++ 	(revision )
@@ -1,568 +1,0 @@
-<?php
-
-class Ujabber
-{
-   /*
-    * Listen 
-    */
-   
-   final function listen()
-   {
-      $return = null;
-		
-		if($_SESSION['phpgw_info']['instant_messenger']['IM_disconnect'])
-		{
-      	$_SESSION['phpgw_info']['instant_messenger']['IM_disconnect'] = false;
-      	return "disconnected";
-		}
-		
-	   $_SESSION['phpgw_info']['instant_messenger']['timeClient'] = time();
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = true;
-      $xml = $_SESSION['phpgw_info']['instant_messenger']['socket']['in'];
-      //str_replace inserido por problemas com clientes que inserem
-      //quebra de linha no XML descomentar e retirar a seguinte para
-      //voltar ao padrão assim que possível
-      //24/10/2007 - problema verificado por usuários do SERPRO na
-      //plataforma Windows ocorrendo também no cliente Linux
-      //por Alexandre e Rodrigo
-		$xml = str_replace("\n","",$xml);
-		$xml = str_replace("\r","",$xml);
-
-      unset($_SESSION['phpgw_info']['instant_messenger']['socket']['in']);
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = false;
-
-      ### Arranjo Tecnico ### 
-      $vkrd = $xml;
-      
-      if(isset($_SESSION['phpgw_info']['instant_messenger']['contacts']))
-         unset($_SESSION['phpgw_info']['instant_messenger']['contacts']);
-
-      ### - messages - ###
-      //Linha abaixo dentro do padrão xmpp, entretanto clientes como
-      //o PSI não seguem o padrão assim ocorre problemas de comunicação
-      //descomentar e retirar a seguinte para voltar ao padrão assim
-      //que possível
-      //24/10/2007 - problema verificado por usuários do SERPRO na
-      //plataforma Windows ocorrendo também no cliente Linux
-      //por Alexandre e Rodrigo
-      //$_messages = "/<message[^>]+from='(\S+)'[^>]*>(?(?=.*?<composing |.*?<paused ).*?<(composing|paused) )(?(?=.*?<html).*?<html[^>]*><body[^>]*>(.*?)<\/body><\/html>).*?<\/message>/s";
-      //retirar a linha abaixo para voltar ao padrão conforme acima
-      $_messages = "/<message[^>]+from='(\S+)'[^>]*>(?(?=.*?<composing |.*?<paused ).*?<(composing|paused) )(?(?=.*?<body).*?<body[^>]*>(.*?)<\/body>).*?<\/message>/s";
-      $_messages = preg_match_all($_messages, $xml, $messages);
-      if ( $_messages !== false && $_messages > 0 )
-      {
-         $xml = preg_replace("/<message.*?<\/message>/", "", $xml);         
-         $return .= $this->getMessages($messages);
-      }
-      ### - Fim messages - ###
-
-      ### - contacts - ###
-      $_contacts = "/<iq[^>]+id='contacts'[^>]*>.*?<\/iq>/";
-      $_contacts = preg_match_all($_contacts, $xml, $_xml);
-
-      $_contacts = "/<item.*?(?(?=[^>]+name)[^>]+name='(.*?)')[^>]+subscription='(.*?)'[^>]+jid='(.*?)'";
-      $_contacts .= "(?(?=[^>]*\/>)[^>]*\/>|[^>]*><group>(.*?)<\/group><\/item>)/";
-      $_contacts = preg_match_all($_contacts, $_xml[0][0], $contacts);
-      if ( $_contacts !== false && $_contacts > 0 )
-      {
-         $xml = preg_replace("/<iq[^>]+id='contacts'[^>]*>.*?<\/iq>/", "", $xml);
-         $return .= rawurldecode(urldecode($this->getContacts($contacts)));
-      }
-      ### - Fim contacts - ###
-
-      ### - presence - ###
-      $xml = $_SESSION['phpgw_info']['instant_messenger']['presences'] . $xml;
-
-      $_presence  = "/<presence(?(?=[^>]+\/>)[^>]+\/>|[^>]+>.*?<\/presence>)/";
-      $_presence = preg_match_all($_presence, $xml, $presence);
-
-      $patterns[0] = '/<priority>[^<]*<\/priority>|<(\S) (?(?=[^>]*\/>)[^>]*\/>|[^>]*>.*?<\/\1>)/';
-      $patterns[1] = '/ xmlns=\'.*?\'| to=\'.*?\'/';
-      $patterns[2] = '/> +</';
-      $replacements[0] = '';
-      $replacements[1] = '';
-      $replacements[2] = '><';
-      $_xml = preg_replace($patterns, $replacements, implode('', $presence[0]));
-
-      $_presence  = "/<presence[^>]+from='(\S+)'[^>]*type='(unavailable)'(?(?=[^>]*\/>)[^>]*\/>|[^>]*>.*?<\/presence>)|";
-      $_presence .= "<presence[^>]+from='(\S+)'(?(?=[^>]+type)[^>]+type='(\S+)')[^>]*";
-      $_presence .= "(?(?=\/>)\/>|>";
-      $_presence .= "(?(?=<s[^>]*?>)<s[^>]*?>(.*?)<\/s[^>]*?>(?(?=<s[^>]*?>)<s[^>]*?>(.*?)<\/s[^>]*?>))";
-      $_presence .= "<\/presence>)/";
-      $_presence = preg_match_all($_presence, $_xml, $presence);
-      if ( $_presence !== false && $_presence > 0 )
-      {
-         foreach ( $presence[5] as $key => $val )
-         {
-            if ( !empty($presence[1][$key]) && (strpos($presence[1][$key], '/') !== false) )
-               $presence[1][$key] = substr($presence[1][$key], 0, strpos($presence[1][$key], '/'));
-            
-            if ( !empty($presence[3][$key]) && strpos($presence[3][$key], '/') !== false )
-               $presence[3][$key] = substr($presence[3][$key], 0, strpos($presence[3][$key], '/'));
-   
-            if ( !empty($val) && !preg_match("/^(away|chat|dnd|xa)$/", $val) )
-               if ( preg_match("/^(away|chat|dnd|xa)$/", $presence[6][$key]) )
-               {
-                  $aux = $presence[5][$key];
-                  $presence[5][$key] = $presence[6][$key];
-                  $presence[6][$key] = $aux;
-               }
-               else
-               {
-                  if ( empty($presence[6][$key]) )          
-                     $presence[6][$key] = $presence[5][$key];
-                  $presence[5][$key] = '';
-               }
-         }
-         $xml = preg_replace("/<presence[^>]\/?>|<presence[^>]>.*?<\/presence>/", "", $xml);
-
-         $return .= $this->getPresence($presence);
-      }
-      ### - Fim presence - ###
-
-      
-      ### - vcard - ###
-      ### - Arranjo Tecnico - ###
-      $_xml = $vkrd;
-      $_vcard = "/<iq.*? id='(.*?)' .*?(<vCard [^>]+\/>|<vCard.*?<\/vCard>)<\/iq>/"; 
-      $_vcard = preg_match_all($_vcard, $_xml, $vcard);
-      if( $_vcard !== false && $_vcard > 0)
-      {
-         $xml = preg_replace("/<iq.*?<vCard.*?<\/iq>/", "", $xml);
-         $return .= urldecode($this->getVcard($vcard));
-      }
-      ### - Fim vcard - ###
-      ## Final do Listen;
-
-      return $return;
-   }
-   
-   function reconnect()
-   {
-      require_once("IMConfigure.php");
-
-      $_transport = TRANSPORT_NON_SECURITY;
-      $_port = PORT_NON_SECURITY;
-
-		$SERVER = "127.0.0.1";
-
-		$fp  = "";
-		@$fp = stream_socket_client($_transport . "://" . $SERVER . ":" . $_port, $errno, $errstr, 10);
-
-		if ( $fp )
-		{
-			fwrite($fp, "GET /" . CONNECT . ";" . session_id() . " HTTP/1.1\r\nHost: " . $SERVER . ":" . $_port . "\r\nAccept: */*\r\n\r\n");
-			return 'true';
-		}
-		else
-			return 'false';
-   } 
-   
-   /*
-    * Contacts
-    */
-
-   function getContacts(array $pContacts)
-   {
-      $_group = array();
-      $return = NULL;
-      $jid = array_unique($pContacts[3]);
-      
-      foreach ( $jid as $key => $val )
-      {
-         $_SESSION['phpgw_info']['instant_messenger']['contacts'][] = $val;
-
-         $item  = NULL;
-         $item .= '<item name="' . (( !empty($pContacts[1][$key]) ) ? $pContacts[1][$key] : $val);
-         $item .= '" jid="' . $val;
-         $item .= '" subscription="' . $pContacts[2][$key];
-         $item .= '" />';
-
-         $_group[utf8_decode(strtolower(!empty($pContacts[4][$key]) ? $pContacts[4][$key] : 'default'))][] = $item;
-      } 
-      
-      ksort($_group);
-
-      foreach ( $_group as $key => $val )
-         $return .= '<group name="' . $key . '">' . implode('', $val) . '</group>';
-
-      return '<contacts>' . $return . '</contacts>';
-   }
-
-   function requireContacts()
-   {
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['getContacts'] = NULL;
-   }
-   
-  /*
-   * Presence 
-   */
-
-   function setPresence($pPresence)
-   {
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['setPresence'] = $pPresence;
-      foreach($pPresence as $key=>$presence)
-      	if($key == 'show' || $key == 'type')
-      	{
-      		$_SESSION['phpgw_info']['instant_messenger']['MyPresence'] = $presence;
-      	}
-   }
-   
-   function MyPresence()
-   {
-   	if(isset($_SESSION['phpgw_info']['instant_messenger']['MyPresence']))
-	   	return $_SESSION['phpgw_info']['instant_messenger']['MyPresence'];
-   }
-   
-   function getPresence(array $pPresence)
-   {
-      $offline = array();
-      foreach ( $pPresence[1] as $key => $val )
-      {
-         if ( empty($val) )
-            continue;
-
-         $_offline = true;
-         for ( $i = $key; $i < sizeof($pPresence[1]); $i++ )
-            if ( $pPresence[1][$key] == $pPresence[3][$i] || $pPresence[1][$key] == $pPresence[5][$i] )
-               $_offline = false;
-
-         if ( $_offline )
-            $offline[$key] = $val;
-      }
-
-      $online = array();
-      foreach ( $pPresence[3] as $key => $val )
-      {
-         if ( empty($val) )
-            continue;
-
-         $_online = true;
-         for ( $i = ($key + 1); $i < sizeof($pPresence[3]); $i++ )
-            if ( in_array($val, $offline) || $pPresence[3][$key] == $pPresence[3][$i] )
-               $_online = false;
-
-         if ( $_online )
-            $online[$key] = $val;
-      }
-
-      $return = NULL;
-
-      foreach ( $offline as $key => $val )
-      {
-         $val = ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val;
-         $return .= "<presence from='" . $val . "' type='unavailable' />";
-      }
-      
-      foreach ( $online as $key => $val )
-      {
-         $val = ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val;
-
-         if ( empty($pPresence[4][$key]) )
-            $pPresence[4][$key] = ( empty($pPresence[5][$key]) ) ?
-               'available' : $pPresence[5][$key];
-
-         $return .= "<presence from='" . $val . "' type='" . $pPresence[4][$key];
-         if ( empty($pPresence[6][$key]) )
-            $return .= "' />";
-         else
-            $return .= "'>" . $pPresence[6][$key] . "</presence>";
-
-         if ( strpos($pPresence[4][$key], 'subscribe') === false )
-         {
-            $session .= "<presence from='" . $val . "'><show>" . $pPresence[4][$key] . "</show>";
-            if ( !empty($pPresence[6][$key]) )
-               $session .= "<status>" . $pPresence[6][$key] . "</status>";
-            $session .= "</presence>";
-         }
-      }
-
-      $_SESSION['phpgw_info']['instant_messenger']['presences'] = $session;
-
-      return $return;
-   }
-
-   /*
-    * GetMessage
-    */
-   
-   function getMessages(array $pMessages)
-   {
-      $_messages = array();
-      $return = NULL;
-
-      foreach ( $pMessages[1] as $key => $val )
-      {
-         trim($pMessages[3][$key]);
-         if ( !empty($pMessages[3][$key]) )
-            $_messages[$val][] = $pMessages[3][$key];
-            
-         if ( !empty($pMessages[2][$key]) )
-         {
-            $return .= '<' . $pMessages[2][$key] . ' from="';
-            $return .= ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val;
-            $return .= '" />';
-         }
-      }
-
-      foreach ( $_messages as $key => $val )
-      {
-         $return .= '<messages from="' . $key . '">';
-         foreach ( $val as $msg )
-            $return .= '<message>' . $msg . '</message>';
-         $return .= '</messages>';
-      }
-
-      return $return;
-   }
-
-   /*
-    * SendMessage
-    */
-
-   function SendMessage($pSendMessage)
-   {
-      $pSendMessage['body'] = stripslashes($pSendMessage['body']);
-      $_emotions  = '/<img emotion="(\S+)?"[^>]+>/';
-      $_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions);
-
-      foreach ( $emotions[0] as $key => $val )
-         $emotions[0][$key] = '/' . addcslashes($val, './()[]{}^$*&?') . '/i';
-
-      $pSendMessage['body'] = preg_replace($emotions[0], $emotions[1], $pSendMessage['body']);
-
-      $to = $pSendMessage['to'];
-      $type = "chat";
-      $id = "";
-      $content = array(
-         "subject" => $pSendMessage['subject'] ? $pSendMessage['subject'] : "",
-         "thread" => $pSendMessage['thread'] ? $pSendMessage['thread'] : "",
-         "body" => $pSendMessage['body'] ? $pSendMessage['body'] : ""
-      );
-
-      $payload = "";
-
-      if ($to && is_array($content))
-      {
-         if (!$id)
-         {
-            $id = $type . "_" . time();
-         }
-
-         $xml = "<message to='$to' type='$type' id='$id'>";
-
-         if ($content['subject'])
-         {
-            $xml .= "<subject>" . $content['subject'] . "</subject>";
-         }
-
-         if ($content['thread'])
-         {
-            $xml .= "<thread>" . $content['thread'] . "</thread>";
-         }
-
-         //Linha abaixo dentro do padrão xmpp, entretanto clientes como
-         //o PSI não seguem o padrão assim ocorre problemas de comunicação
-         //descomentar e retirar a seguinte para voltar ao padrão assim
-         //que possível
-         //24/10/2007 - problema verificado por usuários do SERPRO na
-         //plataforma Windows ocorrendo também no cliente Linux
-         //por Alexandre e Rodrigo
-         //$xml .= "<html><body>" . $content['body'] . "</body></html>";
-         //retirar a linha abaixo para voltar ao padrão conforme acima
-         $xml .= "<body>" . $content['body'] . "</body>";
-         $xml .= $payload;
-         $xml .= "</message>";
-         unset($id);
-
-         $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] .= $xml;
-      }
-      else
-      {
-         $this->writeLog("ERROR: SendMessage() #2");
-         return FALSE;
-      }
-   }
-
-   /*
-    * Composing / Paused Message
-    */
-
-   function composingMessage($pComposing)
-   {
-
-		$xml  = "<message xmlns='jabber:client' to='".$pComposing['to']."' id='".time()."' type='chat'>";
-		$xml .= "<x xmlns='jabber:x:event'>";
-		$xml .= "<composing/>";
-		$xml .= "</x>";
-		$xml .= "<composing xmlns='http://jabber.org/protocol/chatstates'/>";
-		$xml .= "</message>";
-   	$_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] .= $xml;
-   }
-   
-   function pausedMessage($pComposing)
-   {
-		$xml  = "<message xmlns='jabber:client' to='".$pComposing['to']."' id='".time()."' type='chat'>";
-		$xml .= "<x xmlns='jabber:x:event'/>";
-		$xml .= "<paused xmlns='http://jabber.org/protocol/chatstates'/>";
-		$xml .= "</message>";
-
-		$_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] .= $xml;
-   }
-   
-   /*
-    * UpdateContact
-    */
-   
-   function updateContact($pUser)
-   {
-      $jid   = $pUser['jid'];
-      $name  = $pUser['name'];
-      $group = $pUser['group'];
-      
-      if ( $jid )
-      {
-         $updatecontact  = "<item jid='$jid'";
-         $updatecontact .= " name='" . $name . "'";
-         $updatecontact .= "><group>" . $group . "</group></item>";
-         $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['updateContact'] = $updatecontact;
-      }
-      $this->requireContacts();
-   }
-   
-   /*
-    * AddContact
-    */
-   
-   function addContacts($pUser)
-   {
-      $jid = explode("@",$pUser['email']);
-      $pJid = $jid[0]."@".$_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-      $pName = $pUser['name'];
-      $pGroup = $pUser['group'];
-
-      if(trim($jid[0]) != trim($this->username))
-      {
-         if ( $pJid )
-         {
-            $newcontact  = "<item jid='$pJid'";
-            $newcontact .= " name='" . $pName . "'";
-            $newcontact .= "><group>" . $pGroup . "</group></item>";
-            $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['addContacts'] = $newcontact;
-            $this->subscribe($pJid);
-            $this->requireContacts();           
-         }
-      }
-   }
-   
-   /*
-    * RemoveContact
-    */
-    
-    function removeContact($pUser)
-    {
-         $pJid = $pUser['jid'];
-         $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['removeContact'] = $pJid;
-         $this->unsubscribed($pJid);
-         $this->requireContacts();
-    }
-
-   /*
-    * Vcard
-    */
-
-   function newVcard($pVcardUser)
-   {
-      $pVcard = explode("_vkrd_", $pVcardUser['vcard']);
-
-      $xmlVcard  = "<FN>".$pVcard[0]."</FN>";
-      $xmlVcard .= "<NICKNAME>".$pVcard[1]."</NICKNAME>";
-      $xmlVcard .= "<ORG>";
-      $xmlVcard .= "<ORGNAME>".$pVcard[2]."</ORGNAME>";
-      $xmlVcard .= "<ORGUNIT>".$pVcard[3]."</ORGUNIT>";
-      $xmlVcard .= "</ORG>";
-      $xmlVcard .= "<ROLE>".$pVcard[4]."</ROLE>";
-      $xmlVcard .= "<BDAY>".$pVcard[5]."</BDAY>";
-      $xmlVcard .= "<DESC>".$pVcard[6]."</DESC>";
-      
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['newVcard'] = $xmlVcard;
-
-   }
-   
-   function getVcard(array $Vcard)
-   {
-      $div = "";
-      $_expr = "/<[^<vCard xmlns=\'vcard\-temp\'>].*[^<\/vCard>]>/";
-      array_shift($Vcard);
-      $div = '<vcard>';
-      $jid_user = $_SESSION['phpgw_info']['instant_messenger']['user'];
-      $jid_user .= "@" . $_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-      for($i = 0 ; $i < count($Vcard[0]) ; $i++)
-      {
-         preg_match($_expr,$Vcard[1][$i],$div_vcard);
-         $div_new[] = $div_vcard;
-
-         if ( $jid_user == $Vcard[0][$i] )
-            $_SESSION['phpgw_info']['instant_messenger']['vcard'] = $div_new[$i][0];
-         
-         $div .= '<div id="vcard_'.$Vcard[0][$i].'">'.urldecode($div_new[$i][0]).'</div>';
-      }
-      $div .= '</vcard>';
-         
-      return $div;
-   }
-   
-   function Vcard()
-   {
-      $contacts = array();
-      $contacts = $_SESSION['phpgw_info']['instant_messenger']['contacts'];
-      $jid_user = $this->getJid();
-
-      if( count($contacts) > 0 )
-      {
-         array_unshift($contacts,$jid_user);
-
-         foreach($contacts as $user)
-            $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['vcard'][] = $user;
-         return "true";
-      }else{
-         return "false";
-      }
-   }
-   
-   function VcardUser()
-   {
-   	$_SESSION['phpgw_info']['instant_messenger']['socket']['out']['vcard'][] = $this->getJid();;
-   }
-   
-   function getJid()
-   {
-      $jid = $_SESSION['phpgw_info']['instant_messenger']['user'] . "@" . $_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-      return $jid;   
-   }
-   
-   function subscribe($pJid)
-   {
-      $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ;
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['Subscribe'] = $jid;
-   }
-   
-   function subscribed($pJid)
-   {
-      $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ;
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['SubscriptionAcceptRequest'] = $jid;
-   }
-   
-   function unsubscribe($pJid)
-   {
-      $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ;
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['Unsubscribe'] = $jid;
-   }
-   
-   function unsubscribed($pJid)
-   {
-      $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ;
-      $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['SubscriptionDenyRequest'] = $jid;   
-   }
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/class.db_im.inc.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/class.db_im.inc.php	(revision 151)
+++ 	(revision )
@@ -1,97 +1,0 @@
-<?php
-define('PHPGW_INCLUDE_ROOT','../');	
-define('PHPGW_API_INC','../phpgwapi/inc');
-require_once(PHPGW_API_INC.'/class.db.inc.php');
-	
-class db_im
-{	
-	
-	var $db;
-	var $db_name;
-	var $db_host;
-	var $db_port;
-	var $db_user;
-	var $db_pass;
-	var $db_type;
-	var $teste;
-	
-	function db_im(){
-		$this->db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'];
-		$this->db_host = $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'];
-		$this->db_port = $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'];
-		$this->db_user = $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'];
-		$this->db_pass = $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'];
-		$this->db_type = $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'];
-		
-		$this->db = new db();		
-		$this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type);
-	}
-
-	function get_accounts_acl()
-	{
-		$result = array();
-		$query = "select acl_appname, acl_account from phpgw_acl where acl_appname = 'instant_messenger' order by acl_account";	
- 		
- 		if (!$this->db->query($query))
-        	return null;
-		
-		while($this->db->next_record())
-			$result[] = $this->db->row();
-
-		return $result;
-	}
-	
-	function query_db($pQuery)
-	{
-		if (!$this->db->query($pQuery))
-        	return false;
-		else
-			return true;
-	}
-	
-	function set_preferences($param)
-	{
-		$preferences = $param['preferences'];
-		$user_id  = $_SESSION['phpgw_info']['instant_messenger']['user_id']; 
-		$app_name = $this->name_app();
-
-		$query = "insert into phpgw_preferences values('".$user_id."','".$app_name."','".serialize($preferences)."')";
-		
-		if($this->query_db($query))	 
-			return "true";
-		else{
-			$query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='".$app_name."' and preference_owner='".$user_id."'";
-			if($this->query_db($query))
-				return "true";
-			else
-				return "false";			
-		}		
-	}
-	
-	function get_preferences()
-	{
-		$result = array();
-		$user_id  = $_SESSION['phpgw_info']['instant_messenger']['user_id'];
-		$app_name = $this->name_app();
-		
-		$query = "select * from phpgw_preferences where preference_owner = '".$user_id."' and preference_app = '".$app_name."'";
-		
- 		if (!$this->db->query($query))
-        	return NULL;
-		
-		while($this->db->next_record())
-			$result[] = $this->db->row();
-
-		if(count($result) > 0){
-			return unserialize($result[0]['preference_value']);
-		}else{
-			return "ch_offline:true;in_time:1;rd_nm:true;rd_ch:false";
-		}
-	}
-	
-	function name_app()
-	{
-		return "instant_messenger";
-	}
-}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/IMConfigure.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/IMConfigure.php	(revision 151)
+++ 	(revision )
@@ -1,33 +1,0 @@
-<?php
-   ###
-   # definitions of access - BEGIN
-   #
-      define('CONNECT', 'con');
-      define('CLOSE', 'close');
-      define('GET_MESSAGE', 'getMessage');
-      define('SEND_MESSAGE', 'send');
-   #
-   # definitions of access - END
-   ###
-
-   ###
-   # definitions of time - BEGIN
-   #
-      define('DISCONNECT_AFTERWARDS_OF', 20);
-      define('READ_SOCKET_AFTER_OF', 2);
-   #
-   # definitions of time - END
-   ###
-
-   ###
-   # definitions of socket - BEGIN
-   #
-      define('TRANSPORT_NON_SECURITY', 'tcp');
-      define('PORT_NON_SECURITY', '8000');
-
-      //define('TRANSPORT_SECURITY', 'sslv3');
-      //define('PORT_SECURITY', '9001');
-   #
-   # definitions of socket - END
-   ###
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/Jabber.abstract.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/Jabber.abstract.php	(revision 151)
+++ 	(revision )
@@ -1,316 +1,0 @@
-<?php
-/*
-+-------------------------------------------------------------------------+
-|                                                                         |
-| @FILE:        Jabber.abstract.php                                       |
-| @ABSTRACT:    Jabber                                                    |
-| @EXTENDS:     Socket (Socket.class.php)                                 |
-|                                                                         |
-| @DATE:        Wed May,16 2007 08:18:59                                  |
-| @LAST_CHANGE: Wed May,16 2007 09:03:28                                  |
-|                                                                         |
-| @AUTHOR:      [NUTS] Rodrigo Souza - rodsouza@celepar.pr.gov.br         |
-|                                                                         |
-| @BRIEF:       Abstract class for connect with any Jabber server         |
-|                                                                         |
-+-------------------------------------------------------------------------+
-*/
-
-require_once 'Socket.abstract.php';
-
-abstract class Jabber extends Socket
-{
-   const J_FILE    = '/var/log/expresso/Jabber.log';
-   const J_ALL     = false;
-   const J_ERROR   = true;
-   const J_WARNING = true;
-   const J_NOTICE  = true;
-
-   const ALL     = 'ALL';
-   const ERROR   = 'ERROR';
-   const WARNING = 'WARNING';
-   const NOTICE  = 'NOTICE';
-
-   private final function _connect( $pUser = false, $pPassword = false )
-   {
-      try
-      {	
-         if ( !preg_match('/^(.+)@(.+)\/(.+):(\d+)$/',$pUser, $matches) )
-            throw new Exception('[connect] #1 ' . $pUser . ' must be [USER]@[DOMAIN]/[RESOURCE]:[PORT] and [PORT] is integer. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         list($subject, $USER, $SERVER, $RESOURCE, $PORT) = $matches;
-
-         if ( !($socket = $this->open('tcp://' . $SERVER . ':' . $PORT, 1, 1)) )
-            throw new Exception('[connect] #2 can\'t access tcp://' . $SERVER . ':' . $PORT . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         $this->_socket = $socket;
-
-         $xml  = "<?xml version='1.0' encoding='UTF-8'?>";
-         $xml .= "<stream:stream to='" . $SERVER . "' xmlns='jabber:client' ";
-         $xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>";
-
-         if ( $this->write($xml) === false )
-            throw new Exception('[connect] #3 it isn\'t possible write in the socket ' . $socket . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         $this->_server = $SERVER;
-         $this->_username = $USER;
-         $this->_password = $pPassword;
-         $this->_resource = $RESOURCE;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-   protected function connect( $pUser = false, $pPassword = false )
-   {   
-      try
-      {
-         $this->_connect($pUser, $pPassword);
-			
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[connect] #1 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-         
-         if ( preg_match('/(<starttls .*<required\/><\/starttls>)/', $xml, $matches) )
-         {
-            if ( !$this->starttls() )
-               throw new Exception('[connect] #2 it isn\'t possible start tls. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-            # $this->writeLog('NOTICE', 'Connected TLS');
-         }
-         else
-	 		{
-            if ( !$this->_plain() )
-               throw new Exception('[connect] #3 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-	 		}
-
-         return true;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         $this->_disconnect();
-         return false;
-      }
-   }
-
-   protected final function _disconnect()
-   {
-      try
-      {
-         $xml = "</stream:stream>";
-
-         if ( $this->write($xml) === false )
-            throw new Exception('[disconnect] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[disconnect] #2 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-   private final function starttls()
-   {
-      try
-      {
-         $xml = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>";
-         if ( $this->write($xml) === false )
-            throw new Exception('[starttls] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[starttls] #2 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         if ( !preg_match('/<proceed.*\/>/', $xml, $matches) )
-            throw new Exception('[starttls] #3 can\'t start tls in the socket ' .$this->_socket . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-		   stream_socket_enable_crypto($this->_socket, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT);
-
-         $xml  = "<?xml version='1.0' encoding='UTF-8'?>";
-         $xml .= "<stream:stream to='" . $this->_server . "' xmlns='jabber:client' ";
-         $xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>";
-         if ( $this->write($xml) === false )
-            throw new Exception('[starttls] #4 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         usleep(90000);
-         $this->blocking($this->_socket, 0);
-
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[starttls] #5 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         if ( !$this->_plain() )
-            throw new Exception('[starttls] #6 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         return true;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-   private final function _plain()
-   {
-      try
-      {
-         $this->blocking($this->_socket, 0);
-
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[_plain] #1 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         $xml  = "<username>" . $this->_username . "</username>";
-         $xml .= "<password>" . $this->_password . "</password>";
-         $xml .= "<resource>" . $this->_resource . "</resource>";
-
-         unset($this->_password);
-
-         if ( !$this->iq('set', 'auth_1', NULL, NULL, "jabber:iq:auth", $xml) )
-            throw new Exception('[_plain] #2 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         while ( !preg_match("/<iq xmlns='jabber:client' id='auth_1' type='(result|error)'/", ($readSocket = $this->read()), $matches) )
-         	   usleep(10000);
-
-			if($matches[1] == "error")
-				return false;
-
-         if ( ($xml = $this->read()) === false )
-            throw new Exception('[_plain] #3 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         return true;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-	private final function _iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false )
-	{
-		$xml  = "<iq type='" . $pType . "' id='" . $pId . "'";
-		$xml .= ( $pTo ) ? " to='" . $pTo . "'" : "";
-		$xml .= ( $pFrom ) ? " from='" . $pFrom . "'" : "";
-
-		if ( $pXmlns == "vcard-temp" )
-      {
-			$xml .= ">";
-			$xml .= $pLoad;
-		}
-      else
-      {
-			$xml .= "><query xmlns='" . $pXmlns . "'";
-			$xml .= ( $pLoad ) ? ">" . $pLoad . "</query>" : "/>";
-		}
-
-		$xml .= "</iq>";
-		
-		return $xml;	
-	}
-
-   protected final function iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false)
-   {
-      try
-      {
-         if ( !preg_match("/^(get|set|result|error)$/i", $pType, $matches) )
-            throw new Exception('[iq] #1 type must be GET, SET, RESULT or ERROR. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-		   if ( $this->write($this->_iq($pType, $pId, $pTo, $pFrom, $pXmlns, $pLoad)) === false )
-            throw new Exception('[iq] #2 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-         else
-            return true;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-   }
-
-	protected final function presence($pType = false, $pTo = false, $pShow = false, $pStatus = false, $pPriority = false)
-	{
-      try
-      {
-         $xml  = "<presence";
-         $xml .= ($pTo)   ? " to='{$pTo}'" : '';
-         $xml .= ($pType) ? " type='{$pType}'" : '';
-         
-         //$xml .= ($pStatus || $pShow || $pPriority) ? ">" : "/>";
-         if ( !($pStatus || $pShow || $pPriority) )
-				$xml .= "/>";
-			else
-			{
-			 $xml .= ">";
-	         $xml .= ($pStatus) ? "<status>" . $pStatus . "</status>" : '';
-	         $xml .= ($pShow) ? "<show>" . $pShow . "</show>" : '';
-	         $xml .= ($pPriority) ? "<priority>" . $pPriority . "</priority>" : '';
-	         $xml .= ($pStatus || $pShow || $pPriority) ? "</presence>" : '';
-			}
-
-         if ( $this->write($xml) === false )
-            throw new Exception('[presence] #1 it isn\'t possible send presence for ' . $this->_server . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-         return true;
-      }
-      catch(Exception $e)
-      {
-         $this->writeLog('ERROR', $e->getMessage());
-         return false;
-      }
-	}
-
-   protected final function read()
-   {
-      $return = NULL;
-      do
-      {
-         $line = NULL;
-         $line = utf8_decode(parent::read($this->_socket, 4096));
-
-         if ( $line === false )
-         {
-            $return = false;
-            break;
-         }
-
-         if ( $line != NULL )
-            $return .= $line;// . "\n";
-      }
-      while ( $line != NULL );
-
-      return $return;
-   }
-
-	protected final function write($pData = false)
-   {
-      if ( !$pData )
-         return false;
-
-      return parent::write($this->_socket, utf8_encode($pData));
-   }
-
-   protected final function writeLog($pType = false, $pLog = false)
-   {
-      if ( !defined('self::'.$pType) && !$pLog )
-         return false;
-
-      if ( !(bool)constant('self::J_'.$pType) && !(bool)constant('self::J_ALL') )
-         return false;
-
-      $log  = date('m/d/Y H:i:s');
-      $log .= ' [' . constant('self::'.$pType) . '] :: ';
-      $log .= $pLog . "\n";
-      if ( $fp = fopen (self::J_FILE, "a+") )
-      {
-         fwrite($fp, $log);
-         fclose($fp);
-      }
-   }
-}
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/inc/Language.class.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/inc/Language.class.php	(revision 151)
+++ 	(revision )
@@ -1,41 +1,0 @@
-<?php
-
-class Language
-{
-   const _DEFAULT_LANGUAGE_ = 'ENGLISH';
-   static private $_language = NULL;
-
-   static private $_phrase = NULL;
-
-   function __construct()
-   {
-      echo 'ok';
-   }
-
-   function setLanguage( $pLanguage = false )
-   {
-      if ( !$pLanguage || !is_file($pLanguage . '_language.txt') )
-         return false;
-
-      $this->_language = $pLanguage;
-      $this->_phrase = file($this->_language . '_language.txt');
-
-      foreach($this->_phrase as $val )
-      {
-         $_phrase = explode('§§', $val);
-         if ( sizeof($_phrase) != 2 )
-            continue;
-         $this->_phrase[$_phrase[0]] = $_phrase[1];
-      }
-   }
-
-   public function phrase( $pPhrase )
-   {
-      if ( !$this->_phrase || !isset($this->_phrase[$pPhrase]) )
-         return '** ' . self::_DEFAULT_LANGUAGE_;
-      else
-         return $this->_phrase[$pPhrase];
-   }
-}
-
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_menu_action.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_menu_action.js	(revision 151)
+++ 	(revision )
@@ -1,67 +1,0 @@
-// Instant Messenger
-// im_menu_action.js
-
-	var im_menu_action = {
-      "delay_hide" : 500,
-      "delayhide" : false,
-
-      "menu" : function()
-      {
-         try
-         {
-            var pElement = arguments[0];
-            delete arguments[0];
-            var pMenu = ( func.isString(arguments[1]) ) ? arguments[1] : arguments;
-            if ( document.getElementById(pElement).innerHTML == "" )
-            {
-               func.confEl(pElement, 'style', 'display:block;');
-               this.layout(pMenu, pElement);
-            }
-            else
-            {
-               func.confEl(pElement, 'style', 'display:none;');
-               this.del_innerHTML(pElement);
-               this.clear_delayhide();
-            }
-         }
-         catch(e)
-         {
-         }
-      },
-
-	  "layout" : function(pHtml, pElement)
-      {
-			var _this = this;
-			var el_dest_ = ( func.isString(pElement) ) ? func.byId(pElement) : pElement;
-			var div_menu = func.newEl("div");
-         func.confEl(div_menu, 'style', 'padding:0px;border:1px solid #809aa9');
-			div_menu.onmouseover = function(){_this.clear_delayhide();};
-			div_menu.onmouseout = function(){_this.resetit(pElement);};
-			if ( func.isString(pHtml) )
-				div_menu.innerHTML = pHtml;
-         else
-            for ( i = 1; i < pHtml.length; i++ )
-               func.insEl(pHtml[i], div_menu);
-
-			func.insEl(div_menu, el_dest_);
-			this.delayhide = setTimeout("im_menu_action.del_innerHTML('"+pElement+"')", 2000);
-		},
-
-	   "del_innerHTML": function(pElement)
-       {
-           func.confEl(pElement, 'style', 'display:none;');
-		   func.byId(pElement).innerHTML = "";
-		   document.oncontextmenu = new Function("return true");
-	   },
-
-	   "resetit": function(pElement)
-       {
-			this.delayhide = setTimeout("im_menu_action.del_innerHTML('"+pElement+"')",this.delay_hide);
-	   },
-
-	   "clear_delayhide" : function()
-       {
-			if ( this.delayhide )
-				clearTimeout(this.delayhide);
-	   }
-	}
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_preferences.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_preferences.js	(revision 151)
+++ 	(revision )
@@ -1,576 +1,0 @@
-// Instant Messenger
-// im_preferences.js
-
-	function IM_Preferences()
-	{
-		this.save_vcard = "";	
-		this.jid = false;
-		this.im_timer_xa = "";
-	}
-
-   /*
-	* Add
-	*/
-	
-	IM_Preferences.prototype.Add_userLoad = function()
-	{
-		Templates.add_user();
-		this.SearchOrganizationsLdap();
-		var select_contact = document.getElementById('ImSelAddContact');
-		select_contact.innerHTML = "";
-	}
-	
-	IM_Preferences.prototype.SearchOrganizationsLdap = function()
-	{
-		var handler_organizations = function(data)
-		{
-			var data = func.interface(data);
-			var select_org = document.getElementById('ImSelOrg');
-			if(select_org.options.length > 0)
-				select_org.options.splice(0,select_org.options.length);
-			var options = new Option("--Selecione -- ", -1, false, true);
-			select_org[select_org.length] = options;
-			
-			for(var i in data){
-				var options = new Option(data[i], data[i], false, true);
-				select_org[select_org.length] = options;
-			}
-			select_org[0].selected = true;
-		}
-		XMLTools.request('$this.ldap_im.list_organizations_ldap','GET',handler_organizations);
-	}
-	
-	IM_Preferences.prototype.SearchContacts = function()
-	{
-		var select_org = document.getElementById('ImSelOrg');
-		var organization = "";
-		var span_load = document.getElementById('_span_load_im');
-			span_load.style.display = "block";
-		
-		for(var i=0; i < select_org.options.length; i++){
-			if(select_org.options[i].selected == true){
-				organization = select_org.options[i].value;
-			}
-		}
-		var handler_contacts = function(XMLdata)
-		{
-			var data = func.interface(XMLdata);
-			var select_contact = document.getElementById('ImSelAddContact');
-			var text0 = document.getElementById('text0');
-			var text1 = document.getElementById('text1');
-			var content = "";
-			select_contact.innerHTML = "";
-			text0.value = "";
-			text1.value = "";
-			if(data)
-			{
-				for(var i in data)
-				{
-					var options =  new Option(data[i].cn + " ( "+ data[i].mail + " )", data[i].mail + ";" + data[i].uid, false, false);
-					select_contact[select_contact.length] = options;
-				}
-			}
-			span_load.style.display = "none";		
-		}
-		XMLTools.request('$this.contacts_im.list_contacts','POST',handler_contacts, 'ou='+organization);
-	}
-
-	IM_Preferences.prototype.preenche = function()
-	{
-		var select = document.getElementById('ImSelAddContact');
-		if(select.options.length > 0){
-			for(var i=0; i < select.options.length; i++){
-				if(select.options[i].selected == true){
-					var email = select.options[i].value.substr(0,select.options[i].value.indexOf(';'));
-					var uid = select.options[i].value.substr((select.options[i].value.indexOf(';')+1),select.options[i].value.length);
-					document.getElementById('text0').value = email;
-					document.getElementById('text1').value = select.options[i].value.substr(0,select.options[i].value.indexOf('@'));	
-					document.getElementById('text2').focus();
-					document.getElementById('text3').value = uid; 			
-				}
-			}
-		}
-	}
-	
-	IM_Preferences.prototype.Add_user = function(pFunc)
-	{
-		var text0 = document.getElementById('text0');
-		var text1 = document.getElementById('text1');
-		var text2 = document.getElementById('text2');
-		var text3 = ( document.getElementById('text3') != null ) ? document.getElementById('text3') : false;
-
-		var _this = this;
-		var jid   = text0.value;
-		var subscription = "";
-
-		if(func.trim(text0.value) != "" && func.trim(text1.value) != "" && func.trim(text2.value) != "")
-		{
-			var handler_add_contact = function(data)
-			{
-				IM.vcards = false;
-				IM.Vcard();
-				
-				text0.value = "";
-				text1.value = "";
-				text2.value = "";	
-
-				if(pFunc != 'divAddUser_im')
-				{
-					if(document.getElementById('im_cell_' + jid))
-					{
-						var div_jid = document.getElementById('im_cell_' + jid);
-						div_jid.parentNode.removeChild(div_jid);
-				
-						for(var i in IM.UsersNot)
-							if( IM.UsersNot[i] === jid )
-								IM.UsersNot.splice(i,1);
-	
-						im_win.windowClose(pFunc);
-						Subscription.subscribed(jid);
-						IM.setStatus(statusFlag);
-						setTimeout('Subscription.subscribe("'+jid+'")',2000);
-					}
-				}
-				else
-				{
-					Templates.Status_AddUser();
-					setTimeout("Templates.Status_AddUser();",3000);
-				}				
-				if( IM.UsersNot.length == 0 )
-					im_win.windowClose('divFormAuthUser_im');
-			}
-			var name = text1.value;
-			var group = text2.value;
-			if(text3){
-				var email = text3.value + "@" + text0.value.substr((text0.value.indexOf('@')+1),text0.value.length);
-			}else{
-				var email = text0.value;
-			}
-			XMLTools.request('$this.Ujabber.addContacts','POST',handler_add_contact,"email="+email+"&name="+name+"&group="+group);
-		}else{
-			alert("Informe todos os campos!");
-		}
-	}
-	
-	IM_Preferences.prototype.AcceptRequestUser = function(pJid)
-	{
-		Templates.AcceptRequestUser();
-   		document.getElementById('text0').value = pJid;
-   		document.getElementById('text1').value = pJid.substr(0,pJid.indexOf('@'));
-   		document.getElementById('text1').focus();
-   		document.getElementById('text1').select();
-   		document.getElementById('span0').innerHTML = pJid.substr(0,pJid.indexOf('@'));
-	}
-
-   /*
-	* Remove
-	*/
-
-	IM_Preferences.prototype.RemoveContact = function(pJid)
-	{
-		var _this = this;
-		if(!pJid)
-		{
-			var sel_box = document.getElementById('sel_contact');
-			for(var i=0; i < sel_box.options.length; i++)
-			{
-				if(sel_box[i].selected && sel_box.options[i].value != 0)
-					pJid = sel_box.options[i].value;
-			}
-		}
-		if( pJid )
-		{
-			if( confirm('Deseja remover o contato : ' + pJid) )
-			{
-				IM.vcards = false;
-				IM.Vcard();
-				var div_child = document.getElementById(pJid);
-				div_child.parentNode.removeChild(div_child);
-				_this.ComboRemoveUser(_this.LoadJids());		
-				var handler_remove_contact = function(data)
-				{
-				};
-				XMLTools.request('$this.Ujabber.removeContact','POST',handler_remove_contact,"jid="+pJid);
-			}
-		}else
-			alert('Opção inválida !!');
-	}
-	
-	IM_Preferences.prototype.Remove_userLoad = function()
-	{
-		Templates.remove_user();
-		var div_allg = document.getElementById('all_groups');
-		var _this = this;
-		_this.ComboRemoveUser(_this.LoadJids());		
-	}
-
-	IM_Preferences.prototype.ComboRemoveUser = function(pJids)
-	{
-		var sel_box = document.getElementById('sel_contact');
-		
-		if( document.getElementById('sel_contact') != null )
-		{
-			if( sel_box.options.length > 0 )
-			{
-				for(var i=0; i < sel_box.options.length; i++)
-				{
-					sel_box.options[i] = null;
-					i--;
-				}
-			}
-	
-			var opt = new Option('--- Selecione ---',0,false,true);
-			sel_box[sel_box.length] = opt;		
-			for(var i in pJids)
-			{
-				var opt = new Option(pJids[i].substr(0,pJids[i].indexOf('@')), pJids[i], false, true);
-				sel_box[sel_box.length] = opt;
-			}
-			sel_box[0].selected = true;
-		}
-	}
-
-	IM_Preferences.prototype.DenyRequestUser = function(pJid)
-	{
-		if(confirm('Deseja excluir ' + pJid + '?'))
-		{
-			var div_jid = document.getElementById('im_cell_' + pJid);
-			div_jid.parentNode.removeChild(div_jid);
-			
-			for(var i in IM.UsersNot)
-				if(IM.UsersNot[i] === pJid)
-					IM.UsersNot.splice(i,1);
-
-			if( IM.UsersNot.length == 0 )
-				im_win.windowClose('divFormAuthUser_im');
-
-			var handler_denyrequest = function(data)
-			{
-			};
-			XMLTools.request('$this.Ujabber.unsubscribe','POST',handler_denyrequest,'jid='+pJid);
-		}
-	}
-
-	/*
-	 * LoadJids
-	 */
-
-	IM_Preferences.prototype.LoadJids = function()
-	{
-		var div_allg = document.getElementById('all_groups');
-		var elements = div_allg.firstChild;
-		var jids = [];
-		while ( elements )
-		{			
-			var childs = elements.firstChild;
-			while( childs )
-			{
-				if(childs.tagName == "DIV")
-					jids[jids.length] = childs.id;
-				childs = childs.nextSibling;
-			}
-			elements = elements.nextSibling;
-		}
-		jids.sort();
-		
-		return jids;	
-	}
-	
-   /*
-    * Update
-    */
-   
-   IM_Preferences.prototype.Update_ = function(pJid,pType)
-   {
-		var div_child = document.getElementById(pJid);
-		var group = div_child.parentNode.id;
-		var name  = div_child.firstChild;
-			name = name.nextSibling.nodeValue;
-
-		if(pType)
-		{
-			var action = prompt('Digite um novo apelido para : ' + pJid, " ");
-			name = (action == "Apelido") ? "" : action ;
-		}else{
-			var action = prompt('Digite um novo grupo para : ' + pJid , " ");
-			group = action ;
-		}
-		
-		if( action != "" && action != null)
-		{
-			var handler_update_contact = function(XMLdata)
-			{
-			};
-			XMLTools.request('$this.Ujabber.updateContact','POST',handler_update_contact,"jid="+pJid+"&name="+name+"&group="+group);
-		}
-   }
-
-	IM_Preferences.prototype.Update_Group = function(pJid)
-	{
-		this.Update_(pJid,false);		
-	}
-		
-	IM_Preferences.prototype.Update_NickName = function(pJid)
-	{
-		this.Update_(pJid,true);   
-	}
-   
-   /*
-	* Vcard
-	*/
-
-	IM_Preferences.prototype.vCardInit = function()
-	{
-		var _this = this;
-		var nickname = "";
-		var message  = "";
-		var vcards   = "";
-
-		var handler_getId = function(_XMLdata)
-		{
-			var jid = _XMLdata.getElementsByTagName("retorno").item(0);
-			jid = jid.firstChild.nodeValue;
-			_this.jid = jid;
-			
-			if((vcards = _this.vCardLoad(jid)))
-			{
-				nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length);
-				nickname = nickname.substr(0,nickname.indexOf('|'));
-				nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length);
-
-				message = vcards.substr(vcards.indexOf('DESC'),vcards.length);
-				message = message.substr(0,message.indexOf('|'));
-				message = message.substr(message.indexOf(':') + 1 , message.length);
-			}
-			
-			nickname = (func.trim(nickname) != "" ) ? nickname : _this.jid ;
-			message  = (func.trim(message) != "" ) ? message : "Sua Mensagem";
-			IM.custom_message = message;
-			
-			var span_nick = document.getElementById('span_nickname');
-				span_nick.innerHTML = ( nickname ) ? "<b>" + decodeURI(nickname.substring(0,15)) + "</b>" : "<b>" + IM.get_lang('Nickname') + "</b>";
-		}
-		XMLTools.request('$this.Ujabber.getJid','GET',handler_getId);
-	}
-
-	IM_Preferences.prototype.vCardLoad = function(Jid)
-	{
-		var div_jid  = document.getElementById("vcard_" + Jid);
-		var strg = div_jid.innerHTML;
-		var elements = div_jid.firstChild;
-		var exp , tag  = '';
-		
-		while ( elements )
-		{			
-			if(elements.tagName != undefined && elements.tagName.substr(0,1) != "/" )
-			{		
-				tag = elements.tagName;
-				exp = eval('/<'+tag+'>/gi');
-				strg = strg.replace(exp, tag + " : " );
-				exp = eval('/<\\/'+tag+'>/gi');
-				strg = strg.replace(exp, " | ");
-			}
-			elements = elements.nextSibling;
-		}			
-
-		return strg;
-	}
-		
-	IM_Preferences.prototype.vCard = function()
-	{
-		if(!this.jid){
-			alert('Carregando !!');
-		}else{
-			var div_jid  = document.getElementById("vcard_" + this.jid);
-			var strg = div_jid.innerHTML;
-			Templates.information_user(strg);
-		}	
-	}
-
-	IM_Preferences.prototype.vCardLoad_Contact = function(pJid)
-	{
-		if(!this.jid){
-			alert('Carregando !!');
-		}else{
-			if(document.getElementById('vcard_' + pJid) != null)
-			{
-				var vcards = document.getElementById('vcard_' + pJid);
-				Templates.information_Contact(vcards.innerHTML);
-			}else
-				alert('Vcard não carregado!');
-		}
-	}
-	
-	IM_Preferences.prototype.vCardAdd = function()
-	{
-		var Nvcard = new Array('FN','NICKNAME','ORGNAME','ORGUNIT','ROLE','BDAY','DESC');
-		var vcard = "";
-		var new_vcard = "";
-		var value = "";
-		for(var i in Nvcard)
-		{
-			if( Nvcard[i] === 'NICKNAME' )
-			{	
-				var nn = ( func.trim(document.getElementById(Nvcard[i]).value) != "") ? document.getElementById(Nvcard[i]).value : this.jid; 
-				document.getElementById('span_nickname').innerHTML = "<b>" + nn.substring(0,15) + "</b>";
-			}
-			
-			value = document.getElementById(Nvcard[i]).value;
-			new_vcard += '<'+Nvcard[i]+'>'+value+'</'+Nvcard[i]+'>';
-			value = (func.trim(value) != "") ? value : "";
-			vcard += value + "_vkrd_";
-		}
-
-		document.getElementById("vcard_" + this.jid).innerHTML = new_vcard;
-		vcard = vcard.substr(0,vcard.length - 6 );		
-
-		var handler_vcard_add = function(XMLdata)
-		{
-		};
-		XMLTools.request('$this.Ujabber.newVcard','POST',handler_vcard_add,"vcard="+escape(vcard));	
-		alert('Informações Cadastradas / Adicionadas !!!');	
-		im_win.windowClose('divInfoUser_im');
-	}
-	
-   /*
-	* IM_Preferences
-	*/
-	
-	IM_Preferences.prototype.yourPreferences = function()
-	{
-		Templates.yourPreferences();
-	}
-
-	IM_Preferences.prototype.SetYourPreferences = function()
-	{
-		var preferences = "";
-		preferences  = ( func.byId('ch_offline').checked ) ? 'ch_offline:true;' : 'ch_offline:false;';
-		if( func.byId('in_time').value )
-		{
-			var numbers = /^\d+$/;
-			if(numbers.test(func.byId('in_time').value) && func.byId('in_time').value != "0")
-				var minutes = func.byId('in_time').value;
-			else
-			{
-				alert('Informe valores válidos !');
-				func.byId('in_time').focus();
-				return false;
-			}
-		}
-
-		this.im_timer_xa = func.byId('in_time').value;
-		preferences += ( func.trim(func.byId('in_time').value )) ? 'in_time:' + func.byId('in_time').value + ";" : 'in_time:0;';
-		preferences += ( func.byId('rd_nm').checked ) ? 'rd_nm:true;' : 'rd_nm:false;';
-		preferences += ( func.byId('rd_ch').checked ) ? 'rd_ch:true' : 'rd_ch:false';
-		IM.userPrefe = preferences;
-		
-		var handler_preferences = function(XMLdata)
-		{
-			var data = XMLdata.getElementsByTagName('retorno').item(0);
-			data = eval(data.firstChild.nodeValue);
-			if(data)
-			{
-				IM.Contacts_Offline();
-				alert('Preferências salvas !');
-			}
-		};
-		XMLTools.request('$this.db_im.set_preferences','POST',handler_preferences,'preferences='+preferences);
-	}
-	
-	IM_Preferences.prototype.GetYourPreferences = function()
-	{
-		var _this = this;
-		if(!IM.userPrefe)
-		{
-			var handler_getPreferences = function(XMLdata)
-			{
-				var data = XMLdata.getElementsByTagName('retorno').item(0);
-				data = data.firstChild.nodeValue;
-				IM.userPrefe = data;
-				_this.TimerXa(_this.LoadPreferences('in_time'));
-			}
-			XMLTools.request('$this.db_im.get_preferences','GET',handler_getPreferences);
-		}
-	}
-	
-	IM_Preferences.prototype.LoadPreferences = function(pElement)
-	{
-		var preferences_im = IM.userPrefe;
-		
-		while( preferences_im !== "")
-		{
-			var values = "";
-			var value = "";
-			if(value = preferences_im.substr(0,preferences_im.indexOf(';')))
-			{
-				values = value + '\n';
-				preferences_im = preferences_im.replace(value,'');	
-			}
-			if(preferences_im.substr(0,1) == ";"){
-				preferences_im = preferences_im.substr(1,preferences_im.length);
-			}else{
-				values = preferences_im + '\n';
-				preferences_im = '';
-			}
-			
-			var ele = values.substr(0,values.indexOf(':'));
-			var val = values.substr((values.indexOf(':')+1),values.length);
-
-			if(ele == pElement)
-				return val;
-
-			if((document.getElementById(ele)!= null) && (document.getElementById(ele).type == 'text'))
-				document.getElementById(ele).value = val;
-			else
-				if(document.getElementById(ele) != null)
-					document.getElementById(ele).checked = eval(val);
-		}
-	}
-
-   /*
-    * Estado de Ausente Automático
-    */
-	
-	IM_Preferences.prototype.TimerXa = function(pTimer)
-	{
-		this.im_timer_xa = pTimer;
-		_awayTimer = setTimeout("IM.setAway()", parseInt(pTimer) * 60000 );
-	}
-
-   /*
-	*  Detalhes do Contato para Autorização
-	*/
-	
-	IM_Preferences.prototype.Info_Contact = function(pJid)
-	{
-		var element = "_span_not_" + pJid;
-		var uid = pJid.substr(0,pJid.indexOf('@'));
-		var handler_ldap =  function(data)
-		{
-			var data = func.interface(data);
-			var XMLinfoLdap = "";
-			if(data)
-			{
-				XMLinfoLdap = '<info_user>';
-				for(var i in data)			
-					XMLinfoLdap += '<item lang_name="'+IM.get_lang('Name')+'" name="'+ data[i].cn +'" lang_email="'+IM.get_lang('E-mail')+'" email="'+ data[i].mail +'" />';
-				XMLinfoLdap += '</info_user>';
-			}
-			im_menu_action.menu(element, parse_XmlXsl(XMLinfoLdap,'info_contact_ldap.xsl'));
-			if(document.getElementById('im_span_avatar') != null)
-			{
-				var span = document.getElementById('im_span_avatar');
-				var	img = func.newEl('img');
-				func.confEl(img, 'id', pJid + '_avatar');
-				func.confEl(img, 'src', img_photo.src);
-				func.confEl(img, 'style', 'height:65px;width:60px;align:right;');
-				span.appendChild(img);
-				// Foto Ldap;
-				im_win.get_photo_ldap(pJid);
-			}
-		}
-		XMLTools.request('$this.ldap_im.info_user','POST',handler_ldap,'uid='+uid);
-	}
-	
-	// Build Object	
-	var IM_Preferences = new IM_Preferences();
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_init.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_init.js	(revision 151)
+++ 	(revision )
@@ -1,15 +1,0 @@
-function init_jabber()
-{
-   try
-   {
-      if ( window.IM && window.im_win && window.func )
-         IM.load_im();
-      else
-         setTimeout('init_jabber()', 2000);
-   }
-   catch(e)
-   {
-         setTimeout('init_jabber()', 2000);
-   }
-}
-init_jabber();
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_subscription.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_subscription.js	(revision 151)
+++ 	(revision )
@@ -1,51 +1,0 @@
-// Instant Messenger
-// im_subscription.js
-
-	function Subscription()
-	{
-	}
-	
-	Subscription.prototype.subscribe = function(pJid)
-	{
-		var handler_subscribe = function(data)
-		{
-		};
-		XMLTools.request('$this.Ujabber.subscribe','POST',handler_subscribe,'jid='+pJid);
-	}		
-	
-	Subscription.prototype.subscribed = function(pJid)
-	{
-		var handler_subscribe = function(data)
-		{
-		};
-		XMLTools.request('$this.Ujabber.subscribed','POST',handler_subscribe,'jid='+pJid);
-	}
-	
-	Subscription.prototype.unsubscribe = function(pJid)
-	{
-		alert('#1 - O usuário ' + pJid + "\nnão aceitou seu convite ou o excluiu de sua lista!" );	
-	}
-	
-	Subscription.prototype.unsubscribed = function(pJid)
-	{
-		alert('#2 - O usuário ' + pJid + ' não aceitou seu convite!' );
-	}
-	
-	Subscription.prototype.RequestAutorization = function(pJid)
-	{
-		if(confirm('(Re)-requisitar Autorização para o usuário : ' + pJid))
-		{
-			var handler_requestAut = function(data)
-			{
-			};
-			XMLTools.request('$this.Ujabber.subscribe','POST',handler_requestAut,'jid='+pJid);
-		}
-	}
-
-	Subscription.prototype.complete_subscribe = function(pJid)
-	{
-		this.subscribed(pJid);
-	}
-	// Build Object;
-	
-	var Subscription = new Subscription();
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_images.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_images.js	(revision 151)
+++ 	(revision )
@@ -1,35 +1,0 @@
-// Instant Messenger
-// im_images.js
-
-		var navbar = new Image();
-		navbar.src = im_path + 'templates/default/images/navbar.png';
-		var img_group_close = new Image();
-		img_group_close.src = im_path + "templates/default/images/group_close.gif";
-		var img_group_open = new Image();
-		img_group_open.src = im_path + "templates/default/images/group_open.gif";
-		var img_available = new Image();
-		img_available.src = im_path + "templates/default/images/available.gif";
-		var img_unavailable = new Image();
-		img_unavailable.src = im_path + "templates/default/images/unavailable.gif";
-		var img_busy = new Image();
-		img_busy.src = im_path + "templates/default/images/busy.gif";
-		var img_chat = new Image();
-		img_chat.src = im_path + "templates/default/images/chat.gif";
-		var img_photo = new Image();
-		img_photo.src = im_path + "templates/default/images/photo.png";
-		var img_menu = new Image();
-		img_menu.src = im_path + "templates/default/images/menu.gif";
-		var img_chat_bubble = new Image();
-		img_chat_bubble.src = im_path + "templates/default/images/chat_bubble.gif";
-		var img_typing = new Image();
-		img_typing.src = im_path + "templates/default/images/typing.gif";
-		var img_edit = new Image();
-		img_edit.src = im_path + "templates/default/images/img/icon_edit.gif";
-		var img_xa = new Image();
-		img_xa.src = im_path + "templates/default/images/xa.gif";
-		var img_away = new Image();
-		img_away.src = im_path + "templates/default/images/away.gif";
-		var img_dnd = new Image();
-		img_dnd.src = im_path + "templates/default/images/dnd.gif";
-		var img_wait = new Image();
-		img_wait.src = im_path + "templates/default/images/wait.gif";
Index: unk/instant_messenger/bkp/instant_messenger_32/js/build_win.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/build_win.js	(revision 151)
+++ 	(revision )
@@ -1,169 +1,0 @@
-/**
-* @AUTHOR: Alexandre Correia - alexandrecorreia [.at.] celepar [.dot.] pr [.dot.] gov [.dot.] br
-* @AUTHOR: Rodrigo Souza - rodrigosouzadossantos [.at.] gmail [.dot.] com
-* @COPYLEFT: GPL - http://www.gnu.org/copyleft/gpl.html
-* @DATE: 07/11/2007
-* @LAST CHANGE:
-* @BRIEF:
-**/
-
-function build_win()
-{
-	this.window 	= [];
-	this.position 	= {"x":10, "y":10};
-	this.focus 		= 1000;
-	this.xtools		= new XTools();
-}
-
-build_win.prototype = {
-
-	"elementB" : function(pId)
-	{
-		return document.getElementById(pId + '_window_body');
-	},
-
-	"elementC" : function(pId)
-	{
-		return document.getElementById(pId + '_window_body_content');
-	},
-
-	"elementM" : function(pId)
-	{
-		return document.getElementById(pId + '_window_master');
-	},
-	
-	"load" :  function(pId, pParentId, pXml, pXsl, pSize, pButMin, pButMax, pButClose)
-	{
-		try{
-			if( document.getElementById(pId + '_window_master') == null)
-			{
-				pXml  = '<window>' + pXml ;
-				pXml += '<name>' + pId + '</name>';
-				pXml += (pSize) ? '<size>' + pSize + 'px</size>' : '<size>200px</size>' ;
-				pXml += (pButMin) ? '<pButMin>block</pButMin>' : '<pButMin>none</pButMin>';
-				pXml += (pButMax) ? '<pButMax>block</pButMax>' : '<pButMax>none</pButMax>';
-				pXml += (pButClose) ? '<pButClose>block</pButClose>' : '<pButClose>none</pButClose>';
-				pXml += '</window>';
-
-				var div = document.createElement("div");
-				div.innerHTML = this.xtools.parse(pXml,pXsl);
-				document.getElementById(pParentId).appendChild(div);
-
-				this.window_position(pId, this.elementM(pId));
-				this.window_state(pId, 'nm');
-				this.window_focus(this.elementM(pId));
-			}
-			else
-			{
-				this.window_visible(pId);
-				this.window_state(pId, 'nm');
-			}
-		}
-		catch(e){/*alert("Error : \n\n" + e + "\n\n" + e.description);*/}
-	},
-
-	"window_close" :  function(pId)
-	{
-		this.window_state(pId, 'cl');
-		this.elementM(pId).parentNode.removeChild(this.elementM(pId));
-	},
-
-	"window_focus" :  function(pElement)
-	{
-		pElement.style.zIndex = ++this.focus;
-	},
-
-	"window_maximize" : function(pId)
-	{
-		this.window_state(pId, 'max');
-
-		// _button_maximize
-		var button_maximize = document.getElementById(pId + '_button_maximize');
-		button_maximize.onclick = function(){buildIM.window_normal(button_maximize, pId, 'window_maximize');};
-
-		// _window_master
-		this.elementM(pId).style.top = "0px";
-		this.elementM(pId).style.left = "0px";
-		this.elementM(pId).style.width = 'auto';
-		this.elementM(pId).style.height = '100%';
-
-		// _window_body
-		this.elementB(pId).style.width = 'auto';
-		this.elementB(pId).style.height =  '100%';
-
-		// _window_body_content
-		this.elementC(pId).style.height = '100%';
-	},
-
-	"window_minimize" :  function(pId)
-	{
-		this.window_state(pId, 'min');
-
-		// _window_master
-		this.elementM(pId).style.display = 'none';
-	},
-
-	"window_normal" : function(pButton, pId, pFunction)
-	{
-		this.elementM(pId).style.top = this.window[pId].y;
-		this.elementM(pId).style.left = this.window[pId].x;
-		this.elementM(pId).style.width = this.window[pId].w;
-		this.elementM(pId).style.height = 'auto';
-		pButton.onclick = function(){eval('buildIM.' + pFunction + '("' + pId + '")');};
-		this.window_state(pId, 'max');
-	},
-
-	"window_object" : function( pId, pState)
-	{
-		this.window[pId] = {
-			"x": this.elementM(pId).offsetLeft,
-			"y": this.elementM(pId).offsetTop,
-			"w": this.elementM(pId).clientWidth,
-			"h": this.elementM(pId).clientHeight,
-			"s": pState
-		};
-	},
-
-	"window_position" : function( pId, pElement )
-	{
-		pElement.style.position = 'absolute';
-
-		if ( this.window[pId] )
-		{
-			pElement.style.left = this.window[pId].x + "px";
-			pElement.style.top  = this.window[pId].y + "px";
-		}
-		else
-		{
-			pElement.style.left = parseInt( this.position.x += 10 ) + "px";
-			pElement.style.top  = parseInt( this.position.y += 10 ) + "px";
-		}
-	},
-
-	"window_state" : function(pId, pState)
-	{
-
-		if(this.window[pId])
-		{
-			if(pState == 'max')
-			{
-				if(this.window[pId].s == 'max')
-					this.window_object( pId, pState);
-				else
-					this.window_object( pId, pState);
-			}
-			else if( pState == 'cl')
-				this.window_object( pId, pState);
-		}
-		else
-			this.window_object( pId, pState);
-	},
-
-	"window_visible" : function(pId)
-	{
-		if ( this.elementM(pId).style.display == 'none' )
-				this.elementM(pId).style.display = 'block';
-	}
-};
-
-var buildIM = new build_win();
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_functions.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_functions.js	(revision 151)
+++ 	(revision )
@@ -1,963 +1,0 @@
-	function IM()
-	{
-	   this.vcards      = false;
-	   this.statusvcard = false;
-	   this.UsersNot	= [];
-	   this.userPrefe   = false;
-	   this.count_Vcard = 0;
-	   this._listen     = "";
-	   this.custom_message = "";
-	   this.timeout_composing = "";
-	}
-
-	IM.prototype.load_im = function()
-	{
-		this.listen();
-	    this.requireContacts();
-	    this.atalho();
-
-	    var handler_Status = function(XmlData)
-	    {
-			var data = XmlData.getElementsByTagName('retorno').item(0);
-			data = data.firstChild.nodeValue;
-			if( data )
-			{
-				if(data == 'available' || data == 'xa')
-					awayFlag = true;
-				statusFlag = data;
-				setTimeout('IM.ImgStatus("'+data+'")',4000);
-			}
-	    };
-	    XMLTools.request('$this.Ujabber.MyPresence', 'GET', handler_Status);
-	};
-
-	IM.prototype.listen = function()
-	{
-	   var _this = this;
-	   var handler = function(XMLdata)
-	   {
-	      try
-	      {
-				var data = XMLdata.documentElement;
-				if ( data.hasChildNodes() )
-				{
-					data = data.firstChild;
-					if ( data.nodeType == 3 && data.nodeValue == 'disconnected' ) 
-					{
-						document.getElementById('div_contacts').innerHTML = '<a href="javascript:void(0);" onclick="javascript:IM.reconnect();">'+_this.get_lang("Re-connect Expresso Messenger ?")+'</a>';
-						_this.ImgStatus('unavailable');
-						statusFlag = 'unavailable';
-						clearTimeout(_awayTimer);
-						return false;
-					}
-				}					
-				
-				if( !_this.userPrefe )
-				{
-					if(window.IM_Preferences)
-						IM_Preferences.GetYourPreferences();
-				}
-
-	            _this.getContacts(XMLdata);
-	            _this.getPresence(XMLdata);
-				_this.getComposing(XMLdata);
-	            _this.getMessages(XMLdata);
-				_this.getVcard(XMLdata);
-
-            	if(!_this.vcards)
-            	{
-	            	_this.Vcard();
-	            	_this.vcards = true;
-	            }
-
-	      }catch(e){}
-
-	      _this._listen = setTimeout('IM.listen()', 3000);
-	   };
-
-	   XMLTools.__RETURN_MODE__ = 'XML';
-	   XMLTools.request('$this.Ujabber.listen', 'GET', handler);
-	};
-	
-	IM.prototype.reconnect = function()
-	{
-		var _this = this;
-		var handler_reconnect = function(XMLdata)
-		{
-			if ( XMLdata.documentElement.firstChild.nodeValue == 'true' )
-			{
-				document.getElementById('div_contacts').innerHTML  = '<div><img src="' + img_wait.src + '" width="25px" heigth="25px" style="float:left;margin:3px "/>';
-				document.getElementById('div_contacts').innerHTML += '<font style="color:#0000FF;float:left;margin:9px 5px">' + _this.get_lang("Wait a moment !!") + '</font></div>';
-				setTimeout('IM.load_im()',2000);
-	           	_this.count_Vcard = 0;
-				_this.ImgStatus('available');
-				statusFlag = 'available';	   
-				_awayTimer = setTimeout("IM.setAway()", parseInt(IM_Preferences.im_timer_xa) * 60000 );				        	
-			}else{
-				document.getElementById('div_contacts').innerHTML = '<a href="javascript:void(0);" onclick="javascript:IM.reconnect();">'+_this.get_lang("Re-connect Expresso Messenger ?")+'</a>';
-				_this.ImgStatus('unavailable');
-				statusFlag = 'unavailable';				
-				return false;
-			}
-		};
-		XMLTools.__RETURN_MODE__ = 'XML';
-		XMLTools.request('$this.Ujabber.reconnect', 'GET', handler_reconnect);
- 	};
-
-   /*
-	*  Contacts
-	*/
-
-	IM.prototype.requireContacts = function()
-	{
-	   var handler = function(data)
-		{
-		};
-	   XMLTools.request('$this.Ujabber.requireContacts', 'GET', handler);
-	};
-
-	IM.prototype.getContacts = function(data)
-	{
-	   try
-	   {
-	      if ( data.getElementsByTagName('contacts').length > 0 )
-	      {
-	         var node = data.documentElement.firstChild;
-	         while ( node.nodeName != 'contacts' )
-	         	node = node.nextSibling;
-
-	         var div = document.getElementById("div_contacts");
-	         var xsl = XMLTools.load(im_path + 'xsl/contacts.xsl?' + Date.parse(new Date));
-	         var img = document.createElement('img');
-	         img.id  = 'img_all_groups';
-	         img.src = img_group_open.src;
-	         img.onclick = function(){IM.visible_group("all_groups")};
-
-	         var a = document.createElement('div');
-	         a.innerHTML = XMLTools.transform(node, xsl);
-
-	         div.innerHTML = '';
-	         div.appendChild(img);
-	         div.appendChild(document.createTextNode(this.get_lang('List of Contacts')));
-	         div.appendChild(a);
-
-			 var group = func.byId("all_groups").firstChild;
-			 while ( group )
-	         {
-					var contact = group.firstChild.nextSibling;
-					while ( contact = contact.nextSibling )
-					{
-						var img = func.newEl('img');
-						img.src = img_unavailable.src;
-
-						func.insElB(img, func.byId(contact.id).firstChild);
-					}
-
-					try
-					{
-						var img = document.createElement('img');
-						img.src = img_group_open.src;
-						img.id = "img_" + group.id;
-						var el_parent = group;
-
-						el_parent.insertBefore(img,el_parent.firstChild);
-
-					} catch(e){}
-					group = group.nextSibling;
-	         }
-	      }
-	   }catch(e){}
-
-	};
-
-   /*
-	*  Visible / Unvisible
-	*/
-
-	IM.prototype.visible_group = function(el)
-	{
-		var _this = this;
-		var divParent = document.getElementById(el);
-		divParent.style.display = "none";
-		var img = document.getElementById("img_" + el);
-		img.onclick = function(){_this.unvisible_group(el)};
-		img.src = img_group_close.src;
-	}
-
-	IM.prototype.unvisible_group = function(el)
-	{
-		var _this = this;
-		var div = document.getElementById(el);
-		div.style.display = "";
-		var img = document.getElementById("img_" + el);
-		img.onclick = function(){_this.visible_group(el)};
-		img.src = img_group_open.src;
-	}
-
-	/*
-	 * Presence
-	 */
-
-	IM.prototype.getPresence = function(data)
-	{
-	   try
-	   {
-	      var presence = data.documentElement.firstChild;
-		  var _this = this;
-	      while ( presence )
-	      {
-		      if ( presence.nodeName != 'presence' )
-		      {
-                 presence = presence.nextSibling;
-		         continue;
-		      }
-
-				var from = presence.getAttribute('from');
-				var type = presence.getAttribute('type');
-				if ( presence.hasChildNodes() )
-					var status_message = presence.firstChild.nodeValue;
-				else
-					var status_message = false;
-
-				if( from )
-				{
-			         switch ( type )
-			         {
-			         	case 'subscribe' :
-			         		if ( !func.byId(from) )
-								_this.UsersNot[_this.UsersNot.length] = from;
-							else
-							{
-								Subscription.subscribed(from);
-								this.setStatus(statusFlag);
-							}
-						break;
-			         	case 'subscribed' :
-			         		//
-			         	break;
-			         	case 'unsubscribe' :
-			         		Subscription.unsubscribe(from);
-			         		type = 'unavailable';
-			         		func.byId(from).firstChild.src = eval('img_' + type + '.src');
-			         		break;
-			         	case 'unsubscribed' :
-			         		Subscription.unsubscribed(from);
-			         		type = 'unavailable';
-			         		func.byId(from).firstChild.src = eval('img_' + type + '.src');
-			         		break;
-			         	default :
-			     			if ( func.byId(from) )
-			     			{
-			     				func.byId(from).firstChild.src = eval('img_' + type + '.src');
-			     				var status;
-
-			     				if ( (status = func.byId(from + '_im_window')) )
-			     				{
-						        	status.firstChild.style.background = 'url('+func.byId(from).firstChild.src+')';
-									status = func.byId(from + '_im_window_message');
-						        	if( status_message && status_message != "available" )
-						        		status.innerHTML = from.substr(0, from.indexOf('@')) + ' : ' + status_message;
-						        	else
-						        		status.innerHTML = '';
-						        }
-
-	     						if( document.getElementById('status_message_' + from) == null)
-	     						{
-		     						var lbl = document.createElement('label');
-		     						lbl.id = 'status_message_' + from;
-		     						if(!status_message)
-		     							lbl.innerHTML = "";
-		     						else
-		     							if( status_message != "available" )
-				     						lbl.innerHTML = "<span style='margin-left:10px'><br/> ( " + status_message + " )</span>";
-									func.byId(from).appendChild(lbl);
-		     					}else{
-									var lbl = document.getElementById('status_message_' + from);
-		     						if(!status_message)
-		     							lbl.innerHTML = "";
-		     						else
-		     							if( status_message != "available" )
-				     						lbl.innerHTML = "<span style='margin-left:10px'><br/> ( " + status_message + " )</span>";
-		     					}
-			     			}
-			         }
-				 }
-			    if( _this.UsersNot.length > 0 )
-			  		Templates.Users_Not_Auth(_this.UsersNot);
-	         presence = presence.nextSibling;
-	      }
-	      _this.Contacts_Offline();
-	   }catch(e){}
-	};
-
-	/*
-	 * Contatos - Offline
-	 */
-
-	IM.prototype.Contacts_Offline = function()
-	{
-		 var offline = true;
-		 if(IM.userPrefe)
-		 	offline = eval(IM_Preferences.LoadPreferences('ch_offline'));
-		 else
-		 	offline = eval(IM_Preferences.LoadPreferences('ch_offline'));
-
-		 var group = func.byId("all_groups").firstChild;
-		 while ( group )
-         {
-			var contact = group.firstChild;
-			while ( contact )
-			{
-				if(contact.tagName == "DIV")
-				{
-					var childF = contact.firstChild;
-					if( childF.src == img_unavailable.src && !offline)
-						func.byId(contact.id).style.display = "none";
-					else
-						func.byId(contact.id).style.display = "block";
-				}
-				contact = contact.nextSibling;
-			}
-			group = group.nextSibling;
-         }
-	}
-
-	/*
-	 * Get / Send - Messages
-	 */
-
-	IM.prototype.getMessages = function(data)
-	{
-	   try
-	   {
-	      data = data.documentElement;
-	      if ( data.childNodes.length > 0 )
-	      {
-	         var message = data.firstChild;
-	         while ( message )
-	         {
-	            if ( message.tagName == 'messages' )
-	            {
-	               var from = message.getAttribute('from');
-	               with ( from )
-	                  from = substr(0, indexOf('/'))
-
-	               if( document.getElementById('vcard_' + from) != null)
-	               {
-						var vcards = IM_Preferences.vCardLoad(from);
-						var nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length);
-						    nickname = nickname.substr(0,nickname.indexOf('|'));
-						    nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length);
-						    nickname = ( func.trim(nickname) != "" ) ? nickname : from ;
-				   }
-				   else
-				      var nickname = from;
-				  
-				   if(nickname.indexOf('@') != -1)	
-				   		nickname = nickname.substr(0,nickname.indexOf('@'));
-
-	               var win = document.getElementById(from + '_chatMessages');
-	               if ( !win )
-	               {
-	                  im_win.open_chat(from);
-	                  win = document.getElementById(from + '_chatMessages');
-	               }
-
-	               var el = message.firstChild;
-	               while ( el )
-	               {
-	                  var xsl = XMLTools.load(im_path + 'xsl/message.xsl?' + Date.parse(new Date));
-	                  var next = el.nextSibling;
-
-	                  var label = document.createElement('strong');
-	                  label.appendChild(document.createTextNode(nickname));
-
-	                  win.appendChild(label);
-	                  win.appendChild(document.createElement('br'));
-	                  var msg = XMLTools.transform(el, xsl);
-	                  win.innerHTML += this.emotions_icons(msg);
-	                  win.appendChild(document.createElement('br'));
-	                  win.appendChild(document.createElement('br'));
-	                  win.scrollTop = win.scrollHeight;
-			   		  im_win.newMessageNotification();
-
-	                  el = next;
-	               }
-	            }
-
-				if ( (composing = func.byId(from + '_composing')) )
-					if ( composing.style.display = 'block' )
-						composing.style.display = 'none';
-
-	            message = message.nextSibling;
-	         }
-	      }
-	   }catch(e){}
-	}
-
-	IM.prototype.sendMessage = function (pJID)
-	{
-	   var _this = this;
-	   var name_document = document.getElementById(pJID + '_edita');
-	   var envio = name_document.contentWindow.document.getElementsByTagName('body').item(0);
-
-	   var imgs = envio.getElementsByTagName('img');
-	   var cod;
-	   var emotion_regexp;
-
-	   for ( i = imgs.length - 1; i > -1; i--)
-	   {
-	      if ( (cod = imgs[i].getAttribute('emotion')) )
-		  {
-			 emotion_regexp = new RegExp('<img[^>]*?emotion="' + cod_emotions[cod][1] + '"[^>]*?>', "i");
-             envio.innerHTML = envio.innerHTML.replace(emotion_regexp, cod);
-          }
-	      else
-	         imgs[i].parentNode.removeChild(imgs[i]);
-	   }
-
-	   envio.innerHTML = func.trim(envio.innerHTML);
-	   envio.innerHTML = envio.innerHTML.replace(/&nbsp;| +/gi, ' ');
-	   envio.innerHTML = envio.innerHTML.replace(/<br[^>]*>/gi, '<br />');
-
-	   if ( envio.innerHTML != "" )
-	   {
-	      var message_text  = "<div style='";
-	      message_text += (envio.style.fontFamily != "") ? "font-family:"+envio.style.fontFamily+";" : "";
-	      message_text += (envio.style.fontSize != "") ? "font-size:"+envio.style.fontSize+";" : "" ;
-	      message_text += (envio.style.fontWeight != "") ? "font-weight:"+envio.style.fontWeight+";": "";
-	      message_text += (envio.style.fontStyle != "" ) ? "font-style:"+envio.style.fontStyle+";" : "";
-	      message_text += (envio.style.color != "") ? "color:"+envio.style.color+";" : "color:black";
-	      message_text += "'>";
-	      message_text += envio.innerHTML + "</div>";
-
-	   	  message_text = message_text.replace(/&nbsp;| +/gi, ' ');
-	   	  message_text = message_text.replace(/<br[^>]*>/gi, '<br />');
-
-	      envio.innerHTML = '';
-
-	      var message_element = document.getElementById(pJID + '_chatMessages');
-	      var nickname = "me ";
-		  if( IM_Preferences.jid )
-		  {
-			  var vcards = IM_Preferences.vCardLoad(IM_Preferences.jid);
-			  nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length);
-			  nickname = nickname.substr(0,nickname.indexOf('|'));
-			  nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length);
-			  nickname = (func.trim(nickname) != "") ? nickname : IM_Preferences.jid;
-			  if(nickname.indexOf('@') != -1)	
-				nickname = nickname.substr(0,nickname.indexOf('@'));
-		  }
-
-	      message_element.innerHTML += '<strong>' + nickname + ' ';
-	      message_element.innerHTML += ' ' + _this.get_lang('speak') + ':</strong><br />';
-		  message_element.innerHTML += this.emotions_icons(message_text) + '<br />';
-	      message_element.scrollTop = message_element.scrollHeight;
-
-	      var handler_sendMessage = function(data)
-	      {
-			 var data = func.interface(data);
-	         if(!data)
-	            alert(data);
-	      }
-	   	  XMLTools.request('$this.Ujabber.SendMessage','POST',handler_sendMessage,"to="+pJID+"&body="+escape(message_text));
-	   }
-	};
-    
-    /*
-     * Composing / GetComposing / Paused Message
-     */
-
-	IM.prototype.getComposing = function(data)
-	{
-		if ( data.hasChildNodes() )
-		{
-			var node = data.documentElement.firstChild;
-			while ( node )
-			{
-				var composing;
-				if ( node.nodeName == 'composing' )
-					if ( (composing = func.byId(node.getAttribute('from') + '_composing')) )
-						if ( composing.style.display = 'none' )
-							composing.style.display = 'block';
-
-				if ( node.nodeName == 'paused' )
-					if ( (composing = func.byId(node.getAttribute('from') + '_composing')) )
-						if ( composing.style.display = 'block' )
-							composing.style.display = 'none';
-
-				node = node.nextSibling;
-			}
-		}
-	};
-	
-	IM.prototype.composingMessage = function(pId)
-	{
-		if( IM.timeout_composing )
-		{	
-			clearTimeout(IM.timeout_composing);
-			IM.timeout_composing = eval('setTimeout("IM.pausedMessage(\'' + pId + '\')",2000)');
-		}
-		else
-		{
-			IM.timeout_composing = eval('setTimeout("IM.pausedMessage(\'' + pId + '\')",2000)');
-			var handler_composingMessage = function(data)
-			{
-			};
-			XMLTools.request('$this.Ujabber.composingMessage', 'POST', handler_composingMessage,"to="+pId);
-		}
-	};
-	
-	IM.prototype.pausedMessage = function(pId)
-	{
-		clearTimeout(IM.timeout_composing);
-		IM.timeout_composing = "";
-		var handler_pausedMessage = function(data)
-		{
-		};
-		XMLTools.request('$this.Ujabber.pausedMessage','POST',handler_pausedMessage,"to="+pId);
-	};
-
-	/*
-	 * Get_lang
-	 */
-
-	IM.prototype.get_lang = function(_key, _arg1, _arg2, _arg3, _arg4)
-	{
-	   var _value = "";
-
-	   if ( !lang_im[_key.toLowerCase()] )
-	      return _key + "*";
-
-	   _value = lang_im[_key.toLowerCase()];
-
-	   if ( _arg1 || _arg2 ||_arg3 || _arg4 )
-	   {
-	      for (j = 1; j <= 4; j++ )
-	         if( eval("_arg"+j) )
-	         {
-	            var regExp = new RegExp("%" + j + "");
-	            _value = _value.replace(regExp, eval("_arg"+j));
-	         }
-	   }
-
-	   return _value;
-	};
-
-	IM.prototype.getWinContactsState = function()
-	{
-	   try
-	   {
-	      var win_state = false;
-	          win_state = ( windowItems['contacts'].state == WINDOW_STATE_REGULAR ) ? true : false;
-	          win_state = ( win_state ) ? win_state : ( windowItems['contacts'].state == WINDOW_STATE_MAXIMIZED ) ? true : false;
-	      return win_state;
-
-	   }catch(e){}
-	};
-
-	IM.prototype.showContacts = function()
-	{
-	   if ( this.getWinContactsState() )
-	      im_win.windowClose('contacts_im');
-	   else
-	   {
-	      im_win.windowMaximizeRestore('contacts_im');
-	   }
-	};
-
-   /*
-	*  Smiles
-    */
-
-    IM.prototype.emotions_icons = function(pEmotion)
-    {
-	   var emotion_regexp;
-	   for ( i in cod_emotions )
-       {
-		  try
-		  {
-			 emotion_regexp = new RegExp(cod_emotions[i][1], 'gi');
-             if ( emotion_regexp.test(pEmotion) )
-             {
-                var image = eval('smile_' + cod_emotions[i][0] + '.src.substr(smile_' +cod_emotions[i][0]  + '.src.indexOf(im_path))');
-			    emotion_regexp = new RegExp(cod_emotions[i][1], 'gi');
-                pEmotion = pEmotion.replace(emotion_regexp, '<img emotion="' + i + '" src="' + image + '">');
-             }
-		  }catch(e){}
-       }
-       return pEmotion;
-    }
-
-	IM.prototype.atalho = function()
-	{
-	   if ( (local = func.byId('user_info')) && !(func.byId('myStatus')) )
-	   {
-         var aux  = new Array();
-         var _mix = func.newEl('a', 'a', 'img', 'img', 'dl');
-
-         var fast_menu_link  = _mix[0];
-         var contacts_link   = _mix[1];
-         var fast_menu_image = _mix[2];
-         var contacts_image  = _mix[3];
-         var im_fast_menu    = _mix[4];
-
-         fast_menu_link.onclick = function(){IM.showFastMenu();};
-         contacts_link.onclick  = function(){IM.showContacts();};
-
-         aux['fast_menu_image'] = new Array();
-         aux['fast_menu_image']['element'] = fast_menu_image;
-         aux['fast_menu_image']['style']   = 'width:9px;height:9px';
-         aux['fast_menu_image']['src']     = im_path + 'templates/default/images/menuarwopen.gif';
-
-         aux['im_fast_menu'] = new Array();
-         aux['im_fast_menu']['element'] = im_fast_menu;
-         aux['im_fast_menu']['id']      = 'fast_menu_im';
-         aux['im_fast_menu']['class']   = 'menu_im';
-
-         aux['contacts_image'] = new Array();
-         aux['contacts_image']['element'] = contacts_image;
-         aux['contacts_image']['id']      = 'myStatus';
-         aux['contacts_image']['src']     = eval('img_' + statusFlag + '.src');
-         aux['contacts_image']['style']   = 'width:15px;height:15px';
-         func.confEl(aux);
-
-         func.insEl(fast_menu_image, fast_menu_link);
-         func.insEl(contacts_image, contacts_link);
-         func.insElB(fast_menu_link, contacts_link, im_fast_menu, document.createTextNode(' '), local.firstChild);
-	   }
-	   else
-	      setTimeout('IM.atalho()', 5000);
-	};
-
-	/*
-	 * Vcard
-	 */
-
-	IM.prototype.Vcard = function()
-	{
-		var _this = this;
-		if( _this.count_Vcard < 4)
-		{
-			var handler_getVcard = function(_XMLdata)
-			{
-				var data = _XMLdata.getElementsByTagName('retorno').item(0);
-				data = eval(data.firstChild.nodeValue);
-				if(!data)
-					setTimeout("IM.Vcard()",2000);
-				_this.count_Vcard++;
-			};
-	   		XMLTools.request('$this.Ujabber.Vcard','GET',handler_getVcard);
-	   	}else{
-			var handler_getVcardUser = function(XMLdata)
-			{
-			};
-	   		XMLTools.request('$this.Ujabber.VcardUser','GET',handler_getVcardUser);
-	   	}
-
-	};
-
-	IM.prototype.getVcard = function(data)
-	{
-		  var _this = this;
-		  try
-		  {
-			     if ( data.getElementsByTagName('vcard').length > 0  && !_this.statusvcard )
-			     {
-			         var div = document.getElementById("im_vcard_contacts");
-			         var xsl = XMLTools.load(im_path + 'xsl/vcard_contacts.xsl?' + Date.parse(new Date));
-			         _this.statusvcard = true;
-
-			         div.innerHTML = "";
-			         div.innerHTML += XMLTools.transform(data, xsl);
-		 	         IM_Preferences.vCardInit();			         
-				 }
-
-
-		  }catch(e){}
-	};
-
-	IM.prototype.open_chat = function(pJID)
-	{
-	   im_win.open_chat(pJID);
-	};
-
-	IM.prototype.action_button = function(pEv, pJid)
-	{
-		try
-		{
-			if ( pEv.button > 1 )
-			{
-				var posx = 0;
-				var posy = 0;
-				if (pEv.pageX || pEv.pageY)
-				{
-					posx = pEv.pageX;
-					posy = pEv.pageY;
-				}
-				else if (pEv.clientX || pEv.clientY)
-				{
-					posx = pEv.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
-					posy = pEv.clientY + document.body.scrollTop + document.documentElement.scrollTop;
-				}
-				this.menu_button_right(pJid, posx, posy);
-				document.oncontextmenu = new Function("return false");
-			}
-			else
-				if ( func.byId(pJid).firstChild.src != img_unavailable.src )
-					this.open_chat(pJid);
-		}catch(e){}
-	};
-
-	IM.prototype.menu_button_right = function(pElement, pX, pY)
-	{
-	   var form_menu_button_right = '<dl style="z-index:99999">'+
-	                                '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.Update_NickName(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Nick') + '</a>'+
-	                                '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.Update_Group(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Group') + '</a>'+
-	                                '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.RemoveContact(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Delete') + '</a>'+
-									'<dt><a href="javascript:void(0);" onclick="javascript:Subscription.RequestAutorization(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('(Re)-requisitar Autorização') + '</a>' +	                                
-	                                '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.vCardLoad_Contact(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('See Info') + '</a>'+
-	                                '</dl>';
-	   im_menu_action.menu('menu_contato', form_menu_button_right);
-	   func.byId('menu_contato').style.top = pY-10;
-	   func.byId('menu_contato').style.left = pX-10;
-	   func.byId('menu_contato').style.zIndex = zValue + 10;
-	};
-
-	/*
-	 * Menu
-	 */
-
-	IM.prototype.menu_preferences = function()
-	{
-		  var posx = 0;
-		  var posy = 0;
-		  var pEv = arguments[0];
-
-		  if (pEv.pageX || pEv.pageY)
-		  {
-			  posx = pEv.pageX;
-			  posy = pEv.pageY;
-		  }
-		  else if (pEv.clientX || pEv.clientY)
-		  {
-			  posx = pEv.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
-			  posy = pEv.clientY + document.body.scrollTop + document.documentElement.scrollTop;
-		  }
-
-		  var p_element = document.getElementById(arguments[1]);
-		  var _xmlDoc = "";
-		  var _this = this;
-
-		  _xmlDoc = '<menu>' +
-						'<item function="IM_Preferences.Add_userLoad()" lang="'+IM.get_lang('Add Contact')+'"/>' +
-						'<item function="IM_Preferences.Remove_userLoad()" lang="'+IM.get_lang('Remove Contact')+'"/>' +
-						'<item function="IM_Preferences.vCard()" lang="'+IM.get_lang('Vcard')+'"/>' +
-						'<item function="IM_Preferences.yourPreferences()" lang="'+IM.get_lang('preferences')+'"/>' +
-					'</menu>';
-
-	      im_menu_action.menu(p_element.id,parse_XmlXsl(_xmlDoc,'menu_preferences.xsl'));
-	      func.byId(p_element).style.top = posy;
-	      func.byId(p_element).style.left = posx;
-	      func.byId(p_element).style.zIndex = zValue + 10;
-
-	      _this.Load_Images_menu();
-	}
-
-	IM.prototype.Load_Images_menu = function(Element)
-	{
-		try
-		{
-			var group = document.getElementById("dl_im_menu_preferences");
-			var Child =  group.childNodes;
-
-			for(var i = 0; i < Child.length; i++)
-			{
-				var img = document.createElement('img');
-				img.src = img_menu.src;
-				Child[i].firstChild.insertBefore(img, Child[i].firstChild.firstChild);
-			}
-		}catch(e){}
-	}
-
-   /*
- 	*  Função Provisória - By AlC
- 	*/
-
-	function parse_XmlXsl(_xmlDoc, form_xsl)
-	{
-		  var xslWin = false;
-
-		  if ( !xslWin ) xslWin = XMLTools.load(im_path + 'xsl/' + form_xsl + '?' + Date.parse(new Date));
-
-		  a = document.createElement('div');
-		  if (window.ActiveXObject)
-		  {
-		     var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
-		     xmlDoc.async = "false";
-		     xmlDoc.loadXML(_xmlDoc);
-		  }
-		  else
-		  {
-		     var parser = new DOMParser();
-		     var xmlDoc = parser.parseFromString(_xmlDoc, "text/xml");
-		  }
-		  a.innerHTML = XMLTools.transform(xmlDoc, xslWin);
-
-		  return a;
-
-	}
-
-   IM.prototype.showFastMenu = function()
-   {
-		 var _dt = func.newEl('dt', 'dt', 'dt', 'dt', 'dt');
-		 var _a  = func.newEl('a', 'a', 'a', 'a', 'a');
-
-		 for ( var i in _dt )
-		 {
-		    if ( typeof _dt[i] == 'function' )
-		       continue;
-		    eval('var option' + (parseInt(i)+1) + ' = _dt[' + i + '];');
-		    eval('var option' + (parseInt(i)+1) + '_link = _a[' + i + '];');
-		 }
-
-		 var _img = func.newEl('img', 'img', 'img', 'img','img');
-
-		 for ( var i in _img )
-		 {
-		    if ( typeof _dt[i] == 'function' )
-		       continue;
-		    eval('var option' + (parseInt(i)+1) + '_image = _img[' + i + '];');
-		 }
-		
-		 option1_link.onclick = function(){statusFlag = 'available'; IM.setStatus('available');};
-		 option2_link.onclick = function(){statusFlag = 'xa'; awayFlag = false; IM.setStatus('xa');};
-		 option3_link.onclick = function(){statusFlag = 'dnd'; IM.setStatus('dnd');};
-		 option4_link.onclick = function(){statusFlag = 'unavailable'; IM.setStatus('unavailable');};
-		 option5_link.onclick = function(){IM.setStatus('custom')};
-
-		 func.confEl(option1_image, 'src', img_available.src);
-		 func.confEl(option1_image, 'style', 'width:16px;height:16px;cursor:pointer;');
-		 func.confEl(option2_image, 'src', img_xa.src);
-		 func.confEl(option2_image, 'style', 'width:16px;height:16px;cursor:pointer;');
-		 func.confEl(option3_image, 'src', img_dnd.src);
-		 func.confEl(option3_image, 'style', 'width:16px;height:16px;cursor:pointer;');
-		 func.confEl(option4_image, 'src', img_unavailable.src);
-		 func.confEl(option4_image, 'style', 'width:16px;height:16px;cursor:pointer;');
-		 func.confEl(option5_image, 'src', img_edit.src);
-		 func.confEl(option5_image, 'style', 'width:16px;height:16px;cursor:pointer;');
-
-		 func.insEl(option1_image, IM.get_lang('online'), option1_link);
-		 func.confEl(option1_link, 'style','cursor:pointer;');
-		 func.insEl(option1_link, option1);
-
-		 func.insEl(option2_image, IM.get_lang('away'), option2_link);
-		 func.confEl(option2_link, 'style','cursor:pointer;');
-		 func.insEl(option2_link, option2);
-
-		 func.insEl(option3_image, IM.get_lang('busy'), option3_link);
-		 func.confEl(option3_link, 'style','cursor:pointer;');
-		 func.insEl(option3_link, option3);
-
-		 func.insEl(option4_image, IM.get_lang('offline'), option4_link);
-		 func.confEl(option4_link, 'style','cursor:pointer;');
-		 func.insEl(option4_link, option4);
-
-		 func.insEl(option5_image, IM.get_lang('Custom message...'), option5_link);
-		 func.confEl(option5_link, 'style','cursor:pointer;');
-		 func.insEl(option5_link, option5);
-
-		 im_menu_action.menu('fast_menu_im', option1, option2, option3, option4, option5);
-   };
-
-	IM.prototype.setStatus = function(pStatus)
-	{
-		try
-		{
-			var handler = function()
-			{
-			};
-
-			if ( func.byId('fast_menu_im').style.display == 'block' )
-				im_menu_action.menu('fast_menu_im', null);
-			
-			if ( pStatus == 'custom' )
-			{
-				pStatus = prompt('Personalize seu Status : ', this.custom_message);
-				pStatus = 'show=' + statusFlag + '&status=' + pStatus;
-			}
-			else
-			{
-				if ( pStatus == 'unavailable' )
-				{
-					this.ImgStatus(pStatus);
-					pStatus = 'type=' + pStatus;
-				}
-				else
-				{
-					try
-					{
-						this.ImgStatus(pStatus);
-						pStatus = 'show=' + pStatus;
-					}catch(e){}
-				}
-			}
-			XMLTools.request('$this.Ujabber.setPresence', 'POST', handler, pStatus);
-		}catch(e){}
-	};
-
-   IM.prototype.ImgStatus = function(pStatus)
-   {
-		var myStatus;
-		if ( (myStatus = func.byId('myStatus')) )
-			myStatus.src = eval('img_' + pStatus + '.src');
-   };
-
-   IM.prototype.setAway = function()
-   {
-      if(statusFlag != 'dnd' && statusFlag != 'unavailable')
-      {
-		  if ( awayFlag )
-	      {
-		     this.setStatus('available');
-		     statusFlag = 'available';
-	         awayFlag = false;
-	      }
-	      else
-	      {
-	         this.setStatus('xa');
-	   	     statusFlag = 'xa';
-	       	 awayFlag = true;
-	      }		
-      }
-   };
-
-	IM.prototype.infoContact = function(pUid)
-	{
-		try
-		{
-			var info = false;
-			var div_allg = document.getElementById('all_groups');
-			var elements = div_allg.firstChild;
-			while ( elements )
-			{
-				var childs = elements.firstChild;
-				while( childs )
-				{
-					if(childs.tagName == "DIV" && childs.id.indexOf(pUid) === 0 )
-					{
-						info = {'jid':childs.id, 'src':childs.firstChild.src};
-						break;
-					}
-					childs = childs.nextSibling;
-				}
-				if ( !info )
-					elements = elements.nextSibling;
-				else
-					break;
-			}
-			return info;
-		}catch(e){return false;}
-	};
-
-var IM = new IM();
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_conf_font.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_conf_font.js	(revision 151)
+++ 	(revision )
@@ -1,55 +1,0 @@
-var im_conf_font = {
-    
-    content   : null,
-	
-	"get_element" : function()
-	{
-		var _document = document.getElementById(im_win.chat_pJid + '_edita');
-		this.content = _document.contentWindow.document.getElementsByTagName('body').item(0);
-
-	},
-
-	"changeFont" : function(nameFont)
-	{
-  	    this.get_element();
-	    this.content.style.fontFamily = nameFont;
-	    this.content.innerHTML = this.content.innerHTML;
-	    im_win.hideFontNameSelection();
-	},
-	
-	"changeSizeFont" : function(SizeFont)
-	{
-		this.get_element();
-		this.content.style.fontSize = SizeFont;
-		this.content.innerHTML = this.content.innerHTML;
-		im_win.hideFontSizeSelection();
-	},
-	
-	"changeFontColor" : function(ColorFont)
-	{
-		this.get_element();
-		this.content.style.color = ColorFont;
-		this.content.innerHTML = this.content.innerHTML;
-		im_win.hideFontColorSelection();
-	},
-	
-	"changeFontStyle" : function(StyleFont)
-	{
-		this.get_element();
-		if(StyleFont == "bold")
-			this.content.style.fontWeight = "bold";
-		else{
-			this.content.style.fontWeight = "normal";
-			this.content.style.fontStyle = StyleFont;
-		}
-		this.content.innerHTML = this.content.innerHTML;
-		im_win.hideFontStyleSelection();
-	},
-	
-	"defaultOptions" : function()
-	{
-		this.content.style.fontStyle = "normal"	;
-		this.content.style.color = "000000";
-		this.content.style.fontStyle = "10pt";
-	}
-}
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_var_globals.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_var_globals.js	(revision 151)
+++ 	(revision )
@@ -1,96 +1,0 @@
-/**
-* @AUTHOR: [NUTS] Rodrigo Souza
-* @DATE: 2006/10/23 11:37:30
-* @LAST CHANGE: Qui 14 Dez 2006 14:28:12 BRST::
-**/
-
-var focusFlag = true;
-
-window.document.onblur = windowBlur;
-window.document.onfocus = windowFocus;
-window.document.onclick = windowFocus;
-window.document.onmouseover = awayTimer;
-
-var window_title = document.title;
-
-var statusFlag = 'available';
-var awayFlag = false;
-var _awayTimer = null;
-
-function awayTimer()
-{
-	if( awayFlag )
-		IM.setAway();
-	
-	if(window.IM_Preferences)
-	{
-		if( _awayTimer )
-			clearTimeout(_awayTimer);
-		_awayTimer = setTimeout("IM.setAway()", parseInt(IM_Preferences.im_timer_xa) * 60000 );
-	}
-}
-
-awayTimer();
-
-function windowBlur() 
-{
-	try{
-		focusFlag = false; 
-		document.title = window_title;
-	}catch(e){}
-}
-function windowFocus()
-{
-	try{
-		focusFlag = true; 
-		document.title = window_title;
-	}catch(e){}
-}
-
-var WINDOW_STATE_REGULAR = "regular";
-var WINDOW_STATE_MINIMIZED = "minimized";
-var WINDOW_STATE_MAXIMIZED = "maximized";
-var WINDOW_STATE_CLOSED = "closed";
-
-var TASKBAR_STATE_SELECTED = "selected";
-var TASKBAR_STATE_UNSELECTED = "unselected";
-var TASKBAR_STATE_MINIMIZED = "minimized";
-var TASKBAR_STATE_FLASH = "flash";
-
-var windowState = WINDOW_STATE_REGULAR;
-var taskbarItems = new Object();
-var windowItems = new Object();
-
-var zValue = 1000;
-
-var TASKBAR_HEIGHT=27;
-
-var ACTIVE_OBJECTID = "contacts";
-	
-var isEmotionSelectionVisible = false;
-var isFontNameSelectionVisible = false;
-var isFontSizeSelectionVisible = false;
-var isFontColorSelectionVisible = false;
-var isFontStyleSelectionVisible = false;
-var activeChatWindowId = "";
-
-var newMessageTimer;
-var messages_timeout = false;
-var contacts_timeout = false;
-
-var im_busy = false;
-
-var cod_emotions = {
-	":)" : [1,"\\\:\\\)"],
-	":d" : [2,"\\\:d"],
-	";)" : [3,"\\\;\\\)"],
-	":o" : [4,"\\\:o"],
-	":p" : [5,"\\\:p"],
-	"(h)" : [6,"\\\(h\\\)"],
-	":@" : [7,"\\\:\\\@"],
-	":$" : [8,"\\\:\\\$"],
-	":s" : [9,"\\\:s"],
-	":(" : [10,"\\\:\\\("],
-	":'(" : [11,"\\\:\\\'\\\("],
-	":|" : [12,"\\\:\\\|"]
-};
Index: unk/instant_messenger/bkp/instant_messenger_32/js/XMLTools.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/XMLTools.js	(revision 151)
+++ 	(revision )
@@ -1,177 +1,0 @@
-var XMLTools = {
-   "__DEBUG__" : false,
-   "__DEFAULT_URI__" : im_path + 'controller.php?action=',
-   "__HTTP__" : null,
-   "__MODE__" : 'X',
-   "__RETURN_MODE_DEFAULT__" : 'JSON',
-   "__RETURN_MODE__" : false,
-   "__THREADS__" : [],
-   "http" : function()
-   {
-      try
-      {
-         this.__HTTP__ = new XMLHttpRequest();
-         this.__HTTP__.overrideMimeType('text/xml');
-      }
-      catch (e)
-      {
-         try
-         {
-            this.__HTTP__ = new ActiveXObject('Msxml2.XMLHTTP');
-         }
-         catch (e1)
-         {
-            try
-            {
-               this.__HTTP__ = new ActiveXObject('Microsoft.XMLHTTP');
-            }
-            catch (e2)
-            {
-               this.__HTTP__ = null;
-            }
-         }
-      }
-   },
-   "load" : function(pFile)
-   {
-      var data = null;
-      if ( document.implementation.createDocument )
-	     data = document.implementation.createDocument("", "", null);
-      else
-         data = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
-
-      data.async = false;
-      data.load(pFile);
-      return data;
-   },
-   "request" : function(pTarget, pMethod, pHandler, pData)
-   {
-      if ( typeof pHandler != 'function' || this.__THREADS__[pTarget] )
-         return false;
-
-      var __this = this;
-      var __pTarget = pTarget
-      this.http();
-      var __HTTP__ = this.__HTTP__;
-      this.__THREADS__[pTarget] = pHandler;
-
-      var __handler = function ()
-      {
-         try
-         {
-            if ( __HTTP__.readyState == 4 )
-            {
-               switch ( __HTTP__.status )
-               {
-                  case 200:
-                        var data = ( __this.__MODE__ == 'X' ) ?
-                                    __HTTP__.responseXML :
-                                    __HTTP__.responseText;
-
-                        var handler = __this.__THREADS__[__pTarget];
-                        delete __this.__THREADS__[__pTarget];
-                        handler(data, __pTarget);
-                  break; /* [case : status 200] */
-                  case 404:
-                        alert('Page Not Found!');
-                  break; /* [case : status 404] */
-                  default:
-               }
-            }
-         }
-         catch(e)
-         {
-            if ( __this.__DEBUG__ ) alert("request : #2\n\n" + e)
-         }
-      }
-
-      try
-      {
-         var target = this.__DEFAULT_URI__ + pTarget;
-         if ( this.__RETURN_MODE__ )
-         {
-            target += '&returnMode=' + this.__RETURN_MODE__;
-            this.__RETURN_MODE__ = false;
-         }
-         else
-            target += '&returnMode=' + this.__RETURN_MODE_DEFAULT__;
-
-         if ( pMethod == 'POST' )
-         {
-            __HTTP__.open("POST", target, true);
-            __HTTP__.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
-            __HTTP__.setRequestHeader('Cache-Control',  'no-store, no-cache, must-revalidate');
-            __HTTP__.setRequestHeader('Cache-Control', 'post-check=0, pre-check=0');
-            __HTTP__.setRequestHeader('Pragma', 'no-cache');
-            __HTTP__.onreadystatechange = __handler;
-            pData = ( pData ) ? pData : null ;
-         }
-         else
-         {
-            __HTTP__.open("GET", target, true);
-            __HTTP__.onreadystatechange = __handler;
-            pData = null;
-         }
-         __HTTP__.send(pData);
-      }
-      catch(e)
-      {
-         if ( this.__DEBUG__ ) alert("request : #1\n\n" + e)
-      }
-      return true;
-   },
-   "transform" : function(pXML, pXSL)
-   {
-		try
-		{
-			var fragment = null;
-			if ( window.XSLTProcessor )
-			{
-				var xslProc = new XSLTProcessor();
-				xslProc.importStylesheet(pXSL);
-				fragment = xslProc.transformToFragment(pXML, document);
-
-				// para retornar valor igual ao ie.
-				var aux = document.createElement("div");
-				aux.appendChild(fragment);
-				fragment = aux.innerHTML;
-			}
-			else
-			{
-				var xslTemplate = new ActiveXObject("MSXML2.XSLTemplate");
-				xslTemplate.stylesheet = pXSL;
-
-				var myXslProc = xslTemplate.createProcessor();
-				myXslProc.input = pXML;
-
-				myXslProc.transform();
-				fragment = myXslProc.output;
-			}
-			return fragment;
-		}
-		catch(e)
-		{
-			alert("transform\n\n" + e + "\n\n" + e.description);
-		}
-   },
-	"create" : function()
-	{
-		try
-		{
-			var a = false;
-			if ( document.implementation.createDocument )
-				a = document.implementation.createDocument("", "", null);
-			else if ( ActiveXObject )
-				a = new ActiveXObject("Msxml2.DOMDocument");
-
-			with ( a )
-				appendChild(createProcessingInstruction("xml", "version='1.0'"));
-
-			return a;
-		}
-		catch(e)
-		{
-			alert("create\n\n" + e + "\n\n" + e.description);
-		}
-	}
-}
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_smiles.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_smiles.js	(revision 151)
+++ 	(revision )
@@ -1,27 +1,0 @@
-// Instant Messenger
-// im_smiles.js
-
-	   var smile_1 = new Image();
-	   smile_1.src = im_path + "templates/default/images/img/smiles/1.gif"
-	   var smile_2 = new Image();
-	   smile_2.src = im_path + "templates/default/images/img/smiles/2.gif"
-	   var smile_3 = new Image();
-	   smile_3.src = im_path + "templates/default/images/img/smiles/3.gif"
-	   var smile_4 = new Image();
-	   smile_4.src = im_path + "templates/default/images/img/smiles/4.gif"
-	   var smile_5 = new Image();
-	   smile_5.src = im_path + "templates/default/images/img/smiles/5.gif"
-	   var smile_6 = new Image();
-	   smile_6.src = im_path + "templates/default/images/img/smiles/6.gif"
-	   var smile_7 = new Image();
-	   smile_7.src = im_path + "templates/default/images/img/smiles/7.gif"
-	   var smile_8 = new Image();
-	   smile_8.src = im_path + "templates/default/images/img/smiles/8.gif"
-	   var smile_9 = new Image();
-	   smile_9.src = im_path + "templates/default/images/img/smiles/9.gif"
-	   var smile_10 = new Image();
-	   smile_10.src = im_path + "templates/default/images/img/smiles/10.gif"
-	   var smile_11 = new Image();
-	   smile_11.src = im_path + "templates/default/images/img/smiles/11.gif"
-	   var smile_12 = new Image();
-	   smile_12.src = im_path + "templates/default/images/img/smiles/12.gif"
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_win.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_win.js	(revision 151)
+++ 	(revision )
@@ -1,1114 +1,0 @@
-var im_win = {
-
-   chat_pJid : null,
-   _imWindowTemplate : null,
-   xslWin : false,
-   photo  : false,
-	
-   "load" : function()
-   {
-      try
-      {
-			var backFantom = func.newEl('div');
-			func.confEl(backFantom, 'id', 'backFantom');
-			func.confEl(backFantom, 'style', 'position:absolute;top:0px;left:0px;width:100%;height:100%;z-Index:-1;');
-
-			var menu_contato = func.newEl('div');
-			func.confEl(menu_contato, 'id', 'menu_contato');
-			func.confEl(menu_contato, 'class', 'menu_im');
-			func.confEl(menu_contato, 'style', 'position:absolute;z-index:99999');
-
-			var emotions = func.newEl('div');
-			func.confEl(emotions, 'id', 'shared_emotions');
-			func.confEl(emotions, 'class', 'emotionFrame');
-			func.confEl(emotions, 'style', 'position:absolute;padding:1px;left:350px;visibility:hidden;top:0px');
-
-			var font_name = func.newEl('div');
-			func.confEl(font_name, 'id', 'shared_fontName');
-			func.confEl(font_name, 'class', 'statusMenu');
-			func.confEl(font_name, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
-
-			var font_size = func.newEl('div');
-			func.confEl(font_size, 'id', 'shared_fontSize');
-			func.confEl(font_size, 'class', 'statusMenu');
-			func.confEl(font_size, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
-
-			var font_color = func.newEl('div');
-			func.confEl(font_color, 'id', 'shared_fontColor');
-			func.confEl(font_color, 'class', 'statusMenu');
-			func.confEl(font_color, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
-
-			var font_style = func.newEl('div');
-			func.confEl(font_style, 'id', 'shared_fontStyle');
-			func.confEl(font_style, 'class', 'statusMenu');
-			func.confEl(font_style, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
-
-			func.insEl(backFantom, menu_contato, emotions, font_name, font_size, font_color, font_style, false);
-
-			emotions.innerHTML = Templates.emotions();
-			font_name.innerHTML = Templates.font_name();
-			font_size.innerHTML = Templates.font_size();
-			font_color.innerHTML = Templates.font_color();
-			/*font_style.innerHTML = Templates.font_style();*/
-
-			var pId = 'contacts';
-
-			var main_menu_all = func.newEl('div');
-			func.confEl(main_menu_all, 'style', 'margin: 3px;');
-
-			var main_menu_head = func.newEl('div');
-			func.confEl(main_menu_head, 'id', pId + '_im_window_body_inner_head');
-			func.confEl(main_menu_head, 'style', 'margin: 0px 0px 3px 0px; border: 1px solid #809aa9; display: block;');
-
-			var main_menu_vcard = func.newEl('div');
-			func.confEl(main_menu_vcard, 'id', 'im_vcard_contacts');
-			func.confEl(main_menu_vcard, 'style', 'display: none;');
-
-			var main_menu_body = func.newEl('div');
-			func.confEl(main_menu_body, 'id', 'div_contacts');
-			func.confEl(main_menu_body, 'style', 'border: 1px solid #809aa9;');
-			main_menu_body.innerHTML = '<b>Nenhum Contato</b>';
-
-			func.insEl(main_menu_head, main_menu_vcard, main_menu_body, main_menu_all);
-
-			var main_menu_head_picture = func.newEl('img');
-			func.confEl(main_menu_head_picture, 'id', pId + '_avatar');
-			func.confEl(main_menu_head_picture, 'src', img_photo.src);
-			func.confEl(main_menu_head_picture, 'style', 'float: left; height: 65px; margin: 2px; width: 49px;');
-
-			var main_menu_head_name_lable = func.newEl('span');
-			func.confEl(main_menu_head_name_lable,'style','margin: 3px;');
-			main_menu_head_name_lable.innerHTML = IM.get_lang('Nickname');
-
-			var br1 = func.newEl('br');
-						
-			var main_menu_head_name = func.newEl('span');
-			func.confEl(main_menu_head_name, 'id', 'span_nickname');
-			func.confEl(main_menu_head_name, 'style', 'margin-left: 5px;');
-			var main_menu_head_name_txt = document.createTextNode("your nickname");
-			func.insEl(main_menu_head_name_txt, main_menu_head_name);
-
-			var br2 = func.newEl('br');
-			var br3 = func.newEl('br');
-
-			func.insEl(main_menu_head_picture, main_menu_head_name_lable, br1, main_menu_head_name, br2, br3, main_menu_head);
-
-			var main_menu_head_div = func.newEl("div");
-			func.confEl(main_menu_head_div,'id','menu_preferences');
-			func.confEl(main_menu_head_div,'class','menu_im');
-			func.confEl(main_menu_head_div,'style','float: left;cursor:pointer');
-
-			func.insEl(main_menu_head_div, false);
-
-		    var params = [];
-			params['body']       = main_menu_all;
-			params['close']      = true;
-			params['height']     = 270;
-			params['left']       = 10;
-			params['id']         = pId;
-			params['maximize']   = true;
-			params['style']      = 'visibility:hidden';
-			params['title']      = 'Expresso Messenger';
-			params['top']        = 10;
-			params['width']      = 210;
-			this.build(params);
-
-			this.config(pId);
-
-			this.windowMinimize(pId + '_im');
-
-			main_menu_head.innerHTML += '<span id="span_menu_pref" style="float: left;cursor: pointer;" onmousedown="IM.menu_preferences(event ,\'menu_preferences\'); document.oncontextmenu = new Function(\'return false\');"></span>';
-
-			var br3 = func.newEl('br');
-			func.confEl(br3, 'style', 'clear: both');
-
-			var div_ie = func.newEl('div');
-
-			func.insEl(br3, div_ie, main_menu_head);
-
-			main_menu_head_pref_img = func.newEl('img');
-			func.confEl(main_menu_head_pref_img, 'src', img_group_close.src);
-			func.confEl(main_menu_head_pref_img, 'id', 'img_pref');
-
-			main_menu_head_pref_txt = document.createTextNode(IM.get_lang('Options'));
-
-			func.insEl(main_menu_head_pref_img, main_menu_head_pref_txt, 'span_menu_pref');
-      }
-      catch(e)
-      {
-         alert("load\n\n" + e + "\n\n" + e.description)
-      }
-   },
-
-   "config" : function(pId)
-   {
-      try
-      {
-         ADD_DHTML("backFantom"+NO_DRAG);
-         ADD_DHTML("shared_fontStyle"+NO_DRAG);
-         ADD_DHTML("shared_fontColor"+NO_DRAG);
-         ADD_DHTML("shared_fontSize"+NO_DRAG);
-         ADD_DHTML("shared_fontName"+NO_DRAG);
-         ADD_DHTML("shared_emotions"+NO_DRAG);
-         ADD_DHTML(pId+"_im_window_body_inner"+NO_DRAG);
-         ADD_DHTML(pId+"_im_window"+NO_DRAG);
-         ADD_DHTML(pId+"_im_window_master"+NO_DRAG);
-         ADD_DHTML(pId+"_im_window_fantom"+NO_DRAG);
-         ADD_DHTML(pId+"_im_window_movable"+CURSOR_MOVE);
-         ADD_DHTML(pId+"_im_window_resize"+CURSOR_NW_RESIZE);
-
-
-         dd.elements.backFantom.setOpacity(0);
-         document.getElementById("backFantom").style.zIndex = -1;
-
-
-         dd.elements.contacts_im_window_resize.moveTo(dd.elements.contacts_im_window.x+dd.elements.contacts_im_window.w-dd.elements.contacts_im_window_resize.w-2, dd.elements.contacts_im_window.y+dd.elements.contacts_im_window.h-dd.elements.contacts_im_window_resize.h-2);
-         dd.elements.contacts_im_window_movable.moveTo(dd.elements.contacts_im_window.x, dd.elements.contacts_im_window.y);
-         dd.elements.contacts_im_window_movable.setOpacity(0);
-
-         dd.elements.contacts_im_window_resize.setOpacity(1);
-         dd.elements.contacts_im_window_resize.moveTo(dd.elements.contacts_im_window_fantom.x+dd.elements.contacts_im_window_fantom.w-dd.elements.contacts_im_window_resize.w-2, dd.elements.contacts_im_window_fantom.y+dd.elements.contacts_im_window_fantom.h-dd.elements.contacts_im_window_resize.h-2);
-
-         var contacts_im_window = new Object();
-         contacts_im_window.x = dd.elements.contacts_im_window_master.x;
-         contacts_im_window.y = dd.elements.contacts_im_window_master.y;
-         contacts_im_window.w = dd.elements.contacts_im_window_master.w;
-         contacts_im_window.h = dd.elements.contacts_im_window_master.h;
-         contacts_im_window.state = WINDOW_STATE_REGULAR;
-         windowItems[pId] = contacts_im_window;
-      }
-      catch(e)
-      {
-         alert("config\n\n" + e + "\n\n" + e.description)
-      }
-   },
-
-   "build" : function()
-   {
-      var pBody       = '';
-      var pClose      = true;
-      var pHeight     = 360;
-      var pId         = false;
-      var pLeft       = NaN;
-      var pMaximize   = true;
-      var pMinimize   = true;
-      var pStyle      = '';
-      var pTitle      = '';
-      var pTop        = NaN;
-      var pWidth      = 250;
-
-      for ( var i = 0; i < arguments.length; i++ )
-      {
-            for ( var n in arguments[i] )
-               if ( !func.isUndefined(arguments[i][n]) )
-                  switch ( n )
-                  {
-                     case 'body'    : pBody     = arguments[i][n]; break;
-                     case 'close'   : pClose    = arguments[i][n]; break;
-                     case 'height'  : pHeight   = arguments[i][n]; break;
-                     case 'id'      : pId       = arguments[i][n]; break;
-                     case 'left'    : pLeft     = arguments[i][n]; break;
-                     case 'maximize': pMaximize = arguments[i][n]; break;
-                     case 'minimize': pMinimize = arguments[i][n]; break;
-                     case 'style'   : pStyle    = arguments[i][n]; break;
-                     case 'title'   : pTitle    = arguments[i][n]; break;
-                     case 'top'     : pTop      = arguments[i][n]; break;
-                     case 'width'   : pWidth    = arguments[i][n]; break;
-                  }
-      }
-
-      if ( !pId || pHeight < 60 || pWidth < 100 )
-         return false;
-
-      if ( isNaN(pLeft) )
-         if ( windowItems[pId] )
-            pLeft = windowItems[pId].x;
-         else
-            pLeft = Math.floor(Math.random()*(dd.getWndH()-100));
-
-      if ( isNaN(pTop) )
-         if ( windowItems[pId] )
-            pTop = windowItems[pId].y;
-         else
-            pTop = Math.floor(Math.random()*(dd.getWndW()-pHeight-480))
-
-      if ( windowItems[pId] )
-      {
-         pHeight = dd.elements[pId + "_im_window_body_inner"].h;
-         pWidth = dd.elements[pId + "_im_window_body_inner"].w;
-      }
-
-      if ( !this.xslWin ) this.xslWin = XMLTools.load(im_path + 'xsl/window.xsl?' + Date.parse(new Date));
-      _xmlDoc = '<window id="' + pId + '" title="' + pTitle + '" height="' + pHeight + '" width="' + pWidth + '" left="' + pLeft + '" top="' + pTop + '" minimize="' + pMinimize + '" maximize="' + pMaximize  + '" close="' + pClose + '" style="position:absolute;' + pStyle + '" />';
-
-      a = document.createElement('div');
-
-      if (window.ActiveXObject)
-      {
-         var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
-         xmlDoc.async = "false";
-         xmlDoc.loadXML(_xmlDoc);
-      }
-      else
-      {
-         var parser = new DOMParser();
-         var xmlDoc = parser.parseFromString(_xmlDoc, "text/xml");
-      }
-      a.innerHTML = XMLTools.transform(xmlDoc, this.xslWin);
-      document.getElementsByTagName('body').item(0).appendChild(a);
-
-      switch ( typeof pBody )
-      {
-         case 'object' :
-                        func.insEl(pBody, pId + '_im_window_body_inner');
-         break;
-         case 'string' :
-                        func.byId(pId + '_im_window_body_inner').innerHTML = pBody;
-
-      }
-
-      RoundedTop('div#' + pId + '_im_window_master', '', '#cbdae4');
-      this.windowMaximizeZ(pId);
-
-   },
-
-   "hideAllChatSelections" : function()
-   {
-      this.hideEmotionSelection();
-      this.hideFontNameSelection();
-      this.hideFontSizeSelection();
-      this.hideFontColorSelection();
-      this.hideFontStyleSelection();
-   },
-
-   "hideWindowItem" : function(pId)
-   {
-      try
-      {
-         dd.elements[pId + "_im_window"].hide();
-         dd.elements[pId + "_im_window_master"].hide();
-         dd.elements[pId + "_im_window_fantom"].hide();
-         dd.elements[pId + "_im_window_resize"].hide();
-         dd.elements[pId + "_im_window_movable"].hide();
-         if ( (name_document = document.getElementById(pId + '_divEdita')) )
-         {
-            name_document.innerHTML = '';
-            var contact = func.byId(pId);
-            var _status = IM.vcard_contacts[contact.getAttribute('nuncontact')].online
-            contact.firstChild.src = ( _status == parseInt(1) ) ? img_online.src : img_offline.src;
-         }
-      }
-      catch(e)
-      {}
-   },
-
-   "incZ" : function()
-   {
-      zValue += 5;
-      return zValue;
-   },
-
-   "drag" : function()
-   {
-      try
-      {
-         var objName = dd.obj.name;
-         i = objName.indexOf("_");
-         objName = objName.substr(0,i);
-
-         this.incZ();
-         document.getElementById(objName + "_im_window_fantom").style.zIndex = zValue;
-         dd.elements[objName + "_im_window_fantom"].setOpacity(0.5);
-
-         document.getElementById(objName + "_im_window_fantom").className = "im_window_fantom";
-
-         var posX = dd.obj.x;
-         var posY = dd.obj.y;
-         if ( posX < 0 )
-            posX = 0;
-         if ( posY < 0 )
-            posY = 0;
-
-         dd.elements[objName + "_im_window_resize"].setOpacity(0);
-
-         if ( dd.obj.name == (objName + "_im_window_resize") )
-         {
-            windowState = WINDOW_STATE_REGULAR;
-
-            // check if the re-size goes out of the screen
-            if ( posX > ( dd.getWndW() - 15 ) )
-               posX = dd.getWndW()-15;
-            if ( posY > ( dd.getWndH() - 13 ) )
-               posY = dd.getWndH()-13;
-
-            // everything is fine, let's change the size of all required objects
-            var newW = posX-dd.elements[objName + "_im_window_fantom"].x+15;
-            var newH = posY-dd.elements[objName + "_im_window_fantom"].y+15;
-            if ( newW < 100) newW = 100;
-            if ( newH < 100) newH = 100;
-            dd.elements[objName + "_im_window_fantom"].resizeTo(newW, newH);
-
-    		if( document.getElementById(objName + "_chatMessages"))
-    		{
-				func.confEl(document.getElementById(objName + "_chatMessages"),"style","width:" + (newW - 105) +";height:" + (newH - 150) +";margin: 2px 0px 2px 2px; overflow:auto;");
-				func.confEl(document.getElementById(objName + '_edita'),"style","width:" + (newW - 105) + ";height: 50px;margin: 3px 1px 0px 2px;float: left;");
-			}
-
-            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
-            var windowItem = windowItems[objName];
-            windowItem.state = WINDOW_STATE_REGULAR;
-         }
-         else
-         {
-            if ( posX > ( dd.getWndW() - dd.elements[objName + "_im_window_master"].w ) )
-               posX = dd.getWndW() - dd.elements[objName + "_im_window_master"].w;
-
-            if ( posY > ( dd.getWndH() - dd.elements[objName + "_im_window_master"].h ) )
-               posY = dd.getWndH() - dd.elements[objName + "_im_window_master"].h;
-
-            dd.elements[objName + "_im_window_fantom"].moveTo(posX, posY);
-         }
-      }
-      catch(e)
-      {
-      }
-   },
-
-   "drop" : function()
-   {
-      try
-      {
-         document.getElementById("backFantom").style.zIndex = -1;
-
-         var objName = dd.obj.name;
-         i = objName.indexOf("_");
-         objName = objName.substr(0,i);
-
-         var posX = dd.obj.x;
-         var posY = dd.obj.y;
-         if ( posX < 0 )
-            posX = 0;
-         if ( posY < 0 )
-            posY = 0;
-         if ( posX > ( dd.getWndW() - dd.elements[objName + "_im_window_master"].w ) )
-            posX = dd.getWndW() - dd.elements[objName + "_im_window_master"].w;
-         if ( posY > ( dd.getWndH() - dd.elements[objName + "_im_window_master"].h ) )
-            posY = dd.getWndH() - dd.elements[objName + "_im_window_master"].h;
-
-         dd.elements[objName + "_im_window_resize"].setOpacity(1);
-
-         if ( dd.obj.name == (objName + "_im_window_resize") )
-         {
-            var newW = dd.obj.x-dd.elements[objName + "_im_window_fantom"].x+17;
-            var newH = dd.obj.y-dd.elements[objName + "_im_window_fantom"].y+17;
-
-            if ( newW < 100) newW = 100;
-            if ( newH < 100) newH = 100;
-
-            var winW = dd.elements[objName + "_im_window_master"].w - dd.elements[objName + "_im_window"].w;
-            var winH = dd.elements[objName + "_im_window_master"].h - dd.elements[objName + "_im_window"].h;
-
-            dd.elements[objName + "_im_window_fantom"].resizeTo(newW, newH);
-            dd.elements[objName + "_im_window_master"].resizeTo(newW, newH);
-
-            var bodyW = dd.elements[objName + "_im_window"].w - dd.elements[objName + "_im_window_body_inner"].w;
-            var bodyH = dd.elements[objName + "_im_window"].h - dd.elements[objName + "_im_window_body_inner"].h;
-
-            dd.elements[objName + "_im_window"].resizeTo(newW - winW, newH - winH);
-
-            bodyW = dd.elements[objName + "_im_window"].w - bodyW;
-            bodyH = dd.elements[objName + "_im_window"].h - bodyH;
-
-            dd.elements[objName + "_im_window_body_inner"].resizeTo(bodyW, bodyH);
-
-            dd.elements[objName + "_im_window_movable"].resizeTo(newW-55, 25);
-            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
-         }
-         else
-         {
-            dd.elements[objName + "_im_window_fantom"].moveTo(posX, posY);
-            dd.elements[objName + "_im_window_master"].moveTo(posX, posY);
-            dd.elements[objName + "_im_window"].moveTo(posX, (posY+4));
-            dd.elements[objName + "_im_window_movable"].moveTo(posX, posY);
-            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-3, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-3);
-         }
-
-         this.windowMaximizeZ(objName);
-
-         dd.elements[objName + "_im_window_fantom"].setOpacity(0);
-         var windowItem = windowItems[objName];
-
-         if ( windowItem != null )
-         {
-            windowItem.x = dd.elements[objName + "_im_window_master"].x;
-            windowItem.y = dd.elements[objName + "_im_window_master"].y;
-            windowItem.w = dd.elements[objName + "_im_window_master"].w;
-            windowItem.h = dd.elements[objName + "_im_window_master"].h;
-         }
-      }catch(e){}
-   },
-
-   "pick" : function()
-   {
-      document.getElementById("backFantom").style.zIndex = zValue;
-      this.hideAllChatSelections();
-      var objName = dd.obj.name;
-      i = objName.indexOf("_im");
-      objName = objName.substr(0,i);
-      ACTIVE_OBJECTID = objName;
-   },
-
-   "showWindowItem" : function(pId)
-   {
-      /*
-       * Não tire esta linha
-       * Isso deve estar aqui para a janela 'oculta'
-       * não 'piscar' na tela no momento que é criada.
-       */
-      func.byId(pId + '_im_window_body_inner').style.overflow = 'auto';
-
-      if ( (name_document = document.getElementById(pId + '_divEdita')) )
-      {
-         name_document.innerHTML = '<iframe name="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '_edita" class="edit_message" id="' + pId + '_edita" frameborder="0" style="border:margin: 3px 1px 0px 2px; width:220px; height:50px; float:left;"></iframe>';
-
-         name_document = document.getElementById(pId + '_edita');
-         name_document.contentWindow.document.write('<html><body id="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '" style="margin:0px;padding:0px"></body></html>');
-         name_document.contentWindow.document.close();
-         name_document.contentWindow.document.designMode = "On";
-
-         func.attachEvent(name_document.contentWindow.document, 'keypress', im_win.getText);
-         func.attachEvent(name_document.contentWindow.document, 'keyup', im_win.clearText);
-
-         name_document.contentWindow.focus();
-      }
-
-      dd.elements[pId + "_im_window_master"].show();
-      dd.elements[pId + "_im_window"].show();
-      dd.elements[pId + "_im_window_fantom"].show();
-      dd.elements[pId + "_im_window_resize"].show();
-      dd.elements[pId + "_im_window_movable"].show();
-      
-   },
-
-   "windowMaximizeZ" : function(objName)
-   {
-      try
-      {
-         this.incZ();
-         document.getElementById(objName + "_im_window_fantom").style.zIndex = zValue-3;
-         document.getElementById(objName + "_im_window_master").style.zIndex = zValue-2;
-         document.getElementById(objName + "_im_window").style.zIndex = zValue-1;
-         document.getElementById(objName + "_im_window_body_inner").style.zIndex = zValue-1;
-         document.getElementById(objName + "_im_window_resize").style.zIndex = zValue;
-         document.getElementById(objName + "_im_window_movable").style.zIndex = zValue;
-         if ( dd.elements[objName + "_im_window_movable"] )
-            dd.elements[objName + "_im_window_movable"].z = zValue+1;
-      }catch(e){}
-   },
-
-   "windowMinimize" : function(objName)
-   {
-      with(objName)
-         objName = substr(0, indexOf('_im'));
-
-      this.hideWindowItem(objName);
-      windowItem = windowItems[objName];
-      if ( windowItem != null )
-      {
-         windowItem.state = WINDOW_STATE_MINIMIZED;
-      }
-
-   },
-
-   "windowMaximizeRestore" : function(objName)
-   { 
-      with(objName)
-         objName = substr(0, indexOf('_im'));
-
-      this.hideAllChatSelections();
-
-      windowItem = windowItems[objName];
-
-      if ( windowItem != null )
-      {
-         var bodyW = dd.elements[objName + "_im_window"].w - dd.elements[objName + "_im_window_body_inner"].w;
-         var bodyH = dd.elements[objName + "_im_window"].h - dd.elements[objName + "_im_window_body_inner"].h;
-
-         if ( windowItem.state==WINDOW_STATE_REGULAR )
-         {
-            windowItem.x = dd.elements[objName + "_im_window_master"].x;
-            windowItem.y = dd.elements[objName + "_im_window_master"].y;
-            windowItem.w = dd.elements[objName + "_im_window_master"].w;
-            windowItem.h = dd.elements[objName + "_im_window_master"].h;
-
-            var bodyX = dd.elements[objName + "_im_window_body_inner"].x + dd.elements[objName + "_im_window"].x;
-            var bodyY = dd.elements[objName + "_im_window_body_inner"].y + dd.elements[objName + "_im_window"].y;
-
-            dd.elements[objName + "_im_window_fantom"].moveTo(0, 0);
-            dd.elements[objName + "_im_window_master"].moveTo(0, 0);
-            dd.elements[objName + "_im_window"].moveTo(0, 4);
-
-            dd.elements[objName + "_im_window_fantom"].resizeTo(dd.getWndW(), dd.getWndH());
-            dd.elements[objName + "_im_window_master"].resizeTo(dd.getWndW(), dd.getWndH());
-            dd.elements[objName + "_im_window"].resizeTo(dd.getWndW(), dd.getWndH() - 5);
-            dd.elements[objName + "_im_window_body_inner"].resizeTo(dd.getWndW() - bodyW, dd.getWndH() - bodyH - 5);
-
-            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
-            windowItem.state = WINDOW_STATE_MAXIMIZED;
-
-            window.status = objName + "'s Z: " + document.getElementById(objName+"_im_window").style.zIndex;
-
-         }
-         else
-         {
-            dd.elements[objName + "_im_window_fantom"].resizeTo(windowItem.w, windowItem.h);
-            dd.elements[objName + "_im_window_master"].resizeTo(windowItem.w, windowItem.h);
-            dd.elements[objName + "_im_window"].resizeTo(windowItem.w, windowItem.h - 5);
-            dd.elements[objName + "_im_window_body_inner"].resizeTo(windowItem.w - bodyW, windowItem.h - bodyH - 5);
-
-            dd.elements[objName + "_im_window_fantom"].moveTo(windowItem.x, windowItem.y);
-            dd.elements[objName + "_im_window_master"].moveTo(windowItem.x, windowItem.y);
-            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
-            windowItem.state = WINDOW_STATE_REGULAR;
-         }
-
-      dd.elements[objName + "_im_window_movable"].moveTo(dd.elements[objName + "_im_window"].x, dd.elements[objName + "_im_window"].y);
-      dd.elements[objName + "_im_window_movable"].resizeTo(dd.elements[objName + "_im_window"].w-55, 25);
-
-      this.showWindowItem(objName);
-      this.windowMaximizeZ(objName);
-      }
-      
-  	  if( !this.photo )
-  	  {
-		setTimeout('im_win.get_photo_ldap(\"user@user\")',1000 );
-		this.photo = true;
-	  }
-   },
-
-   "create_window" : function()
-   {
-      pId = arguments[0]['id'];
-
-      if ( document.getElementById(pId + '_im_window'))
-      {
-         this.windowMaximizeZ(pId);
-      	 this.showWindowItem(pId);
-      }
-      else
-      {
-         this.build(arguments[0]);
-
-         ADD_DHTML(pId + "_im_window_body_inner"+NO_DRAG);
-         ADD_DHTML(pId + "_im_window"+NO_DRAG);
-         ADD_DHTML(pId + "_im_window_master"+NO_DRAG);
-         ADD_DHTML(pId + "_im_window_fantom"+NO_DRAG);
-         ADD_DHTML(pId + "_im_window_movable"+CURSOR_MOVE);
-         ADD_DHTML(pId + "_im_window_resize"+CURSOR_NW_RESIZE);
-
-         dd.elements[pId + "_im_window_movable"].moveTo(dd.elements[pId + "_im_window"].x, dd.elements[pId + "_im_window"].y);
-         dd.elements[pId + "_im_window_movable"].resizeTo(dd.elements[pId + "_im_window"].w-20, 25);
-         dd.elements[pId + "_im_window_movable"].setOpacity(0);
-
-         dd.elements[pId + "_im_window_resize"].setOpacity(1);
-
-         dd.elements[pId + "_im_window_resize"].moveTo(dd.elements[pId + "_im_window"].x+dd.elements[pId + "_im_window"].w-dd.elements[pId + "_im_window_resize"].w-2, dd.elements[pId + "_im_window"].y+dd.elements[pId + "_im_window"].h-dd.elements[pId + "_im_window_resize"].h-2);
-         dd.elements[pId + "_im_window_resize"].moveTo(dd.elements[pId + "_im_window_fantom"].x+dd.elements[pId + "_im_window_fantom"].w-dd.elements[pId + "_im_window_resize"].w-2, dd.elements[pId + "_im_window_fantom"].y+dd.elements[pId + "_im_window_fantom"].h-dd.elements[pId + "_im_window_resize"].h-2);
-
-         var windowItem = new Object();
-         windowItem.x = dd.elements[pId + "_im_window_master"].x;
-         windowItem.y = dd.elements[pId + "_im_window_master"].y;
-         windowItem.w = dd.elements[pId + "_im_window_master"].w;
-         windowItem.h = dd.elements[pId + "_im_window_master"].h;
-         windowItem.state = WINDOW_STATE_MINIMIZED;
-         windowItems[pId] = windowItem;
-
-         title = (arguments[0]['title']) ? arguments[0]['title'] : arguments[0]['id'];
-         this.windowMinimize(pId + '_im');
-         this.windowMaximizeRestore(pId + '_im');
-      }
-   },
-
-   "open_chat" : function(pId)
-   {
-      if ( !func.byId(pId + '_im_window') )
-      {
-         text = '';
-         text += '<div class="border" id="' + pId + '_chatMessages" style="width:220px; height:130px; margin: 2px 0px 2px 2px; overflow:auto;"></div>';
-         text += '<div style="float: left; position: relative; height:130px;">';
-         text += '   <div class="myAvatar">';
-         text += '      <img id="' + pId + '_avatar" alt="Display Picture" title="Display Picture" src="' + im_path + 'templates/default/images/photo.png" width="49" height="65" border="0" />';
-         text += '   </div>';
-         text += '   <div id="' + pId + '_composing" class="composing"><img src="' + img_typing.src + '" /></div>';
-         text += '</div>';
-         text += '<br style="clear:both;"/>';
-         text += '<dl>';
-         text += '   <dd class="small">';
-         text += '      &nbsp;<span id="selectEmotionsDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showEmotionSelection(\'' + pId + '\');" title="Select Imotions here!"><img src="' + im_path + 'templates/default/images/img/1.gif" width="15" height="15" alt="Select Imotions here!" style="vertical-align:	text-top;" /></span>';
-         text += '   </dd>';
-         text += '   <dd class="small">|</dd>';
-         text += '   <dd class="small">';
-         text += '      <span id="selectFontNameDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontNameSelection(\'' + pId + '\');" title="Select Font Name here!" style="height:19px;">'+IM.get_lang('Font')+'</span>';
-         text += '   </dd>';
-         text += '   <dd class="small">|</dd>';
-         text += '   <dd class="small">';
-         text += '      <span id="selectFontSizeDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontSizeSelection(\'' + pId + '\')" title="Select Font Size here!" style="height:19px;">'+IM.get_lang('Size')+'</span>';
-         text += '   </dd>';
-         text += '   <dd class="small">|</dd>';
-         text += '   <dd class="small">';
-         text += '      <span id="selectFontColorDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontColorSelection(\'' + pId + '\')" title="Select Font Color here!" style="height:19px;">'+IM.get_lang('Color')+'</span>';
-         text += '   </dd>';
-         text += '   <dd class="small">|</dd>';
-         text += '   <dd class="small">';
-         text += '      <span id="selectFontStyleDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontStyleSelection(\'' + pId + '\')" title="Select Font Color here!" style="height:19px;">'+IM.get_lang('Style')+'</span>';
-         text += '   </dd>';
-         text += '</dl>';
-         text += '<div id="' + pId + '_divEdita" style="margin: 0px 2px"><iframe name="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '_edita" class="edit_message" id="' + pId + '_edita" frameborder="0" style="margin: 3px 1px 0px 2px; width:220px; height:50px; float:left;"></iframe></div>';
-         text += '<br/><a onclick="javascript:IM.sendMessage(\'' + pId + '\')" title="Send a message" style="float:left;margin: 0px 2px;"><img src="' + im_path + 'templates/default/images/send.gif" width="50" height="25" border=0 style="margin-top:3px"></a>';
-         text += '<br style="clear:both" /><span id="' + pId + '_im_window_message" style="margin-left: 2px" />';
-
-         var params = [];
-         params['body']     = text;
-         params['height']   = 225;
-         params['id']       = pId;
-         params['maximize'] = false;
-         params['minimize'] = false;
-         params['title']    = pId;
-         params['width']    = 320;
-         this.create_window(params);
-
-         // Photo Ldap;
-         this.get_photo_ldap(pId);
-		
-         name_document = document.getElementById(pId + '_edita');
-         name_document.contentWindow.document.write('<html><body id="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '" style="margin:0px;padding:0px"></body></html>');
-         name_document.contentWindow.document.close();
-         name_document.contentWindow.document.designMode = "On";
-
-         func.attachEvent(name_document.contentWindow.document, 'keypress', im_win.getText);
-         func.attachEvent(name_document.contentWindow.document, 'keyup', im_win.clearText);
-
-         name_document.contentWindow.focus();
-         
-         var status = func.byId(pId + '_im_window');
-         status.firstChild.style.background = 'url('+func.byId(pId).firstChild.src+')';
-      }
-      else
-      {
-         this.showWindowItem(pId);
-      }
-   },
-
-   "get_photo_ldap" : function(IdLdap)
-   {
-		var uid_ldap = IdLdap.substr(0,IdLdap.indexOf('@'));
-		var handler_photo_ldap = function(_XMLdata)
-		{
-			var data = _XMLdata.getElementsByTagName('retorno').item(0);
-			data = eval(data.firstChild.nodeValue);
-			if(data)
-			{
-				IdLdap = ( IdLdap == 'user@user' ) ? 'contacts' : IdLdap;
-				if( document.getElementById(IdLdap + "_avatar") != null ){
-					var ph_img = document.getElementById(IdLdap + "_avatar");
-					ph_img.src = (im_path + "inc/class.ldap_im.inc.php?user="+uid_ldap) ? im_path + "inc/class.ldap_im.inc.php?user="+uid_ldap : img_photo.src ;
-				}
-			}
-		}
-
-	    XMLTools.__RETURN_MODE__ = 'XML';
-		XMLTools.request('$this.ldap_im.photo_ldap','POST',handler_photo_ldap,'uid='+uid_ldap);
-   },
-
-   "windowClose" : function(objName)
-   {
-      with(objName)
-         objName = substr(0, indexOf('_im'));
-
-      this.hideWindowItem(objName);
-      this.hideAllChatSelections();
-
-      var windowItem = windowItems[objName];
-      if ( windowItem != null )
-         windowItem.state = WINDOW_STATE_CLOSED;
-
-      if ( objName != 'contacts' )
-      {
-         var win = document.getElementById(objName + '_im_window_master');
-         var resize = document.getElementById(objName + '_im_window_resize');
-         var fantom = document.getElementById(objName + '_im_window_fantom');
-         var movable = document.getElementById(objName + '_im_window_movable');
-
-         win.parentNode.removeChild(win);
-         resize.parentNode.removeChild(resize);
-         fantom.parentNode.removeChild(fantom);
-         movable.parentNode.removeChild(movable);
-
-         //delete windowItem;
-      }
-   },
-
-   "hideEmotionSelection" : function()
-   {
-      emotionsDiv = document.getElementById("shared_emotions");
-      if ( isEmotionSelectionVisible )
-      {
-         emotionsDiv.style.visibility = "hidden";
-         isEmotionSelectionVisible = false;
-      }
-   },
-
-   "highlightie5" : function (e)
-   {
-      if ( e.className == "emotionItem" )
-         e.className = "emotionItem-sel";
-      else if ( e.className == "menuitems" )
-         e.className = "menuitems-sel";
-
-   },
-
-   "lowlightie5" : function(e)
-   {
-      if ( e.className == "emotionItem-sel" )
-         e.className = "emotionItem";
-      else if ( e.className == "menuitems-sel" )
-         e.className = "menuitems";
-   },
-
-   "addEmotion" : function(emotion)
-   {
-      var n_document = document.getElementById(this.chat_pJid + '_edita');
-      var edita = n_document.contentWindow.document.getElementsByTagName('body').item(0);
-      edita.innerHTML += IM.emotions_icons(emotion);
-
-      this.hideEmotionSelection();
-   },
-
-   "showEmotionSelection" : function(objName)
-   {
-      this.chat_pJid = objName;
-      activeChatWindowId = objName;
-      var emotionsDiv = document.getElementById("shared_emotions");
-      if(!isEmotionSelectionVisible)
-      {
-         this.hideAllChatSelections();
-         chatObj = dd.elements[objName + "_im_window"];
-         x = chatObj.x + 6;
-         y = chatObj.y + chatObj.h - 200;
-         dd.elements.shared_emotions.moveTo(x,y);
-         this.incZ();
-         document.getElementById("shared_emotions").style.zIndex = zValue;
-         emotionsDiv.style.visibility = "visible";
-         isEmotionSelectionVisible = true;
-      }
-      else
-      {
-         this.hideAllChatSelections();
-      }
-   },
-
-   "showFontNameSelection" : function(objName)
-   {
-      this.chat_pJid = objName;
-      activeChatWindowId = objName;
-      var objDiv = document.getElementById("shared_fontName");
-      if(!isFontNameSelectionVisible)
-      {
-         this.hideAllChatSelections();
-         chatObj = dd.elements[objName + "_im_window"];
-         x = chatObj.x + 85;
-         y = chatObj.y + chatObj.h - 185;
-         dd.elements.shared_fontName.moveTo(x,y);
-         this.incZ();
-         document.getElementById("shared_fontName").style.zIndex = zValue;
-         objDiv.style.visibility = "visible";
-         isFontNameSelectionVisible = true;
-      }
-      else
-      {
-         this.hideAllChatSelections();
-      }
-   },
-
-   "hideFontNameSelection" : function()
-   {
-      var objDiv = document.getElementById("shared_fontName");
-      if ( isFontNameSelectionVisible )
-      {
-         objDiv.style.visibility = "hidden";
-         isFontNameSelectionVisible = false;
-      }
-   },
-
-   "showFontSizeSelection" : function(objName)
-   {
-
-      this.chat_pJid = objName;
-      activeChatWindowId = objName;
-      var objDiv = document.getElementById("shared_fontSize");
-      if ( !isFontSizeSelectionVisible )
-      {
-         this.hideAllChatSelections();
-         chatObj = dd.elements[objName + "_im_window"];
-         x = chatObj.x + 154;
-         y = chatObj.y + chatObj.h - 200;
-         dd.elements.shared_fontSize.moveTo(x,y);
-         this.incZ();
-         document.getElementById("shared_fontSize").style.zIndex = zValue;
-         objDiv.style.visibility = "visible";
-         isFontSizeSelectionVisible = true;
-      }
-      else
-      {
-         this.hideAllChatSelections();
-      }
-   },
-
-   "hideFontSizeSelection" : function()
-   {
-      var objDiv = document.getElementById("shared_fontSize");
-      if ( isFontSizeSelectionVisible )
-      {
-         objDiv.style.visibility = "hidden";
-         isFontSizeSelectionVisible = false;
-      }
-   },
-
-   "showFontColorSelection" : function(objName)
-   {
-      this.chat_pJid = objName;
-      activeChatWindowId = objName;
-      var objDiv = document.getElementById("shared_fontColor");
-      if ( !isFontColorSelectionVisible )
-      {
-         this.hideAllChatSelections();
-         chatObj = dd.elements[objName + "_im_window"];
-         x = chatObj.x + 191;
-         y = chatObj.y + chatObj.h - 200;
-         dd.elements.shared_fontColor.moveTo(x,y);
-         this.incZ();
-         document.getElementById("shared_fontColor").style.zIndex = zValue;
-         objDiv.style.visibility = "visible";
-         isFontColorSelectionVisible = true;
-      }
-      else
-      {
-         this.hideAllChatSelections();
-      }
-   },
-
-   "showFontStyleSelection" : function(objName)
-   {
-      this.chat_pJid = objName;
-      activeChatWindowId = objName;
-      var objDiv = document.getElementById("shared_fontStyle");
-      if ( !isFontStyleSelectionVisible )
-      {
-         this.hideAllChatSelections();
-         chatObj = dd.elements[objName + "_im_window"];
-         x = chatObj.x + 234;
-         y = chatObj.y + chatObj.h - 181;
-         dd.elements.shared_fontStyle.moveTo(x,y);
-         this.incZ();
-         document.getElementById("shared_fontStyle").style.zIndex = zValue;
-         objDiv.style.visibility = "visible";
-         isFontStyleSelectionVisible = true;
-      }
-      else
-      {
-         this.hideAllChatSelections();
-      }
-   },
-
-   "hideFontColorSelection" : function()
-   {
-      var objDiv = document.getElementById("shared_fontColor");
-      if ( isFontColorSelectionVisible )
-      {
-         objDiv.style.visibility = "hidden";
-         isFontColorSelectionVisible = false;
-      }
-   },
-
-   "hideFontStyleSelection" : function()
-   {
-      var objDiv = document.getElementById("shared_fontStyle");
-      if ( isFontStyleSelectionVisible )
-      {
-         objDiv.style.visibility = "hidden";
-         isFontStyleSelectionVisible = false;
-      }
-   },
-
-   "newMessageNotification" : function()
-   {
-      if ( !focusFlag )
-      {
-         if ( document.title=="......................" )
-            document.title = IM.get_lang("New Message!");
-         else
-            document.title = "......................";
-         
-         this.Mod_Notification();
-
-         if ( newMessageTimer )
-            clearTimeout(newMessageTimer);
-         newMessageTimer = setTimeout("im_win.newMessageNotification()", 1000);
-      }
-      else
-      {
-         if ( newMessageTimer ) clearTimeout(newMessageTimer);
-      }
-      
-   },
-
-   "Mod_Notification" : function()
-   {
-		// Aviso Normal
-		if(eval(IM_Preferences.LoadPreferences('rd_nm')))
-		{
-		}
-		// Aviso Chato		 
-	 	if(eval(IM_Preferences.LoadPreferences('rd_ch')))
-	 	{
-			if(self.moveBy)
-			{
-				for(i=10;i>0;i--)
-			 	{
-				  self.moveBy(i,0);
-			 	  self.moveBy(-i,0);
-			 	}
-			}
-		}
-   },
-
-   "getText" : function(e)
-   {
-
-      if ( !focusFlag ) windowFocus();
-      evt = e.keyCode;
-      pId = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0).id;
-      pId = pId.replace('_at_', '@').replace(/_dot_/g, '.')
-	  IM.composingMessage(pId);	
-      switch ( evt )
-      {
-         case 13 :
-                  if ( !e.shiftKey )
-                     IM.sendMessage(pId);
-                  return false;
-         break;
-         case 27 :
-                  im_win.windowClose(pId + '_im');
-         break;
-      }
-   },
-
-   "clearText" : function(e)
-   {
-      if ( !focusFlag ) windowFocus();
-      evt = e.keyCode;
-      _text = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0);
-
-      switch ( evt )
-      {
-         case 13 :
-                  //if ( !e.shiftKey )
-                     _text.innerHTML = '';
-                     return false;
-         break;
-      }
-   }
-}
-
-function my_DragFunc()
-{
-   im_win.drag();
-}
-function my_DropFunc()
-{
-   im_win.drop();
-}
-function my_PickFunc()
-{
-   im_win.pick();
-}
-function selectDiv(obj) {
-  obj.className = "sel-small";
-}
-function unselectDiv(obj) {
-  obj.className = "des-small";
-}
-function getElementsBySelector(selector)
-{
-   var i;
-   var s=[];
-   var selid="";
-   var selclass="";
-   var tag=selector;
-   var objlist=[];
-   if ( selector.indexOf(" ") > 0 )
-   {//descendant selector like "tag#id tag"
-      s=selector.split(" ");
-      var fs=s[0].split("#");
-      if ( fs.length == 1 )
-         return(objlist);
-      return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
-   }
-   if ( selector.indexOf("#") > 0 )
-   {//id selector like "tag#id"
-      s=selector.split("#");
-      tag=s[0];
-      selid=s[1];
-   }
-   if ( selid != "" )
-   {
-      objlist.push(document.getElementById(selid));
-      return(objlist);
-   }
-   if ( selector.indexOf(".") > 0 )
-   {//class selector like "tag.class"
-      s=selector.split(".");
-      tag=s[0];
-      selclass=s[1];
-   }
-   var v = document.getElementsByTagName(tag);  // tag selector like "tag"
-   if ( selclass == "" )
-      return(v);
-
-   for ( i = 0; i < v.length; i++ )
-      if ( v[i].className ==selclass )
-         objlist.push(v[i]);
-
-   return(objlist);
-}
-function AddTop(el,bk,color,size)
-{
-   try
-   {
-      var i;
-      var d=document.createElement("b");
-      var cn="_r";
-      var lim=4;
-      if(size && size=="small"){ cn="_rs"; lim=2}
-      d.className="_rtop";
-      d.style.backgroundColor=bk;
-      for(i=1;i<=lim;i++)
-      {
-         var x=document.createElement("b");
-         x.className=cn + i;
-         x.style.backgroundColor=color;
-         d.appendChild(x);
-      }
-      el.insertBefore(d,el.firstChild);
-   }
-   catch(e)
-   {}
-}
-function RoundedTop(selector,bk,color,size){
-   var i;
-   var v=getElementsBySelector(selector);
-   for(i=0;i<v.length;i++)
-          AddTop(v[i],bk,color,size);
-}
-
-im_win.load();
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_fcommon.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_fcommon.js	(revision 151)
+++ 	(revision )
@@ -1,391 +1,0 @@
-/*
-+------------------------------------------------+
-| @FILE:    functions.js                         |
-| @AUTHOR:  [NUTS] Rodrigo Souza                 |
-| @DATE:    Sex 27 Out 2006 12:38:22 BRST        |
-| @LAST CHANGE: Seg 27 Nov 2006 12:35:22 BRST::  |
-+------------------------------------------------+
-*/
-
-/*
- * @DESC The method has one optional boolean argument
- *          deep which when set recursively creates a
- *          deep copy, otherwise (when deep is false
- *          or not defined) a shallow copy is created.
- */
-/*Object.prototype.clone = function(deep)
-{
-   objectClone = new this.constructor();
-   for (var property in this)
-   {
-      if (!deep)
-         objectClone[property] = this[property];
-      else if (typeof this[property] == 'object')
-         objectClone[property] = this[property].clone(deep);
-      else
-         objectClone[property] = this[property];
-   }
-
-      return objectClone;
-}*/
-
-/*
- *
- */
-var func = {
-   "json" : false,
-   "attachEvent" : function(obj, eventName, eventHandler) 
-   {
-      if ( obj )
-      {
-         if ( eventName.substring(0, 2) == 'on' )
-         {
-            eventName = eventName.substring(2,eventName.length);
-         }
-         if ( obj.addEventListener )
-         {
-            obj.addEventListener(eventName, eventHandler, false);
-         }
-         else if ( obj.attachEvent )
-         {
-            obj.attachEvent('on'+eventName, eventHandler);
-         }
-      }
-   },
-
-   "byId" : function()
-   {
-      var elements = new Array();
-      for ( var i = 0; i < arguments.length; i++ )
-      {
-         element = arguments[i];
-         if ( this.isString(element) )
-            element = document.getElementById(element);
-
-         if (arguments.length == 1)
-            return element;
-
-         elements.push(element);
-      }
-      return elements;
-   },
-
-   "byTag" : function()
-   {
-      var elements = new Array();
-      for ( var i = 0; i < arguments.length; i++ )
-      {
-         element = arguments[i];
-         if ( this.isString(element) )
-            element = document.getElementsByTagName(element);
-
-         if ( arguments.length == 1 )
-            return element;
-
-         elements.push(element);
-      }
-      return elements;
-   },
-
-   "client_height" : function()
-   {
-      if( typeof( window.innerWidth ) == 'number' )
-      {
-         //Non-IE
-         return window.innerHeight;
-      }
-      else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
-      {
-         //IE 6+ in 'standards compliant mode'
-         return document.documentElement.clientHeight;
-      }
-      else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
-      {
-         //IE 4 compatible
-         return document.body.clientHeight;
-      }
-   },
-
-   "client_width" : function()
-   {
-         if( typeof( window.innerWidth ) == 'number' )
-         {
-            //Non-IE
-            return window.innerWidth;
-         }
-         else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
-         {
-            //IE 6+ in 'standards compliant mode'
-            return document.documentElement.clientWidth;
-         }
-         else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
-         {
-            //IE 4 compatible
-            return document.body.clientWidth;
-         }
-   },
-
-   "_confEl" : function(pElement, pAttribute, pValue)
-   {
-      if ( !func.isString(pValue) )
-         return false;
-
-      if ( this.isString(pElement) )
-      {
-         pElement = document.getElementById(pElement);
-      }
-
-      switch ( pAttribute )
-      {
-         /*
-          * No IE a propriedade style nÃo funciona se adicionada via setAttribute()
-          */
-         case 'style' :
-                        pElement.style.cssText = pValue;
-         break;
-         case 'class' :
-                        pElement.setAttribute(pAttribute, pValue);
-                        pElement.setAttribute(pAttribute+'Name', pValue); // IE
-         break;
-         default :
-                        pElement.setAttribute(pAttribute, pValue);
-      } /* switch */
-   },
-
-   "confEl" : function()
-   {
-      switch ( arguments.length )
-      {
-         case 1 :
-                  matriz = arguments[0];
-                  if ( !this.isArray(matriz) )
-                     return false;
-
-                  for ( var i in matriz )
-                  {
-                     pElement = matriz[i]['element'];
-                     delete matriz[i]['element'];
-
-                     for ( var j in matriz[i] )
-                     {
-                        this._confEl(pElement, j, matriz[i][j]);
-                     }
-                  }
-         break;
-         case 2 :
-                  var pElement = arguments[0];
-
-                  if ( !this.isArray(arguments[1]) )
-                     return false;
-
-                  for ( var i in arguments[1] )
-                  {
-                     this._confEl(pElement, i, arguments[1][i]);
-                  }
-         break;
-         case 3 :
-                  var pElement = arguments[0];
-
-                  this._confEl(pElement, arguments[1], arguments[2]);
-         break;
-      }
-   },
-
-   "elH" : function(pEl)
-   {
-      // no IE a funcao scrollHeight nÃ£o retorna o valor correto
-      return document.getElementById(pEl).offsetHeight;
-   },
-
-   "elHW" : function(pEl)
-   {
-      aux = {
-               h:this.elH(pEl),
-               w:this.elW(pEl)
-            };
-      return aux;
-   },
-
-   "elW" : function(pEl)
-   {
-      return document.getElementById(pEl).offsetWidth;
-   },
-
-   "interface" : function(_XmlDoc)	
-   {
-	   var data = _XmlDoc.getElementsByTagName('retorno').item(0);
-	   if ( data.childNodes.length == 1 )
-	      data = data.firstChild.nodeValue;
-
-	   if ( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(data) )
-	   {
-	      eval('data = ' + data);
-	      if ( this.json ){
-	         this.json = false;
-	      }else{
-	         data = this.json2array(data);
-	      }
-	   }
-
-	   return data;
-  
-   },
-
-   "insEl" : function()
-   {
-      try
-      {
-         if ( arguments.length == 1 )
-         {
-            var body = document.getElementsByTagName('body');
-            body[0].appendChild(arguments[0]);
-         }
-         else
-         {
-            var parentEl;
-            switch ( typeof arguments[arguments.length-1] )
-            {
-               case 'object' :
-                              parentEl = arguments[arguments.length-1];
-               break;
-               case 'string' :
-                              parentEl = document.getElementById(arguments[arguments.length-1]);
-               break;
-               case 'boolean' : parentEl = document.getElementsByTagName('body').item(0);
-            }
-
-            for ( var i = 0; i < arguments.length-1; i++ )
-            {
-                  if ( this.isString(arguments[i]) )
-                     arguments[i] = document.createTextNode(arguments[i]);
-
-                  parentEl.appendChild(arguments[i]);
-            }
-         } /* else */
-         return true;
-      }
-      catch(e)
-      {}
-   },
-
-   "insElB" : function()
-   {
-      try
-      {
-         if ( arguments.length < 2 )
-         {
-            return false;
-         }
-         else
-         {
-            var referenceEl;
-            var parentEl;
-            switch ( typeof arguments[arguments.length-1] )
-            {
-               case 'object' :
-                              parentEl    = arguments[arguments.length-1].parentNode;
-                              referenceEl = arguments[arguments.length-1];
-               break;
-               case 'string' :
-                              referenceEl = document.getElementById(arguments[arguments.length-1]);
-                              parentEl    = referenceEl.parentNode;
-            }
-
-            for ( var i = 0; i < arguments.length-1; i++ )
-            {
-                  parentEl.insertBefore(arguments[i], referenceEl);
-            }
-         } /* else */
-         return true;
-      }
-      catch(e)
-      {}
-   },
-
-   "isArray" : function(a)
-   {
-      return this.isObject(a) && a.constructor == Array;
-   },
-
-   "isFunction" : function(a)
-   {
-      return typeof a == 'function';
-   },
-
-   "isNumber" : function(a)
-   {
-      return typeof a == 'number' && isFinite(a);
-   },
-
-   "isNull" : function(a)
-   {
-      return a === null;
-   },
-
-   "isObject" : function(a)
-   {
-      return (a && typeof a == 'object') || this.isFunction(a);
-   },
-
-   "isString" : function(a)
-   {
-      return typeof a == 'string';
-   },
-
-   "isUndefined" : function(a)
-   {
-      return typeof a == 'undefined';
-   },
-
-   "json2array" : function(pObject)
-   {
-	   var retorno = [];
-	   for( var i in pObject )
-	      if( pObject[i].constructor == Object )
-	      {
-	         retorno[i] = [];
-	         retorno[i] = this.json2array(pObject[i]);
-	      }
-	      else
-	         retorno[i] = pObject[i];
-	   return retorno;
-   },
-
-   "newEl" : function(pElement)
-   {
-      if ( arguments.length == 1 )
-      {
-         switch ( typeof pElement)
-         {
-            case 'string' :
-                           return document.createElement(pElement);
-            break;
-            case 'object' :
-                           var retorno = new Array();
-                           if (this.isArray(pElement))
-                           {
-                              for (var i in pElement)
-                              {
-                                 retorno[i] = document.createElement(pElement[i]);
-                              }
-                              return retorno;
-                           }
-            break;
-         } /* switch */
-      } /* if */
-      else
-      {
-         var retorno = new Array();
-         for ( var i = 0; i < arguments.length; i++ )
-         {
-            retorno[i] = document.createElement(arguments[i]);
-         }
-         return retorno;
-      }
-   },
-
-   "trim" : function(pString)
-   {
-      return pString.replace(/^( )*|( )*$/g, '');
-   }
-}
Index: unk/instant_messenger/bkp/instant_messenger_32/js/im_templates.js
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/js/im_templates.js	(revision 151)
+++ 	(revision )
@@ -1,244 +1,0 @@
-/**
-* @AUTHOR: Alexandre Correia / Rodrigo Souza
-* @DATE: 2006/10/24 17:03:00
-* @LAST CHANGE: Seg 11 Dez 2006 10:21:34 BRST::
-* Instant Messenger
-* im_templates.js
-**/
-
-	function Templates(){
-
-		this.element 	= document.getElementById("im_expresso");
-		this.form 		= "";
-		this.time_set 	= "";
-		this.transfer	= 0;
-		this.arquivo 	= "";
-	}
-
-   /*
-	* Conf forms
-	*/
-
-	Templates.prototype.conf_form = function(pName,pWidth,pHeight,pHTML,pTitle)
-	{
-	     var params = new Array();
-    	 params['body'] = pHTML;
-      	 params['height'] = pHeight;
-     	 params['id'] = pName;
-     	 params['maximize'] = false;
-     	 params['minimize'] = false;
-     	 params['title'] = pTitle;
-     	 params['width'] = pWidth;
-		 im_win.create_window(params);
-	}
-
-   /*
-	* Add Usuario
-	*/
-
-	Templates.prototype.add_user = function()
-	{
-		var _this = this;
-		var _XmlAddUser = '<adduser>' +	
-							'<top lang1="'+IM.get_lang('Selecione uma Organização')+'" />' +
-							'<bottom lang1="'+IM.get_lang('Jid Contact')+'" lang2="'+IM.get_lang('Nickname')+'" lang3="'+IM.get_lang('Group')+'" lang4="'+IM.get_lang('Add')+'"/>' +
-  					  	  '</adduser>';
-		
-		_this.conf_form("divAddUser",525,295,parse_XmlXsl(_XmlAddUser,'add_user.xsl'),":: " + IM.get_lang('Add New Contact') + " - Expresso ::");
-	}
-	
-	Templates.prototype.AcceptRequestUser = function()
-	{
-		var _this = this;
-		var _XmlupdUser = '<updUser>' +
-							'<body lang1="'+IM.get_lang('Nickname')+'" lang2="'+IM.get_lang('Group')+'" lang3="'+IM.get_lang('Update')+'" />' +		
-						  '</updUser>';	
-						  
-		_this.conf_form("divUpdateUser",300,110,parse_XmlXsl(_XmlupdUser,'upd_user.xsl'),":: " + IM.get_lang('Add New Contact') + " - Expresso ::");
-	}
-	
-	Templates.prototype.Status_AddUser = function()
-	{
-		if( document.getElementById('im_status_add') != null )
-			if( document.getElementById('im_status_add').innerHTML != "" )
-				document.getElementById('im_status_add').innerHTML = "";
-			else
-				document.getElementById('im_status_add').innerHTML = IM.get_lang('Contact Add') + ' ... !!!';
-	}
-
-   /*
-	* Del Usuario
-	*/
-
-	Templates.prototype.remove_user = function()
-	{
-		var _this = this;
-		var _XmlDelUser = '<deluser>' +
-							'<body lang1="'+IM.get_lang('Contact')+'" lang2="'+IM.get_lang('Remove')+'" lang3="'+IM.get_lang('close')+'"/>' +
-						  '</deluser>';
-
-		_this.conf_form("divDelUser",300,110,parse_XmlXsl(_XmlDelUser,'del_user.xsl'),":: " + IM.get_lang('Remove Contact') + " - Expresso ::");
-	}
-
-   /*
-	* Update Usuario
-	*/
-
-	Templates.prototype.Users_Not_Auth = function (jids)
-	{
-		var _this = this;
-		var _XmlUserNAuth = '<jids>';	
-		for(var i in jids)
-		{		
-			_XmlUserNAuth += '<item id="im_cell_'+jids[i]+'" jid="'+jids[i]+'" />';
-		}
-		_XmlUserNAuth += '</jids>';
-		if(document.getElementById('divFormAuthUser_im') == null){
-			_this.conf_form("divFormAuthUser",360,250,parse_XmlXsl(_XmlUserNAuth,'user_not_auth.xsl'), ":: Contatos sem Cadastro - Expresso ::");
-		}else{
-			document.getElementById('divFormAuthUser_im').innerHTML = '';
-			document.getElementById('divFormAuthUser_im').innerHTML = parse_XmlXsl(_XmlUserNAuth,'user_not_auth.xsl');
-		}
-	}
-
-   /*
-	* Vcard Usuario
-	*/
-
-	Templates.prototype.information_user = function(pVcardUser)
-	{
-		var _this = this;
-		var _XmlInfoUser = '<info_user>' +
-								'<vcard>' +
-									pVcardUser +	
-								'</vcard>' +
-							    '<getlang>' +
-									'<FN>' + IM.get_lang('Full Name') + '</FN>'+
-									'<NICKNAME>' + IM.get_lang('NickName') + '</NICKNAME>' +
-									'<ORGNAME>' + IM.get_lang('Orgname') + '</ORGNAME>' +
-									'<ORGUNIT>' + IM.get_lang('Orgunit') + '</ORGUNIT>' +
-									'<ROLE>' + IM.get_lang('Role') + '</ROLE>' +
-									'<BDAY>' + IM.get_lang('Birthday') + '</BDAY>' +
-									'<DESC>' + IM.get_lang('Status') + '</DESC>' +
-									'<SAVE>' +IM.get_lang('save') + '</SAVE>' +
-									'<CLOSE>' +IM.get_lang('close') + '</CLOSE>' +									
-								'</getlang>' +
-						   '</info_user>';	
-		_this.conf_form("divInfoUser",400,220,parse_XmlXsl(_XmlInfoUser,'information_user.xsl'), ":: " + IM.get_lang('Information User') + " - Expresso ::");
-	}
-
-	Templates.prototype.information_Contact = function(pVcardContact)
-	{
-		var _this = this;
-		var _XmlInfoContact = '<info_contact>' + 
-								 '<vcard> ' +
-								 	pVcardContact +
-								 '</vcard> ' +		
-								 '<getlang>'+
-								  	'<FN>' + IM.get_lang('Full Name') + '</FN>' +
-								  	'<NICKNAME>' + IM.get_lang('NickName') + '</NICKNAME>' +	
-								  	'<ORGUNIT>' + IM.get_lang('Orgunit') + '</ORGUNIT>' +	
-								  	'<ROLE>' + IM.get_lang('Role') + '</ROLE>' +	
-								  	'<BDAY>' + IM.get_lang('Birthday') + '</BDAY>' +	
-		 				 	     '</getlang>' +
-		 				 	  '</info_contact>';
-		_this.conf_form("divInfoContact",430,110,parse_XmlXsl(_XmlInfoContact,'info_contact.xsl'),":: Informações do Contato - Expresso ::");
-
-	}
-
-   Templates.prototype.emotions = function()
-   {
-	  var smiles = new Array("\':)\'#smile_1.src","\':d\'#smile_2.src","\';)\'#smile_3.src","\':o\'#smile_4.src","\':p\'#smile_5.src","\'(h)\'#smile_6.src","\':@\'#smile_7.src","\':$\'#smile_8.src","\':s\'#smile_9.src","\':(\'#smile_10.src","\':\\\'\(\'#smile_11.src","\':|\'#smile_12.src");
-	  var grid = '';
-	      grid += '<table cellpadding="0" cellspacing="0" border="0">';
-	      grid += '<tr>';
-	   	  for(var i = 0 ; i < 4; i++)	
-		      grid += '<td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion('+smiles[i].substr(0,smiles[i].indexOf('#'))+')" id="sendMessageMenuId"><img width="19" height="19" src="'+eval(smiles[i].substr(smiles[i].indexOf('#') + 1))+'" /></div></td>';
-		  grid += '</tr>';	
-	      grid += '<tr>';
-	   	  for(var i = 4 ; i < 8; i++)	
-		      grid += '<td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion('+smiles[i].substr(0,smiles[i].indexOf('#'))+')" id="sendMessageMenuId"><img width="19" height="19" src="'+eval(smiles[i].substr(smiles[i].indexOf('#') + 1))+'" /></div></td>';
-		  grid += '</tr>';	
-	      grid += '<tr>';
-	   	  for(var i = 8 ; i < 12; i++)	
-		      grid += '<td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion('+smiles[i].substr(0,smiles[i].indexOf('#'))+')" id="sendMessageMenuId"><img width="19" height="19" src="'+eval(smiles[i].substr(smiles[i].indexOf('#') + 1))+'" /></div></td>';
-		  grid += '</tr>';	
-	      grid += '<tr>';
-	      grid += '<td colspan="18"><hr style="background:#cccccc;margin:1px:size:1px;"/></td>';
-	      grid += '</tr>';
-	      grid += '<tr>';
-	      grid += '<td colspan="18"><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideEmotionSelection()" id="closeEmotionSelectionDiv">Close This Menu</div></td>';
-	      grid += '</tr>';
-	      grid += '</table>';
-      return grid;
-   }
-
-   Templates.prototype.font_name = function()
-   {
-	  var fonts_n = new Array("Arial:Arial","Courier:Courier","Times:Times New Roman");
-	  var grid = '';
-
-	  for( var i = 0 ; i < fonts_n.length; i++ )
-    	  grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFont(\'' + fonts_n[i].substr(0,fonts_n[i].indexOf(':') + 1 )+'\')" id="fontStyle1" style="width:120px;font-family:'+fonts_n[i].substr(fonts_n[i].indexOf(':') + 1 )+'">' + fonts_n[i].substr(fonts_n[i].indexOf(':') + 1 ) + '</div>';	  
-
-      grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
-  	  grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontNameSelection()" id="fontStyle1" style="width:120px">Close This Menu</div>';
-
-      return grid;
-   }
-
-   Templates.prototype.font_size = function()
-   {
-      var fonts_s = new Array("9pt:9","10pt:10","11pt:11","12pt:12","14pt:14","16pt:16","18pt:18");
-      var grid = '';
-
-	  for( var i = 0 ; i < fonts_s.length ; i++ )
-	      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeSizeFont(\'' + fonts_s[i].substr(0,fonts_s[i].indexOf(':')) + '\');" id="fontStyle1" style="width:100px">' + fonts_s[i].substr(fonts_s[i].indexOf(':') + 1 ) + '</div>';
-
-      grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
-      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontSizeSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
-
-      return grid;
-   }
-
-   Templates.prototype.font_color = function()
-   {
-      var fonts_c = new Array("#000000:Black","#c0c0c0:Silver","#ffff00:Yellow","#ff0000:Red","#ff00ff:Pink","#00ff00:Green","#1111ff:Blue","#800080:Magenta");
-	  var grid = '';		 
-	  
-	  for( var i = 0; i < fonts_c.length ; i++ )	
-	      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'' + fonts_c[i].substr(0,fonts_c[i].indexOf(':')) + '\')" id="fontStyle1" style="width:100px">' + fonts_c[i].substr(fonts_c[i].indexOf(':') + 1 )  + '</div>';
-
-      grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
-      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontColorSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
-	  	      
-      return grid;
-   }
-
-   Templates.prototype.font_style = function()
-   {
-     var fonts_st = new Array("normal:Regular","italic:Italic","bold:Bold");
-     var grid = '';
-     
-     for( var i = 0 ; i < fonts_st.length; i++ )
-     	grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontStyle(\'' + fonts_st[i].substr(0,fonts_st.indexOf(':')) + '\')" id="fontStyle1" style="width:100px">' + fonts_st[i].substr( fonts_st[i].indexOf(':') + 1 ) + '</div>';
-     grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
-     grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontStyleSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
-	 
-     return grid;
-   }
-
-  /*
-   * Preferências do usuário
-   */
-   
-   Templates.prototype.yourPreferences = function()
-   {
-		var _this = this;
-		var _XmlPreferences = '<preferences />';
-		_this.conf_form("divYourPreferences",345,222,parse_XmlXsl(_XmlPreferences,'preferences.xsl'),":: Informações do Contato - Expresso ::");
-		IM_Preferences.LoadPreferences(null);
-   }
-
-   //Templates
-   var Templates = new Templates();
Index: unk/instant_messenger/bkp/instant_messenger_32/templates/default/css/chat.css
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/templates/default/css/chat.css	(revision 151)
+++ 	(revision )
@@ -1,104 +1,0 @@
-/***** Chat  *****/
-
-._avatar_
-{
-	background: url(../images/photo1.png);
-	width:	49px;
-	height:	65px;
-	float:	right;
-	position:	aboslute; 
-	top:	0px;
-	margin: 2px;
-	border: 1px solid;
-	border-color: #cecece;
-
-}
-
-._button_bold_
-{
-	background: url(../images/bold.gif) no-repeat top center;
-	height: 20px; 
-	width:  25px; 
-	float: left;
-	position: relative;
-	margin-top: 2px;
-	margin-right: 2px;
-	cursor: pointer;
-}
-
-._button_italic_
-{
-	background: url(../images/italicize.gif) no-repeat top center;
-	height: 20px; 
-	width:  25px; 
-	float: left;
-	position: relative;
-	margin-top: 2px;
-	margin-right: 2px;
-	cursor: pointer;
-}
-
-._button_underline_
-{
-	background: url(../images/underline.gif) no-repeat top center;
-	height: 20px;
-	width:  25px;
-	float: left;
-	margin-top: 2px;
-	margin-right: 2px;
-	position: relative;
-	cursor: pointer;
-}
-
-._button_color_
-{
-	background: url(../images/color.gif) no-repeat top center;
-	height: 20px;
-	width: 25px;
-	float: left;
-	position: relative;
-	margin-top: 2px;
-	margin-right: 2px;
-	cursor: pointer;
-}
-
-._button_emoticons_
-{
-	background: url(../images/emoticonlabel.gif) no-repeat top center;
-	height: 20px;
-	width: 25px;
-	float: left;
-	position: relative;
-	margin-top: 2px;
-	cursor: pointer;
-}
-
-._history_
-{
-	background: #fff;
-	border: 1px solid;
-	border-color: #b3b3b3 #cecece #cecece #b3b3b3;
-	width:	289px;
-	height:	180px;
-	cursor: text;
-	overflow: auto;
-}
-
-._messages_
-{
-	background: #fff;
-	border: 1px solid;
-	border-color: #b3b3b3 #cecece #cecece #b3b3b3;
-	width:289px; 
-	height:46px; 
-	cursor: text;
-
-}
-
-._toolbar_buttons_
-{
-	width:289px; 
-	height:29px; 
-}
-
-/***** Chat  *****/
Index: unk/instant_messenger/bkp/instant_messenger_32/templates/default/css.css
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/templates/default/css.css	(revision 151)
+++ 	(revision )
@@ -1,405 +1,0 @@
-b.rnd
-{
-   background:	#fff;
-   display:	block;
-   font-size:	1px;
-}
-b.rnd b
-{
-   display:	block;
-   height:		1px;
-   overflow:	hidden;
-}
-b.rnd1
-{
-   border-color:     #809aa9;
-   border-width:     1px 1px 0px 1px;
-   border-style:     solid;
-   background:						#cbdae4;
-   margin:							0px 2px;
-}
-b.rnd2
-{
-      border-color:     #809aa9;
-      border-width:     0px 1px 0px 1px;
-      border-style:     solid;
-      background:					   #cbdae4;
-	  margin:							0px 1px;
-}
-
-/* IM:WINDOW - ADD USER */
-
-select.add_user
-{
-   font-family:   Tahoma, Verdana, sans-serif;
-   font-size:     8pt;
-   font-weight:   normal;
-   border-color:  #809aa9;
-   border-width:  1px 1px;
-   border-style:  solid;
-   margin:        2px 2px 2px 2px;
-   width:    	  493px;
-
-
-}
-
-/* IM:WINDOW */
-
-.im_window_fantom
-{
-	position: absolute;
-	padding: 0px;
-	border-style: dashed;
-	border-width: 1px 1px 1px 1px;
-	border-color: #000000;
-	background-color: #ffffff;
-	overflow: hidden;
-}
-
-.im-windowfantom-des
-{
-	position: absolute;
-	padding: 0px;
-	overflow: hidden;
-}
-
-.im-window
-{
-    background: transparent;
-	position:   absolute;
-}
-
-.im-window-resizehandle
-{
-	position: relative;
-	overflow: auto;
-	width: 15px;
-	height: 15px;
-    background-image: url(images/img/winresize2.gif);
-}
-
-.im-window-sel {
-	z-index: 100;
-}
-
-.im-window-des {
-	z-index: 50;
-}
-
-/* IM:WINDOWHEAD */
-
-.im_window_head
-{
-   background:    #cbdae4;
-   border-color:  #809aa9;
-   border-width:  0px 1px;
-   border-style:  solid;
-   height:        24px;
-	margin:        0px;
-	overflow:      hidden;
-	width:         258px;
-}
-
-.im-window-sel .im-windowhead {
-	background-position: 0 0;
-}
-
-.im-window-des .im-windowhead {
-	background-position: 0 -25px;
-}
-
-.im-window-flash .im-windowhead {
-	background-position: 0 0px;
-        background-image: url(images/img/flash_win_top_left2.gif);
-}
-
-.im-windowhead-right{
-	padding-right: 5px;
-	margin: 0;
-	background: 100% 0 transparent no-repeat;
-        background-image: url(images/img/win_top_right.gif);
-	overflow: hidden;
-}
-
-.im-window-sel .im-windowhead-right{
-	background-position: 100% 0;
-}
-
-.im-window-des .im-windowhead-right{
-	background-position: 100% -25px;
-}
-
-.im-window-flash .im-windowhead-right{
-	background-position: 100% 0;
-        background-image: url(images/img/flash_win_top_right2.gif);
-}
-
-.im-windowhead-mid {
-	position: relative;
-	background-position: 0 0;
-        background-image: url(images/img/win_top_mid.gif);
-	background-repeat: repeat-x;
-	overflow: hidden;
-	line-height: 25px;
-	height: 25px;
-	cursor: auto;
-	font-weight: bold;
-	padding-left: 24px;
-}
-
-.im-window-sel .im-windowhead-mid {
-	background-position: 0 0;
-	color: #000000;
-}
-
-.im-window-des .im-windowhead-mid {
-	background-position: 0 -25px;
-	color: #aaaaaa;
-}
-
-.im-window-flash .im-windowhead-mid {
-	background-position: 0 0;
-        background-image: url(images/img/flash_win_top_mid2.gif);
-	color: #aaaaaa;
-}
-
-.im_window_title
-{
-   cursor:        move;
-   float:         left;
-   font-weight:   bolder;
-   height:        16px;
-   left:          8px;
-   overflow:      hidden;
-   position:   	  relative;
-   top:           3px;
-   width:         166px;
-}
-
-.im_window_icon
-{
-   float: left;
-   height: 16px;
-   margin: 0px 5px;
-   width: 16px;
-}
-
-
-/* IM:WINDOWBODY */
-
-
-.im_window_body
-{
-	background-color: #cbdae4;
-	border-color:     #809aa9;
-	border-style:     solid;
-	border-width:     0px 1px 1px 1px;
-}
-
-.im_window_body_inner
-{
-	background: #fff;
-    border:     1px solid #809aa9;
-    margin:  0px 3px;
-	overflow: auto;
-}
-
-.im-window-des .im-windowbody {
-	border-color: #d0dfe5;
-	background-color: #f0f5f8;
-
-}
-
-.im-window-flash .im-windowbody {
-	border-color: #d0dfe5;
-	background-color: #f0f5f8;
-    background-image: url(images/img/flash_window_background.gif);
-}
-
-.im-window-des .im-windowbody-inner {
-	border-color: #b9cfd8;
-}
-
-.edit_message
-{
-	background-color: #fff;
-   border:           2px solid #c9d9e8;
-	color:            #000;
-	font-family:      Tahoma, Verdana, sans-serif;
-	font-size:        10pt;
-	font-weight:      normal;
-   padding:          0px;
-}
-
-/* WINDOWBUTTONS */
-
-.im_window_head_buttons
-{
-    display:       block;
-    float:         left;
-	height:        15px;
-    padding-top:   6px;
-	position:      relative;
-	right:         0px;
-	width:         53px;
-}
-
-.im-window-sel .im-windowbutton-container {
-	background-position: 0 0;
-}
-
-.im-window-des .im-windowbutton-container {
-	background-position: 0 -25px;
-}
-
-.im-window-button {
-	margin: 1px 0px 0 2px;
-	/*float: left;*/
-   /*float: right;*/
-   /*clear: both;*/
-	height: 13px;
-	width: 13px;
-   position: absolute;
-	cursor: pointer;
-   top: 3px;
-   /*left: 20px;
-   /*right: 10px;*/
-}
-
-.im-window-sel .im-window-button {
-	background-position: 0 0;
-}
-
-.im-window-sel .im-window-button-hov {
-	background-position: 0 -13px;
-}
-
-.im-window-sel .im-window-button-pres {
-	background-position: 0 -26px;
-}
-
-.im-window-des .im-window-button {
-	background-position: 0 -39px;
-}
-
-.im-window-des .im-window-button-hov {
-	background-position: 0 -52px;
-}
-
-.im-window-des .im-window-button-pres {
-	background-position: 0 -65px;
-}
-
-.im-window-closebutton {
-   background-image: url(images/img/close.gif);
-}
-
-.im-window-maximizerestorebutton {
-   background-image: url(images/img/max.gif);
-}
-
-.im-window-minimizebutton {
-   background-image: url(images/img/min.gif);
-}
-
-/* IM:TASKBAR */
-
-.im-taskbar
-{
-	position: absolute;
-	width: 100%;
-	height: 27px;
-	z-index: 101; 
-	background-position: 0 0;
-	background-repeat: repeat;
-    overflow: hidden;
-}
-
-/* IM:TASKBARITEM */
-
-.im-taskbaritem-des {
-	position: absolute;
-	top: 0;
-	right: 0;
-	width: 150px;
-	height: 22px;
-    border-style: solid;
-	border-width: 1px 1px 1px 1px;
-	border-color: #B9CFD8;
-    background-position: 0 -4px;
-    background-image: url(images/img/win_top_mid.gif);
-    padding: 3px 10px;
-    color: #555555;
-    -moz-box-sizing: border-box;
-    cursor:pointer ;
-}
-
-.im-taskbaritem-flash {
-	position: absolute;
-	top: 0;
-	right: 0;
-	width: 150px;
-	height: 22px;
-        border-style: solid;
-        border-color: #B9CFD8;
-	border-width: 1px 1px 1px 1px;
-        background-position: 0 0;
-        background-image: url(images/img/flash_window_background.gif);
-        background-repeat: repeat;
-        padding: 3px 10px;
-        color: #555555;
-        -moz-box-sizing: border-box;
-        cursor:pointer ;
-}
-
-.im-taskbaritem {
-    position: absolute;
-	top: 0;
-	right: 0;
-	width: 150px;
-	height: 22px;
-    border-style: solid;
-	border-width: 1px 1px 1px 1px;
-	border-color: #B9CFD8;
-        background-position: 0 -26px;
-        background-image: url(images/img/win_top_mid.gif);
-        padding: 3px 10px;
-        color: #999999;
-        -moz-box-sizing: border-box;
-        cursor:pointer;
-}
-
-.menu_im
-{
-   /*border-bottom: 1px solid #ccc;*/
-   display:       none;
-   /*float:         left;*/
-   list-style:    none;
-   margin:        0px;
-   padding:       0px;
-   position:      absolute;
-   width:         150px; /* Width of Menu Items */
-	z-index:       1000;
-}
-
-.menu_im dt a
-{
-   background:      #cbdae4;
-   border:          1px solid #b9cfd8;
-   border-bottom:   0px;
-   color:           #000;
-   display:         block;
-   padding:         2px;
-   text-decoration: none;
-}
-
-.menu_im dt a:hover
-{
-   color:      #e2144a;
-   background: #f9f9f9;
-}
-
-.contato_hover
-{
-   background-color: #cbdae4;
-}
Index: unk/instant_messenger/bkp/instant_messenger_32/templates/default/messenger.css
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/templates/default/messenger.css	(revision 151)
+++ 	(revision )
@@ -1,361 +1,0 @@
-div.border
-{
-   margin-top: 0px;
-   border: 2px solid #C9D9E8;
-   padding: 0px;
-   float: left;
-}
-
-div.popupChecker
-{
-   position : absolute;
-   left : 15px;
-   top : 100px;
-   background : #FFFFFF;
-   width : 200px;
-   height : 100px;
-   text-align : center;
-   visibility : hidden;
-}
-
-div.deleteContact
-{
-    position : absolute;
-    left : 20px;
-    top : 100px;
-    background : #FFFFFF;
-    width : 250px;
-    height : 150px;
-    text-align : center;
-    visibility : hidden;
-}
-
-div.flyMenu
-{
-    position : absolute;
-    left : 75px;
-    top : 100px;
-    border: 2px solid #C9D9E8;
-    background : #DFEFFE;
-    width : 150px;
-    height : 60px;
-    text-align : left;
-    visibility : hidden;
-}
-
-div.statusMenu
-{
-    position : absolute;
-    border: 1px solid #C9D9E8;
-    background : #DFEFFE;
-    text-align : left;
-    visibility : hidden;
-}
-
-.flyMenuClass
-{
-    position:absolute;
-    width:150px;
-    border:2px solid #C9D9E8;
-    background-color:#DFEFFE;
-    line-height:20px;
-    cursor:default;
-    font-size:11px;
-    z-index:100;
-    visibility:hidden;
-}
-
-.menuitems
-{
-    padding-left:10px;
-    padding-right:10px;
-    font-size:11px;
-    border: 1px solid #DFEFFE;
-    cursor:pointer ;
-}
-
-.padding
-{
-    padding-left:10px;
-    padding-right:10px;
-    font-size:11px;
-}
-
-.contactItem
-{
-    font-size:11px;
-}
-
-table.border
-{
-    margin-top: 0px;
-    border: 2px solid #C9D9E8;
-    padding: 0px;
-    float: left;
-}
-
-p.small
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-
-}
-
-span.small
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-}
-
-p.small-red
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-    color: #FF0000;
-}
-
-font.small
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-}
-
-font.small-grey
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-}
-
-font.large
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 12pt;
-}
-
-table.window
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 10pt;
-	border : 1px solid Black;
-}
-
-table.excel
-{
-	font-family : Tahoma, Verdana, Arial, sans-serif ;
-	font-size : 8pt;
-	border : 0px dashed Black;
-}
-
-div.sel
-{
-  	position: absolute;
-  	padding: 0px 4px 2px;
-  	border: solid 1px;
-  	border-color: #C9D9E8;
-  	background: #ffffff;
-}
-
-div.des
-{
-  	position: absolute;
-  	border: 0px;
-  	padding: 1px 5px 3px;
-}
-
-div.sel-small
-{
-  	position: relative;
-  	padding: 1px 6px 1px 6px;
-  	border: solid 1px;
-  	border-color: #C9D9E8;
-  	background: #DFEFFF;
-  	cursor:pointer;
-  	-moz-box-sizing: border-box;
-}
-
-div.des-small
-{
-  	position: relative;
-  	border: 0px;
-  	padding: 2px 7px 2px 7px;
-  	cursor:pointer ;
-  	-moz-box-sizing: border-box;
-}
-
-span.sel-small
-{
-  	position: relative;
-  	padding: 0px 2px;
-  	border: solid 1px;
-  	border-color: #C9D9E8;
-  	background: #DFEFFF;
-  	cursor:pointer;
-  	-moz-box-sizing: border-box;
-}
-
-span.des-small
-{
-  	position: relative;
-  	border: 0px;
-  	padding: 1px 3px;
-  	cursor:pointer ;
-  	-moz-box-sizing: border-box;
-}
-
-div.menuitems
-{
-    padding: 2px;
-    padding-left:10px;
-    padding-right:10px;
-    font-size:11px;
-    border: 1px solid #DFEFFE;
-    background : #DFEFFE;
-    cursor:pointer ;
-}
-
-div.menuitems-sel
-{
-    padding: 2px;
-    padding-left:10px;
-    padding-right:10px;
-    font-size:11px;
-    border: 1px solid #C9D9E8;
-    background: #ffffff;
-    cursor:pointer ;
-}
-
-div.emotionFrame 
-{
-    position: absolute;
-    border: 1px solid #A9B9C8;
-    background: #DFEFFE;
-}
-
-div.emotionItem
-{
-    padding: 2px;
-    font-size:11px;
-    background: #ffffff;
-    border: 1px solid #DFEFFE;
-    cursor:pointer ;
-}
-
-div.emotionItem-sel
-{
-    padding: 1px;
-    font-size:11px;
-    background: #FFFFFF;
-    border: 2px solid #99a9b8;
-    cursor: pointer;
-}
-
-div.myAvatar
-{
-    background: #fff;
-    border: 2px solid #C9D9E8;
-    height:     65px;
-	margin:     2px;
-    padding:    2px;
-    width:      49px;
-}
-
-div.composing
-{
-    background: #fff;
-	bottom:     0px;
-	display:    none;
-    height:     14px;
-	position:   absolute;
-    width:      14px;
-}
-
-div.avatarSelection
-{
-    position: relative;
-    border-style: solid;
-	border-width: 1px 1px 1px 1px;
-	border-color: #B9CFD8;
-    background-color: #ffffff;
-    padding: 2px;
-    cursor:pointer ;
-    -moz-box-sizing: border-box;
-}
-
-dl
-{
-    margin: 0px;
-    padding: 0px;
-}
-dd
-{
-    margin: 0px;
-    padding: 0px;
-   display: inline;   
-}
-
-   .master
-   {
-      height:     250px;
-      margin:     0px;
-      padding:    0px;
-	   position:   absolute;
-      overflow:   hidden;
-      width:      350px;
-      z-index:    1;
-   }
-   .pai
-   {
-	  background: #cbdae4 4px 2px no-repeat;
-      border:     1px solid #809aa9;
-      border-top: 0px;
-      height:     242px;
-      margin:     0px 0px 0px 0px;
-      padding:    3px 2px 0px 0px;
-	  position:   relative;
-      z-index:    1;
-   }
-   .filho
-   {
-      background: #fff;
-      border:     1px solid #809aa9;
-      height:     208px;
-      left:       4px;
-      margin:     0px 0px 15px 0px;
-      position:   absolute;
-      top: 23px;
-      width:      338px;
-      z-index:    2;
-   }
-   .header
-   {
-      margin:     0px 0px 3px 3px;
-      padding:    0px 0px 0px 20px;
-      height:     20px;
-   }
-   .but
-   {
-      border:  1px solid #809aa9;
-      height:  13px;
-      width:   13px;
-      margin:  3px 58px 3px -3px;
-      padding: 0px;
-   }
-   .tit
-   {
-      float:   left;
-      height: 13px;
-      margin:  0px;
-      padding: 0px;
-      overflow: hidden;
-   }
-._rtop{display:block;}
-._rtop *{display:block;height: 1px;overflow: hidden}
-._r1{margin: 0 4px;height: 0px}
-._r2{margin: 0 3px}
-._r3{margin: 0 2px}
-._r4{margin: 0 1px}
-
-._rs1{margin: 0 2px}
-._rs2{margin: 0 1px}
-._rtop *{border-width: 0px 1px;border-style: solid; border-color: #809aa9}
-._rtop ._r1{border-top: 1px solid #809aa9;}
Index: unk/instant_messenger/bkp/instant_messenger_32/templates/default/stop_script.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/templates/default/stop_script.php	(revision 151)
+++ 	(revision )
@@ -1,9 +1,0 @@
-#!/usr/bin/php5 -q
-<?php
-
-	if(trim($argv[1]) == "user")
-	{
-		exec("killall php >/dev/null &");
-		set_time_limit(1);
-	}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/templates/default/config.tpl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/templates/default/config.tpl	(revision 151)
+++ 	(revision )
@@ -1,78 +1,0 @@
-<!-- BEGIN header -->
-<form method="POST" action="{action_url}">
-<table border="0" align="center">
-   <tr bgcolor="{th_bg}">
-    <td colspan="2"><font color="{th_text}">&nbsp;<b>{title} - Jabber</b></font></td>
-   </tr>
-<!-- END header -->
-
-<!-- BEGIN body -->
-   <tr bgcolor="{row_on}">
-    <td colspan="2">&nbsp;</td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td colspan="2">&nbsp;<b>Configuração do Servidor Jabber</b></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Digite o nome da máquina Servidor Jabber:</td>
-    <td><input id="IM_name_jabber" name="newsettings[name_jabber]" value="{value_name_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td>Digite Nome da Conexão:</td>
-    <td><input id="IM_resource_jabber" name="newsettings[resource_jabber]" value="{value_resource_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Digite a porta do Servidor Jabber:</td>
-    <td><input id="IM_port_jabber" name="newsettings[port_jabber]" value="{value_port_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td>Servidor Ldap:</td>
-    <td><input id="IM_server_ldap_jabber" name="newsettings[server_ldap_jabber]" value="{value_server_ldap_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Contexto:</td>
-    <td><input id="IM_context_ldap_jabber" name="newsettings[context_ldap_jabber]" value="{value_context_ldap_jabber}" size="30"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td>Usuário Ldap:</td>
-    <td><input id="IM_user_ldap_jabber" name="newsettings[user_ldap_jabber]" value="{value_user_ldap_jabber}" size="30"></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Password:</td>
-    <td><input type="password" name="newsettings[password_ldap_jabber]" value="{value_password_ldap_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td colspan="2"> Gerenciamento IMManager</td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-	<td colspan="2">
-		<iframe src ="instant_messenger/templates/default/script_load.php?user={value_user_ldap_jabber}" frameborder="0" height="60px" scrolling="no"></iframe>
-	</td>
-   </tr>
-<!-- END body -->
-
-<!-- BEGIN footer -->
-  <tr bgcolor="{th_bg}">
-    <td colspan="2">
-&nbsp;
-    </td>
-  </tr>
-  <tr>
-    <td colspan="2" align="center">
-      <input type="submit" name="submit" value="{lang_submit}">
-      <input type="submit" name="cancel" value="{lang_cancel}">
-    </td>
-  </tr>
-</table>
-</form>
-<!-- END footer -->
Index: unk/instant_messenger/bkp/instant_messenger_32/templates/default/index.tpl
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/templates/default/index.tpl	(revision 151)
+++ 	(revision )
@@ -1,164 +1,0 @@
-<!-- BEGIN index -->
-    <h1>Como Utilizar o Expresso Messenger</h1>
-    <h2><a name="toc">Conteúdo</a></h2>
-    <ol>
-      <li><a href="#intro">Introdução</a>
-      <li><a href="#acesso_primeiro">Acessando o Expresso Messenger pela Primeira Vez</a>
-      <li><a href="#supported">Browsers Suportados</a>
-	  <li><a href="#prefe">Menu Opções</a>
-      <li><a href="#contact_list">Lista de Contatos</a>
-        <ol>
-          <li><a href="#status">Indicador de Status</a>
-          <li><a href="#useradd">Adicionando um novo contato</a>
-          <li><a href="#userdel">Removendo um contato</a>          
-        </ol>
-      <li><a href="#menu_right">Preferências Avançadas</a>
-      <li><a href="#info_ad">Vcard - Informações Adicionais</a>
-      <li><a href="#info_prefe">Preferências</a>      
-	  <li><a href="#troca_mens">Troca de Mensagens</a>
-	  <li><a href="#troca_status">Troca de Status</a>      
-    </ol>
-
-    <h2><a name="intro">1. Introdução</a></h2>
-    
-    O Expresso Messenger é uma aplicação que permite o envio e recebimento de mensagens instantaneamente. Através da sua lista de contatos, você pode trocar mensagens e arquivos com seus contatos. Através da lista também é possível saber se seus contatos estão Online ou Offline. Para a troca de mensagens basta clicar em cima do nome do seu contato, se o mesmo estiver online ( verifique a sessão <a href="#status">Indicador de Status</a> ) abrirá uma janela onde você poderá enviar/receber as mensagens. O Expresso Messenger está associado
-    a um serviço de mensagens instantâneas Jabber, este serviço é responsável pelo armazenamento dos seus contatos, preferências e mensagens.
-	
-	<br clear="all">
-	<br>
-	( figura 1 )
-    <img src="templates/default/images/lista_contatos.png" width="242" height="381" alt="Im Screenshot" align="left" style="padding-right:4px;"> 
-	
-    <br clear="all">
-
-	<h2><a name="acesso_primeiro">2. Acessando o Expresso Messenger pela Primeira Vez</a></h2>
-	
-	Para o acessar o Expresso Messenger, basta clicar em cima da figura <img src="templates/default/images/available.gif">("bolinha verde"), abrirá uma uma janela igual a figura 2. A lista de contatos aparecerá com a seguinte frase : "Nenhum Contato", até que sejam cadastrados novos contatos. 
-
-	<br clear="all">
-	<br>
-	( figura 2 )
-    <img src="templates/default/images/lista_contatos_primeira.png" width="222" height="337" alt="Im Screenshot" align="left" style="padding-right:4px;"> 
-    
-    <br clear="all">
-
-    <h2><a name="supported">3. Browsers Suportados</a></h2>
-
-    <p>
-      <b>Windows XP/2000/ME/98/95:</b>
-	  <ul>
-	    <li>MS Internet Explorer desde a versão 6.0</li>
-	    <li>Mozilla Firefox desde a versão 1.5</li>
-	  </ul>
-	  
-    <p>
-      <b>Linux:</b>
-      <ul>
-	    <li>Mozilla Firefox desde a versão 1.5</li>
-      </ul>
-    </p>
-
-    <h2><a name="prefe">4. Menu Opções</a></h2>
-	( figura 3 )
-    <img src="templates/default/images/menu_preferencias.png" width="272" height="173" alt="Menu Preferências" align="left">
-    <br clear="all">
-    <br>
-
-	Para acessar o menu "Opções" ( conforme figura 3 ), basta dar um clique com o mouse e abrirá um menu com as opções de Adicionar Contato ( <b>veja <a href="#useradd">Adicionando um novo contato</a></b> ), Remover Contato ( <b>veja <a href="#userdel">Removendo um contato</a></b> ), 
-	Vcard - Informações Adicionais ( <b>veja <a href="#info_ad">Vcard - Informações Adicionais</a></b> ) e Preferências ( <b>veja <a href="#info_prefe">Preferências</a></b> ).
-    
-    <h2><a name="contact_list">5. Lista de Contatos</a></h2>
-	( figura 4 )
-    <img src="templates/default/images/lista_contatos1.png" width="236" height="242" alt="Lista de Contatos" align="left">
-    <br clear="all">
-    <br>
-    
-    Na lista de contato ( conforme figura 4 ), você visualizará seus contatos. 
-    <h3><a name="status">1. Status dos Usuários</a></h3>
-    
-    <img src="templates/default/images/available.gif" align="top"> - Contato Online<br>
-    <img src="templates/default/images/away.gif" align="top"> - Contato Ausente<br>
-    <img src="templates/default/images/dnd.gif" align="top"> - Contato Ocupado<br>
-    <img src="templates/default/images/unavailable.gif" align="top"> - Contato Offline<br>    
-
-    <h3><a name="useradd">2. Adicionando um novo contato </a></h3>
-	( figura 4.1 )
-	<br/>
-    <img src="templates/default/images/adicionar_contato.png" width="536" height="342" alt="Adicionar Contato" align="left">
-    <br clear="all">
-    <br>
-
-	Para adicionar um novo contato ( conforme figura 4.1 ), selecione uma organização e automaticamente carregará os usuários que tem permissão para usar o Mensageiro Instantâneo Expresso. Para escolher
-	seu novo contato basta apenas dar um clique em cima do nome desejado. Logo abaixo, três campos são necessários para adicionar o novo contato, sendo que o campo "Email Expresso" e
-	"Nickname" são preenchidos no momento da escolha do novo contato e o campo grupo terá que ser definido. Tendo os três campos preenchidos basta clicar no Botão Adicionar ( <input type="button" value="Adicionar"> ) .
-
-	<h3><a name="userdel">3. Removendo um contato </a></h3>
-	( figura 4.2 )
-	<br/>	
-    <img src="templates/default/images/remover_contato.png" width="314" height="157" alt="Remover Contato" align="left">
-    <br clear="all">
-    <br>
-
-	Para remover um contato da sua lista ( conforme figura 4.2 ), selecione na lista e clique no botao Botão Remover ( <input type="button" value="Remover"> ) .
-    
-    <h2><a name="menu_right">6. Preferências Avançadas</a></h2>
-	( figura 4.3 )
-	<br/>
-    <img src="templates/default/images/menu_right.png" width="151" height="108" alt="Preferências Avançadas" align="left">
-    <br clear="all"/>
-    <br/>
-
-    Clicando com o botão direito do mouse, você tera acesso a um menu ( conforme figura 3.3 ), com as seguintes funcionalidades :
-
-    <ul>
-      <li>Apelido: Renomeia o Apelido ( Nickname ) do seu contato
-      <li>Grupo: Muda seu contato para um novo grupo
-      <li>Remover: Exclui o contato
-      <li>(Re)-requisitar Autorização: Requisitar autorização
-      <li>Ver Info: Visualize as informações dos seus contatos
-    </ul>
-
-    <h2><a name="info_ad">7. Vcard - Informações Adicionais</a></h2>
-	( figura 5 )
-    <img src="templates/default/images/info_adicionais.png" width="410" height="267" alt="Informações Adicionais" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Efetuando o cadastro ( conforme figura 5 ) com seus dados, os contatos que você adicionou em sua lista poderão ver essas informações. Cada contato cadastrado em sua lista
-	também possui esta opção ( <b>veja <a href="#menu_right">Preferências Avançadas</a></b>, opção Ver Info).
-
-    <h2><a name="info_prefe">8. Preferências</a></h2>
-	( figura 6 )
-    <img src="templates/default/images/preferencias.png" width="356" height="270" alt="Preferências" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Personalize seu tempo para ficar ausente, se em sua lista de contato aparecerá seus contatos offline e um tipo de aviso para uma nova mensagem. 
-
-    <h2><a name="troca_mens">9. Troca de Mensagens</a></h2>
-	( figura 7 )
-    <img src="templates/default/images/troca_mensagem.png" width="332" height="272" alt="Troca de Mensagens" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Clicando com o mouse em cima do nome do contato escolhido, abrirá uma janela ( conforme figura 7 ), para a troca de mensagens. Nessa mesma janela existe um menu, o qual é possível
-	configurar o formato da : Fonte, Tamanho, Cor e o Estilo. Você também pode enviar os Smiles, clicando nessa figura <img src="templates/default/images/img/1.gif">.
-
-    <h2><a name="troca_status">10. Troca de Status</a></h2>
-	( figura 8 )
-    <img src="templates/default/images/troca_status.png" width="449" height="313" alt="Troca de Status" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Para mudar o seu status basta dar um click em cima do status desejado.
-
-	<br/><br/>
-
-    <img src="templates/default/images/available.gif" align="top"> - Online <br/>
-    <img src="templates/default/images/away.gif" align="top"> - Ausente <br/>
-    <img src="templates/default/images/dnd.gif" align="top"> - Ocupado <br/>
-    <img src="templates/default/images/unavailable.gif" align="top"> - Offline - Não recebe mensagem <br/>    
-    <img src="templates/default/images/img/icon_edit.gif" align="top"> - Mensagem - Personalize sua mensagem <br/>        
-
-    <hr noshade>
-<!-- END index -->
Index: unk/instant_messenger/bkp/instant_messenger_32/templates/default/start_script.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/templates/default/start_script.php	(revision 151)
+++ 	(revision )
@@ -1,9 +1,0 @@
-#!/usr/bin/php5 -q
-<?php
-
-	if(trim($argv[1]) == "user")
-	{
-		exec("php -q /var/www/expresso/instant_messenger/IMManager.php &>/dev/null &");
-		set_time_limit(1);
-	}
-?>
Index: unk/instant_messenger/bkp/instant_messenger_32/templates/default/script_load.php
===================================================================
--- /trunk/instant_messenger/bkp/instant_messenger_32/templates/default/script_load.php	(revision 151)
+++ 	(revision )
@@ -1,107 +1,0 @@
-<html>
-<head>
-<script type="text/javascript">
-	var number_process = "";
-
-	function init()
-	{
-		info_process_id();
-		if(!validate_form() || number_process != "")
-			document.im_script_load.start_script.disabled = true;
-		
-	}
-	function info_process_id()
-	{
-		var element = document.getElementById('span_process_id');
-		if(number_process)		
-			element.innerHTML = number_process;
-		else
-			element.innerHTML = "<font color='red'>Serviço parado</font>";	
-	}
-	function validate_form()
-	{
-		if(trim(parent.document.getElementById('IM_name_jabber').value) == "")
-			return false;
-		if(trim(parent.document.getElementById('IM_resource_jabber').value) == "")
-			return false;
-		if(trim(parent.document.getElementById('IM_port_jabber').value) == "")
-			return false;
-		if(trim(parent.document.getElementById('IM_server_ldap_jabber').value) == "")
-			return false;
-		if(trim(parent.document.getElementById('IM_context_ldap_jabber').value) == "")
-			return false;
-		if(trim(parent.document.getElementById('IM_user_ldap_jabber').value) == "")
-			return false;
-
-		return true;
-	}
-	
-	function trim(pString)
-   {
-      return pString.replace(/^( )*|( )*$/g, '');
-   }
-   
-</script>
-<?php
-	
-	if( isset($_SESSION['phpgw_info']['instant_messenger']['user']) )
-	{
-		if($_REQUEST['user'] || $_SESSION['phpgw_info']['instant_messenger']['user'] == "rodsouza" || $_SESSION['phpgw_info']['instant_messenger']['user'] == "alexandrecorreia")
-		{
-			if($_POST['start_script'])
-			{
-				exec("php -q start_script.php user");		
-				unset($_POST['start_script']);
-			}
-			
-			if($_POST['stop_script'])
-			{
-				exec("php -q stop_script.php user");		
-				unset($_POST['stop_script']);
-			}
-			
-			$process = shell_exec("ps aux | grep IMManager.php$ | cut -c10-14");
-			$process = preg_replace("/\\n/","",$process);
-			echo "<script>number_process='".$process."'</script>";
-			
-		}else
-			exit;
-	}else
-		exit;
-
-?>
-<style>
-div
-{
-	font-weight : bold;
-	font-size: 11px !important; 
-	color: #006699 !important; 
-	font-family: Arial, Helvetica, sans-serif !important;
-}
-input,button
-{
-	font-size: 11px !important; 
-	color: #006699 !important; 
-	font-family: Arial, Helvetica, sans-serif !important;
-	border: 1px #bbbbbb solid !important;
-}
-
-input[type=submit],input[type=button],button
-{
-	margin:1px !important;
-	padding:1px !important;
-	cursor: pointer !important; 
-	cursor: hand !important;
-}
-</style>
-</head>
-<body onload="javascript:init();">
-	<div>Número do Processo : <span id="span_process_id"></span></div>
-	<br />
-	<form name="im_script_load" method="POST" action="script_load.php">
-		<input type="submit" value="Start Script" name="start_script" />
-		<input type="submit" value="Stop Script" name="stop_script" />
- 		<input type="hidden" name="user" value="user" />		
-	</form>
-</body>
-</html>
Index: unk/instant_messenger/js/images.js
===================================================================
--- /trunk/instant_messenger/js/images.js	(revision 164)
+++ 	(revision )
@@ -1,68 +1,0 @@
-// Images IM
-	var im_available = new Image();
-	im_available.src = path_im + 'templates/default/images/available.gif';
-	
-	var im_away = new Image();
-	im_away.src = path_im + 'templates/default/images/away.gif';
-	
-	var im_chat = new Image();
-	im_chat.src = path_im + 'templates/default/images/chat.gif';
-	
-	var im_dnd = new Image();
-	im_dnd.src = path_im + 'templates/default/images/dnd.gif';
-	
-	var im_xa = new Image();
-	im_xa.src = path_im + 'templates/default/images/xa.gif';
-	
-	var im_unavailable = new Image();
-	im_unavailable.src = path_im + 'templates/default/images/unavailable.gif';
-	
-	var im_fast_menu = new Image();
-	im_fast_menu.src = path_im + 'templates/default/images/menuarwopen.gif';
-	
-	var im_photo = new Image();
-	im_photo.src = path_im + 'templates/default/images/photo.png';
-	
-	var im_photo_1 = new Image();
-	im_photo_1.src = path_im + 'templates/default/images/photo_1.png';
-
-	var im_group_open = new Image();
-	im_group_open.src = path_im + 'templates/default/images/group_open.gif';
-	
-// Smiles
-
-	var smile_1 = new Image();
-	smile_1.src = path_im + "templates/default/images/smiles/1.gif";
-	
-	var smile_2 = new Image();
-	smile_2.src = path_im + "templates/default/images/smiles/2.gif";
-	
-	var smile_3 = new Image();
-	smile_3.src = path_im + "templates/default/images/smiles/3.gif";
-	
-	var smile_4 = new Image();
-	smile_4.src = path_im + "templates/default/images/smiles/4.gif";
-	
-	var smile_5 = new Image();
-	smile_5.src = path_im + "templates/default/images/smiles/5.gif";
-	
-	var smile_6 = new Image();
-	smile_6.src = path_im + "templates/default/images/smiles/6.gif";
-	
-	var smile_7 = new Image();
-	smile_7.src = path_im + "templates/default/images/smiles/7.gif";
-	
-	var smile_8 = new Image();
-	smile_8.src = path_im + "templates/default/images/smiles/8.gif";
-	
-	var smile_9 = new Image();
-	smile_9.src = path_im + "templates/default/images/smiles/9.gif";
-	
-	var smile_10 = new Image();
-	smile_10.src = path_im + "templates/default/images/smiles/10.gif";
-	
-	var smile_11 = new Image();
-	smile_11.src = path_im + "templates/default/images/smiles/11.gif";
-	
-	var smile_12 = new Image();
-	smile_12.src = path_im + "templates/default/images/smiles/12.gif";	
Index: unk/instant_messenger/js/jabber.js
===================================================================
--- /trunk/instant_messenger/js/jabber.js	(revision 227)
+++ 	(revision )
@@ -1,375 +1,0 @@
-function Jabber()
-{
-	this.con = null;
-	this.xtools = null;
-}
-
-Jabber.prototype = {
-	'doIt' : function(pAction, pParam)
-	{
-		var _this = this;
-		function _connector()
-		{
-			if ( _this.con == null )
-				_this.con = new Connector;
-		}
-		function _xtools()
-		{
-			_this.xtools = new XTools;
-		}
-
-		_connector();
-		_xtools();
-
-		if ( typeof pAction != 'string' || typeof pParam != 'object' )
-			return false;
-
-		switch ( pAction )
-		{
-			case 'iq' :
-				readIq(pParam);
-			break;
-			case 'message' :
-				readMessage(pParam);
-			break;
-			case 'presence' :
-				readPresence(pParam);
-			break;
-			case 'sendMessage':
-				sendMessage(pParam.message,pParam.from);
-				break;
-		}
-
-		function readContacts(pContacts)
-		{ 
-			var XmlDoc = "<layer>" +
-							"<lang1>" + im.get_lang("Nickname") + "</lang1>" +
-							"<lang2>" + im.get_lang("Add Contact") + "</lang2>" +
-							"<lang3>" + im.get_lang("Preferences") + "</lang3>" +
-							"<nickname>" + im.get_lang("Username") + "</nickname>" +
-							"<path>" + path_im + "</path>" +
-						 "</layer>";
-
-			im_window.load('_contacts_im_','instant_messenger_content','<title>.::Expresso Messenger::.</title>','window.xsl','',true,true,false );
-			im_window.elementC('_contacts_im_').innerHTML  = _this.xtools.parse(XmlDoc,'layer.xsl');
-			im_window.elementC('_contacts_im_').innerHTML += _this.xtools.parse(pContacts, 'contacts.xsl');
-			
-			var element = func.byId('im_contact_list').firstChild;
-
-			while(element)
-			{
-				if( element.nodeType == 1 )
-					if(element.nodeName.toLowerCase() == "img")
-						element.src = im_group_open.src
-					else if(element.nodeName.toLowerCase() == "div" && element.hasChildNodes())
-						element.firstChild.src = im_unavailable.src;
-
-				element = element.nextSibling;
-			}
-			
-			if(func.byId('im_avatar').src === im_photo.src)
-			{			
-				im.request_vcard('this',false);
-				im.ldap_photo('im_avatar');
-			}
-			
-			function handler(Xmldata)
-			{
-			};
-			con.go('$this.Ujabber.setStatus', {'request':handler});
-
-			var status = "";
-			if( status = cookies_im.checkCookie('status'))
-			{
-				status = status.substr(status.indexOf("=") + 1,status.length);
-				im.status = status;
-			}
-			else
-			{
-				im.status = 'type=available';
-				im.statusFlag = 'available';
-				func.byId('im_status_src').src = im_available.src;
-			}
-	
-			im.presence(im.status);
-		}
-
-		function readIq(pIq)
-		{
-			switch ( pIq.getAttribute('id') )
-			{
-				case 'contacts' : readContacts(pIq); break;
-				case 'vCard' : 
-				case 'vCard_user' : 
-					readVcard(pIq); 
-					break;
-			}
-		}
-
-		function readMessage(pMessage)
-		{
-			if ( pMessage.getElementsByTagName('body').length > 0 )
-			{
-				var msg = _this.xtools.parse(pMessage, 'message_new.xsl');
-				var from = pMessage.getAttribute('from');
-				from = from.substr(0,from.indexOf('/'));
-
-				if(func.byId('iframe_' + from) != null)
-					func.byId('iframe_' + from).parentNode.removeChild(func.byId('iframe_' + from));
-
-				var win;
-
-				function include_iframe()
-				{
-					win = im_window.elementC(from);
-					
-					var iframe = document.createElement('iframe');
-					iframe.id = 'iframe_' + from;
-					iframe.style.width = '290px';
-					iframe.style.height = '46px';
-					iframe.style.border = '0';
-					iframe.style.margin = '0';
-					iframe.style.padding = '0'
-					
-					var _messages_ = win.firstChild.firstChild.nextSibling.nextSibling;
-					_messages_.appendChild(iframe);
-					
-					iframe.contentWindow.document.write('<html><body id="' + from + '" style="margin:0px;padding:0px"></body></html>');
-					iframe.contentWindow.document.close();
-					iframe.contentWindow.document.designMode = "On";
-					iframe.contentWindow.focus();
-				
-					function keypress_handler(e)
-					{
-						var evt = e.keyCode;
-						var pId = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0).id;
-						switch ( evt )
-						{
-							case 13 :
-								if ( !e.shiftKey )
-									sendMessage(iframe.contentWindow.document.getElementsByTagName('body').item(0), from);
-								return false;
-							break;
-							case 27 :
-								im_window.window_close(pId);
-							break;
-							default :
-							break;
-						}
-					}
-					function keyup_handler(e)
-					{
-						var evt = e.keyCode;
-						var _text = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0);
-
-						switch ( evt )
-						{
-							case 13 :
-								if ( !e.shiftKey )
-									_text.innerHTML = '';
-								return false;
-							break;
-							default :
-							break;
-						}
-					}
-					var obj = iframe.contentWindow.document;
-
-					if ( obj.addEventListener )
-					{
-						obj.addEventListener('keypress', keypress_handler, false);
-						obj.addEventListener('keyup', keyup_handler, false);
-					}
-					else if ( obj.attachEvent )
-					{
-						obj.attachEvent('onkeypress', keypress_handler);
-						obj.attachEvent('onkeyup', keyup_handler);
-					}
-				}				
-
-				if ( !(win = im_window.elementC(from)) )
-				{
-					im_window.load(from, 'instant_messenger_content', '<title>.:: Expresso Messenger ::.</title>', 'chat.xsl', '310', true, true, true);
-					//im_window.visible(from,'block');
-					func.byId(from + '_avatar').src = path_im + "/templates/default/images/photo.png";
-					include_iframe();
-				}
-				else
-				{
-					im_window.load(from, '', '', '', '', true, true, true);
-					//im_window.visible(from,'block');
-					include_iframe();
-				}
-
-				if ( win )
-				{
-					if(!(im.nickname_contacts[from]))
-						im.request_vcard(from, false);
-
-					win = win.firstChild.firstChild;
-					var nick = (im.nickname_contacts[from]) ? im.nickname_contacts[from] : from;
-					win.innerHTML += "<b>" + nick + "</b>" + im.insertEmoticons(msg);
-				    win.scrollTop = win.scrollHeight;					
-
-					im.ldap_photo(from + "_avatar");
-				}
-				im.newMessageNotification();
-			}
-		}
-
-		function readPresence(pPresence)
-		{
-			//@TODO: presenca antes da lista ocasiona erros
-			//verificar e retirar o controle de erros abaixo
-			try
-			{
-				var jidFrom = pPresence.getAttribute('from');
-				jidFrom = jidFrom.substr(0,jidFrom.indexOf('/'));
-	
-				if(pPresence.getAttribute('type'))
-				{
-					switch(pPresence.getAttribute('type'))
-					{
-						case 'subscribe' :
-								if(func.byId(pPresence.getAttribute('from')))
-								{
-									if(confirm('Autorizar o usuário ' + pPresence.getAttribute('from') + '?'))
-										im.subscription(pPresence.getAttribute('from'),'subscribed');
-									else
-										im.subscription(pPresence.getAttribute('from'),'unsubscribe');
-								}
-								else
-								{
-									if(!func.byId(pPresence.getAttribute('from')))
-									{
-										if(confirm('O usuário ' + pPresence.getAttribute('from') + ' quer adicioná-lo ?'))
-										{
-											im.addrequest(pPresence.getAttribute('from'));
-											im.subscription(pPresence.getAttribute('from'),'subscribed');
-										}
-										else
-											im.subscription(pPresence.getAttribute('from'),'unsubscribe');
-									}else
-										im.subscription(pPresence.getAttribute('from'),pPresence.getAttribute('type'));
-								}
-								break;
-						case 'subscribed' :
-								im.subscription(pPresence.getAttribute('from'),pPresence.getAttribute('type'));
-								break;
-						case 'unsubscribed' :						
-								//alert('O usuário ' + pPresence.getAttribute('from') + ' não quer mais papo !');
-								break;
-						case 'unsubscribe' :				
-								alert('O usuário ' + pPresence.getAttribute('from') + ' negou seu pedido !');
-								break;
-						case 'unavailable' :
-								func.byId('img_' + jidFrom).src = eval('im_' + pPresence.getAttribute('type') + '.src');
-								func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:none;");							
-								break;
-						case 'available' :
-								func.byId('img_' + jidFrom).src = eval('im_' + pPresence.getAttribute('type') + '.src');
-								func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:block;");														
-								break;
-					}
-				}
-				else
-				{
-					var node = pPresence.firstChild;
-					while( node )
-					{
-						if(node.hasChildNodes())
-						{						
-							switch(node.nodeName)
-							{
-								case "show" : 					
-										func.byId('img_' + jidFrom).src = eval('im_' + node.firstChild.nodeValue + '.src');
-										func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:block;");							
-										func.byId('status_' + jidFrom).innerHTML = " ";
-										func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;");
-										break;
-								case "status" :	
-										func.byId('status_' + jidFrom).innerHTML = ( node.firstChild.nodeValue ) ? node.firstChild.nodeValue : "" ;
-										func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:block;");
-										break;
-								default :
-										func.byId('img_' + jidFrom).src = im_available.src;									
-										func.byId('status_' + jidFrom).innerHTML = " ";
-										func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;");
-										break;
-							}
-						}
-						node = node.nextSibling;					
-					}
-	
-					if(!im.contacts_off_line)
-						setTimeout("im.off_line()",3000);
-				}
-			}
-			catch(e)
-			{
-			}
-		}
-
-		function readVcard(pVcard)
-		{
-			switch(pVcard.getAttribute('id'))
-			{
-				case "vCard_user" :
-
-					var vcard = pVcard.firstChild;
-					var cc = vcard.firstChild;
-					while( cc )
-					{
-						if(cc.nodeName == "NICKNAME" || cc.nodeName == "nickname")
-						{
-							if(cc.firstChild.nodeValue)
-								func.byId('im_layer_nickname').innerHTML = cc.firstChild.nodeValue;								
-						}
-						cc = cc.nextSibling;
-					}
-					if( im.vcard )
-						templates.vcard_user(pVcard);
-					break;
-
-				case "vCard" :
-
-					var vcard = _this.xtools.parse(pVcard,'nickname.xsl'); 
-					im.nickname_contacts[vcard.substr(0,vcard.indexOf(','))] = ( vcard.substr(vcard.indexOf(',')+1) ) ? vcard.substr(vcard.indexOf(',')+1) : vcard.substr(0,vcard.indexOf(',')) ;
-					if( im.vcard )
-						templates.vcard_contact(pVcard);
-					break;
-			}
-		}
-
-		function sendMessage(pMessage, pFrom)
-		{
-			var handler_sendMessage = function(data)
-			{
-			};
-
-			var sendMessage = pMessage.innerHTML;
-			pMessage.innerHTML = pMessage.innerHTML.replace(/^( )*|( )*$/g, '');
-
-			var send = false;
-			var node = pMessage.firstChild;
-			
-			while ( node && !send )
-			{
-				if ( node.nodeName.toLowerCase() != 'br' )
-					send = true;
-				node = node.nextSibling;
-			}
-			if ( send )
-				_this.con.go('$this.Ujabber.sendMessage', {'request':handler_sendMessage},"to="+pMessage.getAttribute('id')+"&body="+escape(pMessage.innerHTML));
-			pMessage.innerHTML = '';
-			
-			var win = im_window.elementC(pFrom);
-			if ( win )
-			{
-				win = win.firstChild.firstChild;
-				win.innerHTML += "<b>" + im.get_lang("says") +":</br></b>" + sendMessage + "</br></br>";
-			    win.scrollTop = win.scrollHeight;					
-			}
-		}
-	}
-};
Index: unk/instant_messenger/js/xtools.js
===================================================================
--- /trunk/instant_messenger/js/xtools.js	(revision 151)
+++ 	(revision )
@@ -1,115 +1,0 @@
-function XTools()
-{
-}
-
-XTools.prototype = {
-	'convert' : function(pString)
-	{
-		if ( typeof pString != 'string' )
-			return false;
-
-		if (window.ActiveXObject)
-		{
-			var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
-			xmlDoc.async = "false";
-			xmlDoc.loadXML(pString);
-		}
-		else
-		{
-			var parser = new DOMParser();
-			var xmlDoc = parser.parseFromString(pString, "text/xml");
-		}
-
-		return xmlDoc;
-	},
-	'load' : function(pFile)
-	{
-		var data = null;
-		if ( document.implementation.createDocument )
-			data = document.implementation.createDocument("", "", null);
-		else
-			data = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
-
-		data.async = false;
-		data.load( path_im + 'xsl/' + pFile + '?' + Date.parse(new Date));
-		return data;
-	},
-	'parse' : function(pXML, pXSL)
-	{
-		try
-		{
-			switch ( typeof pXML )
-			{
-				case 'object' :
-				break;
-				case 'string' :
-					if ( pXML.indexOf('<') == 0 )
-						pXML = this.convert(pXML);
-					else
-						pXML = this.load(pXML);
-				break;
-				default :
-					return {'error':'invalid xml'}
-			}
-			switch ( typeof pXSL )
-			{
-				case 'object' :
-				break;
-				case 'string' :
-					pXSL = this.load(pXSL);
-				break;
-				default :
-					return {'error':'invalid xsl'}
-			}
-
-			var fragment = null;
-			if ( window.XSLTProcessor )
-			{
-				var xslProc = new XSLTProcessor();
-				xslProc.importStylesheet(pXSL);
-				fragment = xslProc.transformToFragment(pXML, document);
-
-				// para retornar valor igual ao ie.
-				var aux = document.createElement("div");
-				aux.appendChild(fragment);
-				fragment = aux.innerHTML;
-			}
-			else
-			{
-				var xslTemplate = new ActiveXObject("MSXML2.XSLTemplate");
-				xslTemplate.stylesheet = pXSL;
-
-				var myXslProc = xslTemplate.createProcessor();
-				myXslProc.input = pXML;
-
-				myXslProc.transform();
-				fragment = myXslProc.output;
-			}
-			return fragment;
-		}
-		catch(e)
-		{
-			alert("transform\n\n" + e + "\n\n" + e.description);
-		}
-	},
-	'xml' : function()
-	{
-		try
-		{
-			var a = false;
-			if ( document.implementation.createDocument )
-				a = document.implementation.createDocument("", "", null);
-			else if ( ActiveXObject )
-				a = new ActiveXObject("Msxml2.DOMDocument");
-
-			//with ( a )
-			//	appendChild(createProcessingInstruction("xml", "version='1.0'"));
-
-			return a;
-		}
-		catch(e)
-		{
-			alert("create\n\n" + e + "\n\n" + e.description);
-		}
-	}
-};
Index: unk/instant_messenger/js/connector.js
===================================================================
--- /trunk/instant_messenger/js/connector.js	(revision 235)
+++ 	(revision )
@@ -1,213 +1,0 @@
-function Connector()
-{
-	this.__HTTP__ = [];
-	this.__THREADS__ = [];
-}
-
-Connector.prototype = {
-	'go' : function()
-	{
-		// connection
-		//var __HTTP__ = null;
-		//var __THREADS__ = [];
-		var index = 0;
-		var rtlen = 0;
-		var ie = false; // ie don't has stream
-		var __this__ = this;
-		function makeConnection(pThread)
-		{
-			//if ( __this__.__HTTP__ === false )
-				__this__.__HTTP__[pThread] = xhr();
-		}
-		function setPost(pThread)
-		{
-			__this__.__THREADS__[pThread].__METHOD__ = 'POST';
-			return true;
-		}
-		// this set __this__.__THREADS__[?].__TYPE__ to 4 for request or 3 for stream
-		function setStream(pThread)
-		{
-			__this__.__THREADS__[pThread].__TYPE__ = ( !ie ) ? 3 : 4;
-			return true;
-		}
-		function trim(pData)
-		{
-			return pData.replace(/^ +| +$/g, '');
-		}
-		function verifyUserHandler(pThread, pHandler)
-		{
-			var type_of_handler = typeof pHandler;
-			var i;
-			switch ( type_of_handler )
-			{
-				case 'function' :
-					return true;
-				break;
-				case 'object' :
-					for ( i in pHandler )
-						if ( i != 'stream' && i != 'request' )
-							return false;
-						else if ( i == 'stream' )
-							setStream(pThread)
-					return true;
-				break;
-				default :
-					return false;
-			}
-		}
-		// xhr = XMLHttpRequest
-		function xhr()
-		{
-			try
-			{
-				return new XMLHttpRequest();
-			}
-			catch (e)
-			{
-				ie = true;
-				try
-				{
-					return new ActiveXObject('Msxml2.XMLHTTP');
-				}
-				catch (e1)
-				{
-					try
-					{
-						return new ActiveXObject('Microsoft.XMLHTTP');
-					}
-					catch (e2)
-					{
-						return null;
-					}
-				}
-			}
-		}
-
-		function __HANDLER__()
-		{
-			try
-			{
-				if ( ie && __this__.__HTTP__[arguments[0]].readyState != 4 )
-					return false;
-
-				//var threadId = __this__.__HTTP__[arguments[0]].getResponseHeader('ThreadId');
-				var threadId = arguments[0];
-
-				if ( !threadId )
-					return false;
-
-				if ( __this__.__HTTP__[threadId].readyState == 3 || __this__.__HTTP__[threadId].readyState == 4 )
-				{
-					if ( !ie && __this__.__HTTP__[threadId].readyState == 3 && __this__.__THREADS__[threadId].__HANDLER__.stream )
-					{
-						var data = trim(__this__.__HTTP__[threadId].responseText.substr(index));
-						rtlen = __this__.__HTTP__[threadId].responseText.length;
-						if ( index < rtlen && data.length )
-						{
-							__this__.__THREADS__[threadId].__HANDLER__.stream(data);
-							index = rtlen;
-						}
-					}
-					if ( __this__.__THREADS__[threadId].__HANDLER__.request && __this__.__HTTP__[threadId].readyState == 4 )
-					{
-						switch ( __this__.__HTTP__[threadId].status )
-						{
-							case 200:
-								var stream = false;
-								var request = false;
-								var data = ( __this__.__THREADS__[threadId].__MODE__ == 'XML' ) ?
-									__this__.__HTTP__[threadId].responseXML :
-									__this__.__HTTP__[threadId].responseText;
-
-								if ( ie && __this__.__THREADS__[threadId].__HANDLER__.stream )
-									stream = __this__.__THREADS__[threadId].__HANDLER__.stream;
-
-								if ( __this__.__THREADS__[threadId].__HANDLER__.request )
-									request = __this__.__THREADS__[threadId].__HANDLER__.request;
-
-								delete __this__.__THREADS__[threadId];
-
-								if ( stream )
-									stream(data);
-
-								if ( request )
-									request(data);
-
-								break; // [case : status 200]
-							case 404:
-								alert('Page Not Found!');
-								break; // [case : status 404]
-							default:
-						}
-					}
-				}
-				//if ( __this__.__HTTP__.readyState == 4 )
-				//{
-				//	delete __this__.__THREADS__[threadId];
-				//}
-			}
-			catch(e)
-			{
-				//alert("__HANDLER__\n" + threadId + "\n " + e + "\n ErroR: " + e.description);
-				//delete __this__.__THREADS__[threadId];
-			}
-		};
-
-		var argc = arguments.length;
-		if ( argc < 2 || argc > 4 )
-			return {'error':'#0 - invalid params'};
-
-		if ( __this__.__THREADS__[arguments[0]] )
-			return {'error':'#2 - request is running'};
-
-		__this__.__THREADS__[arguments[0]] = {
-			'__HANDLER__' : arguments[1],
-			'__METHOD__'  : 'GET',  // __METHOD__ = [GET | POST]
-			'__MODE__'    : 'TEXT', // __MODE__ = [XML | TEXT]
-			'__TYPE__'    : 4       // __TYPE__ = [4 for request | 3 for stream]
-		};
-
-		makeConnection(arguments[0]);
-
-		if ( !verifyUserHandler(arguments[0], arguments[1]) )
-		{
-			//delete __this__.__THREADS__[arguments[0]];
-			return {'error':'#1 - invalid handler'};
-		}
-
-		if ( argc == 3 )
-			setPost(arguments[0]);
-
-		if ( __this__.__HTTP__[arguments[0]] != null )
-		{
-			try
-			{
-				var __TARGET__ = path_im + 'controller.php?act=' + arguments[0];
-
-				//alert("__METHOD__: " + __this__.__THREADS__[arguments[0]].__METHOD__ + "\n__TARGET__: " + __TARGET__)
-
-				var __SEND__ = null;
-				__this__.__HTTP__[arguments[0]].open(__this__.__THREADS__[arguments[0]].__METHOD__, __TARGET__, true);
-				if ( __this__.__THREADS__[arguments[0]].__METHOD__ == 'POST' )
-				{
-					__this__.__HTTP__[arguments[0]].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
-					__this__.__HTTP__[arguments[0]].setRequestHeader('Cache-Control',  'no-store, no-cache, must-revalidate');
-					__this__.__HTTP__[arguments[0]].setRequestHeader('Cache-Control', 'post-check=0, pre-check=0');
-					__this__.__HTTP__[arguments[0]].setRequestHeader('Pragma', 'no-cache');
-					__SEND__ = arguments[2];
-				}
-				//__this__.__HTTP__.setRequestHeader('ThreadId', arguments[0]);
-				//__this__.__HTTP__.setRequestHeader('Connection', 'close');
-				//__this__.__HTTP__.setRequestHeader('Keep-Alive', '0');
-				var tst = arguments[0];
-				__this__.__HTTP__[arguments[0]].onreadystatechange = function(){__HANDLER__(tst)};
-				__this__.__HTTP__[arguments[0]].send(__SEND__);
-			}
-			catch(e)
-			{
-				alert("go\n" + e.description)
-				return {'error':'#3 - ' + e.description};
-			}
-		}
-	}
-};
Index: unk/instant_messenger/js/client.js
===================================================================
--- /trunk/instant_messenger/js/client.js	(revision 239)
+++ 	(revision )
@@ -1,94 +1,0 @@
-var con = new Connector;
-var disconnected = false;
-
-function client()
-{
-	var jabber = new Jabber;
-	var buffer = '';
-	var xtools = new XTools;
-
-	function request(data)
-	{
-		if ( !disconnected )
-			con.go('$this.Ujabber.listen', {'stream':stream, 'request':request}, '');
-	}
-	function stream(data)
-	{
-		function trim(pData)
-		{
-			return pData.replace(/^ +| +$/g, '');
-		}
-		data = trim(data);
-		if ( data == 'disconnected' || data == '</stream:stream>')
-		{
-			disconnected = true;
-			var XmlDoc = "<disconnected>" +
-							"<path>" + path_im + "</path>" +
-						 "</disconnected>";
-			im_window.load('_contacts_im_','instant_messenger_content','<title>.::Expresso Messenger::.</title>','window.xsl','',true,true,false);
-			im_window.elementC('_contacts_im_').innerHTML  = xtools.parse(XmlDoc,'disconnected.xsl');
-			func.byId('img_status_im').src = im_unavailable.src;
-			im.status = 'type=unavailable';
-			im.statusFlag = 'unavailable';					
-
-		}
-		else if ( data.lastIndexOf('>') == data.length - 1)
-		{
-			if ( buffer.length )
-			{
-				data = buffer + data;
-				buffer = '';
-			}
-
-			// com xmlns ocorre problemas durante o parse entre
-			// xml e xsl e por esse motivo está sendo retirado
-			data = '<handler>' + data.replace(/ xmlns='.*?'/g, '') + '</handler>';
-
-			if ( window.ActiveXObject )
-			{
-				var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
-				xmlDoc.async = "false";
-				xmlDoc.loadXML(data);
-			}
-			else
-			{
-				var parser = new DOMParser();
-				var xmlDoc = parser.parseFromString(data, "text/xml");
-			}
-
-			var node = xmlDoc.documentElement.firstChild;
-
-			while ( node )
-			{
-				with ( node )
-				{
-					jabber.doIt(nodeName, node);
-				}
-				node = node.nextSibling;
-			}
-		}
-		else
-		{
-			buffer += data;
-		}
-	}
-
-	function contacts(data)
-	{
-	}
-	request();
-	setTimeout("con.go('$this.Ujabber.getContacts', {'request':"+contacts+"})", 3000);
-}
-
-var _bkp_onbeforeunload = window.onbeforeunload;
-
-window.onbeforeunload = function()
-{
-	if ( typeof _bkp_onbeforeunload == 'function' )
-		_bkp_onbeforeunload();
-
-	disconnected = true;
-	var i;
-	for ( i in con.__HTTP__ )
-		con.__HTTP__[i].abort();
-};
Index: unk/instant_messenger/js/fcommon.js
===================================================================
--- /trunk/instant_messenger/js/fcommon.js	(revision 151)
+++ 	(revision )
@@ -1,391 +1,0 @@
-/*
-+------------------------------------------------+
-| @FILE:    functions.js                         |
-| @AUTHOR:  [NUTS] Rodrigo Souza                 |
-| @DATE:    Sex 27 Out 2006 12:38:22 BRST        |
-| @LAST CHANGE: Seg 27 Nov 2006 12:35:22 BRST::  |
-+------------------------------------------------+
-*/
-
-/*
- * @DESC The method has one optional boolean argument
- *          deep which when set recursively creates a
- *          deep copy, otherwise (when deep is false
- *          or not defined) a shallow copy is created.
- */
-/*Object.prototype.clone = function(deep)
-{
-   objectClone = new this.constructor();
-   for (var property in this)
-   {
-      if (!deep)
-         objectClone[property] = this[property];
-      else if (typeof this[property] == 'object')
-         objectClone[property] = this[property].clone(deep);
-      else
-         objectClone[property] = this[property];
-   }
-
-      return objectClone;
-}*/
-
-/*
- *
- */
-var func = {
-   "json" : false,
-   "attachEvent" : function(obj, eventName, eventHandler) 
-   {
-      if ( obj )
-      {
-         if ( eventName.substring(0, 2) == 'on' )
-         {
-            eventName = eventName.substring(2,eventName.length);
-         }
-         if ( obj.addEventListener )
-         {
-            obj.addEventListener(eventName, eventHandler, false);
-         }
-         else if ( obj.attachEvent )
-         {
-            obj.attachEvent('on'+eventName, eventHandler);
-         }
-      }
-   },
-
-   "byId" : function()
-   {
-      var elements = new Array();
-      for ( var i = 0; i < arguments.length; i++ )
-      {
-         element = arguments[i];
-         if ( this.isString(element) )
-            element = document.getElementById(element);
-
-         if (arguments.length == 1)
-            return element;
-
-         elements.push(element);
-      }
-      return elements;
-   },
-
-   "byTag" : function()
-   {
-      var elements = new Array();
-      for ( var i = 0; i < arguments.length; i++ )
-      {
-         element = arguments[i];
-         if ( this.isString(element) )
-            element = document.getElementsByTagName(element);
-
-         if ( arguments.length == 1 )
-            return element;
-
-         elements.push(element);
-      }
-      return elements;
-   },
-
-   "client_height" : function()
-   {
-      if( typeof( window.innerWidth ) == 'number' )
-      {
-         //Non-IE
-         return window.innerHeight;
-      }
-      else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
-      {
-         //IE 6+ in 'standards compliant mode'
-         return document.documentElement.clientHeight;
-      }
-      else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
-      {
-         //IE 4 compatible
-         return document.body.clientHeight;
-      }
-   },
-
-   "client_width" : function()
-   {
-         if( typeof( window.innerWidth ) == 'number' )
-         {
-            //Non-IE
-            return window.innerWidth;
-         }
-         else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
-         {
-            //IE 6+ in 'standards compliant mode'
-            return document.documentElement.clientWidth;
-         }
-         else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
-         {
-            //IE 4 compatible
-            return document.body.clientWidth;
-         }
-   },
-
-   "_confEl" : function(pElement, pAttribute, pValue)
-   {
-      if ( !func.isString(pValue) )
-         return false;
-
-      if ( this.isString(pElement) )
-      {
-         pElement = document.getElementById(pElement);
-      }
-
-      switch ( pAttribute )
-      {
-         /*
-          * No IE a propriedade style nÃo funciona se adicionada via setAttribute()
-          */
-         case 'style' :
-                        pElement.style.cssText = pValue;
-         break;
-         case 'class' :
-                        pElement.setAttribute(pAttribute, pValue);
-                        pElement.setAttribute(pAttribute+'Name', pValue); // IE
-         break;
-         default :
-                        pElement.setAttribute(pAttribute, pValue);
-      } /* switch */
-   },
-
-   "confEl" : function()
-   {
-      switch ( arguments.length )
-      {
-         case 1 :
-                  matriz = arguments[0];
-                  if ( !this.isArray(matriz) )
-                     return false;
-
-                  for ( var i in matriz )
-                  {
-                     pElement = matriz[i]['element'];
-                     delete matriz[i]['element'];
-
-                     for ( var j in matriz[i] )
-                     {
-                        this._confEl(pElement, j, matriz[i][j]);
-                     }
-                  }
-         break;
-         case 2 :
-                  var pElement = arguments[0];
-
-                  if ( !this.isArray(arguments[1]) )
-                     return false;
-
-                  for ( var i in arguments[1] )
-                  {
-                     this._confEl(pElement, i, arguments[1][i]);
-                  }
-         break;
-         case 3 :
-                  var pElement = arguments[0];
-
-                  this._confEl(pElement, arguments[1], arguments[2]);
-         break;
-      }
-   },
-
-   "elH" : function(pEl)
-   {
-      // no IE a funcao scrollHeight nÃ£o retorna o valor correto
-      return document.getElementById(pEl).offsetHeight;
-   },
-
-   "elHW" : function(pEl)
-   {
-      aux = {
-               h:this.elH(pEl),
-               w:this.elW(pEl)
-            };
-      return aux;
-   },
-
-   "elW" : function(pEl)
-   {
-      return document.getElementById(pEl).offsetWidth;
-   },
-
-   "interface" : function(_XmlDoc)	
-   {
-	   var data = _XmlDoc.getElementsByTagName('retorno').item(0);
-	   if ( data.childNodes.length == 1 )
-	      data = data.firstChild.nodeValue;
-
-	   if ( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(data) )
-	   {
-	      eval('data = ' + data);
-	      if ( this.json ){
-	         this.json = false;
-	      }else{
-	         data = this.json2array(data);
-	      }
-	   }
-
-	   return data;
-  
-   },
-
-   "insEl" : function()
-   {
-      try
-      {
-         if ( arguments.length == 1 )
-         {
-            var body = document.getElementsByTagName('body');
-            body[0].appendChild(arguments[0]);
-         }
-         else
-         {
-            var parentEl;
-            switch ( typeof arguments[arguments.length-1] )
-            {
-               case 'object' :
-                              parentEl = arguments[arguments.length-1];
-               break;
-               case 'string' :
-                              parentEl = document.getElementById(arguments[arguments.length-1]);
-               break;
-               case 'boolean' : parentEl = document.getElementsByTagName('body').item(0);
-            }
-
-            for ( var i = 0; i < arguments.length-1; i++ )
-            {
-                  if ( this.isString(arguments[i]) )
-                     arguments[i] = document.createTextNode(arguments[i]);
-
-                  parentEl.appendChild(arguments[i]);
-            }
-         } /* else */
-         return true;
-      }
-      catch(e)
-      {}
-   },
-
-   "insElB" : function()
-   {
-      try
-      {
-         if ( arguments.length < 2 )
-         {
-            return false;
-         }
-         else
-         {
-            var referenceEl;
-            var parentEl;
-            switch ( typeof arguments[arguments.length-1] )
-            {
-               case 'object' :
-                              parentEl    = arguments[arguments.length-1].parentNode;
-                              referenceEl = arguments[arguments.length-1];
-               break;
-               case 'string' :
-                              referenceEl = document.getElementById(arguments[arguments.length-1]);
-                              parentEl    = referenceEl.parentNode;
-            }
-
-            for ( var i = 0; i < arguments.length-1; i++ )
-            {
-                  parentEl.insertBefore(arguments[i], referenceEl);
-            }
-         } /* else */
-         return true;
-      }
-      catch(e)
-      {}
-   },
-
-   "isArray" : function(a)
-   {
-      return this.isObject(a) && a.constructor == Array;
-   },
-
-   "isFunction" : function(a)
-   {
-      return typeof a == 'function';
-   },
-
-   "isNumber" : function(a)
-   {
-      return typeof a == 'number' && isFinite(a);
-   },
-
-   "isNull" : function(a)
-   {
-      return a === null;
-   },
-
-   "isObject" : function(a)
-   {
-      return (a && typeof a == 'object') || this.isFunction(a);
-   },
-
-   "isString" : function(a)
-   {
-      return typeof a == 'string';
-   },
-
-   "isUndefined" : function(a)
-   {
-      return typeof a == 'undefined';
-   },
-
-   "json2array" : function(pObject)
-   {
-	   var retorno = [];
-	   for( var i in pObject )
-	      if( pObject[i].constructor == Object )
-	      {
-	         retorno[i] = [];
-	         retorno[i] = this.json2array(pObject[i]);
-	      }
-	      else
-	         retorno[i] = pObject[i];
-	   return retorno;
-   },
-
-   "newEl" : function(pElement)
-   {
-      if ( arguments.length == 1 )
-      {
-         switch ( typeof pElement)
-         {
-            case 'string' :
-                           return document.createElement(pElement);
-            break;
-            case 'object' :
-                           var retorno = new Array();
-                           if (this.isArray(pElement))
-                           {
-                              for (var i in pElement)
-                              {
-                                 retorno[i] = document.createElement(pElement[i]);
-                              }
-                              return retorno;
-                           }
-            break;
-         } /* switch */
-      } /* if */
-      else
-      {
-         var retorno = new Array();
-         for ( var i = 0; i < arguments.length; i++ )
-         {
-            retorno[i] = document.createElement(arguments[i]);
-         }
-         return retorno;
-      }
-   },
-
-   "trim" : function(pString)
-   {
-      return pString.replace(/^( )*|( )*$/g, '');
-   }
-}
Index: unk/instant_messenger/js/templates.js
===================================================================
--- /trunk/instant_messenger/js/templates.js	(revision 235)
+++ 	(revision )
@@ -1,322 +1,0 @@
-function Templates()
-{
-	this.xtools		= new XTools();
-	this.zValue		= 100;
-	this.documentMousedown = null;
-	this.jabber 	= new Jabber;
-}
-
-Templates.prototype = {
-
-	"add_user": function()
-	{
-		var XmlDoc = "<adduser>" +
-						 "<top>" +
-							 "<lang1>" + im.get_lang("Organization Unit")+ "</lang1>" +
-	   					 "</top>" +
-						 "<table>"+
-		   					 "<lang1>" + im.get_lang("Jid Contact") + "</lang1>" +
-							 "<lang2>" + im.get_lang("Nickname") + "</lang2>" +
-							 "<lang3>" + im.get_lang("Group") + "</lang3>" +
-							 "<lang4>" + im.get_lang("Add") + "</lang4>" +
-							 "<lang5>" + im.get_lang("Close") + "</lang5>" +						 
-						 "</table>" +
-					 "</adduser>";
-		im_window.load('add_user_im','instant_messenger_content','<title>.:: Adicionar Novos Contatos ::.</title>','window.xsl','545',true,true,true);
-		im_window.elementC('add_user_im').innerHTML  = this.xtools.parse(XmlDoc,'add_user.xsl');
-		im.ldap();
-	},
-
-	"colors": function(pJid)
-	{
-		var Xmlsmiles = "<colors>" + 	
-							"<lang1>Black</lang1>" +
-							"<lang2>Silver</lang2>" +
-							"<lang3>Yellow</lang3>" +
-							"<lang4>Red</lang4>" +
-							"<lang5>Pink</lang5>" +
-							"<lang6>Green</lang6>" +
-							"<lang7>Blue</lang7>" +
-							"<lang8>Magenta</lang8>" +
-							"<path>"+path_im+"</path>" +
-							"<name>"+pJid+"</name>" +
-						"</colors>";
-
-		menu_action.menu(pJid + '_button_dest', this.xtools.parse(Xmlsmiles,'colors.xsl'));
-		func.byId(pJid + '_button_dest').style.top = func.byId(pJid + '_button_color').offsetTop + 10;
-		func.byId(pJid + '_button_dest').style.left = func.byId(pJid + '_button_color').offsetLeft + 10;
-		func.byId(pJid + '_button_dest').style.zIndex = this.zValue++;
-		func.byId(pJid + '_button_dest').style.position = "absolute";
-	},
-
-	"fast_menu" : function()
-	{
-		if( document.getElementById('_contacts_im_' + '_window_master') != null )
-		{
-			var XmlDoc = "<fast_menu>" +	
-							"<lang1>Online</lang1>" +
-							"<lang2>Ausente</lang2>" +
-							"<lang3>Ocupado</lang3>" +
-							"<lang4>Offline</lang4>" +
-							"<lang5>Mensagem</lang5>" +
-							"<img1>"+path_im+"templates/default/images/available.gif</img1>" +
-							"<img2>"+path_im+"templates/default/images/away.gif</img2>" +
-							"<img3>"+path_im+"templates/default/images/dnd.gif</img3>" +
-							"<img4>"+path_im+"templates/default/images/unavailable.gif</img4>" +
-							"<img5>"+path_im+"templates/default/images/icon_edit.gif</img5>" +																		
-						 "</fast_menu>";
-	
-			menu_action.menu('fast_menu_im', this.xtools.parse(XmlDoc,'fast_menu.xsl'));
-			document.getElementById('fast_menu_im').style.top = document.getElementById('fast_menu_im').offsetTop + 60;
-			document.getElementById('fast_menu_im').style.left = document.getElementById('fast_menu_im').offsetLeft + 5;
-			document.getElementById('fast_menu_im').style.zIndex = this.zValue++;
-			document.getElementById('fast_menu_im').style.position = "absolute";
-		}
-		else
-			alert('Aguarde carregando lista de contatos ....');
-					
-	},
-	
-	"mysettings": function()
-	{
-		var XmlDoc = "<settings>" +
-						"<lang1>Opções</lang1>" +
-						"<lang2>Exibir amigos desconectados</lang2>" +
-						"<lang3>Ausente</lang3>" +
-						"<lang4>Ficar ausente depois de</lang4>" +
-						"<lang5>minutos</lang5>" +
-						"<lang6>Ativar aviso de mensagens recebidas</lang6>" +
-						"<lang7>Normal</lang7>" +																																				
-						"<lang8>Treme Tela</lang8>" +
-						"<lang9>" + im.get_lang("Save") + "</lang9>" +
-						"<lang10>" + im.get_lang("Close") + "</lang10> " +
-					 "</settings>";
-		
-		im_window.load('my_settings_im','instant_messenger_content','<title>.:: ' + im.get_lang("My Settings") + ' ::.</title>','window.xsl','400',true,true,true);
-		im_window.elementC('my_settings_im').innerHTML = this.xtools.parse(XmlDoc,'mysettings.xsl');
-		im.get_preferences();
-	},
-	
-	"options" : function(pEv, pJid)
-	{
-		try
-		{
-			var pEvent = pEv;
-
-			if ( pEvent.button > 1 )
-			{
-				document.oncontextmenu = new Function("return false");				
-				document.onmousedown = new Function("return false");
-
-				this.options_button_right(pJid);
-	
-				document.onmousedown = new Function("return true");							
-			}
-			else
-			{
-				this.options_button_left(pJid);
-			}
-
-		}catch(e){}
-
-	},
-	
-	"options_button_left" : function(pJid)
-	{
-		var _this = this;
-
-		if(!(im.nickname_contacts[pJid]))
-			im.request_vcard(pJid, false);
-
-		if(func.byId('img_' + pJid).src != im_unavailable.src )
-		{
-			im_window.load(pJid, 'instant_messenger_content', '<title>.:: Expresso Messenger ::.</title>', 'chat.xsl','310',true,true,true);
-			//im_window.visible(pJid,'block');			
-			func.byId(pJid + '_avatar').src = path_im + "/templates/default/images/photo.png";
-
-			if(func.byId('iframe_' + pJid) != null)
-				func.byId('iframe_' + pJid).parentNode.removeChild(func.byId('iframe_' + pJid));
-
-			var win = im_window.elementC(pJid);
-
-			var iframe = document.createElement('iframe');
-			iframe.id = 'iframe_' + pJid;
-			iframe.style.width = '290px';
-			iframe.style.height = '46px';
-			iframe.style.border = '0';
-			iframe.style.margin = '0';
-			iframe.style.padding = '0'
-
-			var _messages_ = win.firstChild.firstChild.nextSibling.nextSibling;
-			_messages_.appendChild(iframe);
-
-			iframe.contentWindow.document.write('<html><body id="' + pJid + '" style="margin:0px;padding:0px"></body></html>');
-			iframe.contentWindow.document.close();
-			iframe.contentWindow.document.designMode = "On";
-			iframe.contentWindow.focus();
-
-			function keypress_handler(e)
-			{
-				var evt = e.keyCode;
-				var pId = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0).id;
-				switch ( evt )
-				{
-					case 13 :
-						if ( !e.shiftKey )
-							_this.jabber.doIt('sendMessage',{'message' : iframe.contentWindow.document.getElementsByTagName('body').item(0), 'from' : pJid });
-						return false;
-					break;
-					case 27 :
-						im_window.window_close(pId);
-					break;
-					default :
-					break;
-				}
-			}
-			function keyup_handler(e)
-			{
-				var evt = e.keyCode;
-				var _text = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0);
-
-				switch ( evt )
-				{
-					case 13 :
-						if ( !e.shiftKey )
-							_text.innerHTML = '';
-						return false;
-					break;
-					default :
-					break;
-				}
-			}
-			var obj = iframe.contentWindow.document;
-
-			if ( obj.addEventListener )
-			{
-				obj.addEventListener('keypress', keypress_handler, false);
-				obj.addEventListener('keyup', keyup_handler, false);
-			}
-			else if ( obj.attachEvent )
-			{
-				obj.attachEvent('onkeypress', keypress_handler);
-				obj.attachEvent('onkeyup', keyup_handler);
-			}
-			
-			im.ldap_photo(pJid + "_avatar");
-		}
-	},
-	
-	"options_button_right" : function( pJid )
-	{
-
-		var XmlDoc = "<options>" +	
-						"<lang1>" + im.get_lang("Nickname") + "</lang1>" +
-						"<lang2>" + im.get_lang("Group") + "</lang2>" +
-						"<lang3>" + im.get_lang("Remove") + "</lang3>" +
-						"<lang4>" + im.get_lang("It requisition permission")+ "</lang4>" +
-						"<lang5>" + im.get_lang("See Info") + "</lang5>" +
-						"<jid>" + pJid + "</jid>" +
-						"<path>" + path_im + "</path>" +		
-					 "</options>";
-
-		var posX = parseInt(func.byId('sub_' + pJid).offsetLeft) - parseInt(func.byId('sub_' + pJid).parentNode.scrollLeft);
-		var posY = parseInt(func.byId('sub_' + pJid).offsetTop) - parseInt(func.byId('sub_' + pJid).parentNode.scrollTop);
-
-		menu_action.menu('im_sub_menu', this.xtools.parse(XmlDoc,'options.xsl'));
-	    func.byId('im_sub_menu').style.zIndex = '99999';
-		func.byId('im_sub_menu').style.top = posY;
-		func.byId('im_sub_menu').style.left = posX + 20;	    
-	    func.byId('im_sub_menu').style.position = 'absolute';
-	},
-
-	"preferences": function(pElement)
-	{
-		var XmlDoc = "<preferences>" +
-						"<lang1>" + im.get_lang("Add Contact") + "</lang1>" +
-						"<function1>templates.add_user();</function1>" +
-						"<lang2>" + im.get_lang("Remove Contact") + "</lang2>" +
-						"<function2>templates.remove_user();</function2>" +
-						"<lang3>" + im.get_lang("Vcard") +"</lang3>" +
-						"<function3>im.request_vcard('this',true)</function3>" +
-						"<lang4>" + im.get_lang("Preferences") + "</lang4>" +
-						"<function4>templates.mysettings()</function4>" +
-						"<path>"+ path_im + "</path>" +
-					 "</preferences>";
-
-		menu_action.menu(pElement, this.xtools.parse(XmlDoc,'preferences.xsl'));
-		document.getElementById(pElement).style.zIndex 	 = this.zValue++;
-		document.getElementById(pElement).style.position = "absolute";
-	},
-
-	"remove_user": function()
-	{
-		var XmlDoc = "<remove_user>" +
-						"<lang1>" + im.get_lang("Contact") + "</lang1>" +
-						"<lang2>" + im.get_lang("Remove") +"</lang2>" +
-						"<lang3>" + im.get_lang("Close") + "</lang3>" +
-					 "</remove_user>";
-
-		im_window.load('remove_user_im','instant_messenger_content','<title>.:: Remover Contatos ::.</title>','window.xsl','350',true,true,true);
-		im_window.elementC('remove_user_im').innerHTML = this.xtools.parse(XmlDoc,'remove_user.xsl');
-		im.get_contacts();
-		//im_window.visible('remove_user_im','block');		
-	},
-
-	"smiles": function(pJid)
-	{
-		var Xmlsmiles = "<smiles>" + 	
-							"<path>"+path_im+"</path>" +																																										
-							"<pjid>"+pJid+"</pjid>" +
-						"</smiles>";
-
-		menu_action.menu(pJid + '_button_dest', this.xtools.parse(Xmlsmiles,'smiles.xsl'));
-		func.byId(pJid + '_button_dest').style.top = func.byId(pJid + '_button_emoticons').offsetTop + 10;
-		func.byId(pJid + '_button_dest').style.left = func.byId(pJid + '_button_emoticons').offsetLeft + 10;
-		func.byId(pJid + '_button_dest').style.zIndex = this.zValue++;
-		func.byId(pJid + '_button_dest').style.position = "absolute";
-	},
-
-	"vcard_contact" : function(pXml)	
-	{
-		im.vcard = false;
-		var title = "Informações do Contato - Expresso";
-		var XmlDoc = "<vcard_contact>" + 
-						"<lang1>" + im.get_lang("Full Name") + "</lang1>" +
-						"<lang2>" + im.get_lang("Nickname") + "</lang2>" +
-						"<lang3>" + im.get_lang("Organization") +"</lang3>" +
-						"<lang4>" + im.get_lang("Sector") + "</lang4>" +
-						"<lang5>" + im.get_lang("Role") + "</lang5>" +
-						"<lang6>" + im.get_lang("Birthday") + "</lang6>" +
-						"<lang7>" + im.get_lang("Close") + "</lang7>" +																	
-						this.xtools.parse(pXml,'vcard.xsl') + 
-						"<id>vcard_contact_im</id>"+
-					"</vcard_contact>";
-
-		im_window.load('vcard_contact_im','instant_messenger_content','<title>.:: ' + title +' ::.</title>','window.xsl','390',true,true,true);
-		im_window.elementC('vcard_contact_im').innerHTML = this.xtools.parse(XmlDoc,'vcard_contacts.xsl');
-		//im_window.visible('vcard_contact_im','block');		
-	},
-
-	"vcard_user" : function(pXml)
-	{
-		im.vcard = false;
-		var title = "Informações Pessoais - Expresso";
-		var XmlDoc = "<vcard_user>" +	
-						"<lang1>" + im.get_lang("Full Name") + "</lang1>" +
-						"<lang2>" + im.get_lang("Nickname") + "</lang2>" +
-						"<lang3>" + im.get_lang("Organization") + "</lang3>" +
-						"<lang4>" + im.get_lang("Sector") + "</lang4>" +
-						"<lang5>" + im.get_lang("Role") + "</lang5>" +
-						"<lang6>" + im.get_lang("Birthday") + "</lang6>" +
-						"<lang7>" + im.get_lang("Save") + "</lang7>" +
-						"<lang8>" + im.get_lang("Close") + "</lang8>" +
-						this.xtools.parse(pXml,'vcard.xsl') + 						
-						"<id>vcard_user_im</id>"+						
-					 "</vcard_user>";
-		im_window.load('vcard_user_im','instant_messenger_content','<title>.:: ' + title +' ::.</title>','window.xsl','470',true,true,true);
-		im_window.elementC('vcard_user_im').innerHTML = this.xtools.parse(XmlDoc,'vcard_user.xsl');
-		//im_window.visible('vcard_user_im','block');		
-	}
-}
-
-var templates = new Templates();
Index: unk/instant_messenger/js/load.js
===================================================================
--- /trunk/instant_messenger/js/load.js	(revision 235)
+++ 	(revision )
@@ -1,79 +1,0 @@
-	var focusFlag = true;
-	
-	//window.document.onblur	= windowBlur;
-	//window.document.onclick	= windowFocus;
-	//window.document.onmouseover	= awayTimer;
-	
-	var window_title = document.title;
-
-    var _awayTimer_	= null;
-	var cod_emotions = {
-		":)" : [1,"\\\:\\\)"],
-		":d" : [2,"\\\:d"],
-		";)" : [3,"\\\;\\\)"],
-		":o" : [4,"\\\:o"],
-		":p" : [5,"\\\:p"],
-		"(h)" : [6,"\\\(h\\\)"],
-		":@" : [7,"\\\:\\\@"],
-		":$" : [8,"\\\:\\\$"],
-		":s" : [9,"\\\:s"],
-		":(" : [10,"\\\:\\\("],
-		":'(" : [11,"\\\:\\\'\\\("],
-		":|" : [12,"\\\:\\\|"]
-	};
-    
-	function load_im_contacts()
-	{
-		if( document.getElementById('_contacts_im_' + '_window_master') != null )
-			im_window.load('_contacts_im_','instant_messenger_content', '<title>Expresso Messenger</title>', 'window.xsl','',true,true,false);
-		else
-			alert('Aguarde carregando lista de contatos ....');			
-	}
-	
-	function shortcut_im()
-	{
-		var local = "";
-		if((local = func.byId('user_info')) && !(func.byId('instant_messenger_content')))
-		{
-			var local_old = local.innerHTML ;
-			local.innerHTML  = '<img src="' + im_fast_menu.src + '" onclick="javascript:templates.fast_menu();">';
-			local.innerHTML += '<img id="im_status_src" src="' + im_available.src + '" onclick="javascript:load_im_contacts();"/>';
-			local.innerHTML += local_old;
-			local.innerHTML += '<div id="instant_messenger_content"></div><span id="fast_menu_im"/>';
-		}
-
-		// Carregando Preferências do usuário
-		im.get_preferences();
-	}
-	
-	function awayTimer()
-	{
-		/*if( _awayTimer_ )
-		{
-			clearTimeout(_awayTimer_);
-			if( im.statusFlag && im.statusFlag === 'xa')
-				im.presence('available');
-		}
-		_awayTimer_ = setTimeout("im.set_timeOut()", parseInt(im.timeOut_im) * 60000 );*/
-	}
-
-	function windowBlur() 
-	{
-		try
-		{
-			focusFlag = false; 
-			document.title = window_title;
-		}catch(e){}
-	}
-
-	function windowFocus()
-	{
-		try
-		{
-			focusFlag = true; 
-			document.title = window_title;
-		}catch(e){}
-	}
-
-	shortcut_im();			
-	awayTimer();
Index: unk/instant_messenger/js/cookies_im.js
===================================================================
--- /trunk/instant_messenger/js/cookies_im.js	(revision 151)
+++ 	(revision )
@@ -1,32 +1,0 @@
-var cookies_im = {
-
-	"getCookie" : function (pNameCookie)
-	{
-		if (document.cookie.length>0)
-		{
-			var c_start = document.cookie.indexOf(pNameCookie + "=");
-			if ( c_start != -1)
-			{ 
-				c_start = c_start + pNameCookie.length + 1; 
-				var c_end = document.cookie.indexOf(";",c_start);
-
-				if ( c_end == -1) c_end=document.cookie.length;
-					return unescape(document.cookie.substring( c_start, c_end));
-			} 
-		}
-		return false;
-	},
-
-	"setCookie" : function setCookie(pNameCookie, pValue, pExpire)
-	{
-		var dt = new Date();
-		if( pExpire )
-			dt.setTime( dt.getTime() + (pExpire * (60 * 1000)));
-		document.cookie = pNameCookie+ "=" + escape(pValue) + (( pExpire == null ) ? "" : ";expires="+dt.toGMTString());
-	},
-
-	"checkCookie" : function(pNameCookie)
-	{
-		return this.getCookie(pNameCookie);
-	}
-}
Index: unk/instant_messenger/js/menu_action.js
===================================================================
--- /trunk/instant_messenger/js/menu_action.js	(revision 151)
+++ 	(revision )
@@ -1,63 +1,0 @@
-var menu_action = {
-
-	"delay_hide" : 500,
-	"delayhide" : false,
-
-	"menu" : function()
-	{
-		try
-		{
-			var pElement = arguments[0];
-			delete arguments[0];
-			var pMenu = ( func.isString(arguments[1]) ) ? arguments[1] : arguments;
-			if ( document.getElementById(pElement).innerHTML == "" )
-			{
-				func.confEl(pElement, 'style', 'display:block');
-				this.layout(pMenu, pElement);
-			}
-			else
-			{
-				func.confEl(pElement, 'style', 'display:none;');
-				this.del_innerHTML(pElement);
-				this.clear_delayhide();
-			}
-		}catch(e){}
-	},
-
-	"layout" : function(pHtml, pElement)
-	{
-		var _this = this;
-		var el_dest_ = ( func.isString(pElement) ) ? func.byId(pElement) : pElement;
-		var div_menu = func.newEl("div");
-		func.confEl(div_menu, 'style', 'padding:0px;border:1px solid #809aa9; background: #b4cfe5; font: 9pt Verdana, Arial, Helvetica, sans-serif;');
-		div_menu.onmouseover = function(){_this.clear_delayhide();};
-		div_menu.onmouseout = function(){_this.resetit(pElement);};
-		if ( func.isString(pHtml) )
-			div_menu.innerHTML = pHtml;
-		else
-		{
-			for ( i = 1; i < pHtml.length; i++ )
-				func.insEl(pHtml[i], div_menu);
-		}
-		func.insEl(div_menu, el_dest_);
-		this.delayhide = setTimeout("menu_action.del_innerHTML('"+pElement+"')", 2000);
-	},
-
-	"del_innerHTML": function(pElement)
-	{
-		func.confEl(pElement, 'style', 'display:none;');
-		func.byId(pElement).innerHTML = "";
-		document.oncontextmenu = new Function("return true");
-	},
-
-	"resetit": function(pElement)
-	{
-		this.delayhide = setTimeout("menu_action.del_innerHTML('"+pElement+"')",this.delay_hide);
-	},
-
-	"clear_delayhide" : function()
-	{
-		if ( this.delayhide )
-			clearTimeout(this.delayhide);
-	}
-}
Index: unk/instant_messenger/js/dragdrop.js
===================================================================
--- /trunk/instant_messenger/js/dragdrop.js	(revision 151)
+++ 	(revision )
@@ -1,161 +1,0 @@
-/**
-* @AUTHOR: Alexandre Correia - alexandrecorreia [.at.] celepar [.dot.] pr [.dot.] gov [.dot.] br
-* @AUTHOR: Rodrigo Souza - rodrigosouzadossantos [.at.] gmail [.dot.] com
-* @COPYLEFT: GPL - http://www.gnu.org/copyleft/gpl.html
-* @DATE: 10/10/2007
-* @LAST CHANGE: 11/10/2007
-* @BRIEF:
-**/
-
-function DragDrop()
-{
-	this.dragObject		= null;
-	this.mouseOffset	= null;
-	this.documentMouseMove	= null;
-	this.documentMouseUp	= null;
-
-}
-
-DragDrop.prototype = {
-	"drag" : function(ev, pObject)
-	{
-		function mouseMove(pEv, pObject, pTarget)
-		{
-			function getMouseOffset(pThis, target, pEv)
-			{
-				function getPosition(pObject)
-				{
-					try
-					{
-						var left = 0;
-						var top  = 0;
-
-						while (pObject.offsetParent)
-						{
-							left += pObject.offsetLeft;
-							top  += pObject.offsetTop;
-							pObject = pObject.offsetParent;
-						}
-
-						left += pObject.offsetLeft;
-						top  += pObject.offsetTop;
-
-						return {x:left, y:top};
-					}catch(e){}
-				}
-				try
-				{
-					var ev = pEv || window.event;
-
-					var docPos = getPosition(target);
-					var mousePos = mouseCoords(ev);
-					return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
-				}
-				catch(e){}
-			}
-			function mouseCoords(pEv)
-			{
-				try
-				{
-					var ev = pEv;
-					var CoordX = "";
-					var CoordY = "";
-
-					if(ev.pageX || ev.pageY)
-						return {x:ev.pageX, y:ev.pageY};
-
-					CoordX = ev.clientX + document.body.scrollLeft - document.body.clientLeft;
-					CoordY = ev.clientY + document.body.scrollTop  - document.body.clientTop;
-					return { x:CoordX, y:CoordY };
-				}
-				catch(e){}
-			}
-			try
-			{
-				if ( pObject.mouseOffset == null )
-					pObject.mouseOffset = getMouseOffset(pObject, pTarget, pEv);
-
-				var ev = pEv || window.event;
-				var mousePos = mouseCoords(ev);
-
-				if( pObject.dragObject )
-				{
-					var x = mousePos.x - pObject.mouseOffset.x;
-					var y = mousePos.y - pObject.mouseOffset.y;
-					pObject.dragObject.style.left = ( x < 0 ) ? 0 : x;
-					pObject.dragObject.style.top  = ( y < 0 ) ? 0 : y;
-				}
-				if ( typeof pObject.documentMouseMove == 'function' )
-					pObject.documentMouseMove();
-			}
-			catch(e){}
-		}
-		function mouseUp(pObject)
-		{
-			try
-			{
-				if ( typeof pObject.documentMouseUp == 'function' )
-					pObject.documentMouseUp();
-				pObject.dragObject = null;
-				document.onmousemove = pObject.documentMouseMove;
-				document.onmouseup = pObject.documentMouseUp;
-				pObject.documentMouseMove = pObject.documentMouseUp = null;
-				pObject.mouseOffset = null;
-			}
-			catch(e){}
-		}
-		try
-		{
-			if( !pObject )
-				return;
-
-			if (typeof ev.preventDefault != 'undefined')
-				ev.preventDefault();
-			else
-				pObject.onselectstart = new Function("return false;");
-
-			this.mouseOffset = null;
-
-			if ( pObject.getAttribute('dragdrop') === "true" )
-			{
-				var _this = this;
-				pObject.style.cursor = "pointer";
-				pObject.style.position = 'absolute';
-
-				pObject.onmousemove = function(ev)
-				{
-					mouseMove(ev, _this, pObject);
-				};
-
-				if ( typeof document.onmousemove == 'function' && document.onmousemove != pObject.onmousemove )
-					this.documentMouseMove = document.onmousemove;
-
-				document.onmousemove = function(ev)
-				{
-					mouseMove(ev, _this, pObject);
-				};
-
-				pObject.onmouseup = function()
-				{
-					mouseUp(_this);
-				};
-
-				if ( typeof document.onmouseup == 'function' && document.onmouseup != pObject.onmouseup )
-					this.documentMouseUp = document.onmouseup;
-
-				document.onmouseup = pObject.onmouseup;
-
-				var el = ( window.event ) ? window.event.srcElement : ev.target;
-
-				if ( el.getAttribute('dragdrop') === "true" )
-				{
-					_this.dragObject  = pObject;
-					return false;
-				}
-			}
-		}
-		catch(e){alert(e.description);}
-	}
-};
-
-var drag_drop = new DragDrop();
Index: unk/instant_messenger/templates/default/css/common.css
===================================================================
--- /trunk/instant_messenger/templates/default/css/common.css	(revision 151)
+++ 	(revision )
@@ -1,59 +1,0 @@
-/* IM:WINDOW - ADD USER */
-
-select.add_user
-{
-   font: 8pt Verdana, Arial, Helvetica, sans-serif;   
-   font-weight:   normal;
-   border-color:  #809aa9;
-   border-width:  1px 1px;
-   border-style:  solid;
-   margin:        2px 2px 2px 2px;
-   width:    	  493px;
-
-
-}
-
-table.add_user
-{
-	margin-left:	5px;
-	margin-top:		5px;
-}
-
-td.add_user
-{
-	font: 8pt Verdana, Arial, Helvetica, sans-serif;
-}
-
-.font_menu
-{
-	font: 8pt Verdana, Arial, Helvetica, sans-serif;
-}
-
-.layer
-{
-	border:	1px solid #b4cfe5;
-	margin:	2px;
-}
-
-/* Disconnected */
-
-.disconnected
-{
-	font: 9pt Verdana, Arial, Helvetica, sans-serif;
-	border: 1px solid #b4cfe5;
-	margin: 2px;
-}
-
-/* Vcard */
-
-.vcard_user
-{
-	font: 9pt Verdana, Arial, Helvetica, sans-serif;
-	margin:10px;
-}
-
-.vcard_contact
-{
-	font: 9pt Verdana, Arial, Helvetica, sans-serif;
-	margin:10px;
-}
Index: unk/instant_messenger/templates/default/css/window.css
===================================================================
--- /trunk/instant_messenger/templates/default/css/window.css	(revision 151)
+++ 	(revision )
@@ -1,80 +1,0 @@
-/***** Cantos Arredondados *****/
-.corner { display: block; }
-.corner * { display: block; height: 1px; overflow: hidden; font-size: 0; }
-.corner1 { padding: 0 1px; margin: 0 3px; }
-.corner2 { padding: 0 1px; margin: 0 1px; }
-.corner3 { margin: 0 1px; }
-.blackcorner *{ background: #b4cfe5; }
-/***** Cantos Arredondados *****/
-
-/***** Window  *****/
-.window
-{
-	font: 10pt Verdana, Arial, Helvetica, sans-serif;
-	margin: 0px;
-	position: absolute;
-}
-
-#instant_messenger_content .body
-{
-	background: #b4cfe5;
-}
-
-#instant_messenger_content .titulo
-{
-	font: 8pt Verdana, Arial, Helvetica, sans-serif;
-	background: #b4cfe5;
-	margin: 0px 0px;
-	padding: 0px 0px 0px 5px;
-	cursor: pointer;
-	height: 20px;
-}
-
-#instant_messenger_content .titulo div div
-{
-	cursor: pointer;
-	float: left;
-	margin-right: 2px;
-	position: relative;
-	width: 13px;
-	height:13px;
-}
-
-#instant_messenger_content .button_minimize
-{
-	background: #b4cfe5 url(../images/window_min.gif) no-repeat top center;
-}
-
-#instant_messenger_content .button_maximize1
-{
-	background: #b4cfe5 url(../images/window_max1.gif) no-repeat top center;
-}
-
-#instant_messenger_content .button_maximize
-{
-	background: #b4cfe5 url(../images/window_max.gif) no-repeat top center;
-}
-
-#instant_messenger_content .button_close
-{
-	background: #b4cfe5 url(../images/window_close.gif) no-repeat top center;
-	margin-right: 0px;
-}
-
-#instant_messenger_content .content
-{
-	font: 9pt Verdana, Arial, Helvetica, sans-serif;
-	background: #fff;
-	border: 1px solid;
-	border-color: #b3b3b3 #c1d6eb #c1d6eb #b3b3b3;
-	margin: 0px 5px;
-	cursor: default;
-}
-
-#instant_messenger_content .rodape
-{
-	background: #b4cfe5 url(../images/handle.gif) no-repeat bottom right;
-	height: 15px;
-}
-
-/***** Window - *****/
Index: unk/instant_messenger/templates/default/config.tpl
===================================================================
--- /trunk/instant_messenger/templates/default/config.tpl	(revision 164)
+++ 	(revision )
@@ -1,63 +1,0 @@
-<!-- BEGIN header -->
-<form method="POST" action="{action_url}">
-<table border="0" align="center">
-   <tr bgcolor="{th_bg}">
-    <td colspan="2"><font color="{th_text}">&nbsp;<b>{title} - Jabber</b></font></td>
-   </tr>
-<!-- END header -->
-
-<!-- BEGIN body -->
-   <tr bgcolor="{row_on}">
-    <td colspan="2">&nbsp;</td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td colspan="2">&nbsp;<b>ConfiguraÃ§Ã£oo do Servidor Jabber</b></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Digite o nome da mÃ¡quina Servidor Jabber:</td>
-    <td><input id="IM_name_jabber" name="newsettings[name_jabber]" value="{value_name_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td>Digite Nome da ConexÃ£o:</td>
-    <td><input id="IM_resource_jabber" name="newsettings[resource_jabber]" value="{value_resource_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Digite a porta do Servidor Jabber:</td>
-    <td><input id="IM_port_jabber" name="newsettings[port_jabber]" value="{value_port_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td>Servidor Ldap:</td>
-    <td><input id="IM_server_ldap_jabber" name="newsettings[server_ldap_jabber]" value="{value_server_ldap_jabber}"></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Contexto:</td>
-    <td><input id="IM_context_ldap_jabber" name="newsettings[context_ldap_jabber]" value="{value_context_ldap_jabber}" size="30"></td>
-   </tr>
-
-   <tr bgcolor="{row_off}">
-    <td>UsuÃ¡rio Ldap:</td>
-    <td><input id="IM_user_ldap_jabber" name="newsettings[user_ldap_jabber]" value="{value_user_ldap_jabber}" size="30"></td>
-   </tr>
-
-   <tr bgcolor="{row_on}">
-    <td>Password:</td>
-    <td><input type="password" name="newsettings[password_ldap_jabber]" value="{value_password_ldap_jabber}"></td>
-   </tr>
-<!-- END body -->
-
-<!-- BEGIN footer -->
-  <tr>
-    <td colspan="2" align="center">
-      <input type="submit" name="submit" value="{lang_submit}">
-      <input type="submit" name="cancel" value="{lang_cancel}">
-    </td>
-  </tr>
-</table>
-</form>
-<!-- END footer -->
Index: unk/instant_messenger/templates/default/index.tpl
===================================================================
--- /trunk/instant_messenger/templates/default/index.tpl	(revision 164)
+++ 	(revision )
@@ -1,165 +1,0 @@
-<!-- BEGIN index -->
-    <h1>Como Utilizar o Expresso Messenger</h1>
-    <h2><a name="toc">Conteúdo</a></h2>
-    <ol>
-      <li><a href="#intro">Introdução</a>
-      <li><a href="#acesso_primeiro">Acessando o Expresso Messenger pela Primeira Vez</a>
-      <li><a href="#supported">Browsers Suportados</a>
-	  <li><a href="#prefe">Menu Opções</a>
-      <li><a href="#contact_list">Lista de Contatos</a>
-        <ol>
-          <li><a href="#status">Indicador de Status</a>
-          <li><a href="#useradd">Adicionando um novo contato</a>
-          <li><a href="#userdel">Removendo um contato</a>          
-        </ol>
-      <li><a href="#menu_right">Preferências Avançadas</a>
-      <li><a href="#info_ad">Vcard - Informações Adicionais</a>
-      <li><a href="#info_prefe">Preferências</a>      
-	  <li><a href="#troca_mens">Troca de Mensagens</a>
-	  <li><a href="#troca_status">Troca de Status</a>      
-    </ol>
-
-    <h2><a name="intro">1. Introdução</a></h2>
-    
-    O Expresso Messenger é uma aplicação que permite o envio e recebimento de mensagens instantaneamente. Através da sua lista de contatos, você pode trocar mensagens e arquivos com seus contatos. Através da lista também é possível saber se seus contatos estão Online ou Offline. Para a troca de mensagens basta clicar em cima do nome do seu contato, se o mesmo estiver online ( verifique a sessão <a href="#status">Indicador de Status</a> ) abrirá uma janela onde você poderá enviar/receber as mensagens. O Expresso Messenger está associado
-    a um serviço de mensagens instantâneas Jabber, este serviço é responsável pelo armazenamento dos seus contatos, preferências e mensagens.
-
-	<br clear="all">
-	<br>
-	( figura 1 )
-    <img src="templates/default/images/lista_contatos.png" width="200" height="319" alt="Im Screenshot" align="left" style="padding-right:4px;"> 
-	
-    <br clear="all">
-
-	<h2><a name="acesso_primeiro">2. Acessando o Expresso Messenger pela Primeira Vez</a></h2>
-	
-	Para o acessar o Expresso Messenger, basta clicar em cima da figura <img src="templates/default/images/available.gif">("bolinha verde"), abrirá uma uma janela igual a figura 2. A lista de contatos aparecerá com a seguinte frase : "Nenhum Contato", atá que sejam cadastrados novos contatos. 
-
-	<br clear="all">
-	<br>
-	( figura 2 )
-    <img src="templates/default/images/lista_contatos_primeira.png" width="201" height="318" alt="Im Screenshot" align="left" style="padding-right:4px;"> 
-    
-    <br clear="all">
-
-    <h2><a name="supported">3. Browsers Suportados</a></h2>
-
-    <p>
-      <b>Windows XP/2000/ME/98/95:</b>
-	  <ul>
-	    <!--li>MS Internet Explorer desde a versão 6.0</li-->
-	    <li>Mozilla Firefox desde a versão 1.5</li>
-	  </ul>
-	  
-    <p>
-      <b>Linux:</b>
-      <ul>
-	    <li>Mozilla Firefox desde a versão 1.5</li>
-      </ul>
-    </p>
-
-    <h2><a name="prefe">4. Menu Opções</a></h2>
-	( figura 3 )
-    <img src="templates/default/images/menu_preferencias.png" width="201" height="320" alt="Menu Preferências" align="left">
-    <br clear="all">
-    <br>
-
-	Para acessar o menu "Opções" ( conforme figura 3 ), basta dar um clique com o mouse e abrirá um menu com as opções de Adicionar Contato ( <b>veja <a href="#useradd">Adicionando um novo contato</a></b> ), Remover Contato ( <b>veja <a href="#userdel">Removendo um contato</a></b> ), 
-	Vcard - Informações Adicionais ( <b>veja <a href="#info_ad">Vcard - Informações Adicionais</a></b> ) e Preferências ( <b>veja <a href="#info_prefe">Preferências</a></b> ).
-    
-    <h2><a name="contact_list">5. Lista de Contatos</a></h2>
-	( figura 4 )
-    <img src="templates/default/images/lista_contatos1.png" width="236" height="242" alt="Lista de Contatos" align="left">
-    <br clear="all">
-    <br>
-    
-    Na lista de contato ( conforme figura 4 ), você visualizará seus contatos. 
-    <h3><a name="status">1. Status dos Usuários</a></h3>
-    
-    <img src="templates/default/images/available.gif" align="top"> - Contato Online<br>
-    <img src="templates/default/images/away.gif" align="top"> - Contato Ausente<br>
-    <img src="templates/default/images/dnd.gif" align="top"> - Contato Ocupado<br>
-    <img src="templates/default/images/unavailable.gif" align="top"> - Contato Offline<br>    
-
-    <h3><a name="useradd">2. Adicionando um novo contato </a></h3>
-	( figura 4.1 )
-	<br/>
-    <img src="templates/default/images/adicionar_contato.png" width="555" height="294" alt="Adicionar Contato" align="left">
-    <br clear="all">
-    <br>
-
-	Para adicinar um novo contato, clique na imagem <img src="templates/default/images/addBuddy1.gif"/>  e abrirá uma janela ( conforme figura 4.1 ) selecione uma organização e automaticamente carregará os usuários que tem permissão para usar o Mensageiro Instantâneo Expresso. 
-	Para escolher seu novo contato basta apenas dar um clique em cima do nome desejado. Logo abaixo, três campos são necessários para adicionar o novo contato, sendo que o campo "Email Expresso" e
-	"Nickname" são preenchidos no momento da escolha do novo contato e o campo grupo terá que ser definido. Tendo os três campos preenchidos basta clicar no Botão Adicionar ( <input type="button" value="Adicionar"> ) .
-
-	<h3><a name="userdel">3. Removendo um contato </a></h3>
-	( figura 4.2 )
-	<br/>	
-    <img src="templates/default/images/remover_contato.png" width="359" height="125" alt="Remover Contato" align="left">
-    <br clear="all">
-    <br>
-
-	Para remover um contato da sua lista ( conforme figura 4.2 ), selecione na lista e clique no botao Botï¿œo Remover ( <input type="button" value="Remover"> ) .
-    
-    <h2><a name="menu_right">6. Preferências Avançadas</a></h2>
-	( figura 4.3 )
-	<br/>
-    <img src="templates/default/images/menu_right.png" width="212" height="126" alt="Preferï¿œncias Avanï¿œadas" align="left">
-    <br clear="all"/>
-    <br/>
-
-    Clicando com o botão direito do mouse, você tera acesso a um menu ( conforme figura 3.3 ), com as seguintes funcionalidades :
-
-    <ul>
-      <li>Apelido: Renomeia o Apelido ( Nickname ) do seu contato
-      <li>Grupo: Muda seu contato para um novo grupo
-      <li>Remover: Exclui o contato
-      <li>(Re)-requisitar Autorização: Requisitar autorização
-      <li>Ver Info: Visualize as informações dos seus contatos
-    </ul>
-
-    <h2><a name="info_ad">7. Vcard - Informações Adicionais</a></h2>
-	( figura 5 )
-    <img src="templates/default/images/info_adicionais.png" width="480" height="227" alt="Informações Adicionais" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Efetuando o cadastro ( conforme figura 5 ) com seus dados, os contatos que você adicionou em sua lista poderão ver essas informações. Cada contato cadastrado em sua lista
-	também possui esta opção ( <b>veja <a href="#menu_right">Preferências Avançadas</a></b>, opção Ver Info).
-
-    <h2><a name="info_prefe">8. Preferências</a></h2>
-	( figura 6 )
-    <img src="templates/default/images/preferencias.png" width="405" height="284" alt="Preferências" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Personalize seu tempo para ficar ausente, se em sua lista de contato aparecerá seus contatos offline e um tipo de aviso para uma nova mensagem. 
-
-    <h2><a name="troca_mens">9. Troca de Mensagens</a></h2>
-	( figura 7 )
-    <img src="templates/default/images/troca_mensagem.png" width="311" height="308" alt="Troca de Mensagens" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Clicando com o mouse em cima do nome do contato escolhido, abrirá uma janela ( conforme figura 7 ), para a troca de mensagens. Nessa mesma janela existe um menu, o qual é possível
-	configurar o formato da Fonte como : <b>Negrito</b>, <i>Itálico</i> e a cor. Você também pode enviar os Smiles, clicando em <img src="templates/default/images/emoticonlabel.gif">
-	e acessar as informações do contato clicando em <img src="templates/default/images/profileBuddy.gif">.
-
-    <h2><a name="troca_status">10. Troca de Status</a></h2>
-	( figura 8 )
-    <img src="templates/default/images/troca_status.png" width="449" height="313" alt="Troca de Status" align="left">
-    <br clear="all"/>
-    <br/>
-
-	Para mudar o seu status basta dar um click em cima do status desejado.
-
-	<br/><br/>
-
-    <img src="templates/default/images/available.gif" align="top"> - Online <br/>
-    <img src="templates/default/images/away.gif" align="top"> - Ausente <br/>
-    <img src="templates/default/images/dnd.gif" align="top"> - Ocupado <br/>
-    <img src="templates/default/images/unavailable.gif" align="top"> - Offline - Não recebe mensagem <br/>    
-    <img src="templates/default/images/icon_edit.gif" align="top"> - Mensagem - Personalize sua mensagem <br/>        
-
-    <hr noshade>
-<!-- END index -->
