annotate libpurple/example/nullclient.c @ 17314:42c2d75b3d3e

Update a comment: We don't check idle status every 5 seconds any more. Fixes #1113
author Richard Laager <rlaager@wiktel.com>
date Fri, 25 May 2007 16:17:50 +0000
parents 4b65a67d23b8
children 9ffa9af32854
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 /*
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 * pidgin
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 *
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 * Pidgin is the legal property of its developers, whose names are too numerous
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 * source distribution.
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 *
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 *
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 *
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 *
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 */
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 #include "account.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 #include "conversation.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 #include "core.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 #include "debug.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 #include "eventloop.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 #include "ft.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 #include "log.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 #include "notify.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 #include "prefs.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 #include "prpl.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 #include "pounce.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 #include "savedstatuses.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 #include "sound.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 #include "status.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 #include "util.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 #include "whiteboard.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 #include <glib.h>
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 #include <string.h>
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 #include <unistd.h>
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 #include "defines.h"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 /**
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
48 * The following eventloop functions are used in both pidgin and purple-text. If your
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 * application uses glib mainloop, you can safely use this verbatim.
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
51 #define PURPLE_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
52 #define PURPLE_GLIB_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
54 typedef struct _PurpleGLibIOClosure {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
55 PurpleInputFunction function;
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 guint result;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 gpointer data;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
58 } PurpleGLibIOClosure;
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
60 static void purple_glib_io_destroy(gpointer data)
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 {
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 g_free(data);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
65 static gboolean purple_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
67 PurpleGLibIOClosure *closure = data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
68 PurpleInputCondition purple_cond = 0;
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
70 if (condition & PURPLE_GLIB_READ_COND)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
71 purple_cond |= PURPLE_INPUT_READ;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
72 if (condition & PURPLE_GLIB_WRITE_COND)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
73 purple_cond |= PURPLE_INPUT_WRITE;
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 closure->function(closure->data, g_io_channel_unix_get_fd(source),
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
76 purple_cond);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 return TRUE;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
81 static guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function,
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 gpointer data)
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
84 PurpleGLibIOClosure *closure = g_new0(PurpleGLibIOClosure, 1);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 GIOChannel *channel;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 GIOCondition cond = 0;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 closure->function = function;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 closure->data = data;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
91 if (condition & PURPLE_INPUT_READ)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
92 cond |= PURPLE_GLIB_READ_COND;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
93 if (condition & PURPLE_INPUT_WRITE)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
94 cond |= PURPLE_GLIB_WRITE_COND;
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 channel = g_io_channel_unix_new(fd);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
98 purple_glib_io_invoke, closure, purple_glib_io_destroy);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 g_io_channel_unref(channel);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 return closure->result;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
104 static PurpleEventLoopUiOps glib_eventloops =
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 {
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 g_timeout_add,
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 g_source_remove,
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108 glib_input_add,
15694
cd02b303b81f Fix the following compiler warning:
Mark Doliner <mark@kingant.net>
parents: 15618
diff changeset
109 g_source_remove,
16676
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
110 NULL,
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
111
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
112 /* padding */
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
113 NULL,
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
114 NULL,
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
115 NULL,
15694
cd02b303b81f Fix the following compiler warning:
Mark Doliner <mark@kingant.net>
parents: 15618
diff changeset
116 NULL
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 };
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 /*** End of the eventloop functions. ***/
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 /*** Conversation uiops ***/
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
122 null_write_conv(PurpleConversation *conv, const char *who, const char *alias,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
123 const char *message, PurpleMessageFlags flags, time_t mtime)
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 {
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 const char *name;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 if (alias && *alias)
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 name = alias;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 else if (who && *who)
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 name = who;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 else
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 name = NULL;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
133 printf("(%s) %s %s: %s\n", purple_conversation_get_name(conv),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
134 purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)),
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 name, message);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
138 static PurpleConversationUiOps null_conv_uiops =
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 {
17093
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
140 NULL, /* create_conversation */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
141 NULL, /* destroy_conversation */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
142 NULL, /* write_chat */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
143 NULL, /* write_im */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
144 null_write_conv, /* write_conv */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
145 NULL, /* chat_add_users */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
146 NULL, /* chat_rename_user */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
147 NULL, /* chat_remove_users */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
148 NULL, /* chat_update_user */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
149 NULL, /* present */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
150 NULL, /* has_focus */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
151 NULL, /* custom_smiley_add */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
152 NULL, /* custom_smiley_write */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
153 NULL, /* custom_smiley_close */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
154 NULL, /* send_confirm */
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
155 NULL,
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
156 NULL,
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
157 NULL,
4b65a67d23b8 Replace some C99 struct syntax.
Richard Laager <rlaager@wiktel.com>
parents: 16676
diff changeset
158 NULL
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 };
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 static void
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 null_ui_init()
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 {
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 /**
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 * This should initialize the UI components for all the modules. Here we
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 * just initialize the UI for conversations.
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
168 purple_conversations_set_ui_ops(&null_conv_uiops);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
171 static PurpleCoreUiOps null_core_uiops =
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 {
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 NULL,
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 NULL,
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 null_ui_init,
16676
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
176 NULL,
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
177
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
178 /* padding */
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
179 NULL,
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
180 NULL,
07cf49a0f404 I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents: 16098
diff changeset
181 NULL,
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 NULL
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 };
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 static void
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186 init_libpurple()
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 {
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 /* Set a custom user directory (optional) */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
189 purple_util_set_user_dir(CUSTOM_USER_DIRECTORY);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 /* We do not want any debugging for now to keep the noise to a minimum. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
192 purple_debug_set_enabled(FALSE);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 /* Set the core-uiops, which is used to
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 * - initialize the ui specific preferences.
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 * - initialize the debug ui.
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 * - initialize the ui components for all the modules.
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 * - uninitialize the ui components for all the modules when the core terminates.
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199 */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
200 purple_core_set_ui_ops(&null_core_uiops);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 /* Set the uiops for the eventloop. If your client is glib-based, you can safely
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 * copy this verbatim. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
204 purple_eventloop_set_ui_ops(&glib_eventloops);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 /* Set path to search for plugins. The core (libpurple) takes care of loading the
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 * core-plugins, which includes the protocol-plugins. So it is not essential to add
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 * any path here, but it might be desired, especially for ui-specific plugins. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
209 purple_plugins_add_search_path(CUSTOM_PLUGIN_PATH);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211 /* Now that all the essential stuff has been set, let's try to init the core. It's
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 * necessary to provide a non-NULL name for the current ui to the core. This name
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 * is used by stuff that depends on this ui, for example the ui-specific plugins. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
214 if (!purple_core_init(UI_ID)) {
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 /* Initializing the core failed. Terminate. */
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216 fprintf(stderr,
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 "libpurple initialization failed. Dumping core.\n"
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218 "Please report this!\n");
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 abort();
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 /* Create and load the buddylist. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
223 purple_set_blist(purple_blist_new());
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
224 purple_blist_load();
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 /* Load the preferences. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
227 purple_prefs_load();
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 /* Load the desired plugins. The client should save the list of loaded plugins in
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
230 * the preferences using purple_plugins_save_loaded(PLUGIN_SAVE_PREF) */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
231 purple_plugins_load_saved(PLUGIN_SAVE_PREF);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 /* Load the pounces. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
234 purple_pounces_load();
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
238 signed_on(PurpleConnection *gc, gpointer null)
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
240 PurpleAccount *account = purple_connection_get_account(gc);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 printf("Account connected: %s %s\n", account->username, account->protocol_id);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 static void
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245 connect_to_signals_for_demonstration_purposes_only()
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246 {
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 static int handle;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
248 purple_signal_connect(purple_connections_get_handle(), "signed-on", &handle,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
249 PURPLE_CALLBACK(signed_on), NULL);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 int main()
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 {
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 GList *iter;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 int i, num;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 GList *names = NULL;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 const char *prpl;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 char name[128];
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259 char *password;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 GMainLoop *loop = g_main_loop_new(NULL, FALSE);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
261 PurpleAccount *account;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
262 PurpleSavedStatus *status;
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 init_libpurple();
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
265
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266 printf("libpurple initialized.\n");
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
268 iter = purple_plugins_get_protocols();
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
269 for (i = 0; iter; iter = iter->next) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
270 PurplePlugin *plugin = iter->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
271 PurplePluginInfo *info = plugin->info;
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272 if (info && info->name) {
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 printf("\t%d: %s\n", i++, info->name);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 names = g_list_append(names, info->id);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
277 printf("Select the protocol [0-%d]: ", i-1);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278 fgets(name, sizeof(name), stdin);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279 sscanf(name, "%d", &num);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280 prpl = g_list_nth_data(names, num);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
281
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
282 printf("Username: ");
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
283 fgets(name, sizeof(name), stdin);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
284 name[strlen(name) - 1] = 0; /* strip the \n at the end */
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
285
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
286 /* Create the account */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
287 account = purple_account_new(name, prpl);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
288
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289 /* Get the password for the account */
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290 password = getpass("Password: ");
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
291 purple_account_set_password(account, password);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
293 /* It's necessary to enable the account first. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
294 purple_account_set_enabled(account, UI_ID, TRUE);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
295
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
296 /* Now, to connect the account(s), create a status and activate it. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
297 status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15694
diff changeset
298 purple_savedstatus_activate(status);
15618
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
300 connect_to_signals_for_demonstration_purposes_only();
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302 g_main_loop_run(loop);
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304 return 0;
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 }
7e0c0062c428 Add the example nullclient here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306