Sun, 01 Sep 2013 02:28:54 +0530
Refactored the rest of libpurple to use the new protocol API
|
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 | |
|
22278
111ef6c0ea1a
'make -f Makefile.oot' will successfully compile the nullclient out-of-tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22188
diff
changeset
|
24 | #include "purple.h" |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
25 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
26 | #include <glib.h> |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
27 | |
|
22278
111ef6c0ea1a
'make -f Makefile.oot' will successfully compile the nullclient out-of-tree.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22188
diff
changeset
|
28 | #include <signal.h> |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
29 | #include <string.h> |
|
29765
b995f5cc4a0a
incomplete win32 fixes
Daniel Atallah <datallah@pidgin.im>
parents:
22278
diff
changeset
|
30 | #ifndef _WIN32 |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
31 | #include <unistd.h> |
|
29765
b995f5cc4a0a
incomplete win32 fixes
Daniel Atallah <datallah@pidgin.im>
parents:
22278
diff
changeset
|
32 | #else |
|
b995f5cc4a0a
incomplete win32 fixes
Daniel Atallah <datallah@pidgin.im>
parents:
22278
diff
changeset
|
33 | #include "win32/win32dep.h" |
|
b995f5cc4a0a
incomplete win32 fixes
Daniel Atallah <datallah@pidgin.im>
parents:
22278
diff
changeset
|
34 | #endif |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
35 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
36 | #include "defines.h" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
37 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
38 | /** |
| 15884 | 39 | * 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
|
40 | * 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
|
41 | */ |
| 15884 | 42 | #define PURPLE_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) |
| 43 | #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
|
44 | |
| 15884 | 45 | typedef struct _PurpleGLibIOClosure { |
| 46 | PurpleInputFunction function; | |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
47 | guint result; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
48 | gpointer data; |
| 15884 | 49 | } PurpleGLibIOClosure; |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
50 | |
| 15884 | 51 | static void purple_glib_io_destroy(gpointer data) |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
52 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
53 | g_free(data); |
|
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 | |
| 15884 | 56 | 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
|
57 | { |
| 15884 | 58 | PurpleGLibIOClosure *closure = data; |
| 59 | PurpleInputCondition purple_cond = 0; | |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
60 | |
| 15884 | 61 | if (condition & PURPLE_GLIB_READ_COND) |
| 62 | purple_cond |= PURPLE_INPUT_READ; | |
| 63 | if (condition & PURPLE_GLIB_WRITE_COND) | |
| 64 | purple_cond |= PURPLE_INPUT_WRITE; | |
|
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 | closure->function(closure->data, g_io_channel_unix_get_fd(source), |
| 15884 | 67 | purple_cond); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
68 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
69 | return TRUE; |
|
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 | |
| 15884 | 72 | 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
|
73 | gpointer data) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
74 | { |
| 15884 | 75 | PurpleGLibIOClosure *closure = g_new0(PurpleGLibIOClosure, 1); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
76 | GIOChannel *channel; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
77 | GIOCondition cond = 0; |
|
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 = function; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
80 | closure->data = data; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
81 | |
| 15884 | 82 | if (condition & PURPLE_INPUT_READ) |
| 83 | cond |= PURPLE_GLIB_READ_COND; | |
| 84 | if (condition & PURPLE_INPUT_WRITE) | |
| 85 | cond |= PURPLE_GLIB_WRITE_COND; | |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
86 | |
|
29765
b995f5cc4a0a
incomplete win32 fixes
Daniel Atallah <datallah@pidgin.im>
parents:
22278
diff
changeset
|
87 | #if defined _WIN32 && !defined WINPIDGIN_USE_GLIB_IO_CHANNEL |
|
b995f5cc4a0a
incomplete win32 fixes
Daniel Atallah <datallah@pidgin.im>
parents:
22278
diff
changeset
|
88 | channel = wpurple_g_io_channel_win32_new_socket(fd); |
|
b995f5cc4a0a
incomplete win32 fixes
Daniel Atallah <datallah@pidgin.im>
parents:
22278
diff
changeset
|
89 | #else |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
90 | channel = g_io_channel_unix_new(fd); |
|
29765
b995f5cc4a0a
incomplete win32 fixes
Daniel Atallah <datallah@pidgin.im>
parents:
22278
diff
changeset
|
91 | #endif |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
92 | closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, |
| 15884 | 93 | 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
|
94 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
95 | g_io_channel_unref(channel); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
96 | return closure->result; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
97 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
98 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29765
diff
changeset
|
99 | static PurpleEventLoopUiOps glib_eventloops = |
|
15673
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_timeout_add, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
102 | g_source_remove, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
103 | glib_input_add, |
|
15755
ab33ab6b08ae
Fix the following compiler warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
15673
diff
changeset
|
104 | g_source_remove, |
|
16747
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
105 | NULL, |
|
18071
9b5d872583c9
Wire in g_timeout_add_seconds for Finch and nullclient as well.
Richard Laager <rlaager@pidgin.im>
parents:
17153
diff
changeset
|
106 | g_timeout_add_seconds, |
|
16747
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
107 | |
|
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
108 | /* padding */ |
|
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
109 | NULL, |
|
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
110 | NULL, |
|
15755
ab33ab6b08ae
Fix the following compiler warning:
Mark Doliner <markdoliner@pidgin.im>
parents:
15673
diff
changeset
|
111 | NULL |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
112 | }; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
113 | /*** End of the eventloop functions. ***/ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
114 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
115 | /*** Conversation uiops ***/ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
116 | static void |
| 15884 | 117 | null_write_conv(PurpleConversation *conv, const char *who, const char *alias, |
| 118 | const char *message, PurpleMessageFlags flags, time_t mtime) | |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
119 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
120 | const char *name; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
121 | if (alias && *alias) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
122 | name = alias; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
123 | else if (who && *who) |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
124 | name = who; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
125 | else |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
126 | name = NULL; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
127 | |
| 15884 | 128 | printf("(%s) %s %s: %s\n", purple_conversation_get_name(conv), |
| 129 | purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), | |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
130 | name, message); |
|
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 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29765
diff
changeset
|
133 | static PurpleConversationUiOps null_conv_uiops = |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
134 | { |
|
17153
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
135 | NULL, /* create_conversation */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
136 | NULL, /* destroy_conversation */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
137 | NULL, /* write_chat */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
138 | NULL, /* write_im */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
139 | null_write_conv, /* write_conv */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
140 | NULL, /* chat_add_users */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
141 | NULL, /* chat_rename_user */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
142 | NULL, /* chat_remove_users */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
143 | NULL, /* chat_update_user */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
144 | NULL, /* present */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
145 | NULL, /* has_focus */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
146 | NULL, /* custom_smiley_add */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
147 | NULL, /* custom_smiley_write */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
148 | NULL, /* custom_smiley_close */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
149 | NULL, /* send_confirm */ |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
150 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
151 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
152 | NULL, |
|
7da4e85b6a05
Replace some C99 struct syntax.
Richard Laager <rlaager@pidgin.im>
parents:
16747
diff
changeset
|
153 | NULL |
|
15673
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 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
156 | static void |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20289
diff
changeset
|
157 | null_ui_init(void) |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
158 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
159 | /** |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
160 | * 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
|
161 | * just initialize the UI for conversations. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
162 | */ |
| 15884 | 163 | purple_conversations_set_ui_ops(&null_conv_uiops); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
164 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
165 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29765
diff
changeset
|
166 | static PurpleCoreUiOps null_core_uiops = |
|
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 | NULL, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
169 | NULL, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
170 | null_ui_init, |
|
16747
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
171 | NULL, |
|
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
172 | |
|
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
173 | /* padding */ |
|
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
174 | NULL, |
|
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
175 | NULL, |
|
fc3608e1e661
I _think_ this is it for libpurple's padding...
Gary Kramlich <grim@reaperworld.com>
parents:
16158
diff
changeset
|
176 | NULL, |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
177 | NULL |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
178 | }; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
179 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
180 | static void |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20289
diff
changeset
|
181 | init_libpurple(void) |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
182 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
183 | /* Set a custom user directory (optional) */ |
| 15884 | 184 | purple_util_set_user_dir(CUSTOM_USER_DIRECTORY); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
185 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
186 | /* 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
|
187 | purple_debug_set_enabled(FALSE); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
188 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
189 | /* Set the core-uiops, which is used to |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
190 | * - initialize the ui specific preferences. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
191 | * - initialize the debug ui. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
192 | * - initialize the ui components for all the modules. |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
193 | * - 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
|
194 | */ |
| 15884 | 195 | purple_core_set_ui_ops(&null_core_uiops); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
196 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
197 | /* 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
|
198 | * copy this verbatim. */ |
| 15884 | 199 | purple_eventloop_set_ui_ops(&glib_eventloops); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
200 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
201 | /* 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
|
202 | * 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
|
203 | * is used by stuff that depends on this ui, for example the ui-specific plugins. */ |
| 15884 | 204 | if (!purple_core_init(UI_ID)) { |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
205 | /* Initializing the core failed. Terminate. */ |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
206 | fprintf(stderr, |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
207 | "libpurple initialization failed. Dumping core.\n" |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
208 | "Please report this!\n"); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
209 | abort(); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
210 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
211 | |
|
36379
e74da88fd308
Refactored nullclient to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents:
34173
diff
changeset
|
212 | /* Set path to search for plugins. The core (libpurple) takes care of loading the |
|
e74da88fd308
Refactored nullclient to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents:
34173
diff
changeset
|
213 | * core-plugins, which includes the protocol-plugins. So it is not essential to add |
|
e74da88fd308
Refactored nullclient to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents:
34173
diff
changeset
|
214 | * any path here, but it might be desired, especially for ui-specific plugins. */ |
|
36431
ea007725fd4d
Refactored the codebase to use the plugin wrapper functions
Ankit Vani <a@nevitus.org>
parents:
36379
diff
changeset
|
215 | purple_plugins_add_search_path(CUSTOM_PLUGIN_PATH); |
|
ea007725fd4d
Refactored the codebase to use the plugin wrapper functions
Ankit Vani <a@nevitus.org>
parents:
36379
diff
changeset
|
216 | purple_plugins_refresh(); |
|
36379
e74da88fd308
Refactored nullclient to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents:
34173
diff
changeset
|
217 | |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
218 | /* Load the preferences. */ |
| 15884 | 219 | purple_prefs_load(); |
|
15673
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 | /* Load the desired plugins. The client should save the list of loaded plugins in |
| 15884 | 222 | * the preferences using purple_plugins_save_loaded(PLUGIN_SAVE_PREF) */ |
| 223 | purple_plugins_load_saved(PLUGIN_SAVE_PREF); | |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
224 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
225 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
226 | static void |
| 15884 | 227 | signed_on(PurpleConnection *gc, gpointer null) |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
228 | { |
| 15884 | 229 | PurpleAccount *account = purple_connection_get_account(gc); |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
230 | printf("Account connected: %s %s\n", purple_account_get_username(account), purple_account_get_protocol_id(account)); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
231 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
232 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
233 | static void |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20289
diff
changeset
|
234 | connect_to_signals_for_demonstration_purposes_only(void) |
|
15673
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 | static int handle; |
| 15884 | 237 | purple_signal_connect(purple_connections_get_handle(), "signed-on", &handle, |
| 238 | PURPLE_CALLBACK(signed_on), NULL); | |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
239 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
240 | |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20289
diff
changeset
|
241 | int main(int argc, char *argv[]) |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
242 | { |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
243 | GList *iter; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
244 | int i, num; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
245 | GList *names = NULL; |
|
33809
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
246 | const char *prpl = NULL; |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
247 | char name[128]; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
248 | char *password; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
249 | GMainLoop *loop = g_main_loop_new(NULL, FALSE); |
| 15884 | 250 | PurpleAccount *account; |
| 251 | PurpleSavedStatus *status; | |
|
22188
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
252 | char *res; |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
253 | |
|
29765
b995f5cc4a0a
incomplete win32 fixes
Daniel Atallah <datallah@pidgin.im>
parents:
22278
diff
changeset
|
254 | #ifndef _WIN32 |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
255 | /* libpurple's built-in DNS resolution forks processes to perform |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
256 | * blocking lookups without blocking the main process. It does not |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
257 | * 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
|
258 | * of zombie subprocesses marching around. |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
259 | */ |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
260 | signal(SIGCHLD, SIG_IGN); |
|
29765
b995f5cc4a0a
incomplete win32 fixes
Daniel Atallah <datallah@pidgin.im>
parents:
22278
diff
changeset
|
261 | #endif |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
262 | |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
263 | init_libpurple(); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
264 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
265 | printf("libpurple initialized.\n"); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
266 | |
|
36379
e74da88fd308
Refactored nullclient to use the initial GObject plugin API
Ankit Vani <a@nevitus.org>
parents:
34173
diff
changeset
|
267 | iter = purple_protocols_get_all(); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
268 | for (i = 0; iter; iter = iter->next) { |
|
36630
ff356949df25
Refactored the rest of libpurple to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
269 | PurpleProtocol *protocol = iter->data; |
|
ff356949df25
Refactored the rest of libpurple to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
270 | if (protocol && purple_protocol_get_name(protocol)) { |
|
ff356949df25
Refactored the rest of libpurple to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
271 | printf("\t%d: %s\n", i++, purple_protocol_get_name(protocol)); |
|
ff356949df25
Refactored the rest of libpurple to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
272 | names = g_list_append(names, (gpointer)purple_protocol_get_id(protocol)); |
|
15673
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 | } |
|
19709
a772794cbb25
Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents:
19164
diff
changeset
|
275 | printf("Select the protocol [0-%d]: ", i-1); |
|
22188
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
276 | res = fgets(name, sizeof(name), stdin); |
|
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
277 | if (!res) { |
|
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
278 | fprintf(stderr, "Failed to gets protocol selection."); |
|
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
279 | abort(); |
|
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
280 | } |
|
33809
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
281 | if (sscanf(name, "%d", &num) == 1) |
|
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
282 | prpl = g_list_nth_data(names, num); |
|
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
283 | if (!prpl) { |
|
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
284 | fprintf(stderr, "Failed to gets protocol."); |
|
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
285 | abort(); |
|
d5e9c888ccd7
Add some error checking for sscanf usage (there are more places that could use this)
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
286 | } |
|
19709
a772794cbb25
Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents:
19164
diff
changeset
|
287 | |
|
a772794cbb25
Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents:
19164
diff
changeset
|
288 | printf("Username: "); |
|
22188
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
289 | res = fgets(name, sizeof(name), stdin); |
|
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
290 | if (!res) { |
|
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
291 | fprintf(stderr, "Failed to read user name."); |
|
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
292 | abort(); |
|
601d7825b3b4
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
293 | } |
|
19709
a772794cbb25
Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents:
19164
diff
changeset
|
294 | 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
|
295 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
296 | /* Create the account */ |
|
19709
a772794cbb25
Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents:
19164
diff
changeset
|
297 | 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
|
298 | |
|
a772794cbb25
Revert jeff2's changes from 2007-08-12. Specifically revision
Mark Doliner <markdoliner@pidgin.im>
parents:
19164
diff
changeset
|
299 | /* 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
|
300 | password = getpass("Password: "); |
|
34029
059c1270db1f
Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34028
diff
changeset
|
301 | purple_account_set_password(account, password, NULL, NULL); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
302 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
303 | /* It's necessary to enable the account first. */ |
| 15884 | 304 | purple_account_set_enabled(account, UI_ID, TRUE); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
305 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
306 | /* 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
|
307 | 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
|
308 | purple_savedstatus_activate(status); |
|
15673
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
309 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
310 | connect_to_signals_for_demonstration_purposes_only(); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
311 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
312 | g_main_loop_run(loop); |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
313 | |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
314 | return 0; |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
315 | } |
|
7f2c84ae63b0
Add the example nullclient here.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
316 |