Sun, 11 Feb 2007 04:22:22 +0000
Add the example nullclient here.
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
2 | * pidgin |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
3 | * |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
4 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
6 | * source distribution. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
7 | * |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
11 | * (at your option) any later version. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
12 | * |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
16 | * GNU General Public License for more details. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
17 | * |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
21 | * |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
22 | */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
23 | #include "account.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
24 | #include "conversation.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
25 | #include "core.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
26 | #include "debug.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
27 | #include "eventloop.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
28 | #include "ft.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
29 | #include "log.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
30 | #include "notify.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
31 | #include "prefix.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
32 | #include "prefs.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
33 | #include "prpl.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
34 | #include "pounce.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
35 | #include "savedstatuses.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
36 | #include "sound.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
37 | #include "status.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
38 | #include "util.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
39 | #include "whiteboard.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
40 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
41 | #include <glib.h> |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
42 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
43 | #include <string.h> |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
44 | #include <unistd.h> |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
45 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
46 | #include "defines.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
47 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
48 | /** |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
49 | * The following eventloop functions are used in both pidgin and gaim-text. If your |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
50 | * application uses glib mainloop, you can safely use this verbatim. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
51 | */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
52 | #define GAIM_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
53 | #define GAIM_GLIB_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
54 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
55 | typedef struct _GaimGLibIOClosure { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
56 | GaimInputFunction function; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
57 | guint result; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
58 | gpointer data; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
59 | } GaimGLibIOClosure; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
60 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
61 | static void gaim_glib_io_destroy(gpointer data) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
62 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
63 | g_free(data); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
64 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
65 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
66 | static gboolean gaim_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
67 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
68 | GaimGLibIOClosure *closure = data; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
69 | GaimInputCondition gaim_cond = 0; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
70 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
71 | if (condition & GAIM_GLIB_READ_COND) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
72 | gaim_cond |= GAIM_INPUT_READ; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
73 | if (condition & GAIM_GLIB_WRITE_COND) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
74 | gaim_cond |= GAIM_INPUT_WRITE; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
75 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
76 | closure->function(closure->data, g_io_channel_unix_get_fd(source), |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
77 | gaim_cond); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
78 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
79 | return TRUE; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
80 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
81 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
82 | static guint glib_input_add(gint fd, GaimInputCondition condition, GaimInputFunction function, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
83 | gpointer data) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
84 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
85 | GaimGLibIOClosure *closure = g_new0(GaimGLibIOClosure, 1); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
86 | GIOChannel *channel; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
87 | GIOCondition cond = 0; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
88 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
89 | closure->function = function; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
90 | closure->data = data; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
91 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
92 | if (condition & GAIM_INPUT_READ) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
93 | cond |= GAIM_GLIB_READ_COND; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
94 | if (condition & GAIM_INPUT_WRITE) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
95 | cond |= GAIM_GLIB_WRITE_COND; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
96 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
97 | channel = g_io_channel_unix_new(fd); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
98 | closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
99 | gaim_glib_io_invoke, closure, gaim_glib_io_destroy); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
100 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
101 | g_io_channel_unref(channel); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
102 | return closure->result; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
103 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
104 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
105 | static GaimEventLoopUiOps glib_eventloops = |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
106 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
107 | g_timeout_add, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
108 | g_source_remove, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
109 | glib_input_add, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
110 | g_source_remove |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
111 | }; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
112 | /*** End of the eventloop functions. ***/ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
113 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
114 | /*** Conversation uiops ***/ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
115 | static void |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
116 | null_write_conv(GaimConversation *conv, const char *who, const char *alias, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
117 | const char *message, GaimMessageFlags flags, time_t mtime) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
118 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
119 | const char *name; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
120 | if (alias && *alias) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
121 | name = alias; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
122 | else if (who && *who) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
123 | name = who; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
124 | else |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
125 | name = NULL; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
126 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
127 | printf("(%s) %s %s: %s\n", gaim_conversation_get_name(conv), |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
128 | gaim_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
129 | name, message); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
130 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
131 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
132 | static GaimConversationUiOps null_conv_uiops = |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
133 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
134 | .write_conv = null_write_conv |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
135 | }; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
136 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
137 | static void |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
138 | null_ui_init() |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
139 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
140 | /** |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
141 | * This should initialize the UI components for all the modules. Here we |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
142 | * just initialize the UI for conversations. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
143 | */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
144 | gaim_conversations_set_ui_ops(&null_conv_uiops); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
145 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
146 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
147 | static GaimCoreUiOps null_core_uiops = |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
148 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
149 | NULL, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
150 | NULL, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
151 | null_ui_init, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
152 | NULL |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
153 | }; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
154 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
155 | static void |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
156 | init_libpurple() |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
157 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
158 | /* Set a custom user directory (optional) */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
159 | gaim_util_set_user_dir(CUSTOM_USER_DIRECTORY); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
160 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
161 | /* We do not want any debugging for now to keep the noise to a minimum. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
162 | gaim_debug_set_enabled(FALSE); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
163 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
164 | /* Set the core-uiops, which is used to |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
165 | * - initialize the ui specific preferences. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
166 | * - initialize the debug ui. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
167 | * - initialize the ui components for all the modules. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
168 | * - uninitialize the ui components for all the modules when the core terminates. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
169 | */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
170 | gaim_core_set_ui_ops(&null_core_uiops); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
171 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
172 | /* Set the uiops for the eventloop. If your client is glib-based, you can safely |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
173 | * copy this verbatim. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
174 | gaim_eventloop_set_ui_ops(&glib_eventloops); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
175 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
176 | /* Set path to search for plugins. The core (libpurple) takes care of loading the |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
177 | * core-plugins, which includes the protocol-plugins. So it is not essential to add |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
178 | * any path here, but it might be desired, especially for ui-specific plugins. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
179 | gaim_plugins_add_search_path(CUSTOM_PLUGIN_PATH); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
180 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
181 | /* Now that all the essential stuff has been set, let's try to init the core. It's |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
182 | * necessary to provide a non-NULL name for the current ui to the core. This name |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
183 | * is used by stuff that depends on this ui, for example the ui-specific plugins. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
184 | if (!gaim_core_init(UI_ID)) { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
185 | /* Initializing the core failed. Terminate. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
186 | fprintf(stderr, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
187 | "libpurple initialization failed. Dumping core.\n" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
188 | "Please report this!\n"); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
189 | abort(); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
190 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
191 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
192 | /* Create and load the buddylist. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
193 | gaim_set_blist(gaim_blist_new()); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
194 | gaim_blist_load(); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
195 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
196 | /* Load the preferences. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
197 | gaim_prefs_load(); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
198 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
199 | /* Load the desired plugins. The client should save the list of loaded plugins in |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
200 | * the preferences using gaim_plugins_save_loaded(PLUGIN_SAVE_PREF) */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
201 | gaim_plugins_load_saved(PLUGIN_SAVE_PREF); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
202 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
203 | /* Load the pounces. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
204 | gaim_pounces_load(); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
205 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
206 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
207 | static void |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
208 | signed_on(GaimConnection *gc, gpointer null) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
209 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
210 | GaimAccount *account = gaim_connection_get_account(gc); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
211 | printf("Account connected: %s %s\n", account->username, account->protocol_id); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
212 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
213 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
214 | static void |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
215 | connect_to_signals_for_demonstration_purposes_only() |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
216 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
217 | static int handle; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
218 | gaim_signal_connect(gaim_connections_get_handle(), "signed-on", &handle, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
219 | GAIM_CALLBACK(signed_on), NULL); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
220 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
221 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
222 | int main() |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
223 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
224 | GList *iter; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
225 | int i, num; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
226 | GList *names = NULL; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
227 | const char *prpl; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
228 | char name[128]; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
229 | char *password; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
230 | GMainLoop *loop = g_main_loop_new(NULL, FALSE); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
231 | GaimAccount *account; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
232 | GaimSavedStatus *status; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
233 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
234 | init_libpurple(); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
235 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
236 | printf("libpurple initialized.\n"); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
237 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
238 | iter = gaim_plugins_get_protocols(); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
239 | for (i = 0; iter; iter = iter->next) { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
240 | GaimPlugin *plugin = iter->data; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
241 | GaimPluginInfo *info = plugin->info; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
242 | if (info && info->name) { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
243 | printf("\t%d: %s\n", i++, info->name); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
244 | names = g_list_append(names, info->id); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
245 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
246 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
247 | printf("Select the protocol [0-%d]: ", i-1); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
248 | fgets(name, sizeof(name), stdin); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
249 | sscanf(name, "%d", &num); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
250 | prpl = g_list_nth_data(names, num); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
251 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
252 | printf("Username: "); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
253 | fgets(name, sizeof(name), stdin); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
254 | name[strlen(name) - 1] = 0; /* strip the \n at the end */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
255 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
256 | /* Create the account */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
257 | account = gaim_account_new(name, prpl); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
258 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
259 | /* Get the password for the account */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
260 | password = getpass("Password: "); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
261 | gaim_account_set_password(account, password); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
262 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
263 | /* It's necessary to enable the account first. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
264 | gaim_account_set_enabled(account, UI_ID, TRUE); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
265 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
266 | /* Now, to connect the account(s), create a status and activate it. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
267 | status = gaim_savedstatus_new(NULL, GAIM_STATUS_AVAILABLE); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
268 | gaim_savedstatus_activate(status); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
269 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
270 | connect_to_signals_for_demonstration_purposes_only(); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
271 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
272 | g_main_loop_run(loop); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
273 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
274 | return 0; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
275 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
276 |