libpurple/example/nullclient.c

Fri, 09 Nov 2007 08:48:40 +0000

author
John Bailey <rekkanoryo@rekkanoryo.org>
date
Fri, 09 Nov 2007 08:48:40 +0000
branch
release-2.2.3
changeset 20289
5c844288fbec
parent 19859
71d37b57eff2
child 22104
56970903b8e9
permissions
-rw-r--r--

applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
through a9f75de97d6cdf8fe8bf091b95def6c648aac82f

applied changes from a9f75de97d6cdf8fe8bf091b95def6c648aac82f
through 7c9f2e0cc4967a3eaade95d32f164349b6d1aa03

applied changes from a9f75de97d6cdf8fe8bf091b95def6c648aac82f
through fc4350a15fdd1f51b4496568afaa83355e18b714

applied changes from fc4350a15fdd1f51b4496568afaa83355e18b714
through 18ccd2ba2c1c9b7fa3dfedf72b48b3bd01c3a7c4

applied changes from a9f75de97d6cdf8fe8bf091b95def6c648aac82f
through 20236f54c97e87512b7eb716559a4bd86b73f833

applied changes from 868a040ee69c6e45b9132e7254a3f523e55385b2
through 0e154355bb3e8bdaeb793b142075b60671b37a48

applied changes from 329395b9793793f35bcf231033c1eb942513ab01
through 9d8120be512c235d76a8f6fee60cae024da8772e

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
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19733
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15673
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 */
18273
e61c53184c52 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18075
diff changeset
23
19733
ec657d978c5a disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19732
diff changeset
24 /* XXX: we probably shouldn't include internal.h in examples */
ec657d978c5a disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19732
diff changeset
25 #include "internal.h"
ec657d978c5a disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19732
diff changeset
26
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
27 #include "account.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
28 #include "conversation.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
29 #include "core.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
30 #include "debug.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
31 #include "eventloop.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
32 #include "ft.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
33 #include "log.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
34 #include "notify.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
35 #include "prefs.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
36 #include "prpl.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
37 #include "pounce.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
38 #include "savedstatuses.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
39 #include "sound.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
40 #include "status.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
41 #include "util.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
42 #include "whiteboard.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
43
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
44 #include <glib.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 <string.h>
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
47 #include <unistd.h>
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 #include "defines.h"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
50
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
51 /**
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
52 * The following eventloop functions are used in both pidgin and purple-text. If your
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
53 * 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
54 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
55 #define PURPLE_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
56 #define PURPLE_GLIB_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
57
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
58 typedef struct _PurpleGLibIOClosure {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
59 PurpleInputFunction function;
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
60 guint result;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
61 gpointer data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
62 } PurpleGLibIOClosure;
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
63
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
64 static void purple_glib_io_destroy(gpointer data)
15673
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 g_free(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
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
69 static gboolean purple_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
70 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
71 PurpleGLibIOClosure *closure = data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
72 PurpleInputCondition purple_cond = 0;
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
73
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
74 if (condition & PURPLE_GLIB_READ_COND)
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
75 purple_cond |= PURPLE_INPUT_READ;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
76 if (condition & PURPLE_GLIB_WRITE_COND)
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
77 purple_cond |= PURPLE_INPUT_WRITE;
15673
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 closure->function(closure->data, g_io_channel_unix_get_fd(source),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
80 purple_cond);
15673
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 return TRUE;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
83 }
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
84
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
85 static guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function,
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
86 gpointer data)
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
87 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
88 PurpleGLibIOClosure *closure = g_new0(PurpleGLibIOClosure, 1);
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
89 GIOChannel *channel;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
90 GIOCondition cond = 0;
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 closure->function = function;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
93 closure->data = data;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
94
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
95 if (condition & PURPLE_INPUT_READ)
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
96 cond |= PURPLE_GLIB_READ_COND;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
97 if (condition & PURPLE_INPUT_WRITE)
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
98 cond |= PURPLE_GLIB_WRITE_COND;
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
99
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
100 channel = g_io_channel_unix_new(fd);
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
101 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
102 purple_glib_io_invoke, closure, purple_glib_io_destroy);
15673
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 g_io_channel_unref(channel);
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
105 return closure->result;
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
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
108 static PurpleEventLoopUiOps glib_eventloops =
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
109 {
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
110 g_timeout_add,
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
111 g_source_remove,
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
112 glib_input_add,
15755
ab33ab6b08ae Fix the following compiler warning:
Mark Doliner <markdoliner@pidgin.im>
parents: 15673
diff changeset
113 g_source_remove,
16747
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
114 NULL,
18075
1e4bb0043a98 It's GLIB_CHECK_VERSION, not GLIB_VERSION_CHECK.
Richard Laager <rlaager@pidgin.im>
parents: 18071
diff changeset
115 #if GLIB_CHECK_VERSION(2,14,0)
18071
9b5d872583c9 Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@pidgin.im>
parents: 17153
diff changeset
116 g_timeout_add_seconds,
9b5d872583c9 Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@pidgin.im>
parents: 17153
diff changeset
117 #else
9b5d872583c9 Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@pidgin.im>
parents: 17153
diff changeset
118 NULL,
9b5d872583c9 Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@pidgin.im>
parents: 17153
diff changeset
119 #endif
16747
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
120
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
121 /* padding */
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
122 NULL,
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
123 NULL,
15755
ab33ab6b08ae Fix the following compiler warning:
Mark Doliner <markdoliner@pidgin.im>
parents: 15673
diff changeset
124 NULL
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
125 };
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
126 /*** End of the eventloop functions. ***/
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
127
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
128 /*** Conversation uiops ***/
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
129 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
130 null_write_conv(PurpleConversation *conv, const char *who, const char *alias,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
131 const char *message, PurpleMessageFlags flags, time_t mtime)
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
132 {
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
133 const char *name;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
134 if (alias && *alias)
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
135 name = alias;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
136 else if (who && *who)
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
137 name = who;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
138 else
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
139 name = NULL;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
140
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
141 printf("(%s) %s %s: %s\n", purple_conversation_get_name(conv),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
142 purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)),
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
143 name, message);
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
144 }
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
145
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
146 static PurpleConversationUiOps null_conv_uiops =
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
147 {
17153
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
148 NULL, /* create_conversation */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
149 NULL, /* destroy_conversation */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
150 NULL, /* write_chat */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
151 NULL, /* write_im */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
152 null_write_conv, /* write_conv */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
153 NULL, /* chat_add_users */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
154 NULL, /* chat_rename_user */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
155 NULL, /* chat_remove_users */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
156 NULL, /* chat_update_user */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
157 NULL, /* present */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
158 NULL, /* has_focus */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
159 NULL, /* custom_smiley_add */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
160 NULL, /* custom_smiley_write */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
161 NULL, /* custom_smiley_close */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
162 NULL, /* send_confirm */
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
163 NULL,
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
164 NULL,
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
165 NULL,
7da4e85b6a05 Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents: 16747
diff changeset
166 NULL
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
167 };
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
168
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
169 static void
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
170 null_ui_init()
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 /**
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
173 * 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
174 * just initialize the UI for conversations.
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
175 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
176 purple_conversations_set_ui_ops(&null_conv_uiops);
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
177 }
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
178
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
179 static PurpleCoreUiOps null_core_uiops =
15673
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 NULL,
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
182 NULL,
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
183 null_ui_init,
16747
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
184 NULL,
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
185
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
186 /* padding */
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
187 NULL,
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
188 NULL,
fc3608e1e661 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16158
diff changeset
189 NULL,
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
190 NULL
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
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
193 static void
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
194 init_libpurple()
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 /* Set a custom user directory (optional) */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
197 purple_util_set_user_dir(CUSTOM_USER_DIRECTORY);
15673
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 /* We do not want any debugging for now to keep the noise to a minimum. */
19709
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
200 purple_debug_set_enabled(FALSE);
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
201
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
202 /* Set the core-uiops, which is used to
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
203 * - initialize the ui specific preferences.
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
204 * - initialize the debug ui.
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
205 * - initialize the ui components for all the modules.
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
206 * - 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
207 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
208 purple_core_set_ui_ops(&null_core_uiops);
15673
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 /* 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
211 * copy this verbatim. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
212 purple_eventloop_set_ui_ops(&glib_eventloops);
15673
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 /* 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
215 * 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
216 * any path here, but it might be desired, especially for ui-specific plugins. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
217 purple_plugins_add_search_path(CUSTOM_PLUGIN_PATH);
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
218
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
219 /* 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
220 * 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
221 * is used by stuff that depends on this ui, for example the ui-specific plugins. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
222 if (!purple_core_init(UI_ID)) {
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
223 /* Initializing the core failed. Terminate. */
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
224 fprintf(stderr,
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
225 "libpurple initialization failed. Dumping core.\n"
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
226 "Please report this!\n");
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
227 abort();
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
228 }
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
229
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
230 /* Create and load the buddylist. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
231 purple_set_blist(purple_blist_new());
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
232 purple_blist_load();
15673
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 /* Load the preferences. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
235 purple_prefs_load();
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
236
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
237 /* Load the desired plugins. The client should save the list of loaded plugins in
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
238 * the preferences using purple_plugins_save_loaded(PLUGIN_SAVE_PREF) */
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
239 purple_plugins_load_saved(PLUGIN_SAVE_PREF);
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
240
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
241 /* Load the pounces. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
242 purple_pounces_load();
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
243 }
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
244
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
245 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
246 signed_on(PurpleConnection *gc, gpointer null)
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
247 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
248 PurpleAccount *account = purple_connection_get_account(gc);
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
249 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
250 }
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 static void
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
253 connect_to_signals_for_demonstration_purposes_only()
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
254 {
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
255 static int handle;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
256 purple_signal_connect(purple_connections_get_handle(), "signed-on", &handle,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
257 PURPLE_CALLBACK(signed_on), NULL);
15673
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
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
260 int main()
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
261 {
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
262 GList *iter;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
263 int i, num;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
264 GList *names = NULL;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
265 const char *prpl;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
266 char name[128];
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
267 char *password;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
268 GMainLoop *loop = g_main_loop_new(NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
269 PurpleAccount *account;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
270 PurpleSavedStatus *status;
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
271
20289
5c844288fbec applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
272 /* libpurple's built-in DNS resolution forks processes to perform
5c844288fbec applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
273 * blocking lookups without blocking the main process. It does not
5c844288fbec applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
274 * handle SIGCHLD itself, so if the UI does not you quickly get an army
5c844288fbec applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
275 * of zombie subprocesses marching around.
5c844288fbec applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
276 */
5c844288fbec applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
277 signal(SIGCHLD, SIG_IGN);
5c844288fbec applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
278
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
279 init_libpurple();
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
280
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
281 printf("libpurple initialized.\n");
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
282
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
283 iter = purple_plugins_get_protocols();
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
284 for (i = 0; iter; iter = iter->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
285 PurplePlugin *plugin = iter->data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
286 PurplePluginInfo *info = plugin->info;
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
287 if (info && info->name) {
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
288 printf("\t%d: %s\n", i++, info->name);
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
289 names = g_list_append(names, info->id);
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
290 }
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
291 }
19709
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
292 printf("Select the protocol [0-%d]: ", i-1);
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
293 fgets(name, sizeof(name), stdin);
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
294 sscanf(name, "%d", &num);
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
295 prpl = g_list_nth_data(names, num);
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
296
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
297 printf("Username: ");
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
298 fgets(name, sizeof(name), stdin);
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
299 name[strlen(name) - 1] = 0; /* strip the \n at the end */
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
300
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
301 /* Create the account */
19709
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
302 account = purple_account_new(name, prpl);
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
303
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
304 /* Get the password for the account */
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
305 password = getpass("Password: ");
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
306 purple_account_set_password(account, password);
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
307
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
308 /* It's necessary to enable the account first. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15755
diff changeset
309 purple_account_set_enabled(account, UI_ID, TRUE);
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
310
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
311 /* Now, to connect the account(s), create a status and activate it. */
19709
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
312 status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE);
a772794cbb25 Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents: 19164
diff changeset
313 purple_savedstatus_activate(status);
15673
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
314
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
315 connect_to_signals_for_demonstration_purposes_only();
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
316
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
317 g_main_loop_run(loop);
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
318
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
319 return 0;
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
320 }
7f2c84ae63b0 Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
321

mercurial