示例#1
0
文件: irc.c 项目: Limsik/e17
EMAPI int
protocol_init(Emote_Protocol *p)
{
   unsigned int i;
   m = p;

   ecore_con_init();

   _irc_servers = eina_hash_string_superfast_new(NULL);

   for (i = 0; i < (sizeof(_em_events)/sizeof(Emote_Event_Type)); ++i)
      emote_event_handler_add(_em_events[i], _irc_event_handler, NULL);

   return 1;
}
示例#2
0
/* public functions */
EAPI int
elm_main(int argc, char **argv)
{
   Emote_Event *d;
   struct sigaction action;
   Emote_Protocol *p;
   unsigned int i;

   if (argc < 3)
     {
        printf("Usage:\n\temote <server> <nick> [username] [password]\n");
        exit(1);
     }

# ifdef ENABLE_NLS
   setlocale(LC_ALL, "");
   bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
   textdomain(PACKAGE);
# endif

   /* trap keyboard interrupt from user (Ctrl + C) */
   action.sa_sigaction = _em_main_interrupt;
   action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
   sigemptyset(&action.sa_mask);
   sigaction(SIGINT, &action, NULL);

   /* init our config subsystem */
   if (!em_config_init()) _em_main_shutdown(EXIT_FAILURE);
   _em_main_shutdown_push(em_config_shutdown);

   /* init protocol subsystem */
   if (!emote_init()) _em_main_shutdown(EXIT_FAILURE);
   _em_main_shutdown_push(emote_shutdown);

   /* init our gui subsystem */
   if (!em_gui_init()) _em_main_shutdown(EXIT_FAILURE);
   _em_main_shutdown_push(em_gui_shutdown);

   for (i = 0; i < (sizeof(_em_events)/sizeof(Emote_Event_Type)); i++)
     {
        emote_event_handler_add(_em_events[i],
                                _em_main_chat_events_handler, NULL);
     }

   em_protocols = eina_hash_string_superfast_new(NULL);

   p = emote_protocol_load("irc");
   eina_hash_add(em_protocols, "irc", p);

   d = emote_event_new(p, EMOTE_EVENT_SERVER_CONNECT, argv[1], 6667, argv[2],
                       ((argc > 3) ? argv[3] : "emote"),
                       ((argc > 4) ? argv[4] : NULL));
   emote_event_send(d);

   /* start main loop */
   elm_run();

   /* shutdown elm */
   elm_shutdown();

   /* shutdown */
   _em_main_shutdown(EXIT_SUCCESS);

   return EXIT_SUCCESS;
}