/*************************************************************************************************************
* This file contains main function
* 2012/6 by Dlxko
**************************************************************************************************************/
#include "Main.h"

// Init GTK+2
using namespace std;
int main( int argc, char **argv );

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow)
{
	return main (__argc, __argv);
}

// Main include
int main(int argc, char *argv[])
{
	// Initialize extern variables
	current_buddy = 0;
	activated_events = 0;

	// Start threads support
	if( ! g_thread_supported() )
		g_thread_init( NULL );

	// GTK init
	gtk_init (&argc, &argv);

	// Create dialog window
	create_dialog_window();

	// Create log_window or report
	if(!create_loggin())
		function_show_error("Can't create log window. Closing!");

	// Load pixmap
	if(!create_pixmaps())
		function_show_error("Can't load important images. Closing!");

	// Get connection or close
	s = dxconnect();
	if (s == 0 || s == -1)
		function_show_error("Can't create connection. Closing!");

	// Create channel
	if(!create_channel())
		function_show_error("Can't create channel. Closing!");

	// Create buddy_list
	if(!create_buddylist())
		function_show_error("Can't create buddylist. Closing!");

	// Create events
	if(!crate_requests())
		function_show_error("Can't create requests. Closing!");

	// Create loop
	gtk_main();

	// Exit
	return 0;
}