comparison plugins/gaim-remote/remote.c @ 6177:73f8f5c0e348

[gaim-migrate @ 6662] This should fix the bug where loading the Remote Control plugin was causing duplicate stuff in the buddy list. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 17 Jul 2003 06:41:50 +0000
parents 38410dac4ac2
children 16e384bb7fbf
comparison
equal deleted inserted replaced
6176:aa806c22fb40 6177:73f8f5c0e348
655 g_log(NULL, G_LOG_LEVEL_CRITICAL, "Unable to open socket: %s", strerror(errno)); 655 g_log(NULL, G_LOG_LEVEL_CRITICAL, "Unable to open socket: %s", strerror(errno));
656 return fd; 656 return fd;
657 } 657 }
658 #endif /*! _WIN32*/ 658 #endif /*! _WIN32*/
659 659
660 static int 660 static gboolean
661 core_main() 661 plugin_load(GaimPlugin *plugin)
662 { 662 {
663 /*
664 GMainLoop *loop;
665 */
666 #ifndef _WIN32 663 #ifndef _WIN32
667 GIOChannel *channel; 664 GIOChannel *channel;
668 #endif 665
669 666 if ((UI_fd = open_socket()) < 0)
670 gaim_set_blist(gaim_blist_new()); 667 return FALSE;
671 gaim_blist_load();
672
673 #ifndef _WIN32
674
675 UI_fd = open_socket();
676 if (UI_fd < 0)
677 return 1;
678 668
679 channel = g_io_channel_unix_new(UI_fd); 669 channel = g_io_channel_unix_new(UI_fd);
680 watcher = g_io_add_watch(channel, G_IO_IN, socket_readable, NULL); 670 watcher = g_io_add_watch(channel, G_IO_IN, socket_readable, NULL);
681 g_io_channel_unref(channel); 671 g_io_channel_unref(channel);
672
673 return TRUE;
674 #else
675 return FALSE;
682 #endif 676 #endif
683 677 }
684 /* 678
685 loop = g_main_new(TRUE); 679 static gboolean
686 g_main_run(loop); 680 plugin_unload(GaimPlugin *plugin)
687 */
688
689 return 0;
690 }
691
692 static void
693 core_quit()
694 { 681 {
695 /* don't save prefs after plugins are gone... */ 682 /* don't save prefs after plugins are gone... */
696 #ifndef _WIN32 683 #ifndef _WIN32
697 char buf[1024]; 684 char buf[1024];
685
698 g_source_remove(watcher); 686 g_source_remove(watcher);
699 close(UI_fd); 687 close(UI_fd);
688
700 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", 689 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d",
701 g_get_tmp_dir(), g_get_user_name(), gaim_session); 690 g_get_tmp_dir(), g_get_user_name(), gaim_session);
702 691
703 unlink(buf); 692 unlink(buf);
704 693
705 gaim_debug(GAIM_DEBUG_MISC, "core", "Removed core\n"); 694 gaim_debug(GAIM_DEBUG_MISC, "core", "Removed core\n");
695
696 return TRUE;
697 #else
698 return FALSE;
706 #endif 699 #endif
707 }
708
709 static gboolean
710 plugin_load(GaimPlugin *plugin)
711 {
712 core_main();
713
714 return TRUE;
715 }
716
717 static gboolean
718 plugin_unload(GaimPlugin *plugin)
719 {
720 core_quit();
721
722 return TRUE;
723 } 700 }
724 701
725 static GaimPluginInfo info = 702 static GaimPluginInfo info =
726 { 703 {
727 2, /**< api_version */ 704 2, /**< api_version */
753 static void 730 static void
754 __init_plugin(GaimPlugin *plugin) 731 __init_plugin(GaimPlugin *plugin)
755 { 732 {
756 } 733 }
757 734
735 /* This may be horribly wrong. Oh the mayhem! */
758 GAIM_INIT_PLUGIN(remote, __init_plugin, info) 736 GAIM_INIT_PLUGIN(remote, __init_plugin, info)