MSN prpl lacks a status type for the EXTENDED_AWAY primitive.
[thrasher.git] / threquest.c
blobb9625017762e31eecb196689f1cc51939a4d65a8
1 /*
2 * Thrasher Bird - XMPP transport via libpurple
3 * Copyright (C) 2008 Barracuda Networks, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Thrasher Bird; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
19 #include <glib.h>
20 #include <request.h>
22 #include "threquest.h"
23 #include "thft.h"
24 #include "thperl.h"
25 #include "thrasher.h"
27 static void *
28 thrasher_request_input(const char *title,
29 const char *primary,
30 const char *secondary,
31 const char *default_value,
32 gboolean multiline,
33 gboolean masked, gchar *hint,
34 const char *ok_text,
35 GCallback ok_cb,
36 const char *cancel_text,
37 GCallback cancel_cb,
38 PurpleAccount *account,
39 const char *who,
40 PurpleConversation *conv,
41 void *user_data) {
42 /* Non-matching input requests fire no callback, which is the
43 * default if the UI does not provide this request uiop.
46 /* Ensure callback to actually send the authorization request
47 * fires. For now, always use the default message.
49 if (0 == g_strcmp0(primary, _("Authorization Request Message:"))) {
50 gchar* jid = thrasher_account_get_jid(account);
51 purple_debug_info("thrasher request",
52 "%s: Requesting authorization from %s: %s\n",
53 jid,
54 who,
55 default_value);
56 ((PurpleRequestInputCb)ok_cb)(user_data, default_value);
59 else {
60 purple_debug_error("thrasher_request",
61 "Unhandled thrasher_request_input(%s, %s, %s)\n",
62 title,
63 primary,
64 secondary);
67 /* No meaningful UI handle. */
68 return NULL;
71 static void *
72 thrasher_request_action(const char *title,
73 const char *primary,
74 const char *secondary,
75 int default_action,
76 PurpleAccount *account,
77 const char *who,
78 PurpleConversation *conv,
79 void *user_data,
80 size_t action_count,
81 va_list actions) {
83 PurpleRequestActionCb default_cb = NULL;
84 int i;
85 for (i = 0; i < action_count; ) {
86 char* label = va_arg(actions, char*); /* throw away label */
87 PurpleRequestActionCb cb = va_arg(actions, PurpleRequestActionCb);
88 if (i == default_action) {
89 default_cb = cb;
90 break;
92 i++;
94 if (! default_cb) {
95 purple_debug_error("thrasher request",
96 "Default action not found?"
97 " thrasher_request_action(%s, %s, %s)\n",
98 title,
99 primary,
100 secondary);
101 /* No meaningful UI handle. */
102 return NULL;
105 if (0 == g_strcmp0(title, _("SSL Certificate Verification"))) {
106 purple_debug_info("thrasher request",
107 "%s %s\n",
108 /* Accept certificate for ...? */
109 primary,
110 /* text of errors */
111 secondary);
112 default_cb(user_data, default_action);
115 else {
116 purple_debug_error("thrasher_request",
117 "Unhandled thrasher_request_action(%s, %s, %s)\n",
118 title,
119 primary,
120 secondary);
123 /* No meaningful UI handle. */
124 return NULL;
127 static PurpleRequestUiOps thrasher_request_uiops =
129 // request_input
130 thrasher_request_input,
132 // request_choice
133 NULL,
135 // request_action
136 thrasher_request_action,
138 // request_fields
139 NULL,
141 // request_file
142 thrasher_request_file, /* from thft */
144 // close_request
145 NULL,
147 // request_folder
148 NULL,
150 // 4 reserved
151 NULL,
152 NULL,
153 NULL,
154 NULL
157 void thrasher_request_init() {
158 purple_request_set_ui_ops(&thrasher_request_uiops);