/* -TAG:LICENSE-
   
   This file is under the DigitalSpark Freeware Class License, see the
   file LICENSE for complete licensing information.
                                                         
                                                         -TAG:LICENSE- */
#include <Threading.h>
#include <Strings.h>
#include "tricky.h"

extern  size_t	Write( int slot, void *data, size_t size );
extern	void	IRCNotice( int Sock, char *type, char *message );
extern	void    UpdateSessionInfo( int Block );

void	ResumeIRCState( int Sock )
{
int	i=0;
char	outbuff[1024];

/* Request update on my status (to update channel list, etc) */
//NickError=1;
UpdateSessionInfo(1);

/* get user modes */
sprintf(outbuff,"MODE %s\r\n",Nick);
Write(ServerSock,outbuff,0);

while ( Channels[i] != NULL )
   {
   /* Write the join */
   sprintf(outbuff,":%s JOIN :%s\r\n",IDString,Channels[i]);
   Write(Sock,outbuff,0);

   /* Get channel modes */
   sprintf(outbuff,"MODE %s\r\n",Channels[i]);
   Write(ServerSock,outbuff,0);
   /* Get channel names */
   sprintf(outbuff,"NAMES %s\r\n",Channels[i]);
   Write(ServerSock,outbuff,0);
   /* Get channel topics */
   sprintf(outbuff,"TOPIC %s\r\n",Channels[i]);
   Write(ServerSock,outbuff,0);
   i++;
   }

IRCNotice(Sock,Nick,"[TrickyIRC] Session restored");
}
