diff src/core.c @ 6179:16e384bb7fbf

[gaim-migrate @ 6664] Core/UI split the core initialization and shutdown. I think I got all the bugs worked out. It's looking nice and stable here, but if it causes CVS to go to hell for everyone.. er, try to fix it or let me know :) I don't have this in patch form. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 17 Jul 2003 10:35:43 +0000
parents 7574c6e35fd9
children 0342af6a8b36
line wrap: on
line diff
--- a/src/core.c	Thu Jul 17 06:55:29 2003 +0000
+++ b/src/core.c	Thu Jul 17 10:35:43 2003 +0000
@@ -1,6 +1,10 @@
-/*
+/**
+ * @file core.c Gaim Core API
+ * @ingroup core
+ *
  * gaim
  *
+ * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,7 +19,131 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
  */
+#include "internal.h"
+#include "connection.h"
+#include "conversation.h"
+#include "core.h"
+#include "debug.h"
+#include "plugin.h"
+#include "pounce.h"
+#include "prefs.h"
+#include "proxy.h"
+#include "sound.h"
 
-/* DONE! */
+struct GaimCore
+{
+	char *ui;
+
+	void *reserved;
+};
+
+static GaimCoreUiOps *_ops  = NULL;
+static GaimCore      *_core = NULL;
+
+STATIC_PROTO_INIT
+
+gboolean
+gaim_core_init(const char *ui)
+{
+	GaimCoreUiOps *ops;
+	GaimCore *core;
+
+	g_return_val_if_fail(ui != NULL, FALSE);
+	g_return_val_if_fail(gaim_get_core() == NULL, FALSE);
+
+	_core = core = g_new0(GaimCore, 1);
+	core->ui = g_strdup(ui);
+	core->reserved = NULL;
+
+	ops = gaim_get_core_ui_ops();
+
+	/* Initialize all static protocols. */
+	static_proto_init();
+
+	printf("gaim_prefs_init\n");
+	gaim_prefs_init();
+
+	if (ops != NULL) {
+		if (ops->ui_prefs_init != NULL)
+			ops->ui_prefs_init();
+
+		if (ops->debug_ui_init != NULL)
+			ops->debug_ui_init();
+	}
+
+	printf("conversation_init\n");
+	gaim_conversation_init();
+	gaim_proxy_init();
+	gaim_sound_init();
+	gaim_pounces_init();
+
+	if (ops != NULL && ops->ui_init != NULL)
+		ops->ui_init();
+
+	return TRUE;
+}
+
+void
+gaim_core_quit(void)
+{
+	GaimCoreUiOps *ops;
+	GaimCore *core = gaim_get_core();
+
+	g_return_if_fail(core != NULL);
+
+	ops = gaim_get_core_ui_ops();
+
+	if (ops != NULL && ops->quit != NULL)
+		ops->quit();
+
+	/* The self destruct sequence has been initiated */
+	gaim_event_broadcast(event_quit);
+
+	/* Transmission ends */
+	gaim_connections_disconnect_all();
+
+	/* Record what we have before we blow it away... */
+	gaim_prefs_sync();
+	gaim_accounts_sync();
+
+	gaim_debug(GAIM_DEBUG_INFO, "main", "Unloading all plugins\n");
+	gaim_plugins_destroy_all();
+
+	if (core->ui != NULL) {
+		g_free(core->ui);
+		core->ui = NULL;
+	}
+
+	g_free(core);
+
+	_core = NULL;
+}
+
+const char *
+gaim_core_get_ui(void)
+{
+	GaimCore *core = gaim_get_core();
+
+	g_return_val_if_fail(core != NULL, NULL);
+
+	return core->ui;
+}
+
+GaimCore *
+gaim_get_core(void)
+{
+	return _core;
+}
+
+void
+gaim_set_core_ui_ops(GaimCoreUiOps *ops)
+{
+	_ops = ops;
+}
+
+GaimCoreUiOps *
+gaim_get_core_ui_ops(void)
+{
+	return _ops;
+}