Release 1.25.0 -- Buddy Idle Time, RTF
[siplcs.git] / src / purple / purple-user.c
blobe65bc3f9ecbe493313a1cce0eab97e62a4b616ea
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-common.h"
43 #include "sipe-core.h"
44 #include "sipe-nls.h"
46 #define SIPE_TYPING_RECV_TIMEOUT 6
48 void sipe_backend_user_feedback_typing(struct sipe_core_public *sipe_public,
49 const gchar *from)
51 struct sipe_backend_private *purple_private = sipe_public->backend_private;
52 purple_serv_got_typing(purple_private->gc, from,
53 SIPE_TYPING_RECV_TIMEOUT,
54 PURPLE_IM_TYPING);
57 void sipe_backend_user_feedback_typing_stop(struct sipe_core_public *sipe_public,
58 const gchar *from)
60 struct sipe_backend_private *purple_private = sipe_public->backend_private;
61 purple_serv_got_typing_stopped(purple_private->gc, from);
64 static void accept_cb(gpointer key, SIPE_UNUSED_PARAMETER int choice)
66 sipe_core_user_ask_cb(key, TRUE);
69 static void decline_cb(gpointer key, SIPE_UNUSED_PARAMETER int choice)
71 sipe_core_user_ask_cb(key, FALSE);
74 void sipe_backend_user_ask(struct sipe_core_public *sipe_public,
75 const gchar *message,
76 const gchar *accept_label,
77 const gchar *decline_label,
78 gpointer key)
80 struct sipe_backend_private *purple_private = sipe_public->backend_private;
82 purple_request_action(key, "Office Communicator", message,
83 NULL, 0,
84 #if PURPLE_VERSION_CHECK(3,0,0)
85 purple_request_cpar_from_account(purple_private->account),
86 #else
87 purple_private->account, NULL, NULL,
88 #endif
89 key, decline_label ? 2 : 1,
90 accept_label, (PurpleRequestActionCb) accept_cb,
91 decline_label, (PurpleRequestActionCb) decline_cb);
94 void sipe_backend_user_close_ask(gpointer key)
96 purple_request_close_with_handle(key);
99 static void ask_choice_accept_cb(gpointer key, PurpleRequestFields *fields)
101 guint choice_id =
102 GPOINTER_TO_INT(purple_request_fields_get_choice(fields, "choice"));
104 sipe_core_user_ask_choice_cb(key, choice_id);
107 static void ask_choice_cancel_cb(gpointer key)
109 sipe_core_user_ask_choice_cb(key, SIPE_CHOICE_CANCELLED);
113 void sipe_backend_user_ask_choice(struct sipe_core_public *sipe_public,
114 const gchar *message,
115 GSList *choices,
116 gpointer key)
118 struct sipe_backend_private *purple_private = sipe_public->backend_private;
120 PurpleRequestFields *fields = purple_request_fields_new();
121 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL);
122 PurpleRequestField *field =
123 purple_request_field_choice_new("choice", message, 0);
125 guint i;
126 for (i = 0; i != g_slist_length(choices); ++i) {
127 purple_request_field_choice_add(field,
128 g_slist_nth_data(choices, i)
129 #if PURPLE_VERSION_CHECK(3,0,0)
130 , GUINT_TO_POINTER(i)
131 #endif
135 purple_request_field_group_add_field(group, field);
136 purple_request_fields_add_group(fields, group);
138 purple_request_fields(key, "Microsoft Lync",
139 NULL, NULL, fields,
140 _("OK"), (GCallback)ask_choice_accept_cb,
141 _("Cancel"), (GCallback)ask_choice_cancel_cb,
142 #if PURPLE_VERSION_CHECK(3,0,0)
143 purple_request_cpar_from_account(purple_private->account),
144 #else
145 purple_private->account, NULL, NULL,
146 #endif
147 key);
151 Local Variables:
152 mode: c
153 c-file-style: "bsd"
154 indent-tabs-mode: t
155 tab-width: 8
156 End: