annotate console/gntgaim.c @ 13964:0a0d2a1fd2bc

[gaim-migrate @ 16520] Add multi-column support for GntTree. Use it for email-notifications. Restore colors before exiting. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 19 Jul 2006 07:12:59 +0000
parents 4ed8330435eb
children 80cbf6c2d562
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 #include "account.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 #include "conversation.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 #include "core.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 #include "debug.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 #include "eventloop.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 #include "ft.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 #include "log.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 #include "notify.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 #include "prefs.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 #include "prpl.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 #include "pounce.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 #include "savedstatuses.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 #include "sound.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 #include "status.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 #include "util.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 #include "whiteboard.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 #include "gntgaim.h"
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
19 #include "gntui.h"
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
21 #define _GNU_SOURCE
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
22 #include <getopt.h>
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
23
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 /* Anything IO-related is directly copied from gtkgaim's source tree */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 static GaimCoreUiOps core_ops =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 NULL, /*gaim_gtk_prefs_init,*/
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 NULL, /*debug_init,*/
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 NULL, /*gaim_gtk_ui_init,*/
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 NULL, /*gaim_gtk_quit*/
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 };
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 static GaimCoreUiOps *
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 gnt_core_get_ui_ops()
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 return &core_ops;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 #define GAIM_GTK_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 #define GAIM_GTK_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 typedef struct _GaimGtkIOClosure {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 GaimInputFunction function;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 guint result;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 gpointer data;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 } GaimGtkIOClosure;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 static void gaim_gtk_io_destroy(gpointer data)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 g_free(data);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 static gboolean gaim_gtk_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 GaimGtkIOClosure *closure = data;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 GaimInputCondition gaim_cond = 0;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 if (condition & GAIM_GTK_READ_COND)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 gaim_cond |= GAIM_INPUT_READ;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 if (condition & GAIM_GTK_WRITE_COND)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 gaim_cond |= GAIM_INPUT_WRITE;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65 #if 0
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 gaim_debug(GAIM_DEBUG_MISC, "gtk_eventloop",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 "CLOSURE: callback for %d, fd is %d\n",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 closure->result, g_io_channel_unix_get_fd(source));
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 #endif
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 #ifdef _WIN32
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 if(! gaim_cond) {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 #if DEBUG
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 gaim_debug(GAIM_DEBUG_MISC, "gtk_eventloop",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 "CLOSURE received GIOCondition of 0x%x, which does not"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 " match 0x%x (READ) or 0x%x (WRITE)\n",
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 condition, GAIM_GTK_READ_COND, GAIM_GTK_WRITE_COND);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 #endif /* DEBUG */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 return TRUE;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 #endif /* _WIN32 */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 closure->function(closure->data, g_io_channel_unix_get_fd(source),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 gaim_cond);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 return TRUE;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 static guint gnt_input_add(gint fd, GaimInputCondition condition, GaimInputFunction function,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 gpointer data)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 GaimGtkIOClosure *closure = g_new0(GaimGtkIOClosure, 1);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 GIOChannel *channel;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 GIOCondition cond = 0;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 closure->function = function;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 closure->data = data;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 if (condition & GAIM_INPUT_READ)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 cond |= GAIM_GTK_READ_COND;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 if (condition & GAIM_INPUT_WRITE)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 cond |= GAIM_GTK_WRITE_COND;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 channel = g_io_channel_unix_new(fd);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 gaim_gtk_io_invoke, closure, gaim_gtk_io_destroy);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109 g_io_channel_unref(channel);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 return closure->result;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 static GaimEventLoopUiOps eventloop_ops =
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 g_timeout_add,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 (guint (*)(guint))g_source_remove,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 gnt_input_add,
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 (guint (*)(guint))g_source_remove
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 };
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 GaimEventLoopUiOps *
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122 gnt_eventloop_get_ui_ops(void)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 return &eventloop_ops;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 /* This is mostly copied from gtkgaim's source tree */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 static void
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
129 show_usage(const char *name, gboolean terse)
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
130 {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
131 char *text;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
132
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
133 if (terse) {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
134 text = g_strdup_printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
135 } else {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
136 text = g_strdup_printf(_("Gaim %s\n"
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
137 "Usage: %s [OPTION]...\n\n"
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
138 " -c, --config=DIR use DIR for config files\n"
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
139 " -d, --debug print debugging messages to stdout\n"
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
140 " -h, --help display this help and exit\n"
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
141 " -n, --nologin don't automatically login\n"
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
142 " -v, --version display the current version and exit\n"), VERSION, name);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
143 }
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
144
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
145 gaim_print_utf8_to_console(stdout, text);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
146 g_free(text);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
147 }
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
148
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
149 static int
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
150 init_libgaim(int argc, char **argv)
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 char *path;
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
153 int opt;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
154 gboolean opt_help = FALSE;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
155 gboolean opt_nologin = FALSE;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
156 gboolean opt_version = FALSE;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
157 char *opt_config_dir_arg = NULL;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
158 char *opt_session_arg = NULL;
13928
4ed8330435eb [gaim-migrate @ 16448]
Sean Egan <seanegan@gmail.com>
parents: 13927
diff changeset
159 gboolean debug_enabled = FALSE;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
161 struct option long_options[] = {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
162 {"config", required_argument, NULL, 'c'},
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
163 {"debug", no_argument, NULL, 'd'},
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
164 {"help", no_argument, NULL, 'h'},
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
165 {"nologin", no_argument, NULL, 'n'},
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
166 {"session", required_argument, NULL, 's'},
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
167 {"version", no_argument, NULL, 'v'},
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
168 {0, 0, 0, 0}
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
169 };
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
170
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
171 /* scan command-line options */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
172 opterr = 1;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
173 while ((opt = getopt_long(argc, argv,
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
174 #ifndef _WIN32
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
175 "c:dhn::s:v",
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
176 #else
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
177 "c:dhn::v",
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
178 #endif
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
179 long_options, NULL)) != -1) {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
180 switch (opt) {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
181 case 'c': /* config dir */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
182 g_free(opt_config_dir_arg);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
183 opt_config_dir_arg = g_strdup(optarg);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
184 break;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
185 case 'd': /* debug */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
186 debug_enabled = TRUE;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
187 break;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
188 case 'h': /* help */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
189 opt_help = TRUE;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
190 break;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
191 case 'n': /* no autologin */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
192 opt_nologin = TRUE;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
193 break;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
194 case 's': /* use existing session ID */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
195 g_free(opt_session_arg);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
196 opt_session_arg = g_strdup(optarg);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
197 break;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
198 case 'v': /* version */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
199 opt_version = TRUE;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
200 break;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
201 case '?': /* show terse help */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
202 default:
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
203 show_usage(argv[0], TRUE);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
204 return 0;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
205 break;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
206 }
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
207 }
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
208
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
209 /* show help message */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
210 if (opt_help) {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
211 show_usage(argv[0], FALSE);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
212 return 0;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
213 }
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
214 /* show version message */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
215 if (opt_version) {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
216 printf("Gaim %s\n", VERSION);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
217 return 0;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
218 }
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
219
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
220 /* set a user-specified config directory */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
221 if (opt_config_dir_arg != NULL) {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
222 gaim_util_set_user_dir(opt_config_dir_arg);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
223 }
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
224
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
225 /*
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
226 * We're done piddling around with command line arguments.
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
227 * Fire up this baby.
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
228 */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
229
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
230 /* Because we don't want debug-messages to show up and corrup the display */
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13911
diff changeset
231 gaim_debug_set_enabled(debug_enabled);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 gaim_core_set_ui_ops(gnt_core_get_ui_ops());
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234 gaim_eventloop_set_ui_ops(gnt_eventloop_get_ui_ops());
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 path = g_build_filename(gaim_user_dir(), "plugins", NULL);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 gaim_plugins_add_search_path(path);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 g_free(path);
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
239
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 gaim_plugins_add_search_path("/usr/local/lib/gaim"); /* XXX: */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 if (!gaim_core_init(GAIM_GNT_UI))
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 {
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
244 fprintf(stderr,
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
245 "Initialization of the Gaim core failed. Dumping core.\n"
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
246 "Please report this!\n");
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 abort();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 /* TODO: Move blist loading into gaim_blist_init() */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 gaim_set_blist(gaim_blist_new());
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 gaim_blist_load();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 /* TODO: Move prefs loading into gaim_prefs_init() */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 gaim_prefs_load();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 gaim_prefs_update_old();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 /* load plugins we had when we quit */
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
259 gaim_plugins_load_saved("/gaim/gnt/plugins/loaded");
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
261 /* TODO: Move pounces loading into gaim_pounces_init() */
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 gaim_pounces_load();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
264 if (opt_nologin)
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
265 {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
266 /* Set all accounts to "offline" */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
267 GaimSavedStatus *saved_status;
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
268
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
269 /* If we've used this type+message before, lookup the transient status */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
270 saved_status = gaim_savedstatus_find_transient_by_type_and_message(
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
271 GAIM_STATUS_OFFLINE, NULL);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
272
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
273 /* If this type+message is unique then create a new transient saved status */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
274 if (saved_status == NULL)
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
275 saved_status = gaim_savedstatus_new(NULL, GAIM_STATUS_OFFLINE);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
276
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
277 /* Set the status for each account */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
278 gaim_savedstatus_activate(saved_status);
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
279 }
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
280 else
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
281 {
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
282 /* Everything is good to go--sign on already */
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
283 if (!gaim_prefs_get_bool("/core/savedstatus/startup_current_status"))
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
284 gaim_savedstatus_activate(gaim_savedstatus_get_startup());
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
285 gaim_accounts_restore_current_statuses();
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
286 }
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
287
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
288 return 1;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291 int main(int argc, char **argv)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292 {
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13857
diff changeset
293 /* XXX: Don't puke */
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
294 freopen(".error", "w", stderr);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13857
diff changeset
295
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
296 /* Initialize the libgaim stuff */
13911
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
297 if (!init_libgaim(argc, argv))
b210409cdc56 [gaim-migrate @ 16410]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
298 return 0;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
300 /* Initialize and run the UI */
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301 init_gnt_ui();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 gaim_core_quit();
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 return 0;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307