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

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

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

// Main function of program
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();

	// Get connection or close
	s = dxconnect();
	if (s == 0 || s == -1)
		function_show_error(LANG_CANT_CREATE_CONNECT);

	// Create log_window or report
	create_loggin();

	// Load pixmap
	if(!create_pixmaps())
		function_show_error(LANG_CANT_CREATE_IMAGES);

	// Create channel
	if(!create_channel())
		function_show_error(LANG_CANT_CREATE_CHANNEL);

	// Create buddy_list
	create_buddylist();

	// Create events
	crate_requests();

	// Create info window
	create_info_window();

	// Create history window
	create_history_window();

	// Create history view
	create_history_view_window();

	// Create loop
	gtk_main();

	// Exit
	return 0;
}