purple: include config.h before sipe-nls.h
[siplcs.git] / src / purple / purple-user.c
blob9d83af7dca838211f8f8e6719f891882ce4a0085
1 /**
2 * @file purple-user.c
4 * pidgin-sipe
6 * Copyright (C) 2010-2018 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
27 #include <glib.h>
29 #include "server.h"
30 #include "request.h"
32 #include "purple-private.h"
34 #if PURPLE_VERSION_CHECK(3,0,0)
35 #else
36 #define purple_serv_got_typing(c, n, t, s) serv_got_typing(c, n, t, s)
37 #define purple_serv_got_typing_stopped(c, n) serv_got_typing_stopped(c, n)
38 #define PURPLE_IM_TYPING PURPLE_TYPING
39 #endif
41 #include "sipe-backend.h"
42 #include "sipe-core.h"
43 #include "sipe-nls.h"
45 #define SIPE_TYPING_RECV_TIMEOUT 6
47 void sipe_backend_user_feedback_typing(struct sipe_core_public *sipe_public,
48 const gchar *from)
50 struct sipe_backend_private *purple_private = sipe_public->backend_private;
51 purple_serv_got_typing(purple_private->gc, from,
52 SIPE_TYPING_RECV_TIMEOUT,
53 PURPLE_IM_TYPING);
56 void sipe_backend_user_feedback_typing_stop(struct sipe_core_public *sipe_public,
57 const gchar *from)
59 struct sipe_backend_private *purple_private = sipe_public->backend_private;
60 purple_serv_got_typing_stopped(purple_private->gc, from);
63 static void ask_cb(gpointer key, int choice)
65 sipe_core_user_ask_cb(key, choice == 1);
68 void sipe_backend_user_ask(struct sipe_core_public *sipe_public,
69 const gchar *message,
70 const gchar *accept_label,
71 const gchar *decline_label,
72 gpointer key)
74 struct sipe_backend_private *purple_private = sipe_public->backend_private;
76 purple_request_action(key, "Office Communicator", message,
77 NULL, 0,
78 #if PURPLE_VERSION_CHECK(3,0,0)
79 purple_request_cpar_from_account(purple_private->account),
80 #else
81 purple_private->account, NULL, NULL,
82 #endif
83 key, 2,
84 accept_label, (PurpleRequestActionCb) ask_cb,
85 decline_label, (PurpleRequestActionCb) ask_cb);
88 void sipe_backend_user_close_ask(gpointer key)
90 purple_request_close_with_handle(key);
93 static void ask_choice_accept_cb(gpointer key, PurpleRequestFields *fields)
95 guint choice_id =
96 GPOINTER_TO_INT(purple_request_fields_get_choice(fields, "choice"));
98 sipe_core_user_ask_choice_cb(key, choice_id);
101 static void ask_choice_cancel_cb(gpointer key)
103 sipe_core_user_ask_choice_cb(key, SIPE_CHOICE_CANCELLED);
107 void sipe_backend_user_ask_choice(struct sipe_core_public *sipe_public,
108 const gchar *message,
109 GSList *choices,
110 gpointer key)
112 struct sipe_backend_private *purple_private = sipe_public->backend_private;
114 PurpleRequestFields *fields = purple_request_fields_new();
115 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL);
116 PurpleRequestField *field =
117 purple_request_field_choice_new("choice", message, 0);
119 guint i;
120 for (i = 0; i != g_slist_length(choices); ++i) {
121 purple_request_field_choice_add(field,
122 g_slist_nth_data(choices, i)
123 #if PURPLE_VERSION_CHECK(3,0,0)
124 , GUINT_TO_POINTER(i)
125 #endif
129 purple_request_field_group_add_field(group, field);
130 purple_request_fields_add_group(fields, group);
132 purple_request_fields(key, "Microsoft Lync",
133 NULL, NULL, fields,
134 _("OK"), (GCallback)ask_choice_accept_cb,
135 _("Cancel"), (GCallback)ask_choice_cancel_cb,
136 #if PURPLE_VERSION_CHECK(3,0,0)
137 purple_request_cpar_from_account(purple_private->account),
138 #else
139 purple_private->account, NULL, NULL,
140 #endif
141 key);
145 Local Variables:
146 mode: c
147 c-file-style: "bsd"
148 indent-tabs-mode: t
149 tab-width: 8
150 End: